\section{entry\+\_\+example.\+c}

\begin{DoxyCodeInclude}
\textcolor{comment}{/*}
\textcolor{comment}{ * gcc -o entry\_example entry\_example.c `pkg-config --cflags --libs elementary`}
\textcolor{comment}{ */}
\textcolor{preprocessor}{#include <Elementary.h>}

\textcolor{keyword}{typedef} \textcolor{keyword}{struct}
\{
   Evas\_Object *win;
   Evas\_Object *edit\_buffer;
\} App\_Data;

\textcolor{keyword}{typedef} \textcolor{keyword}{struct}
\{
   Evas\_Object *inwin;
   Evas\_Object *naviframe;
   Evas\_Object *grid;
   Evas\_Object *settings;

   \textcolor{keywordtype}{int} size;
   \textcolor{keywordtype}{int} vsize;
   \textcolor{keywordtype}{int} width, height;

   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *emo;

   App\_Data *ad;
\} App\_Inwin\_Data;

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_edit\_buffer\_insert(Evas\_Object *e, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *text)
\{
   elm\_entry\_entry\_insert(e, text);
   elm_object_focus_set(e, EINA\_TRUE);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_it\_sel\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   App\_Inwin\_Data *aid = data;
   Elm_Object_Item *gg\_it = event;

   aid->emo = elm_object_item_data_get(gg\_it);

   elm\_naviframe\_item\_simple\_promote(aid->naviframe, aid->settings);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{char} *
\_emo\_label\_get(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *part)
\{
   \textcolor{keywordflow}{return} strdup(data);
\}

\textcolor{keyword}{static} Evas\_Object *
\_emo\_content\_get(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *part)
\{
   Evas\_Object *o;

   \textcolor{keywordflow}{if} (strcmp(part, \textcolor{stringliteral}{"elm.swallow.icon"}))
     \textcolor{keywordflow}{return} NULL;
   o = elm_layout_add(obj);
   \textcolor{keywordflow}{if} (!elm\_layout\_theme\_set(o, \textcolor{stringliteral}{"entry/emoticon"}, data, \textcolor{stringliteral}{"default"}))
     \{
        fprintf(stderr, \textcolor{stringliteral}{"Failed to set layout"});
        \textcolor{keywordflow}{return} NULL;
     \}
   \textcolor{keywordflow}{return} o;
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_emo\_del(\textcolor{keywordtype}{void} *data, Evas\_Object *obj)
\{
   free(data);
\}

\textcolor{keyword}{static} Evas\_Object *
\_page\_grid\_add(Evas\_Object *parent, App\_Inwin\_Data *aid)
\{
   Evas\_Object *grid;
   \textcolor{keywordtype}{char} *theme, *emo;
   Eina\_List *emos, *it;
   \textcolor{keyword}{static} Elm_Gengrid_Item_Class *it\_class;
   it\_class = elm_gengrid_item_class_new();
   it\_class->item\_style = \textcolor{stringliteral}{"default"};
   it\_class->func.text\_get = \_emo\_label\_get;
   it\_class->func.content\_get = \_emo\_content\_get;
   it\_class->func.del = \_emo\_del;

   theme = elm_theme_list_item_path_get(\textcolor{stringliteral}{"default"}, NULL);
   \textcolor{keywordflow}{if} (!theme) \textcolor{keywordflow}{return} NULL;
   emos = edje\_file\_collection\_list(theme);
   free(theme);
   \textcolor{keywordflow}{if} (!emos) \textcolor{keywordflow}{return} NULL;

   grid = elm_gengrid_add(parent);
   elm\_gengrid\_item\_size\_set(grid, 64, 80);
   evas\_object\_size\_hint\_weight\_set(grid, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(grid, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);

   EINA\_LIST\_FOREACH(emos, it, emo)
     \{
        \textcolor{keywordtype}{char} name[512];

        \textcolor{keywordflow}{if} (strncmp(emo, \textcolor{stringliteral}{"elm/entry/emoticon/"}, 19))
          \textcolor{keywordflow}{continue};
        sscanf(emo, \textcolor{stringliteral}{"elm/entry/emoticon/%[^/]/default"}, name);
        elm\_gengrid\_item\_append(grid, it\_class, strdup(name), \_it\_sel\_cb, aid);
     \}
   edje\_file\_collection\_list\_free(emos);
   elm_gengrid_item_class_free(it\_class);

   \textcolor{keywordflow}{return} grid;
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_insert\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   App\_Inwin\_Data *aid = data;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *size[] = \{
        \textcolor{stringliteral}{"size"},
        \textcolor{stringliteral}{"absize"},
        \textcolor{stringliteral}{"relsize"}
   \};
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *vsize[] = \{
        \textcolor{stringliteral}{"full"},
        \textcolor{stringliteral}{"ascent"}
   \};
   \textcolor{keywordtype}{char} buf[512];

   snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"<item %s=%dx%d vsize=%s href=emoticon/%s>"}
            \textcolor{stringliteral}{"</item>"}, size[aid->size], aid->width, aid->height,
            vsize[aid->vsize], aid->emo);
   \_edit\_buffer\_insert(aid->ad->edit\_buffer, buf);

   evas\_object\_del(aid->inwin);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_width\_changed\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   App\_Inwin\_Data *aid = data;

   aid->width = atoi(elm\_object\_text\_get(obj));
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_height\_changed\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   App\_Inwin\_Data *aid = data;

   aid->height = atoi(elm\_object\_text\_get(obj));
\}

\textcolor{keyword}{static} Evas\_Object *
\_page\_settings\_add(Evas\_Object *parent, App\_Inwin\_Data *aid)
\{
   Evas\_Object *box, *sizeopts, *box2, *sizebox, *vsizebox,
               *rsize, *rabsize, *rrelsize, *rvfull, *rvascent,
               *fwidth, *ewidth, *fheight, *eheight,
               *binsert;
   \textcolor{keywordtype}{char} buf[100];
   \textcolor{keyword}{static} Elm_Entry_Filter_Accept_Set accept\_set = \{
        .accepted = \textcolor{stringliteral}{"0123456789"},
        .rejected = NULL
   \};
   \textcolor{keyword}{static} Elm_Entry_Filter_Limit_Size limit\_size = \{
        .max_char_count = 5,
        .max\_byte\_count = 0
   \};

   box = elm_box_add(parent);
   evas\_object\_size\_hint\_weight\_set(box, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(box, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);

   sizeopts = elm_frame_add(parent);
   elm\_object\_text\_set(sizeopts, \textcolor{stringliteral}{"Size"});
   evas\_object\_size\_hint\_weight\_set(sizeopts, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(sizeopts, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(box, sizeopts);
   evas\_object\_show(sizeopts);

   box2 = elm_box_add(parent);
   evas\_object\_size\_hint\_weight\_set(box2, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(box2, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_object\_content\_set(sizeopts, box2);
   evas\_object\_show(box2);

   sizebox = elm_box_add(parent);
   elm\_box\_horizontal\_set(sizebox, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(sizebox, EVAS\_HINT\_EXPAND,
                                    EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(sizebox, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(box2, sizebox);
   evas\_object\_show(sizebox);

   rsize = elm_radio_add(parent);
   elm\_object\_text\_set(rsize, \textcolor{stringliteral}{"Scale adjusted (size)"});
   elm\_radio\_state\_value\_set(rsize, 0);
   elm\_radio\_value\_pointer\_set(rsize, &aid->size);
   elm\_box\_pack\_end(sizebox, rsize);
   evas\_object\_show(rsize);

   rabsize = elm_radio_add(parent);
   elm\_object\_text\_set(rabsize, \textcolor{stringliteral}{"Absolute size (absize)"});
   elm\_radio\_state\_value\_set(rabsize, 1);
   elm\_radio\_value\_pointer\_set(rabsize, &aid->size);
   elm\_radio\_group\_add(rabsize, rsize);
   elm\_box\_pack\_end(sizebox, rabsize);
   evas\_object\_show(rabsize);

   rrelsize = elm_radio_add(parent);
   elm\_object\_text\_set(rrelsize, \textcolor{stringliteral}{"Relative to line (relsize)"});
   elm\_radio\_state\_value\_set(rrelsize, 2);
   elm\_radio\_value\_pointer\_set(rrelsize, &aid->size);
   elm\_radio\_group\_add(rrelsize, rsize);
   elm\_box\_pack\_end(sizebox, rrelsize);
   evas\_object\_show(rrelsize);

   vsizebox = elm_box_add(parent);
   elm\_box\_horizontal\_set(vsizebox, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(vsizebox, EVAS\_HINT\_EXPAND,
                                    EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(vsizebox, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(box2, vsizebox);
   evas\_object\_show(vsizebox);

   rvfull = elm_radio_add(parent);
   elm\_object\_text\_set(rvfull, \textcolor{stringliteral}{"Full height (vsize=full)"});
   elm\_radio\_state\_value\_set(rvfull, 0);
   elm\_radio\_value\_pointer\_set(rvfull, &aid->vsize);
   elm\_box\_pack\_end(vsizebox, rvfull);
   evas\_object\_show(rvfull);

   rvascent = elm_radio_add(parent);
   elm\_object\_text\_set(rvascent, \textcolor{stringliteral}{"Ascent only (vsize=ascent)"});
   elm\_radio\_state\_value\_set(rvascent, 1);
   elm\_radio\_value\_pointer\_set(rvascent, &aid->vsize);
   elm\_radio\_group\_add(rvascent, rvfull);
   elm\_box\_pack\_end(vsizebox, rvascent);
   evas\_object\_show(rvascent);

   fwidth = elm_frame_add(parent);
   elm\_object\_text\_set(fwidth, \textcolor{stringliteral}{"Width"});
   evas\_object\_size\_hint\_weight\_set(fwidth, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(fwidth, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(box2, fwidth);
   evas\_object\_show(fwidth);

   snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"%d"}, aid->width);
   ewidth = elm_entry_add(parent);
   elm\_entry\_single\_line\_set(ewidth, EINA\_TRUE);
   elm\_entry\_markup\_filter\_append(ewidth, elm_entry_filter_accept_set,
                                  &accept\_set);
   elm\_entry\_markup\_filter\_append(ewidth, elm_entry_filter_limit_size,
                                  &limit\_size);
   elm\_object\_text\_set(ewidth, buf);
   evas\_object\_size\_hint\_weight\_set(ewidth, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(ewidth, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_object\_content\_set(fwidth, ewidth);
   evas\_object\_show(ewidth);

   evas\_object\_smart\_callback\_add(ewidth, \textcolor{stringliteral}{"changed"}, \_width\_changed\_cb, aid);

   fheight = elm_frame_add(parent);
   elm\_object\_text\_set(fheight, \textcolor{stringliteral}{"Height"});
   evas\_object\_size\_hint\_weight\_set(fheight, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(fheight, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(box2, fheight);
   evas\_object\_show(fheight);

   snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"%d"}, aid->height);
   eheight = elm_entry_add(parent);
   elm\_entry\_single\_line\_set(eheight, EINA\_TRUE);
   elm\_entry\_markup\_filter\_append(eheight, elm_entry_filter_accept_set,
                                  &accept\_set);
   elm\_entry\_markup\_filter\_append(eheight, elm_entry_filter_limit_size,
                                  &limit\_size);
   elm\_object\_text\_set(eheight, buf);
   evas\_object\_size\_hint\_weight\_set(eheight, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(eheight, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_object\_content\_set(fheight, eheight);
   evas\_object\_show(eheight);

   evas\_object\_smart\_callback\_add(eheight, \textcolor{stringliteral}{"changed"}, \_height\_changed\_cb, aid);

   binsert = elm_button_add(parent);
   elm\_object\_text\_set(binsert, \textcolor{stringliteral}{"Insert"});
   elm\_box\_pack\_end(box, binsert);
   evas\_object\_show(binsert);

   evas\_object\_smart\_callback\_add(binsert, \textcolor{stringliteral}{"clicked"}, \_btn\_insert\_cb, aid);

   \textcolor{keywordflow}{return} box;
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_insert\_cancel\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   App\_Inwin\_Data *aid = data;

   evas\_object\_del(aid->inwin);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_inwin\_del\_cb(\textcolor{keywordtype}{void} *data, Evas *e, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   free(data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_image\_insert\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   App\_Data *ad = data;
   App\_Inwin\_Data *aid;
   Evas\_Object *inwin, *box, *box2, *naviframe, *o;

   aid = calloc(1, \textcolor{keyword}{sizeof}(App\_Inwin\_Data));
   \textcolor{keywordflow}{if} (!aid) \textcolor{keywordflow}{return};

   aid->ad = ad;
   aid->size = 1;
   aid->vsize = 1;
   aid->width = 64;
   aid->height = 64;

   inwin = elm_win_inwin_add(ad->win);
   evas\_object\_size\_hint\_weight\_set(inwin, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(inwin, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   evas\_object\_show(inwin);

   evas\_object\_event\_callback\_add(inwin, EVAS\_CALLBACK\_DEL, \_inwin\_del\_cb,
                                  aid);

   box = elm_box_add(ad->win);
   evas\_object\_size\_hint\_weight\_set(box, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(box, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_win_inwin_content_set(inwin, box);
   evas\_object\_show(box);

   naviframe = elm_naviframe_add(ad->win);
   evas\_object\_size\_hint\_weight\_set(naviframe, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(naviframe, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(box, naviframe);
   evas\_object\_show(naviframe);

   o = \_page\_grid\_add(ad->win, aid);
   elm\_naviframe\_item\_simple\_push(naviframe, o);
   aid->grid = o;

   o = \_page\_settings\_add(ad->win, aid);
   elm\_naviframe\_item\_simple\_push(naviframe, o);
   aid->settings = o;

   elm\_naviframe\_item\_simple\_promote(naviframe, aid->grid);

   box2 = elm_box_add(ad->win);
   elm\_box\_horizontal\_set(box2, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(box2, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(box2, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(box, box2);
   evas\_object\_show(box2);

   o = elm_button_add(ad->win);
   elm\_object\_text\_set(o, \textcolor{stringliteral}{"Cancel"});
   evas\_object\_size\_hint\_weight\_set(o, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(o, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(box2, o);
   evas\_object\_show(o);

   evas\_object\_smart\_callback\_add(o, \textcolor{stringliteral}{"clicked"}, \_insert\_cancel\_cb, aid);

   aid->inwin = inwin;
   aid->naviframe = naviframe;
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_format\_change\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   App\_Data *ad = data;
   \textcolor{keywordtype}{char} fmt\_open[5], fmt\_close[6];
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *sel;
   \textcolor{keywordtype}{int} cursor;
   \textcolor{keywordtype}{char} *s;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *ptr, *what;
   Eina\_Strbuf *buf = NULL;

   sel = elm\_object\_text\_get(obj);
   snprintf(fmt\_open, \textcolor{keyword}{sizeof}(fmt\_open), \textcolor{stringliteral}{"<%s>"}, sel);
   snprintf(fmt\_close, \textcolor{keyword}{sizeof}(fmt\_close), \textcolor{stringliteral}{"</%s>"}, sel);

   buf = eina\_strbuf\_new();

   cursor = elm\_entry\_cursor\_pos\_get(ad->edit\_buffer);
   elm\_entry\_cursor\_begin\_set(ad->edit\_buffer);
   elm\_entry\_cursor\_selection\_begin(ad->edit\_buffer);
   elm\_entry\_cursor\_pos\_set(ad->edit\_buffer, cursor);
   elm\_entry\_cursor\_selection\_end(ad->edit\_buffer);
   sel = elm\_entry\_selection\_get(ad->edit\_buffer);
   \textcolor{keywordflow}{if} (!sel || !sel[0])
     \{
        eina\_strbuf\_append(buf, fmt\_open);
        \textcolor{keywordflow}{goto} all\_done;
     \}
   what = fmt\_open;
   ptr = sel;
   \textcolor{keywordflow}{while} ((s = strstr(ptr, what)))
     \{
        ptr = s + strlen(what);
        \textcolor{keywordflow}{if} (what == fmt\_open) what = fmt\_close;
        \textcolor{keywordflow}{else} what = fmt\_open;
     \}
   eina\_strbuf\_append(buf, what);
   \textcolor{keywordflow}{if} (what == fmt\_close)
     \{
        elm\_entry\_cursor\_selection\_begin(ad->edit\_buffer);
        elm\_entry\_cursor\_end\_set(ad->edit\_buffer);
        elm\_entry\_cursor\_selection\_end(ad->edit\_buffer);
        sel = elm\_entry\_selection\_get(ad->edit\_buffer);
        \textcolor{keywordflow}{if} (sel)
          \{
             Eina\_Strbuf *buf2 = eina\_strbuf\_new();
             eina\_strbuf\_append(buf2, sel);
             eina\_strbuf\_replace\_first(buf2, fmt\_close, \textcolor{stringliteral}{""});
             elm\_entry\_entry\_insert(ad->edit\_buffer,
                                    eina\_strbuf\_string\_get(buf2));
             eina\_strbuf\_free(buf2);
          \}
     \}
   elm\_entry\_select\_none(ad->edit\_buffer);
   elm\_entry\_cursor\_pos\_set(ad->edit\_buffer, cursor);

all\_done:
   \_edit\_buffer\_insert(ad->edit\_buffer, eina\_strbuf\_string\_get(buf));
   eina\_strbuf\_free(buf);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_autosave\_change\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   App\_Data *ad = data;
   Eina\_Bool state = elm\_check\_state\_get(obj);

   elm\_entry\_autosave\_set(ad->edit\_buffer, state);
   \textcolor{keywordflow}{if} (state) elm\_entry\_file\_save(ad->edit\_buffer);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_edit\_dblclick\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   \textcolor{keywordtype}{int} current\_cursor;

   current\_cursor = elm\_entry\_cursor\_pos\_get(obj);

   \textcolor{keywordflow}{while} (elm\_entry\_cursor\_prev(obj))
     \{
        \textcolor{keyword}{const} \textcolor{keywordtype}{char} *content;
        \textcolor{keywordflow}{if} (elm\_entry\_cursor\_is\_visible\_format\_get(obj))
          \textcolor{keywordflow}{break};
        content = elm\_entry\_cursor\_content\_get(obj);
        \textcolor{keywordflow}{if} (content && (content[0] == \textcolor{charliteral}{' '}))
          \textcolor{keywordflow}{break};
     \}

   \textcolor{keywordflow}{if} (current\_cursor == elm\_entry\_cursor\_pos\_get(obj))
     \textcolor{keywordflow}{return};

   elm\_entry\_cursor\_next(obj);
   elm\_entry\_cursor\_selection\_begin(obj);
   elm\_entry\_cursor\_pos\_set(obj, current\_cursor);
   \textcolor{keywordflow}{while} (elm\_entry\_cursor\_next(obj))
     \{
        \textcolor{keyword}{const} \textcolor{keywordtype}{char} *content;
        \textcolor{keywordflow}{if} (elm\_entry\_cursor\_is\_visible\_format\_get(obj))
          \textcolor{keywordflow}{break};
        content = elm\_entry\_cursor\_content\_get(obj);
        \textcolor{keywordflow}{if} (content && (content[0] == \textcolor{charliteral}{' '}))
          \textcolor{keywordflow}{break};
     \}
   elm\_entry\_cursor\_selection\_end(obj);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_edit\_tplclick\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   elm\_entry\_cursor\_line\_begin\_set(obj);
   elm\_entry\_cursor\_selection\_begin(obj);
   elm\_entry\_cursor\_line\_end\_set(obj);
   elm\_entry\_cursor\_selection\_end(obj);
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} *argv[])
\{
   Evas\_Object *win, *box, *tb, *en, *o, *icon;
   App\_Data app;

   memset(&app, 0, \textcolor{keyword}{sizeof}(app));

   elm_policy_set(ELM\_POLICY\_QUIT, ELM\_POLICY\_QUIT\_LAST\_WINDOW\_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"entry-example"}, \textcolor{stringliteral}{"Emacs Lite"});
   elm\_win\_autodel\_set(win, EINA\_TRUE);

   box = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(box, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm\_win\_resize\_object\_add(win, box);
   evas\_object\_show(box);

   tb = elm_box_add(win);
   elm\_box\_horizontal\_set(tb, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(tb, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_weight\_set(tb, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(box, tb);
   evas\_object\_show(tb);

   o = elm_check_add(win);
   elm\_check\_state\_set(o, EINA\_FALSE);
   elm\_object\_text\_set(o, \textcolor{stringliteral}{"Autosave"});
   elm\_box\_pack\_end(tb, o);
   evas\_object\_show(o);

   evas\_object\_smart\_callback\_add(o, \textcolor{stringliteral}{"changed"}, \_autosave\_change\_cb, &app);

   o = elm_button_add(win);
   elm\_object\_text\_set(o, \textcolor{stringliteral}{"b"});
   elm\_box\_pack\_end(tb, o);
   evas\_object\_show(o);

   evas\_object\_smart\_callback\_add(o, \textcolor{stringliteral}{"clicked"}, \_format\_change\_cb, &app);

   o = elm_button_add(win);
   elm\_object\_text\_set(o, \textcolor{stringliteral}{"em"});
   elm\_box\_pack\_end(tb, o);
   evas\_object\_show(o);

   evas\_object\_smart\_callback\_add(o, \textcolor{stringliteral}{"clicked"}, \_format\_change\_cb, &app);

   o = elm_button_add(win);
   elm\_box\_pack\_end(tb, o);
   evas\_object\_show(o);

   icon = elm_layout_add(win);

   \textcolor{keywordflow}{if} (!elm\_layout\_theme\_set(
         icon, \textcolor{stringliteral}{"entry"}, \textcolor{stringliteral}{"emoticon/haha"}, \textcolor{stringliteral}{"default"}))
     fprintf(stderr, \textcolor{stringliteral}{"Failed to set layout"});

   elm_object_part_content_set(o, \textcolor{stringliteral}{"icon"}, icon);

   evas\_object\_smart\_callback\_add(o, \textcolor{stringliteral}{"clicked"}, \_image\_insert\_cb, &app);

   en = elm_entry_add(win);
   elm\_entry\_autosave\_set(en, EINA\_FALSE);
   elm_entry_file_set(en, \textcolor{stringliteral}{"/tmp/da\_test.txt"}, ELM\_TEXT\_FORMAT\_MARKUP\_UTF8);
   evas\_object\_size\_hint\_weight\_set(en, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(en, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(box, en);
   evas\_object\_show(en);

   app.win = win;
   app.edit\_buffer = en;

   evas\_object\_smart\_callback\_add(en, \textcolor{stringliteral}{"clicked,double"}, \_edit\_dblclick\_cb,
                                  NULL);
   evas\_object\_smart\_callback\_add(en, \textcolor{stringliteral}{"clicked,triple"}, \_edit\_tplclick\_cb,
                                  NULL);

   elm_object_focus_set(app.edit\_buffer, EINA\_TRUE);

   evas\_object\_resize(win, 300, 780);

   evas\_object\_show(win);

   elm_run();

   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()
\end{DoxyCodeInclude}
 