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


\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#include <Ecore.h>}
\textcolor{preprocessor}{#include <\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
\{
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}           *rect;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}           *txt\_obj;
   \hyperlink{group__Evas__Object__Textblock_ga0936b029caf5493691f7fd523f8b885c}{Evas\_Textblock\_Style}  *txt\_style;
   \hyperlink{group__Evas__Object__Textblock_ga0b6c2d49d4271badfa08e89a53a1dd12}{Evas\_Textblock\_Cursor} *cursor;
   \hyperlink{group__Evas__Object__Textblock_ga0b6c2d49d4271badfa08e89a53a1dd12}{Evas\_Textblock\_Cursor} *preedit\_start;
   \hyperlink{group__Evas__Object__Textblock_ga0b6c2d49d4271badfa08e89a53a1dd12}{Evas\_Textblock\_Cursor} *preedit\_end;
   \hyperlink{group__Ecore__IMF__Context__Group_gab990e052e8501815371d7289dfd4a017}{Ecore\_IMF\_Context}     *imf\_context;
   \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}
\_mouse\_down\_cb(\textcolor{keywordtype}{void} *data, \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *e EINA\_UNUSED, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *o EINA\_UNUSED, \textcolor{keywordtype}{void} *event\_info
      )
\{
   Entry *en = data;
   \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)
     \{
        \hyperlink{struct__Ecore__IMF__Event__Mouse__Down}{Ecore\_IMF\_Event\_Mouse\_Down} ecore\_ev;
        \hyperlink{group__Ecore__IMF__Evas__Group_gae2f41c890f7e9630197bf32a8278f9a0}{ecore\_imf\_evas\_event\_mouse\_down\_wrap}(ev, &ecore\_ev);
        \textcolor{keywordflow}{if} (\hyperlink{group__Ecore__IMF__Context__Group_gacf389a792142af2dc14f660c70cde7ec}{ecore\_imf\_context\_filter\_event}(en->imf\_context,
                                           \hyperlink{group__Ecore__IMF__Context__Group_gga9dcc60537ec7b124a90da72daba4f780ab7204eadb553c0444df98bab6579b0da}{ECORE\_IMF\_EVENT\_MOUSE\_DOWN},
                                           (\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}
        \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, \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *e EINA\_UNUSED, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *o EINA\_UNUSED, \textcolor{keywordtype}{void} *event\_info)
\{
   Entry *en = data;
   \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 & \hyperlink{Evas__Common_8h_a89ffbc5f4d2796994c8b07ef95ef3d1aa2370cbd360270536042b7cfd8c7fcd83}{EVAS\_EVENT\_FLAG\_ON\_HOLD})
     \{
        \_imf\_cursor\_info\_set(en);
        \textcolor{keywordflow}{return};
     \}

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

   \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, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
\}

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

   \textcolor{keywordflow}{if} (en->imf\_context)
     \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, \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *e EINA\_UNUSED, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *o EINA\_UNUSED, \textcolor{keywordtype}{void} *
      event\_info 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}
        \hyperlink{group__Ecore__IMF__Context__Group_ga853f78bd8ab1bcedbc56c32bbc2af9aa}{ecore\_imf\_context\_reset}(en->imf\_context);
        \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 EINA\_UNUSED, \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *e, \textcolor{keywordtype}{void} *event\_info EINA\_UNUSED)
\{
   Entry *en;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj = \hyperlink{group__Evas__Object__Group__Find_gaf5a6ebc4c45f1297e816ff809e5d7d0c}{evas\_focus\_get}(e);
   \textcolor{keywordflow}{if} (!obj) \textcolor{keywordflow}{return};

   en = \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 EINA\_UNUSED, \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *e, \textcolor{keywordtype}{void} *event\_info EINA\_UNUSED)
\{
   Entry *en;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj = \hyperlink{group__Evas__Object__Group__Find_gaf5a6ebc4c45f1297e816ff809e5d7d0c}{evas\_focus\_get}(e);
   \textcolor{keywordflow}{if} (!obj) \textcolor{keywordflow}{return};

   en = \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)
\{
   \hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord} x, y, w, h;
   \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}
   \hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}(en->txt\_obj, &x, &y, &w, &h);
   \hyperlink{group__Evas__Object__Textblock_gad25d397f7c5b988300cff3ae21748c9a}{evas\_textblock\_cursor\_geometry\_get}(en->cursor, &cx, &cy, &cw, &ch, &
      dir, \hyperlink{group__Evas__Object__Textblock_ggaba40faa1b6a6dcd55193db1e3ca31476a12f34cc9432856994ebbb113c78b59f7}{EVAS\_TEXTBLOCK\_CURSOR\_BEFORE});

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

   \hyperlink{group__Ecore__IMF__Context__Group_gaf66f299c16e705570b296d6f85670177}{ecore\_imf\_context\_cursor\_position\_set}(en->imf\_context, cursor\_pos);
   \hyperlink{group__Ecore__IMF__Context__Group_ga8272537bac2b469bfb50bb39397c3a3f}{ecore\_imf\_context\_cursor\_location\_set}(en->imf\_context, x + cx, y + 
      cy, cw, ch);
   \hyperlink{group__Ecore__IMF__Context__Group_gae43b38407a28322748a44de22a122abd}{ecore\_imf\_context\_bidi\_direction\_set}(en->imf\_context, (
      \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} (!\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}
   \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)
     \{
        \hyperlink{group__Evas__Object__Textblock_ga601d0627d1eeddf9a0309ee9b8ccbdf8}{evas\_textblock\_cursor\_free}(en->preedit\_start);
        en->preedit\_start = NULL;
     \}

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

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

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_ecore\_imf\_retrieve\_surrounding\_cb(\textcolor{keywordtype}{void} *data, \hyperlink{group__Ecore__IMF__Context__Group_gab990e052e8501815371d7289dfd4a017}{Ecore\_IMF\_Context} *ctx 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} \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};

   str = 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)
     *cursor\_pos = \hyperlink{group__Evas__Object__Textblock_ga26f34e45c5694208a640d1edbe1645c7}{evas\_textblock\_cursor\_pos\_get}(en->cursor);

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

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_ecore\_imf\_event\_delete\_surrounding\_cb(\textcolor{keywordtype}{void} *data, \hyperlink{group__Ecore__IMF__Context__Group_gab990e052e8501815371d7289dfd4a017}{Ecore\_IMF\_Context} *ctx 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;
   \hyperlink{struct__Ecore__IMF__Event__Delete__Surrounding}{Ecore\_IMF\_Event\_Delete\_Surrounding} *ev = event\_info;
   \hyperlink{group__Evas__Object__Textblock_ga0b6c2d49d4271badfa08e89a53a1dd12}{Evas\_Textblock\_Cursor} *del\_start, *del\_end;
   \textcolor{keywordtype}{int} cursor\_pos;

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

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

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

   \textcolor{comment}{// end cursor position to be deleted}
   del\_end = evas\_object\_textblock\_cursor\_new(en->txt\_obj);
   \hyperlink{group__Evas__Object__Textblock_gab4c4175469da1aac05b9a94352cede66}{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'}
   \hyperlink{group__Evas__Object__Textblock_gad863c689181a25bbfd6cdc24f5452585}{evas\_textblock\_cursor\_range\_delete}(del\_start, del\_end);

   \hyperlink{group__Evas__Object__Textblock_ga601d0627d1eeddf9a0309ee9b8ccbdf8}{evas\_textblock\_cursor\_free}(del\_start);
   \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, \hyperlink{group__Ecore__IMF__Context__Group_gab990e052e8501815371d7289dfd4a017}{Ecore\_IMF\_Context} *ctx 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}
   \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, \hyperlink{group__Ecore__IMF__Context__Group_gab990e052e8501815371d7289dfd4a017}{Ecore\_IMF\_Context} *ctx, \textcolor{keywordtype}{void} *event\_info 
      EINA\_UNUSED)
\{
   \textcolor{comment}{// example how to get preedit string}
   Entry *en = data;
   \textcolor{keywordtype}{char} *preedit\_string;
   \textcolor{keywordtype}{int} cursor\_pos;
   \hyperlink{struct__Eina__List}{Eina\_List} *attrs = NULL;
   \hyperlink{struct__Eina__List}{Eina\_List} *l;
   \hyperlink{struct__Ecore__IMF__Preedit__Attr}{Ecore\_IMF\_Preedit\_Attr} *attr;
   \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;
   \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool} preedit\_end\_state = \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};

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

   \textcolor{comment}{// get preedit string and attributes}
   \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 = \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};

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

   preedit\_start\_pos = \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)
          \{
             \hyperlink{group__Eina__List__Group_gad02f746a08ee0b12b7ed66d4bc0d71d8}{EINA\_LIST\_FOREACH}(attrs, l, attr)
               \{
                  \textcolor{keywordflow}{if} (attr->\hyperlink{struct__Ecore__IMF__Preedit__Attr_ab43d4e86ad2d2fcc5bdc7b534ec2e933}{preedit\_type} == 
      \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->\hyperlink{struct__Ecore__IMF__Preedit__Attr_ab43d4e86ad2d2fcc5bdc7b534ec2e933}{preedit\_type} == 
      \hyperlink{group__Ecore__IMF__Context__Group_ggacd213f9a030646e4f50072426443849aa68ce0b7eb48488808a57096bd28e8723}{ECORE\_IMF\_PREEDIT\_TYPE\_SUB2} || attr->\hyperlink{struct__Ecore__IMF__Preedit__Attr_ab43d4e86ad2d2fcc5bdc7b534ec2e933}{preedit\_type} == 
      \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}
             \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 = evas\_object\_textblock\_cursor\_new(en->txt\_obj);
        \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 = evas\_object\_textblock\_cursor\_new(en->txt\_obj);
        \hyperlink{group__Evas__Object__Textblock_ga7fc4731e670d010ac17af02bd88bd9ef}{evas\_textblock\_cursor\_copy}(en->cursor, en->preedit\_end);

        preedit\_end\_pos = \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++)
          \{
             \hyperlink{group__Evas__Object__Textblock_ga73f736bddac5cd29419493b6628e18c7}{evas\_textblock\_cursor\_char\_prev}(en->preedit\_start);
          \}

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

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

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

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

   free(preedit\_string);
\}

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

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

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

   \textcolor{keywordflow}{if} (!strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"BackSpace"}))
     \{
        \textcolor{keywordflow}{if} (\hyperlink{group__Evas__Object__Textblock_ga73f736bddac5cd29419493b6628e18c7}{evas\_textblock\_cursor\_char\_prev}(en->cursor))
          \{
             \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->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"Delete"}) ||
            (!strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"KP\_Delete"}) && !ev->\hyperlink{struct__Evas__Event__Key__Down_a1b64741ca0b90a5119463f320ebeea00}{string}))
     \{
        \textcolor{comment}{// FILLME}
     \}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} ((control) && (!strcmp(ev->\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->\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->\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->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"c"}) || (!strcmp(ev->\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->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"x"}) || (!strcmp(ev->\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->\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->\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->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"Return"})) || (!strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"KP\_Enter"})))
     \{
        \textcolor{comment}{// FILLME}
     \}
   \textcolor{keywordflow}{else}
     \{
        \textcolor{keywordflow}{if} (ev->\hyperlink{struct__Evas__Event__Key__Down_a1b64741ca0b90a5119463f320ebeea00}{string})
          \{
             printf(\textcolor{stringliteral}{"key down string : %s\(\backslash\)n"}, ev->\hyperlink{struct__Evas__Event__Key__Down_a1b64741ca0b90a5119463f320ebeea00}{string});
             \hyperlink{group__Evas__Object__Textblock_gaa97aaef2ad0653782c7ad1ca30bcb3cb}{evas\_object\_textblock\_text\_markup\_prepend}(en->cursor,
       ev->\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, \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *e EINA\_UNUSED, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *o EINA\_UNUSED, \textcolor{keywordtype}{void} *event\_info)
\{
   Entry *en = data;
   \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)
     \{
        \hyperlink{struct__Ecore__IMF__Event__Key__Up}{Ecore\_IMF\_Event\_Key\_Up} ecore\_ev;

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

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

   en->have\_preedit = \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 = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(evas);
   \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);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(en->rect);
   \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 = \hyperlink{group__Evas__Object__Textblock_ga5059cda84291080e59bcc72ead81ca93}{evas\_object\_textblock\_add}(evas);
   \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, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
   evas\_object\_move(en->txt\_obj, x, y);
   evas\_object\_resize(en->txt\_obj, w, h);
   \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 = \hyperlink{group__Evas__Object__Textblock_ga5047d80b99150342ce3cd5518b474df8}{evas\_textblock\_style\_new}();
   \hyperlink{group__Evas__Object__Textblock_gaf536f7e63f652e36a125006e31cf5457}{evas\_textblock\_style\_set}(en->txt\_style, style\_buf);
   evas\_object\_textblock\_style\_set(en->txt\_obj, en->txt\_style);

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

   \textcolor{comment}{// create input context}
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *default\_id = \hyperlink{group__Ecore__IMF__Context__Group_ga0e34ef45fc0ccb7157a8d7cf96b112ca}{ecore\_imf\_context\_default\_id\_get}();
   \textcolor{keywordflow}{if} (!default\_id)
     \textcolor{keywordflow}{return};

   en->imf\_context = \hyperlink{group__Ecore__IMF__Context__Group_gae2b65dd991c760ae7876ee7df637f68f}{ecore\_imf\_context\_add}(default\_id);
   \hyperlink{group__Ecore__IMF__Context__Group_gacde49b947bdb8837823d8206159b05a2}{ecore\_imf\_context\_client\_window\_set}(en->imf\_context, (\textcolor{keywordtype}{void} *)
      \hyperlink{group__Ecore__Evas__Group_ga70da56eb8130b90623b5b99cf65c22e4}{ecore\_evas\_window\_get}(\hyperlink{group__Ecore__Evas__Group_ga81e49472d5b55809952bf9676daf6a82}{ecore\_evas\_ecore\_evas\_get}(evas)));
   \hyperlink{group__Ecore__IMF__Context__Group_ga96d1d3c9ca63ef47d2e66bd9fae19a8c}{ecore\_imf\_context\_client\_canvas\_set}(en->imf\_context, evas);

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

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

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

   \textcolor{comment}{// register retrieve surrounding callback}
   \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}
   \hyperlink{group__Ecore__IMF__Context__Group_ga7e0ef28b49fbdc54c4657d88a139d5f5}{ecore\_imf\_context\_event\_callback\_add}(en->imf\_context, 
      \hyperlink{group__Ecore__IMF__Context__Group_gga06aadd645f11ba5c8d00943aa327be5aa9d05d645b3c1edde3b959fee4cd87dec}{ECORE\_IMF\_CALLBACK\_COMMIT}, \_ecore\_imf\_event\_commit\_cb, en);

   \textcolor{comment}{// register preedit changed event handler}
   \hyperlink{group__Ecore__IMF__Context__Group_ga7e0ef28b49fbdc54c4657d88a139d5f5}{ecore\_imf\_context\_event\_callback\_add}(en->imf\_context, 
      \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}
   \hyperlink{group__Ecore__IMF__Context__Group_ga7e0ef28b49fbdc54c4657d88a139d5f5}{ecore\_imf\_context\_event\_callback\_add}(en->imf\_context, 
      \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)
     \{
        \hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}(en->rect);
        en->rect = NULL;
     \}

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

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

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

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

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

   \textcolor{keywordflow}{if} (en->imf\_context)
     \{
        \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;
   \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *evas;
   Entry en1, en2;

   \textcolor{keywordflow}{if} (!\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;
     \}

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

   \textcolor{comment}{// create a new window, with size=WIDTHxHEIGHT and default engine}
   ee = \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;
     \}

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

   \textcolor{comment}{// get the canvas off just-created window}
   evas = \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}
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *bg = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(evas);
   evas\_object\_move(bg, 0, 0);
   evas\_object\_resize(bg, WIDTH, HEIGHT);
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(bg, 255, 255, 255, 255);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(bg);

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

   \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, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});

   \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}

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

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

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

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

\end{DoxyCodeInclude}
 