\hypertarget{ecore_imf_example_8c-example}{}\section{ecore\+\_\+imf\+\_\+example.\+c}
Shows how to write simple editor using the Ecore\+\_\+\+I\+MF library.


\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#include <Ecore.h>}
\textcolor{preprocessor}{#include <\mbox{\hyperlink{Ecore__Evas_8h}{Ecore\_Evas.h}}>}
\textcolor{preprocessor}{#include <Ecore\_IMF.h>}
\textcolor{preprocessor}{#include <Ecore\_IMF\_Evas.h>}
\textcolor{preprocessor}{#include <Evas.h>}
\textcolor{preprocessor}{#include <stdio.h>}

\textcolor{preprocessor}{#define WIDTH 480}
\textcolor{preprocessor}{#define HEIGHT 800}

\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Entry Entry;

\textcolor{keyword}{struct }\_Entry
\{
   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}           *rect;
   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}           *txt\_obj;
   \mbox{\hyperlink{group__Evas__Object__Textblock_ga0936b029caf5493691f7fd523f8b885c}{Evas\_Textblock\_Style}}  *txt\_style;
   \mbox{\hyperlink{group__Evas__Object__Textblock_ga0b6c2d49d4271badfa08e89a53a1dd12}{Evas\_Textblock\_Cursor}} *cursor;
   \mbox{\hyperlink{group__Evas__Object__Textblock_ga0b6c2d49d4271badfa08e89a53a1dd12}{Evas\_Textblock\_Cursor}} *preedit\_start;
   \mbox{\hyperlink{group__Evas__Object__Textblock_ga0b6c2d49d4271badfa08e89a53a1dd12}{Evas\_Textblock\_Cursor}} *preedit\_end;
   \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gab990e052e8501815371d7289dfd4a017}{Ecore\_IMF\_Context}}     *imf\_context;
   \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}              have\_preedit : 1;
\};

\textcolor{keyword}{static} \textcolor{keywordtype}{void} \_imf\_cursor\_info\_set(Entry *en);

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\mbox{\hyperlink{group__Elm__Gesture__Layer_gac99bfa54a39fbdd3e6ef1ed06abca820}{\_mouse\_down\_cb}}(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *e \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, 
      \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *event\_info)
\{
   Entry *en = data;
   \mbox{\hyperlink{struct__Evas__Event__Mouse__Down}{Evas\_Event\_Mouse\_Down}} *ev = event\_info;
   \textcolor{keywordflow}{if} (!en) \textcolor{keywordflow}{return};

   \textcolor{keywordflow}{if} (en->imf\_context)
     \{
        \mbox{\hyperlink{struct__Ecore__IMF__Event__Mouse__Down}{Ecore\_IMF\_Event\_Mouse\_Down}} ecore\_ev;
        \mbox{\hyperlink{group__Ecore__IMF__Evas__Group_gae2f41c890f7e9630197bf32a8278f9a0}{ecore\_imf\_evas\_event\_mouse\_down\_wrap}}(ev, &ecore\_ev);
        \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Ecore__IMF__Context__Group_gacf389a792142af2dc14f660c70cde7ec}{ecore\_imf\_context\_filter\_event}}(en->imf\_context,
                                           \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gga9dcc60537ec7b124a90da72daba4f780ab7204eadb553c0444df98bab6579b0da}{ECORE\_IMF\_EVENT\_MOUSE\_DOWN}},
                                           (\mbox{\hyperlink{union__Ecore__IMF__Event}{Ecore\_IMF\_Event}} *)&ecore\_ev))
          \textcolor{keywordflow}{return};

        \textcolor{comment}{// ecore\_imf\_context\_reset should be called before calculating new cursor position}
        \mbox{\hyperlink{group__Ecore__IMF__Context__Group_ga853f78bd8ab1bcedbc56c32bbc2af9aa}{ecore\_imf\_context\_reset}}(en->imf\_context);
     \}

   \textcolor{comment}{// calculate new cursor position}
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_mouse\_up\_cb(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *e \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *event\_info)
\{
   Entry *en = data;
   \mbox{\hyperlink{struct__Evas__Event__Mouse__Up}{Evas\_Event\_Mouse\_Up}} *ev = event\_info;
   \textcolor{keywordflow}{if} (!en) \textcolor{keywordflow}{return};

   \textcolor{keywordflow}{if} (ev->event\_flags & EVAS\_EVENT\_FLAG\_ON\_HOLD)
     \{
        \_imf\_cursor\_info\_set(en);
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (en->imf\_context)
     \{
        \mbox{\hyperlink{struct__Ecore__IMF__Event__Mouse__Up}{Ecore\_IMF\_Event\_Mouse\_Up}} ecore\_ev;
        \mbox{\hyperlink{group__Ecore__IMF__Evas__Group_gaf20488b6add20938213d8c762e258a04}{ecore\_imf\_evas\_event\_mouse\_up\_wrap}}(ev, &ecore\_ev);
        \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Ecore__IMF__Context__Group_gacf389a792142af2dc14f660c70cde7ec}{ecore\_imf\_context\_filter\_event}}(en->imf\_context,
                                           \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gga9dcc60537ec7b124a90da72daba4f780a39ecdd38e486c3f62a852587cf81b0bf}{ECORE\_IMF\_EVENT\_MOUSE\_UP}},
                                           (\mbox{\hyperlink{union__Ecore__IMF__Event}{Ecore\_IMF\_Event}} *)&ecore\_ev))
          \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (en->rect)
     \{
        \textcolor{keywordflow}{if} (evas\_object\_focus\_get(en->rect))
          \{
             \textcolor{comment}{// notify cursor information}
             \_imf\_cursor\_info\_set(en);
          \}
        \textcolor{keywordflow}{else}
          evas\_object\_focus\_set(en->rect, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});
     \}
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_entry\_focus\_in\_cb(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *e \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *event\_info \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   Entry *en = data;
   \textcolor{keywordflow}{if} (!en) \textcolor{keywordflow}{return};

   \textcolor{keywordflow}{if} (en->imf\_context)
     \mbox{\hyperlink{group__Ecore__IMF__Context__Group_ga339824577964ce0f221cae1f4b43755d}{ecore\_imf\_context\_focus\_in}}(en->imf\_context);

   \textcolor{comment}{// notify the cursor information}
   \_imf\_cursor\_info\_set(en);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_entry\_focus\_out\_cb(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *e \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *event\_info \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   Entry *en = data;
   \textcolor{keywordflow}{if} (!en) \textcolor{keywordflow}{return};

   \textcolor{keywordflow}{if} (en->imf\_context)
     \{
        \textcolor{comment}{// ecore\_imf\_context\_reset should be called for flushing the preedit string in focus-out event
       handler}
        \mbox{\hyperlink{group__Ecore__IMF__Context__Group_ga853f78bd8ab1bcedbc56c32bbc2af9aa}{ecore\_imf\_context\_reset}}(en->imf\_context);
        \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gafee39309634c1663f7b8ea910c75bcbd}{ecore\_imf\_context\_focus\_out}}(en->imf\_context);
     \}
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_canvas\_focus\_in\_cb(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *e, \textcolor{keywordtype}{void} *event\_info 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   Entry *en;
   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj = \mbox{\hyperlink{group__Evas__Canvas_gabeeab2a18e586a4195d85b6a0c50413a}{evas\_focus\_get}}(e);
   \textcolor{keywordflow}{if} (!obj) \textcolor{keywordflow}{return};

   en = \mbox{\hyperlink{group__Evas__Object__Group__Extras_gafbad43015793eda4ae50202c0ce0e652}{evas\_object\_data\_get}}(obj, \textcolor{stringliteral}{"Entry"});
   \textcolor{keywordflow}{if} (en)
     \_entry\_focus\_in\_cb(en, NULL, NULL, NULL);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_canvas\_focus\_out\_cb(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *e, \textcolor{keywordtype}{void} *event\_info 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   Entry *en;
   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj = \mbox{\hyperlink{group__Evas__Canvas_gabeeab2a18e586a4195d85b6a0c50413a}{evas\_focus\_get}}(e);
   \textcolor{keywordflow}{if} (!obj) \textcolor{keywordflow}{return};

   en = \mbox{\hyperlink{group__Evas__Object__Group__Extras_gafbad43015793eda4ae50202c0ce0e652}{evas\_object\_data\_get}}(obj, \textcolor{stringliteral}{"Entry"});
   \textcolor{keywordflow}{if} (en)
     \_entry\_focus\_out\_cb(en, NULL, NULL, NULL);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_imf\_cursor\_info\_set(Entry *en)
\{
   \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} x, y, w, h;
   \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} cx, cy, cw, ch; \textcolor{comment}{// cursor geometry}
   \textcolor{keywordtype}{int} cursor\_pos; \textcolor{comment}{// cursor position in chars (Not bytes)}
   Evas\_BiDi\_Direction dir;

   \textcolor{keywordflow}{if} (!en) \textcolor{keywordflow}{return};

   \textcolor{comment}{// get cursor geometry}
   \textcolor{keywordflow}{if} (en->txt\_obj)
     \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}}(en->txt\_obj, &x, &y, &w, &h);

   \textcolor{keywordflow}{if} (en->cursor && en->imf\_context)
     \{
        \mbox{\hyperlink{group__Evas__Object__Textblock_gad25d397f7c5b988300cff3ae21748c9a}{evas\_textblock\_cursor\_geometry\_get}}(en->cursor, &cx, &cy, &cw, &ch
      , &dir, \mbox{\hyperlink{group__Evas__Object__Textblock_ggaba40faa1b6a6dcd55193db1e3ca31476a12f34cc9432856994ebbb113c78b59f7}{EVAS\_TEXTBLOCK\_CURSOR\_BEFORE}});

        \textcolor{comment}{// get cursor position}
        cursor\_pos = \mbox{\hyperlink{group__Evas__Object__Textblock_ga26f34e45c5694208a640d1edbe1645c7}{evas\_textblock\_cursor\_pos\_get}}(en->cursor);

        \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gaf66f299c16e705570b296d6f85670177}{ecore\_imf\_context\_cursor\_position\_set}}(en->imf\_context, 
      cursor\_pos);
        \mbox{\hyperlink{group__Ecore__IMF__Context__Group_ga8272537bac2b469bfb50bb39397c3a3f}{ecore\_imf\_context\_cursor\_location\_set}}(en->imf\_context, x + cx,
       y + cy, cw, ch);
        \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gae43b38407a28322748a44de22a122abd}{ecore\_imf\_context\_bidi\_direction\_set}}(en->imf\_context, (
      \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gab5bba399a46704b755971577b0e462d3}{Ecore\_IMF\_BiDi\_Direction}})dir);
     \}
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_preedit\_del(Entry *en)
\{
   \textcolor{keywordflow}{if} (!en || !en->have\_preedit) \textcolor{keywordflow}{return};
   \textcolor{keywordflow}{if} (!en->preedit\_start || !en->preedit\_end) \textcolor{keywordflow}{return};
   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Evas__Object__Textblock_gacc51709ebde1d12e3fc43d1235048791}{evas\_textblock\_cursor\_compare}}(en->preedit\_start, en->preedit\_end)) \textcolor{keywordflow}{
      return};

   \textcolor{comment}{// delete the preedit characters}
   \mbox{\hyperlink{group__Evas__Object__Textblock_gad863c689181a25bbfd6cdc24f5452585}{evas\_textblock\_cursor\_range\_delete}}(en->preedit\_start, en->preedit\_end)
      ;
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_preedit\_clear(Entry *en)
\{
   \textcolor{keywordflow}{if} (en->preedit\_start)
     \{
        \mbox{\hyperlink{group__Evas__Object__Textblock_ga601d0627d1eeddf9a0309ee9b8ccbdf8}{evas\_textblock\_cursor\_free}}(en->preedit\_start);
        en->preedit\_start = NULL;
     \}

   \textcolor{keywordflow}{if} (en->preedit\_end)
     \{
        \mbox{\hyperlink{group__Evas__Object__Textblock_ga601d0627d1eeddf9a0309ee9b8ccbdf8}{evas\_textblock\_cursor\_free}}(en->preedit\_end);
        en->preedit\_end = NULL;
     \}

   en->have\_preedit = \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};
\}

\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}
\_ecore\_imf\_retrieve\_surrounding\_cb(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gab990e052e8501815371d7289dfd4a017}{Ecore\_IMF\_Context}} *ctx 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{char} **text, \textcolor{keywordtype}{int} *cursor\_pos)
\{
   \textcolor{comment}{// This callback will be called when the Input Method Context module requests the surrounding context.}
   Entry *en = data;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *str;

   \textcolor{keywordflow}{if} (!en) \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};

   str = \mbox{\hyperlink{group__Evas__Object__Textblock_ga958d72110ffb13d78e63a4ca9981412c}{evas\_object\_textblock\_text\_markup\_get}}(en->txt\_obj);

   \textcolor{keywordflow}{if} (text)
     *text = str ? strdup(str) : strdup(\textcolor{stringliteral}{""});

   \textcolor{comment}{// get the current position of cursor}
   \textcolor{keywordflow}{if} (cursor\_pos && en->cursor)
     *cursor\_pos = \mbox{\hyperlink{group__Evas__Object__Textblock_ga26f34e45c5694208a640d1edbe1645c7}{evas\_textblock\_cursor\_pos\_get}}(en->cursor);

   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_ecore\_imf\_event\_delete\_surrounding\_cb(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gab990e052e8501815371d7289dfd4a017}{Ecore\_IMF\_Context}} *ctx 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *event\_info)
\{
   \textcolor{comment}{// called when the input method needs to delete all or part of the context surrounding the cursor}
   Entry *en = data;
   \mbox{\hyperlink{struct__Ecore__IMF__Event__Delete__Surrounding}{Ecore\_IMF\_Event\_Delete\_Surrounding}} *ev = event\_info;
   \mbox{\hyperlink{group__Evas__Object__Textblock_ga0b6c2d49d4271badfa08e89a53a1dd12}{Evas\_Textblock\_Cursor}} *del\_start, *del\_end;
   \textcolor{keywordtype}{int} cursor\_pos;

   \textcolor{keywordflow}{if} ((!en) || (!ev) || (!en->cursor)) \textcolor{keywordflow}{return};

   \textcolor{comment}{// get the current cursor position}
   cursor\_pos = \mbox{\hyperlink{group__Evas__Object__Textblock_ga26f34e45c5694208a640d1edbe1645c7}{evas\_textblock\_cursor\_pos\_get}}(en->cursor);

   \textcolor{comment}{// start cursor position to be deleted}
   del\_start = \mbox{\hyperlink{group__Evas__Object__Textblock_ga3689177b714bfd62242826525fcc0def}{evas\_object\_textblock\_cursor\_new}}(en->txt\_obj);
   \mbox{\hyperlink{group__Evas__Object__Textblock_gaa2be92d419712069399b4dfacada0125}{evas\_textblock\_cursor\_pos\_set}}(del\_start, cursor\_pos + ev->offset);

   \textcolor{comment}{// end cursor position to be deleted}
   del\_end = \mbox{\hyperlink{group__Evas__Object__Textblock_ga3689177b714bfd62242826525fcc0def}{evas\_object\_textblock\_cursor\_new}}(en->txt\_obj);
   \mbox{\hyperlink{group__Evas__Object__Textblock_gaa2be92d419712069399b4dfacada0125}{evas\_textblock\_cursor\_pos\_set}}(del\_end, cursor\_pos + ev->offset + ev->
      n\_chars);

   \textcolor{comment}{// implement function to delete character(s) from 'cursor\_pos+ev->offset' cursor position to 'cursor\_pos
       + ev->offset + ev->n\_chars'}
   \mbox{\hyperlink{group__Evas__Object__Textblock_gad863c689181a25bbfd6cdc24f5452585}{evas\_textblock\_cursor\_range\_delete}}(del\_start, del\_end);

   \mbox{\hyperlink{group__Evas__Object__Textblock_ga601d0627d1eeddf9a0309ee9b8ccbdf8}{evas\_textblock\_cursor\_free}}(del\_start);
   \mbox{\hyperlink{group__Evas__Object__Textblock_ga601d0627d1eeddf9a0309ee9b8ccbdf8}{evas\_textblock\_cursor\_free}}(del\_end);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_ecore\_imf\_event\_commit\_cb(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gab990e052e8501815371d7289dfd4a017}{Ecore\_IMF\_Context}} *ctx 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *event\_info)
\{
   Entry *en = data;
   \textcolor{keywordtype}{char} *commit\_str = (\textcolor{keywordtype}{char} *)event\_info;
   \textcolor{keywordflow}{if} (!en) \textcolor{keywordflow}{return};

   \textcolor{comment}{// delete preedit string}
   \_preedit\_del(en);
   \_preedit\_clear(en);

   printf(\textcolor{stringliteral}{"commit string : %s\(\backslash\)n"}, commit\_str);

   \textcolor{comment}{// insert the commit string in the editor}
   \textcolor{keywordflow}{if} (en->cursor && commit\_str)
     \mbox{\hyperlink{group__Evas__Object__Textblock_gaa97aaef2ad0653782c7ad1ca30bcb3cb}{evas\_object\_textblock\_text\_markup\_prepend}}(en->cursor, 
      commit\_str);

   \textcolor{comment}{// notify the cursor information}
   \_imf\_cursor\_info\_set(en);

   \textcolor{keywordflow}{return};
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_ecore\_imf\_event\_preedit\_changed\_cb(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gab990e052e8501815371d7289dfd4a017}{Ecore\_IMF\_Context}} *ctx, \textcolor{keywordtype}{void} *event\_info 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   \textcolor{comment}{// example how to get preedit string}
   Entry *en = data;
   \textcolor{keywordtype}{char} *preedit\_string;
   \textcolor{keywordtype}{int} cursor\_pos;
   \mbox{\hyperlink{struct__Eina__List}{Eina\_List}} *attrs = NULL;
   \mbox{\hyperlink{struct__Eina__List}{Eina\_List}} *l;
   \mbox{\hyperlink{struct__Ecore__IMF__Preedit__Attr}{Ecore\_IMF\_Preedit\_Attr}} *attr;
   \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gab990e052e8501815371d7289dfd4a017}{Ecore\_IMF\_Context}} *imf\_context = ctx;
   \textcolor{keywordtype}{int} preedit\_start\_pos, preedit\_end\_pos;
   \textcolor{keywordtype}{int} i;
   \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}} preedit\_end\_state = \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};

   \textcolor{keywordflow}{if} (!en || !en->cursor) \textcolor{keywordflow}{return};

   \textcolor{comment}{// get preedit string and attributes}
   \mbox{\hyperlink{group__Ecore__IMF__Context__Group_ga5e3fb2324a5f20cb761e19d4fbc9a9a5}{ecore\_imf\_context\_preedit\_string\_with\_attributes\_get}}
      (imf\_context, &preedit\_string, &attrs, &cursor\_pos);
   printf(\textcolor{stringliteral}{"preedit string : %s\(\backslash\)n"}, preedit\_string);

   \textcolor{keywordflow}{if} (!strcmp(preedit\_string, \textcolor{stringliteral}{""}))
     preedit\_end\_state = \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};

   \textcolor{comment}{// delete preedit}
   \_preedit\_del(en);

   preedit\_start\_pos = \mbox{\hyperlink{group__Evas__Object__Textblock_ga26f34e45c5694208a640d1edbe1645c7}{evas\_textblock\_cursor\_pos\_get}}(en->cursor);

   \textcolor{comment}{// insert preedit character(s)}
   \textcolor{keywordflow}{if} (strlen(preedit\_string) > 0)
     \{
        \textcolor{keywordflow}{if} (attrs)
          \{
             \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(attrs, l, attr)
               \{
                  \textcolor{keywordflow}{if} (attr->\mbox{\hyperlink{struct__Ecore__IMF__Preedit__Attr_ab43d4e86ad2d2fcc5bdc7b534ec2e933}{preedit\_type}} == 
      \mbox{\hyperlink{group__Ecore__IMF__Context__Group_ggacd213f9a030646e4f50072426443849aa2c9d33fd5683078e23148cd923915ef6}{ECORE\_IMF\_PREEDIT\_TYPE\_SUB1}}) \textcolor{comment}{// style type}
                    \{
                       \textcolor{comment}{// apply appropriate style such as underline}
                    \}
                  \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (attr->\mbox{\hyperlink{struct__Ecore__IMF__Preedit__Attr_ab43d4e86ad2d2fcc5bdc7b534ec2e933}{preedit\_type}} == 
      \mbox{\hyperlink{group__Ecore__IMF__Context__Group_ggacd213f9a030646e4f50072426443849aa68ce0b7eb48488808a57096bd28e8723}{ECORE\_IMF\_PREEDIT\_TYPE\_SUB2}} || attr->\mbox{\hyperlink{struct__Ecore__IMF__Preedit__Attr_ab43d4e86ad2d2fcc5bdc7b534ec2e933}{preedit\_type}} == 
      \mbox{\hyperlink{group__Ecore__IMF__Context__Group_ggacd213f9a030646e4f50072426443849aaa95fced9f4039f6c3c8d340754d451f2}{ECORE\_IMF\_PREEDIT\_TYPE\_SUB3}})
                    \{
                       \textcolor{comment}{// apply appropriate style such as underline}
                    \}
               \}

             \textcolor{comment}{// insert code to display preedit string in your editor}
             \mbox{\hyperlink{group__Evas__Object__Textblock_gaa97aaef2ad0653782c7ad1ca30bcb3cb}{evas\_object\_textblock\_text\_markup\_prepend}}(en->cursor,
       preedit\_string);
          \}
     \}

   \textcolor{keywordflow}{if} (!preedit\_end\_state)
     \{
        \textcolor{comment}{// set preedit start cursor}
        \textcolor{keywordflow}{if} (!en->preedit\_start)
          en->preedit\_start = \mbox{\hyperlink{group__Evas__Object__Textblock_ga3689177b714bfd62242826525fcc0def}{evas\_object\_textblock\_cursor\_new}}(en->txt\_obj)
      ;
        \mbox{\hyperlink{group__Evas__Object__Textblock_ga7fc4731e670d010ac17af02bd88bd9ef}{evas\_textblock\_cursor\_copy}}(en->cursor, en->preedit\_start);

        \textcolor{comment}{// set preedit end cursor}
        \textcolor{keywordflow}{if} (!en->preedit\_end)
          en->preedit\_end = \mbox{\hyperlink{group__Evas__Object__Textblock_ga3689177b714bfd62242826525fcc0def}{evas\_object\_textblock\_cursor\_new}}(en->txt\_obj);
        \mbox{\hyperlink{group__Evas__Object__Textblock_ga7fc4731e670d010ac17af02bd88bd9ef}{evas\_textblock\_cursor\_copy}}(en->cursor, en->preedit\_end);

        preedit\_end\_pos = \mbox{\hyperlink{group__Evas__Object__Textblock_ga26f34e45c5694208a640d1edbe1645c7}{evas\_textblock\_cursor\_pos\_get}}(en->cursor);

        \textcolor{keywordflow}{for} (i = 0; i < (preedit\_end\_pos - preedit\_start\_pos); i++)
          \{
             \mbox{\hyperlink{group__Evas__Object__Textblock_ga02b7a75dc3ca5518acbe795988fa44a9}{evas\_textblock\_cursor\_char\_prev}}(en->preedit\_start);
          \}

        en->have\_preedit = \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};

        \textcolor{comment}{// set cursor position}
        \mbox{\hyperlink{group__Evas__Object__Textblock_gaa2be92d419712069399b4dfacada0125}{evas\_textblock\_cursor\_pos\_set}}(en->cursor, preedit\_start\_pos + 
      cursor\_pos);
     \}

   \textcolor{comment}{// notify the cursor information}
   \_imf\_cursor\_info\_set(en);

   \mbox{\hyperlink{group__Eina__List__Group_gae27a2c686a0a11693f9b06957c9bba83}{EINA\_LIST\_FREE}}(attrs, attr)
     free(attr);

   free(preedit\_string);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_key\_down\_cb(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *e \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *event\_info)
\{
   Entry *en = data;
   \mbox{\hyperlink{struct__Evas__Event__Key__Down}{Evas\_Event\_Key\_Down}} *ev = event\_info;
   \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}} control, alt, shift;
   \textcolor{keywordflow}{if} ((!en) || (!ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}) || (!en->cursor)) \textcolor{keywordflow}{return};

   \textcolor{keywordflow}{if} (en->imf\_context)
     \{
        \mbox{\hyperlink{struct__Ecore__IMF__Event__Key__Down}{Ecore\_IMF\_Event\_Key\_Down}} ecore\_ev;
        \mbox{\hyperlink{group__Ecore__IMF__Evas__Group_gad6b3b7cbb61105c492be1d816b6bc899}{ecore\_imf\_evas\_event\_key\_down\_wrap}}(ev, &ecore\_ev);
        \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Ecore__IMF__Context__Group_gacf389a792142af2dc14f660c70cde7ec}{ecore\_imf\_context\_filter\_event}}(en->imf\_context,
                                           \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gga9dcc60537ec7b124a90da72daba4f780afc7b57a1b56d6310705e8dfdc8a782d6}{ECORE\_IMF\_EVENT\_KEY\_DOWN}},
                                           (\mbox{\hyperlink{union__Ecore__IMF__Event}{Ecore\_IMF\_Event}} *)&ecore\_ev))
          \textcolor{keywordflow}{return};
     \}

   control = \mbox{\hyperlink{group__Evas__Keys_ga6cc24a5ea4b39b84c7a3e617de3db261}{evas\_key\_modifier\_is\_set}}(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a065e345f013dc4099eb180ce4833377f}{modifiers}}, \textcolor{stringliteral}{"Control"});
   alt = \mbox{\hyperlink{group__Evas__Keys_ga6cc24a5ea4b39b84c7a3e617de3db261}{evas\_key\_modifier\_is\_set}}(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a065e345f013dc4099eb180ce4833377f}{modifiers}}, \textcolor{stringliteral}{"Alt"});
   shift = \mbox{\hyperlink{group__Evas__Keys_ga6cc24a5ea4b39b84c7a3e617de3db261}{evas\_key\_modifier\_is\_set}}(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a065e345f013dc4099eb180ce4833377f}{modifiers}}, \textcolor{stringliteral}{"Shift"});
   (void)alt;
   (void)shift;

   \textcolor{keywordflow}{if} (!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"BackSpace"}))
     \{
        \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Evas__Object__Textblock_ga02b7a75dc3ca5518acbe795988fa44a9}{evas\_textblock\_cursor\_char\_prev}}(en->cursor))
          \{
             \mbox{\hyperlink{group__Evas__Object__Textblock_ga89cb7b380acc84797b2ef8cb9ae22b09}{evas\_textblock\_cursor\_char\_delete}}(en->cursor);
             \textcolor{comment}{// notify the cursor information}
             \_imf\_cursor\_info\_set(en);
          \}
         \textcolor{keywordflow}{return};
     \}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"Delete"}) ||
            (!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"KP\_Delete"}) && !ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a1b64741ca0b90a5119463f320ebeea00}{string}}))
     \{
        \textcolor{comment}{// FILLME}
     \}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} ((control) && (!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"v"})))
     \{
        \textcolor{comment}{// ctrl + v}
        \textcolor{comment}{// FILLME}
     \}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} ((control) && (!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"a"})))
     \{
        \textcolor{comment}{// ctrl + a}
        \textcolor{comment}{// FILLME}
     \}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} ((control) && (!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"A"})))
     \{
        \textcolor{comment}{// ctrl + A}
        \textcolor{comment}{// FILLME}
     \}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} ((control) && ((!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"c"}) || (!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"Insert"})))))
     \{
        \textcolor{comment}{// ctrl + c}
        \textcolor{comment}{// FILLME}
     \}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} ((control) && ((!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"x"}) || (!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"m"})))))
     \{
        \textcolor{comment}{// ctrl + x}
        \textcolor{comment}{// FILLME}
     \}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} ((control) && (!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"z"})))
     \{
        \textcolor{comment}{// ctrl + z (undo)}
        \textcolor{comment}{// FILLME}
     \}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} ((control) && (!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"y"})))
     \{
        \textcolor{comment}{// ctrl + y (redo)}
        \textcolor{comment}{// FILLME}
     \}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} ((!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"Return"})) || (!strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"KP\_Enter"})))
     \{
        \textcolor{comment}{// FILLME}
     \}
   \textcolor{keywordflow}{else}
     \{
        \textcolor{keywordflow}{if} (ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a1b64741ca0b90a5119463f320ebeea00}{string}})
          \{
             printf(\textcolor{stringliteral}{"key down string : %s\(\backslash\)n"}, ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a1b64741ca0b90a5119463f320ebeea00}{string}});
             \mbox{\hyperlink{group__Evas__Object__Textblock_gaa97aaef2ad0653782c7ad1ca30bcb3cb}{evas\_object\_textblock\_text\_markup\_prepend}}(en->cursor,
       ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a1b64741ca0b90a5119463f320ebeea00}{string}});
          \}
     \}

   \textcolor{comment}{// notify the cursor information}
   \_imf\_cursor\_info\_set(en);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_key\_up\_cb(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *e \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *event\_info)
\{
   Entry *en = data;
   \mbox{\hyperlink{struct__Evas__Event__Key__Up}{Evas\_Event\_Key\_Up}} *ev = event\_info;

   \textcolor{keywordflow}{if} (!en) \textcolor{keywordflow}{return};

   \textcolor{keywordflow}{if} (en->imf\_context)
     \{
        \mbox{\hyperlink{struct__Ecore__IMF__Event__Key__Up}{Ecore\_IMF\_Event\_Key\_Up}} ecore\_ev;

        \mbox{\hyperlink{group__Ecore__IMF__Evas__Group_ga780bcd9093b281d92da4428cd721d239}{ecore\_imf\_evas\_event\_key\_up\_wrap}}(ev, &ecore\_ev);
        \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Ecore__IMF__Context__Group_gacf389a792142af2dc14f660c70cde7ec}{ecore\_imf\_context\_filter\_event}}(en->imf\_context,
                                           \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gga9dcc60537ec7b124a90da72daba4f780a30b3d7d6b56fccb57ceaedb753eb170b}{ECORE\_IMF\_EVENT\_KEY\_UP}},
                                           (\mbox{\hyperlink{union__Ecore__IMF__Event}{Ecore\_IMF\_Event}} *)&ecore\_ev))
          \textcolor{keywordflow}{return};
     \}
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
create\_input\_field(\mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *evas, Entry *en, \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} x, \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} y, 
      \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} w, \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} h)
\{
   \textcolor{keywordflow}{if} (!en) \textcolor{keywordflow}{return};

   en->have\_preedit = \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};
   en->preedit\_start = NULL;
   en->preedit\_end = NULL;

   \textcolor{comment}{// create the background for text input field}
   en->rect = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}}(evas);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(en->rect, 150, 150, 150, 255); \textcolor{comment}{// gray color}
   evas\_object\_move(en->rect, x, y);
   evas\_object\_resize(en->rect, w, h);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(en->rect);
   \mbox{\hyperlink{group__Evas__Object__Group__Extras_ga70134a7068c9bff4107a761abe0a2ad4}{evas\_object\_data\_set}}(en->rect, \textcolor{stringliteral}{"Entry"}, en);

   \textcolor{comment}{// create text object for displaying text}
   en->txt\_obj = \mbox{\hyperlink{group__Evas__Object__Textblock_ga5059cda84291080e59bcc72ead81ca93}{evas\_object\_textblock\_add}}(evas);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(en->txt\_obj, 0, 0, 0, 255);
   evas\_object\_pass\_events\_set(en->txt\_obj, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});
   evas\_object\_move(en->txt\_obj, x, y);
   evas\_object\_resize(en->txt\_obj, w, h);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(en->txt\_obj);

   \textcolor{comment}{// set style on textblock}
   \textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *style\_buf =
      \textcolor{stringliteral}{"DEFAULT='font=Sans font\_size=30 color=#000 text\_class=entry'"}
      \textcolor{stringliteral}{"newline='br'"}
      \textcolor{stringliteral}{"b='+ font=Sans:style=bold'"};
   en->txt\_style = \mbox{\hyperlink{group__Evas__Object__Textblock_ga5047d80b99150342ce3cd5518b474df8}{evas\_textblock\_style\_new}}();
   \mbox{\hyperlink{group__Evas__Object__Textblock_gaf536f7e63f652e36a125006e31cf5457}{evas\_textblock\_style\_set}}(en->txt\_style, style\_buf);
   \mbox{\hyperlink{group__Evas__Object__Textblock_ga14c222cd68f4c101dc9e52361c47c35e}{evas\_object\_textblock\_style\_set}}(en->txt\_obj, en->txt\_style);

   \textcolor{comment}{// create cursor}
   en->cursor = \mbox{\hyperlink{group__Evas__Object__Textblock_ga3689177b714bfd62242826525fcc0def}{evas\_object\_textblock\_cursor\_new}}(en->txt\_obj);

   \textcolor{comment}{// create input context}
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *default\_id = \mbox{\hyperlink{group__Ecore__IMF__Context__Group_ga0e34ef45fc0ccb7157a8d7cf96b112ca}{ecore\_imf\_context\_default\_id\_get}}();
   \textcolor{keywordflow}{if} (!default\_id)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"Can't create ecore\_imf\_context\(\backslash\)n"});
        \textcolor{keywordflow}{return};
     \}

   en->imf\_context = \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gae2b65dd991c760ae7876ee7df637f68f}{ecore\_imf\_context\_add}}(default\_id);
   \mbox{\hyperlink{group__Ecore__IMF__Context__Group_ga96d1d3c9ca63ef47d2e66bd9fae19a8c}{ecore\_imf\_context\_client\_canvas\_set}}(en->imf\_context, evas);

   \textcolor{comment}{// register key event handler}
   \mbox{\hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}}(en->rect, 
      \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a336b86bad4f145f84c155e4922335584}{EVAS\_CALLBACK\_KEY\_DOWN}}, \_key\_down\_cb, en);
   \mbox{\hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}}(en->rect, 
      \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968ac436b50ad665089f8a24b0fb827cec5f}{EVAS\_CALLBACK\_KEY\_UP}}, \_key\_up\_cb, en);

   \textcolor{comment}{// register mouse event handler}
   \mbox{\hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}}(en->rect, 
      \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN}}, \mbox{\hyperlink{group__Elm__Gesture__Layer_gac99bfa54a39fbdd3e6ef1ed06abca820}{\_mouse\_down\_cb}}, en);
   \mbox{\hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}}(en->rect, 
      \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a8c1b22c99dd0231cd9ba1fecbffffac7}{EVAS\_CALLBACK\_MOUSE\_UP}}, \_mouse\_up\_cb, en);

   \textcolor{comment}{// register focus event handler}
   \mbox{\hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}}(en->rect, 
      \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a819cf61e9d11012b7402338c2ccb7b97}{EVAS\_CALLBACK\_FOCUS\_IN}}, \_entry\_focus\_in\_cb, en);
   \mbox{\hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}}(en->rect, 
      \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968ab26a0af7efaa8b77e996bd438accf8d3}{EVAS\_CALLBACK\_FOCUS\_OUT}}, \_entry\_focus\_out\_cb, en);

   \textcolor{comment}{// register retrieve surrounding callback}
   \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gaf4da8dacae69d82559f808645b118df5}{ecore\_imf\_context\_retrieve\_surrounding\_callback\_set}}(
      en->imf\_context, \_ecore\_imf\_retrieve\_surrounding\_cb, en);

   \textcolor{comment}{// register commit event callback}
   \mbox{\hyperlink{group__Ecore__IMF__Context__Group_ga7e0ef28b49fbdc54c4657d88a139d5f5}{ecore\_imf\_context\_event\_callback\_add}}(en->imf\_context, 
      \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gga06aadd645f11ba5c8d00943aa327be5aa9d05d645b3c1edde3b959fee4cd87dec}{ECORE\_IMF\_CALLBACK\_COMMIT}}, \_ecore\_imf\_event\_commit\_cb, en);

   \textcolor{comment}{// register preedit changed event handler}
   \mbox{\hyperlink{group__Ecore__IMF__Context__Group_ga7e0ef28b49fbdc54c4657d88a139d5f5}{ecore\_imf\_context\_event\_callback\_add}}(en->imf\_context, 
      \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gga06aadd645f11ba5c8d00943aa327be5aa9e354e49b61f3e67c4210cc85478975e}{ECORE\_IMF\_CALLBACK\_PREEDIT\_CHANGED}}, \_ecore\_imf\_event\_preedit\_changed\_cb, 
      en);

   \textcolor{comment}{// register surrounding delete event callback}
   \mbox{\hyperlink{group__Ecore__IMF__Context__Group_ga7e0ef28b49fbdc54c4657d88a139d5f5}{ecore\_imf\_context\_event\_callback\_add}}(en->imf\_context, 
      \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gga06aadd645f11ba5c8d00943aa327be5aa696bc156e7efd93c83128fc2e18bfeba}{ECORE\_IMF\_CALLBACK\_DELETE\_SURROUNDING}}, 
      \_ecore\_imf\_event\_delete\_surrounding\_cb, en);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
delete\_input\_field(Entry *en)
\{
   \textcolor{keywordflow}{if} (!en) \textcolor{keywordflow}{return};

   \textcolor{keywordflow}{if} (en->rect)
     \{
        \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}}(en->rect);
        en->rect = NULL;
     \}

   \textcolor{keywordflow}{if} (en->cursor)
     \{
        \mbox{\hyperlink{group__Evas__Object__Textblock_ga601d0627d1eeddf9a0309ee9b8ccbdf8}{evas\_textblock\_cursor\_free}}(en->cursor);
        en->cursor = NULL;
     \}

   \textcolor{keywordflow}{if} (en->preedit\_start)
     \{
        \mbox{\hyperlink{group__Evas__Object__Textblock_ga601d0627d1eeddf9a0309ee9b8ccbdf8}{evas\_textblock\_cursor\_free}}(en->preedit\_start);
        en->preedit\_start = NULL;
     \}

   \textcolor{keywordflow}{if} (en->preedit\_end)
     \{
        \mbox{\hyperlink{group__Evas__Object__Textblock_ga601d0627d1eeddf9a0309ee9b8ccbdf8}{evas\_textblock\_cursor\_free}}(en->preedit\_end);
        en->preedit\_end = NULL;
     \}

   \textcolor{keywordflow}{if} (en->txt\_obj)
     \{
        \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}}(en->txt\_obj);
        en->txt\_obj = NULL;
     \}

   \textcolor{keywordflow}{if} (en->txt\_style)
     \{
        \mbox{\hyperlink{group__Evas__Object__Textblock_gafdc12ce69d5b4ccf1f8434d1555faee1}{evas\_textblock\_style\_free}}(en->txt\_style);
        en->txt\_style = NULL;
     \}

   \textcolor{keywordflow}{if} (en->imf\_context)
     \{
        \mbox{\hyperlink{group__Ecore__IMF__Context__Group_gaad34fcaedfc6ed098525d2c8928ec409}{ecore\_imf\_context\_del}}(en->imf\_context);
        en->imf\_context = NULL;
     \}
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   Ecore\_Evas *ee;
   \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *evas;
   Entry en1, en2;

   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}}())
     \{
        fprintf(stderr, \textcolor{stringliteral}{"failed to call ecore\_evas\_init()\(\backslash\)n"});
        \textcolor{keywordflow}{return} EXIT\_FAILURE;
     \}

   \mbox{\hyperlink{group__Ecore__IMF__Lib__Group_gade7d780e03136d2799e6d212d188184a}{ecore\_imf\_init}}();

   \textcolor{comment}{// create a new window, with size=WIDTHxHEIGHT and default engine}
   ee = \mbox{\hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}}(NULL, 0, 0, WIDTH, HEIGHT, NULL);

   \textcolor{keywordflow}{if} (!ee)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"failed to call ecore\_evas\_new\(\backslash\)n"});
        \textcolor{keywordflow}{return} EXIT\_FAILURE;
     \}

   \mbox{\hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}}(ee);

   \textcolor{comment}{// get the canvas off just-created window}
   evas = \mbox{\hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}}(ee);
   \textcolor{keywordflow}{if} (!evas)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"failed to call ecore\_evas\_get\(\backslash\)n"});
        \textcolor{keywordflow}{return} EXIT\_FAILURE;
     \}

   \textcolor{comment}{// create input field rectangle}
   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *bg = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}}(evas);
   evas\_object\_move(bg, 0, 0);
   evas\_object\_resize(bg, WIDTH, HEIGHT);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(bg, 255, 255, 255, 255);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(bg);

   \textcolor{comment}{// register canvas focus in/out event handler}
   evas\_event\_callback\_add(evas, \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968ac3a1defaffac4dcb6fe9e568919c45d1}{EVAS\_CALLBACK\_CANVAS\_FOCUS\_IN}}, 
      \_canvas\_focus\_in\_cb, NULL);
   evas\_event\_callback\_add(evas, \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a444e79ca91d910d500dc26f71cf0518f}{EVAS\_CALLBACK\_CANVAS\_FOCUS\_OUT}}, 
      \_canvas\_focus\_out\_cb, NULL);

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

   \textcolor{comment}{// create input field 1}
   create\_input\_field(evas, &en1, 40, 60, 400, 80);

   \textcolor{comment}{// create input field 2}
   create\_input\_field(evas, &en2, 40, 180, 400, 80);

   \textcolor{comment}{// give focus to input field 1}
   evas\_object\_focus\_set(en1.rect, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});

   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}(); \textcolor{comment}{// begin mainloop}

   delete\_input\_field(&en1); \textcolor{comment}{// delete input field 1}
   delete\_input\_field(&en2); \textcolor{comment}{// delete input field 2}

   evas\_event\_callback\_del\_full(evas, \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968ac3a1defaffac4dcb6fe9e568919c45d1}{EVAS\_CALLBACK\_CANVAS\_FOCUS\_IN}}, 
      \_canvas\_focus\_in\_cb, NULL);
   evas\_event\_callback\_del\_full(evas, \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a444e79ca91d910d500dc26f71cf0518f}{EVAS\_CALLBACK\_CANVAS\_FOCUS\_OUT}}, 
      \_canvas\_focus\_out\_cb, NULL);

   \mbox{\hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}}(ee);

   \mbox{\hyperlink{group__Ecore__IMF__Lib__Group_ga498318d0ef919461c2a84d68989bfa76}{ecore\_imf\_shutdown}}();
   \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();

   \textcolor{keywordflow}{return} 0;
\}

\end{DoxyCodeInclude}
 