summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJihoon Kim <jihoon48.kim@samsung.com>2014-01-23 10:44:00 +0900
committerJihoon Kim <jihoon48.kim@samsung.com>2014-01-23 10:44:00 +0900
commitfa165f09022d2d002ed0ccdf05cc7ee00735c4a3 (patch)
treef32e88fb5879b4a765e0c56ca99b278c977e2f32 /src
parent1c2da046dccd68f606504bc2029e3e6425293390 (diff)
Add ecore_imf_context_selection_get API to allow Input Method to get the selected text.
Diffstat (limited to 'src')
-rw-r--r--src/lib/ecore_imf/Ecore_IMF.h36
-rw-r--r--src/lib/ecore_imf/ecore_imf_context.c37
-rw-r--r--src/lib/ecore_imf/ecore_imf_private.h2
3 files changed, 75 insertions, 0 deletions
diff --git a/src/lib/ecore_imf/Ecore_IMF.h b/src/lib/ecore_imf/Ecore_IMF.h
index ee1c24919d..2d96a22ab0 100644
--- a/src/lib/ecore_imf/Ecore_IMF.h
+++ b/src/lib/ecore_imf/Ecore_IMF.h
@@ -908,6 +908,20 @@ EAPI void ecore_imf_context_use_preedit_set(Ecore_IMF_C
908EAPI void ecore_imf_context_retrieve_surrounding_callback_set(Ecore_IMF_Context *ctx, Eina_Bool (*func)(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos), const void *data); 908EAPI void ecore_imf_context_retrieve_surrounding_callback_set(Ecore_IMF_Context *ctx, Eina_Bool (*func)(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos), const void *data);
909 909
910/** 910/**
911 * Set the callback to be used on selection_get request.
912 *
913 * This callback will be called when the Input Method Context
914 * module requests the selection context.
915 *
916 * @param ctx An #Ecore_IMF_Context.
917 * @param func The callback to be called.
918 * @param data The data pointer to be passed to @p func
919 * @ingroup Ecore_IMF_Context_Group
920 * @since 1.9.0
921 */
922EAPI void ecore_imf_context_retrieve_selection_callback_set(Ecore_IMF_Context *ctx, Eina_Bool (*func)(void *data, Ecore_IMF_Context *ctx, char **text), const void *data);
923
924/**
911 * Set the input mode used by the Ecore Input Context. 925 * Set the input mode used by the Ecore Input Context.
912 * 926 *
913 * The input mode can be one of the input modes defined in 927 * The input mode can be one of the input modes defined in
@@ -1044,6 +1058,28 @@ EAPI void *ecore_imf_context_data_get(Ecore_IMF_Context
1044EAPI Eina_Bool ecore_imf_context_surrounding_get(Ecore_IMF_Context *ctx, char **text, int *cursor_pos); 1058EAPI Eina_Bool ecore_imf_context_surrounding_get(Ecore_IMF_Context *ctx, char **text, int *cursor_pos);
1045 1059
1046/** 1060/**
1061 * Retrieve the selected text.
1062 *
1063 * This function is implemented by calling the
1064 * Ecore_IMF_Context::retrieve_selection_func (
1065 * set using #ecore_imf_context_retrieve_selection_callback_set).
1066 *
1067 * There is no obligation for a widget to respond to the
1068 * retrieve_surrounding_func, so input methods must be prepared
1069 * to function without context.
1070 *
1071 * @param ctx An #Ecore_IMF_Context.
1072 * @param text Location to store a UTF-8 encoded string of the selected text.
1073 * If the function returns @c EINA_TRUE, then you must free
1074 * the result stored in this location with free().
1075 * @return @c EINA_TRUE if selected text was provided; otherwise
1076 * @c EINA_FALSE.
1077 * @ingroup Ecore_IMF_Context_Module_Group
1078 * @since 1.9.0
1079 */
1080EAPI Eina_Bool ecore_imf_context_selection_get(Ecore_IMF_Context *ctx, char **text);
1081
1082/**
1047 * Adds ECORE_IMF_EVENT_PREEDIT_START to the event queue. 1083 * Adds ECORE_IMF_EVENT_PREEDIT_START to the event queue.
1048 * 1084 *
1049 * ECORE_IMF_EVENT_PREEDIT_START should be added when a new preedit sequence starts. 1085 * ECORE_IMF_EVENT_PREEDIT_START should be added when a new preedit sequence starts.
diff --git a/src/lib/ecore_imf/ecore_imf_context.c b/src/lib/ecore_imf/ecore_imf_context.c
index 63c41c8d02..7b554e6b53 100644
--- a/src/lib/ecore_imf/ecore_imf_context.c
+++ b/src/lib/ecore_imf/ecore_imf_context.c
@@ -462,6 +462,20 @@ ecore_imf_context_retrieve_surrounding_callback_set(Ecore_IMF_Context *ctx, Eina
462} 462}
463 463
464EAPI void 464EAPI void
465ecore_imf_context_retrieve_selection_callback_set(Ecore_IMF_Context *ctx, Eina_Bool (*func)(void *data, Ecore_IMF_Context *ctx, char **text), const void *data)
466{
467 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
468 {
469 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
470 "ecore_imf_context_retrieve_selection_callback_set");
471 return;
472 }
473
474 ctx->retrieve_selection_func = func;
475 ctx->retrieve_selection_data = (void *) data;
476}
477
478EAPI void
465ecore_imf_context_input_mode_set(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode) 479ecore_imf_context_input_mode_set(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode)
466{ 480{
467 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) 481 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
@@ -563,6 +577,29 @@ ecore_imf_context_surrounding_get(Ecore_IMF_Context *ctx, char **text, int *curs
563 return result; 577 return result;
564} 578}
565 579
580EAPI Eina_Bool
581ecore_imf_context_selection_get(Ecore_IMF_Context *ctx, char **text)
582{
583 Eina_Bool result = EINA_FALSE;
584
585 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
586 {
587 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
588 "ecore_imf_context_selection_get");
589 return EINA_FALSE;
590 }
591
592 if (ctx->retrieve_selection_func)
593 {
594 result = ctx->retrieve_selection_func(ctx->retrieve_selection_data, ctx, text);
595 if (!result)
596 {
597 if (text) *text = NULL;
598 }
599 }
600 return result;
601}
602
566static void 603static void
567_ecore_imf_event_free_preedit(void *data EINA_UNUSED, void *event) 604_ecore_imf_event_free_preedit(void *data EINA_UNUSED, void *event)
568{ 605{
diff --git a/src/lib/ecore_imf/ecore_imf_private.h b/src/lib/ecore_imf/ecore_imf_private.h
index 81d71c9263..d6bf257efc 100644
--- a/src/lib/ecore_imf/ecore_imf_private.h
+++ b/src/lib/ecore_imf/ecore_imf_private.h
@@ -56,6 +56,8 @@ struct _Ecore_IMF_Context
56 Ecore_IMF_Input_Panel_Lang input_panel_lang; 56 Ecore_IMF_Input_Panel_Lang input_panel_lang;
57 Ecore_IMF_Input_Panel_Return_Key_Type input_panel_return_key_type; 57 Ecore_IMF_Input_Panel_Return_Key_Type input_panel_return_key_type;
58 int input_panel_layout_variation; 58 int input_panel_layout_variation;
59 Eina_Bool (*retrieve_selection_func)(void *data, Ecore_IMF_Context *ctx, char **text);
60 void *retrieve_selection_data;
59 Eina_Bool allow_prediction : 1; 61 Eina_Bool allow_prediction : 1;
60 Eina_Bool input_panel_enabled : 1; 62 Eina_Bool input_panel_enabled : 1;
61 Eina_Bool input_panel_return_key_disabled : 1; 63 Eina_Bool input_panel_return_key_disabled : 1;