\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);
   evas\_object\_show(win);

   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);

   elm_run();
   elm_shutdown();

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