sample: remove complex code 45/191545/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Thu, 18 Oct 2018 07:27:52 +0000 (16:27 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 18 Oct 2018 07:27:52 +0000 (16:27 +0900)
Change-Id: I0a02c88b9374b0c2e68ebc574fecab80abfb3823
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
test/ecore_imf_example.c

index 75e78b7..ed67853 100644 (file)
@@ -394,56 +394,6 @@ _preedit_clear(Entry *en)
     en->have_preedit = EINA_FALSE;
 }
 
-static Eina_Bool
-_ecore_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, char **text, int *cursor_pos)
-{
-    // This callback will be called when the Input Method Context module requests the surrounding context.
-    Entry *en = data;
-    const char *str;
-
-    if (!en) return EINA_FALSE;
-
-    str = evas_object_textblock_text_markup_get(en->txt_obj);
-
-    if (text)
-        *text = str ? strdup(str) : strdup("");
-
-    // get the current position of cursor
-    if (cursor_pos && en->cursor)
-        *cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
-
-    return EINA_TRUE;
-}
-
-static void
-_ecore_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void *event_info)
-{
-    // called when the input method needs to delete all or part of the context surrounding the cursor
-    Entry *en = data;
-    Ecore_IMF_Event_Delete_Surrounding *ev = event_info;
-    Evas_Textblock_Cursor *del_start, *del_end;
-    int cursor_pos;
-
-    if ((!en) || (!ev) || (!en->cursor)) return;
-
-    // get the current cursor position
-    cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
-
-    // start cursor position to be deleted
-    del_start = evas_object_textblock_cursor_new(en->txt_obj);
-    evas_textblock_cursor_pos_set(del_start, cursor_pos + ev->offset);
-
-    // end cursor position to be deleted
-    del_end = evas_object_textblock_cursor_new(en->txt_obj);
-    evas_textblock_cursor_pos_set(del_end, cursor_pos + ev->offset + ev->n_chars);
-
-    // implement function to delete character(s) from 'cursor_pos+ev->offset' cursor position to 'cursor_pos + ev->offset + ev->n_chars'
-    evas_textblock_cursor_range_delete(del_start, del_end);
-
-    evas_textblock_cursor_free(del_start);
-    evas_textblock_cursor_free(del_end);
-}
-
 static void
 _ecore_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void *event_info)
 {
@@ -559,7 +509,6 @@ _key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *
 {
     Entry *en = data;
     Evas_Event_Key_Down *ev = event_info;
-    Eina_Bool control, alt, shift;
     if ((!en) || (!ev->key) || (!en->cursor)) return;
 
     if (en->imf_context)
@@ -572,12 +521,6 @@ _key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *
             return;
     }
 
-    control = evas_key_modifier_is_set(ev->modifiers, "Control");
-    alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
-    shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
-    (void)alt;
-    (void)shift;
-
     if (!strcmp(ev->key, "BackSpace"))
     {
         if (evas_textblock_cursor_char_prev(en->cursor))
@@ -593,41 +536,6 @@ _key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *
     {
         // FILLME
     }
-    else if ((control) && (!strcmp(ev->key, "v")))
-    {
-        // ctrl + v
-        // FILLME
-    }
-    else if ((control) && (!strcmp(ev->key, "a")))
-    {
-        // ctrl + a
-        // FILLME
-    }
-    else if ((control) && (!strcmp(ev->key, "A")))
-    {
-        // ctrl + A
-        // FILLME
-    }
-    else if ((control) && ((!strcmp(ev->key, "c") || (!strcmp(ev->key, "Insert")))))
-    {
-        // ctrl + c
-        // FILLME
-    }
-    else if ((control) && ((!strcmp(ev->key, "x") || (!strcmp(ev->key, "m")))))
-    {
-        // ctrl + x
-        // FILLME
-    }
-    else if ((control) && (!strcmp(ev->key, "z")))
-    {
-        // ctrl + z (undo)
-        // FILLME
-    }
-    else if ((control) && (!strcmp(ev->key, "y")))
-    {
-        // ctrl + y (redo)
-        // FILLME
-    }
     else if ((!strcmp(ev->key, "Return")) || (!strcmp(ev->key, "KP_Enter")))
     {
         // FILLME
@@ -737,17 +645,11 @@ create_input_field(Evas *evas, Entry *en, const char *id, const char *label, boo
     evas_object_event_callback_add(en->rect, EVAS_CALLBACK_FOCUS_IN, _entry_focus_in_cb, en);
     evas_object_event_callback_add(en->rect, EVAS_CALLBACK_FOCUS_OUT, _entry_focus_out_cb, en);
 
-    // register retrieve surrounding callback
-    ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context, _ecore_imf_retrieve_surrounding_cb, en);
-
     // register commit event callback
     ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _ecore_imf_event_commit_cb, en);
 
     // register preedit changed event handler
     ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _ecore_imf_event_preedit_changed_cb, en);
-
-    // register surrounding delete event callback
-    ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _ecore_imf_event_delete_surrounding_cb, en);
 }
 
 static void