11 #include <ecore_private.h>
13 #include "Ecore_IMF.h"
14 #include "ecore_imf_private.h"
17 * @defgroup Ecore_IMF_Context_Group Ecore Input Method Context Functions
19 * Functions that operate on Ecore Input Method Context objects.
23 * Get the list of the available Input Method Context ids.
25 * Note that the caller is responsible for freeing the Eina_List
26 * when finished with it. There is no need to finish the list strings.
28 * @return Return an Eina_List of strings;
29 * on failure it returns NULL.
30 * @ingroup Ecore_IMF_Context_Group
33 ecore_imf_context_available_ids_get(void)
35 return ecore_imf_module_context_ids_get();
39 ecore_imf_context_available_ids_by_canvas_type_get(const char *canvas_type)
41 return ecore_imf_module_context_ids_by_canvas_type_get(canvas_type);
45 * Match @locale against @against.
47 * 'en_US' against 'en_US' => 4
48 * 'en_US' against 'en' => 3
49 * 'en', 'en_UK' against 'en_US' => 2
50 * all locales, against '*' => 1
53 _ecore_imf_context_match_locale(const char *locale, const char *against, int against_len)
55 if (strcmp(against, "*") == 0)
58 if (strcasecmp(locale, against) == 0)
61 if (strncasecmp(locale, against, 2) == 0)
62 return (against_len == 2) ? 3 : 2;
68 * Get the id of the default Input Method Context.
69 * The id may to used to create a new instance of an Input Method
72 * @return Return a string containing the id of the default Input
73 * Method Context; on failure it returns NULL.
74 * @ingroup Ecore_IMF_Context_Group
77 ecore_imf_context_default_id_get(void)
79 return ecore_imf_context_default_id_by_canvas_type_get(NULL);
83 ecore_imf_context_default_id_by_canvas_type_get(const char *canvas_type)
87 Ecore_IMF_Module *module;
90 int best_goodness = 0;
92 id = getenv("ECORE_IMF_MODULE");
95 if (strcmp(id, "none") == 0) return NULL;
96 if (ecore_imf_module_get(id)) return id;
99 modules = ecore_imf_module_available_get();
100 if (!modules) return NULL;
102 locale = setlocale(LC_CTYPE, NULL);
103 if (!locale) return NULL;
105 locale = strdup(locale);
107 tmp = strchr(locale, '.');
108 if (tmp) *tmp = '\0';
109 tmp = strchr(locale, '@');
110 if (tmp) *tmp = '\0';
114 EINA_LIST_FREE(modules, module)
117 strcmp(module->info->canvas_type, canvas_type) == 0)
120 const char *p = module->info->default_locales;
123 const char *q = strchr(p, ':');
124 int goodness = _ecore_imf_context_match_locale(locale, p, q ? (size_t)(q - p) : strlen (p));
126 if (goodness > best_goodness)
128 id = module->info->id;
129 best_goodness = goodness;
132 p = q ? q + 1 : NULL;
141 * Retrieve the info for the Input Method Context with @p id.
143 * @param id The Input Method Context id to query for.
144 * @return Return a #Ecore_IMF_Context_Info for the Input Method Context with @p id;
145 * on failure it returns NULL.
146 * @ingroup Ecore_IMF_Context_Group
148 EAPI const Ecore_IMF_Context_Info *
149 ecore_imf_context_info_by_id_get(const char *id)
151 Ecore_IMF_Module *module;
153 if (!id) return NULL;
154 module = ecore_imf_module_get(id);
155 if (!module) return NULL;
160 * Create a new Input Method Context defined by the given id.
162 * @param id The Input Method Context id.
163 * @return A newly allocated Input Method Context;
164 * on failure it returns NULL.
165 * @ingroup Ecore_IMF_Context_Group
167 EAPI Ecore_IMF_Context *
168 ecore_imf_context_add(const char *id)
170 Ecore_IMF_Context *ctx;
172 if (!id) return NULL;
173 ctx = ecore_imf_module_context_create(id);
174 if (!ctx || !ctx->klass) return NULL;
175 if (ctx->klass->add) ctx->klass->add(ctx);
176 /* default use_preedit is EINA_TRUE, so let's make sure it's
177 * set on the immodule */
178 ecore_imf_context_use_preedit_set(ctx, EINA_TRUE);
179 /* default input_mode is ECORE_IMF_INPUT_MODE_FULL, so let's make sure it's
180 * set on the immodule */
181 ecore_imf_context_input_mode_set(ctx, ECORE_IMF_INPUT_MODE_FULL);
186 * Retrieve the info for the given Input Method Context.
188 * @param ctx An #Ecore_IMF_Context.
189 * @return Return a #Ecore_IMF_Context_Info for the given Input Method Context;
190 * on failure it returns NULL.
191 * @ingroup Ecore_IMF_Context_Group
193 EAPI const Ecore_IMF_Context_Info *
194 ecore_imf_context_info_get(Ecore_IMF_Context *ctx)
196 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
198 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
199 "ecore_imf_context_info_get");
202 return ctx->module->info;
206 * Delete the given Input Method Context and free its memory.
208 * @param ctx An #Ecore_IMF_Context.
209 * @ingroup Ecore_IMF_Context_Group
212 ecore_imf_context_del(Ecore_IMF_Context *ctx)
216 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
218 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
219 "ecore_imf_context_del");
222 if (ctx->klass->del) ctx->klass->del(ctx);
223 ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE);
225 EINA_LIST_FREE(ctx->private_key_list, data)
228 EINA_LIST_FREE(ctx->disabled_key_list, data)
231 ctx->private_key_list = NULL;
232 ctx->disabled_key_list = NULL;
238 * Set the client window for the Input Method Context; this is the
239 * Ecore_X_Window when using X11, Ecore_Win32_Window when using Win32, etc.
240 * This window is used in order to correctly position status windows, and may
241 * also be used for purposes internal to the Input Method Context.
243 * @param ctx An #Ecore_IMF_Context.
244 * @param window The client window. This may be NULL to indicate
245 * that the previous client window no longer exists.
246 * @ingroup Ecore_IMF_Context_Group
249 ecore_imf_context_client_window_set(Ecore_IMF_Context *ctx, void *window)
251 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
253 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
254 "ecore_imf_context_client_window_set");
257 if (ctx->klass->client_window_set) ctx->klass->client_window_set(ctx, window);
258 ctx->window = window;
262 ecore_imf_context_client_window_get(Ecore_IMF_Context *ctx)
264 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
266 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
267 "ecore_imf_context_client_window_get");
274 * Set the client canvas for the Input Method Context; this is the
275 * canvas in which the input appears.
276 * The canvas type can be determined by using the context canvas type.
277 * Actually only canvas with type "evas" (Evas *) is supported.
278 * This canvas may be used in order to correctly position status windows, and may
279 * also be used for purposes internal to the Input Method Context.
281 * @param ctx An #Ecore_IMF_Context.
282 * @param canvas The client canvas. This may be NULL to indicate
283 * that the previous client canvas no longer exists.
284 * @ingroup Ecore_IMF_Context_Group
287 ecore_imf_context_client_canvas_set(Ecore_IMF_Context *ctx, void *canvas)
289 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
291 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
292 "ecore_imf_context_client_canvas_set");
295 if (ctx->klass->client_canvas_set) ctx->klass->client_canvas_set(ctx, canvas);
296 ctx->client_canvas = canvas;
300 ecore_imf_context_client_canvas_get(Ecore_IMF_Context *ctx)
302 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
304 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
305 "ecore_imf_context_client_canvas_get");
308 return ctx->client_canvas;
312 * Ask the Input Method Context to show itself.
314 * @param ctx An #Ecore_IMF_Context.
315 * @ingroup Ecore_IMF_Context_Group
317 EINA_DEPRECATED EAPI void
318 ecore_imf_context_show(Ecore_IMF_Context *ctx)
320 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
322 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
323 "ecore_imf_context_show");
326 if (ctx->klass->show) ctx->klass->show(ctx);
330 * Ask the Input Method Context to hide itself.
332 * @param ctx An #Ecore_IMF_Context.
333 * @ingroup Ecore_IMF_Context_Group
335 EINA_DEPRECATED EAPI void
336 ecore_imf_context_hide(Ecore_IMF_Context *ctx)
338 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
340 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
341 "ecore_imf_context_hide");
344 if (ctx->klass->hide) ctx->klass->hide(ctx);
348 * Retrieve the current preedit string and cursor position
349 * for the Input Method Context.
351 * @param ctx An #Ecore_IMF_Context.
352 * @param str Location to store the retrieved string. The
353 * string retrieved must be freed with free().
354 * @param cursor_pos Location to store position of cursor (in characters)
355 * within the preedit string.
356 * @ingroup Ecore_IMF_Context_Group
359 ecore_imf_context_preedit_string_get(Ecore_IMF_Context *ctx, char **str, int *cursor_pos)
361 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
363 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
364 "ecore_imf_context_preedit_string_get");
367 if (ctx->klass->preedit_string_get)
368 ctx->klass->preedit_string_get(ctx, str, cursor_pos);
371 if (str) *str = strdup("");
372 if (cursor_pos) *cursor_pos = 0;
377 ecore_imf_context_preedit_string_with_attributes_get(Ecore_IMF_Context *ctx, char **str, Eina_List **attrs, int *cursor_pos)
379 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
381 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
382 "ecore_imf_context_preedit_string_with_attributes_get");
385 if (ctx->klass->preedit_string_with_attributes_get)
386 ctx->klass->preedit_string_with_attributes_get(ctx, str, attrs, cursor_pos);
389 if (str) *str = strdup("");
390 if (attrs) *attrs = NULL;
391 if (cursor_pos) *cursor_pos = 0;
396 * Notify the Input Method Context that the widget to which its
397 * correspond has gained focus.
399 * @param ctx An #Ecore_IMF_Context.
400 * @ingroup Ecore_IMF_Context_Group
403 ecore_imf_context_focus_in(Ecore_IMF_Context *ctx)
405 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
407 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
408 "ecore_imf_context_focus_in");
411 if (ctx->klass->focus_in) ctx->klass->focus_in(ctx);
415 * Notify the Input Method Context that the widget to which its
416 * correspond has lost focus.
418 * @param ctx An #Ecore_IMF_Context.
419 * @ingroup Ecore_IMF_Context_Group
422 ecore_imf_context_focus_out(Ecore_IMF_Context *ctx)
424 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
426 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
427 "ecore_imf_context_focus_out");
430 if (ctx->klass->focus_out) ctx->klass->focus_out(ctx);
434 * Notify the Input Method Context that a change such as a
435 * change in cursor position has been made. This will typically
436 * cause the Input Method Context to clear the preedit state.
438 * @param ctx An #Ecore_IMF_Context.
439 * @ingroup Ecore_IMF_Context_Group
442 ecore_imf_context_reset(Ecore_IMF_Context *ctx)
444 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
446 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
447 "ecore_imf_context_reset");
450 if (ctx->klass->reset) ctx->klass->reset(ctx);
454 * Notify the Input Method Context that a change in the cursor
455 * position has been made.
457 * @param ctx An #Ecore_IMF_Context.
458 * @param cursor_pos New cursor position in characters.
459 * @ingroup Ecore_IMF_Context_Group
462 ecore_imf_context_cursor_position_set(Ecore_IMF_Context *ctx, int cursor_pos)
464 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
466 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
467 "ecore_imf_context_cursor_position_set");
470 if (ctx->klass->cursor_position_set) ctx->klass->cursor_position_set(ctx, cursor_pos);
474 * Set whether the IM context should use the preedit string
475 * to display feedback. If @use_preedit is EINA_FALSE (default
476 * is EINA_TRUE), then the IM context may use some other method to display
477 * feedback, such as displaying it in a child of the root window.
479 * @param ctx An #Ecore_IMF_Context.
480 * @param use_preedit Whether the IM context should use the preedit string.
481 * @ingroup Ecore_IMF_Context_Group
484 ecore_imf_context_use_preedit_set(Ecore_IMF_Context *ctx, Eina_Bool use_preedit)
486 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
488 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
489 "ecore_imf_context_use_preedit_set");
492 if (ctx->klass->use_preedit_set) ctx->klass->use_preedit_set(ctx, use_preedit);
496 * Set the callback to be used on get_surrounding request.
498 * This callback will be called when the Input Method Context
499 * module requests the surrounding context.
501 * @param ctx An #Ecore_IMF_Context.
502 * @param func The callback to be called.
503 * @param data The data pointer to be passed to @p func
504 * @ingroup Ecore_IMF_Context_Group
507 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)
509 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
511 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
512 "ecore_imf_context_retrieve_surrounding_callback_set");
516 ctx->retrieve_surrounding_func = func;
517 ctx->retrieve_surrounding_data = (void *) data;
521 * Set the input mode used by the Ecore Input Context.
523 * The input mode can be one of the input modes defined in
524 * #Ecore_IMF_Input_Mode. The default input mode is
525 * ECORE_IMF_INPUT_MODE_FULL.
527 * @param ctx An #Ecore_IMF_Context.
528 * @param input_mode The input mode to be used by @p ctx.
529 * @ingroup Ecore_IMF_Context_Group
531 EINA_DEPRECATED EAPI void
532 ecore_imf_context_input_mode_set(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode)
534 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
536 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
537 "ecore_imf_context_input_mode_set");
540 if (ctx->klass->input_mode_set) ctx->klass->input_mode_set(ctx, input_mode);
541 ctx->input_mode = input_mode;
545 * Get the input mode being used by the Ecore Input Context.
547 * See @ref ecore_imf_context_input_mode_set for more details.
549 * @param ctx An #Ecore_IMF_Context.
550 * @return The input mode being used by @p ctx.
551 * @ingroup Ecore_IMF_Context_Group
553 EINA_DEPRECATED EAPI Ecore_IMF_Input_Mode
554 ecore_imf_context_input_mode_get(Ecore_IMF_Context *ctx)
556 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
558 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
559 "ecore_imf_context_input_mode_set");
562 return ctx->input_mode;
566 * Allow an Ecore Input Context to internally handle an event.
567 * If this function returns EINA_TRUE, then no further processing
568 * should be done for this event.
570 * Input methods must be able to accept all types of events (simply
571 * returning EINA_FALSE if the event was not handled), but there is no
572 * obligation of any events to be submitted to this function.
574 * @param ctx An #Ecore_IMF_Context.
575 * @param type The type of event defined by #Ecore_IMF_Event_Type.
576 * @param event The event itself.
577 * @return EINA_TRUE if the event was handled; otherwise EINA_FALSE.
578 * @ingroup Ecore_IMF_Context_Group
581 ecore_imf_context_filter_event(Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, Ecore_IMF_Event *event)
583 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
585 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
586 "ecore_imf_context_filter_event");
589 if (ctx->klass->filter_event) return ctx->klass->filter_event(ctx, type, event);
594 * @defgroup Ecore_IMF_Context_Module_Group Ecore Input Method Context Module Functions
596 * Functions that should be used by Ecore Input Method Context modules.
600 * Creates a new Input Method Context with klass specified by @p ctxc.
602 * This method should be used by modules implementing the Input
603 * Method Context interface.
605 * @param ctxc An #Ecore_IMF_Context_Class.
606 * @return A new #Ecore_IMF_Context; on failure it returns NULL.
607 * @ingroup Ecore_IMF_Context_Module_Group
609 EAPI Ecore_IMF_Context *
610 ecore_imf_context_new(const Ecore_IMF_Context_Class *ctxc)
612 Ecore_IMF_Context *ctx;
614 if (!ctxc) return NULL;
615 ctx = calloc(1, sizeof(Ecore_IMF_Context));
616 if (!ctx) return NULL;
617 ECORE_MAGIC_SET(ctx, ECORE_MAGIC_CONTEXT);
620 ctx->retrieve_surrounding_func = NULL;
621 ctx->retrieve_surrounding_data = NULL;
622 ctx->input_panel_x = 0;
623 ctx->input_panel_y = 0;
624 ctx->input_panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
625 ctx->input_panel_orient = ECORE_IMF_INPUT_PANEL_ORIENT_NONE;
626 ctx->use_effect = EINA_TRUE;
627 ctx->callbacks = NULL;
633 * Set the Input Method Context specific data.
635 * Note that this method should be used by modules to set
636 * the Input Method Context specific data and it's not meant to
637 * be used by applications to store application specific data.
639 * @param ctx An #Ecore_IMF_Context.
640 * @param data The Input Method Context specific data.
641 * @return A new #Ecore_IMF_Context; on failure it returns NULL.
642 * @ingroup Ecore_IMF_Context_Module_Group
645 ecore_imf_context_data_set(Ecore_IMF_Context *ctx, void *data)
647 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
649 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
650 "ecore_imf_context_data_set");
657 * Get the Input Method Context specific data.
659 * See @ref ecore_imf_context_data_set for more details.
661 * @param ctx An #Ecore_IMF_Context.
662 * @return The Input Method Context specific data.
663 * @ingroup Ecore_IMF_Context_Module_Group
665 EAPI void *ecore_imf_context_data_get(Ecore_IMF_Context *ctx)
667 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
669 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
670 "ecore_imf_context_data_get");
677 * Retrieve context around insertion point.
679 * This function is implemented by calling the
680 * Ecore_IMF_Context::retrieve_surrounding_func (
681 * set using #ecore_imf_context_retrieve_surrounding_callback_set).
683 * There is no obligation for a widget to respond to the
684 * ::retrieve_surrounding_func, so input methods must be prepared
685 * to function without context.
687 * @param ctx An #Ecore_IMF_Context.
688 * @param text Location to store a UTF-8 encoded string of text
689 * holding context around the insertion point.
690 * If the function returns EINA_TRUE, then you must free
691 * the result stored in this location with free().
692 * @param cursor_pos Location to store the position in characters of
693 * the insertion cursor within @text.
694 * @return EINA_TRUE if surrounding text was provided; otherwise EINA_FALSE.
695 * @ingroup Ecore_IMF_Context_Module_Group
698 ecore_imf_context_surrounding_get(Ecore_IMF_Context *ctx, char **text, int *cursor_pos)
700 int result = EINA_FALSE;
702 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
704 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
705 "ecore_imf_context_surrounding_get");
709 if (ctx->retrieve_surrounding_func)
711 result = ctx->retrieve_surrounding_func(ctx->retrieve_surrounding_data, ctx, text, cursor_pos);
714 if (text) *text = NULL;
715 if (cursor_pos) *cursor_pos = 0;
722 _ecore_imf_event_free_preedit(void *data __UNUSED__, void *event)
728 * Adds ECORE_IMF_EVENT_PREEDIT_START to the event queue.
729 * ECORE_IMF_EVENT_PREEDIT_START should be added when a new preedit sequence starts.
731 * @param ctx An #Ecore_IMF_Context.
732 * @ingroup Ecore_IMF_Context_Module_Group
735 ecore_imf_context_preedit_start_event_add(Ecore_IMF_Context *ctx)
737 Ecore_IMF_Event_Commit *ev;
739 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
741 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
742 "ecore_imf_context_preedit_start_event_add");
746 ev = malloc(sizeof(Ecore_IMF_Event_Preedit_Start));
748 ecore_event_add(ECORE_IMF_EVENT_PREEDIT_START,
749 ev, _ecore_imf_event_free_preedit, NULL);
753 * Adds ECORE_IMF_EVENT_PREEDIT_END to the event queue.
754 * ECORE_IMF_EVENT_PREEDIT_END should be added when a new preedit sequence has been completed or canceled.
756 * @param ctx An #Ecore_IMF_Context.
757 * @ingroup Ecore_IMF_Context_Module_Group
760 ecore_imf_context_preedit_end_event_add(Ecore_IMF_Context *ctx)
762 Ecore_IMF_Event_Commit *ev;
764 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
766 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
767 "ecore_imf_context_preedit_end_event_add");
771 ev = malloc(sizeof(Ecore_IMF_Event_Preedit_End));
773 ecore_event_add(ECORE_IMF_EVENT_PREEDIT_END,
774 ev, _ecore_imf_event_free_preedit, NULL);
778 * Adds ECORE_IMF_EVENT_PREEDIT_CHANGED to the event queue.
780 * @param ctx An #Ecore_IMF_Context.
781 * @ingroup Ecore_IMF_Context_Module_Group
784 ecore_imf_context_preedit_changed_event_add(Ecore_IMF_Context *ctx)
786 Ecore_IMF_Event_Commit *ev;
788 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
790 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
791 "ecore_imf_context_preedit_changed_event_add");
795 ev = malloc(sizeof(Ecore_IMF_Event_Preedit_Changed));
797 ecore_event_add(ECORE_IMF_EVENT_PREEDIT_CHANGED,
798 ev, _ecore_imf_event_free_preedit, NULL);
802 _ecore_imf_event_free_commit(void *data __UNUSED__, void *event)
804 Ecore_IMF_Event_Commit *ev;
807 if (ev->str) free(ev->str);
812 * Adds ECORE_IMF_EVENT_COMMIT to the event queue.
814 * @param ctx An #Ecore_IMF_Context.
815 * @param str The committed string.
816 * @ingroup Ecore_IMF_Context_Module_Group
819 ecore_imf_context_commit_event_add(Ecore_IMF_Context *ctx, const char *str)
821 Ecore_IMF_Event_Commit *ev;
823 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
825 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
826 "ecore_imf_context_commit_event_add");
830 ev = malloc(sizeof(Ecore_IMF_Event_Commit));
832 ev->str = str ? strdup(str) : NULL;
833 ecore_event_add(ECORE_IMF_EVENT_COMMIT,
834 ev, _ecore_imf_event_free_commit, NULL);
839 _ecore_imf_event_free_delete_surrounding(void *data __UNUSED__, void *event)
845 * Asks the widget that the input context is attached to to delete characters around the cursor position
846 * by adding the ECORE_IMF_EVENT_DELETE_SURROUNDING to the event queue.
847 * Note that offset and n_chars are in characters not in bytes.
849 * @param ctx An #Ecore_IMF_Context.
850 * @param offset The start offset of surrounding to be deleted.
851 * @param n_chars The number of characters to be deleted.
852 * @ingroup Ecore_IMF_Context_Module_Group
855 ecore_imf_context_delete_surrounding_event_add(Ecore_IMF_Context *ctx, int offset, int n_chars)
857 Ecore_IMF_Event_Delete_Surrounding *ev;
859 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
861 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
862 "ecore_imf_context_delete_surrounding_event_add");
866 ev = malloc(sizeof(Ecore_IMF_Event_Delete_Surrounding));
869 ev->n_chars = n_chars;
870 ecore_event_add(ECORE_IMF_EVENT_DELETE_SURROUNDING,
871 ev, _ecore_imf_event_free_delete_surrounding, NULL);
874 /*** ImControl Related APIs */
876 ecore_imf_context_input_panel_show(Ecore_IMF_Context *ctx)
878 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
880 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_show");
884 if (ctx->klass->show) ctx->klass->show(ctx);
888 ecore_imf_context_input_panel_hide(Ecore_IMF_Context *ctx)
890 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
892 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_hide");
896 if (ctx->klass->hide) ctx->klass->hide(ctx);
900 ecore_imf_context_control_panel_show (Ecore_IMF_Context *ctx)
902 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
904 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_control_panel_show");
908 if (ctx->klass->control_panel_show) ctx->klass->control_panel_show(ctx);
912 ecore_imf_context_control_panel_hide (Ecore_IMF_Context *ctx)
914 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
916 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_control_panel_hide");
920 if (ctx->klass->control_panel_hide) ctx->klass->control_panel_hide(ctx);
924 ecore_imf_context_input_panel_language_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Lang lang)
926 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
928 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_language_set");
931 if (ctx->klass->input_panel_language_set) ctx->klass->input_panel_language_set(ctx, lang);
932 ctx->input_panel_lang = lang;
935 EAPI Ecore_IMF_Input_Panel_Lang
936 ecore_imf_context_input_panel_language_get (Ecore_IMF_Context *ctx)
938 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
940 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_language_get");
941 return ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC;
944 return ctx->input_panel_lang;
948 ecore_imf_context_ise_get_ise_language (Ecore_IMF_Context *ctx, const char* ise_name, char ***langlist)
950 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
952 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_get_ise_language");
958 printf ("input parameters error!!! \n");
962 if (ctx->klass->ise_get_ise_language)
964 return ctx->klass->ise_get_ise_language(ctx, ise_name, langlist);
970 EAPI void ecore_imf_context_keyboard_language_set (Ecore_IMF_Context *ctx, Ecore_IMF_Keyboard_Lang lang)
972 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
974 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_keyboard_language_set");
977 // if (ctx->klass->ise_set_language) ctx->klass->ise_set_language(ctx, lang);
980 EAPI Ecore_IMF_Keyboard_Lang ecore_imf_context_keyboard_language_get (Ecore_IMF_Context *ctx)
982 Ecore_IMF_Keyboard_Lang lang = ECORE_IMF_KEYBOARD_LANG_NATIVE;
983 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
985 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_keyboard_language_get");
989 if (ctx->klass->input_panel_language_get)
990 lang = ctx->klass->input_panel_language_get(ctx);
996 ecore_imf_context_ise_set_isf_language (Ecore_IMF_Context *ctx, const char* lang)
998 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1000 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_set_isf_language");
1006 printf ("input parameters error!!! \n");
1010 if (ctx->klass->ise_set_isf_language) ctx->klass->ise_set_isf_language(ctx, lang);
1014 ecore_imf_context_input_panel_imdata_set (Ecore_IMF_Context *ctx, const char * data, int len)
1016 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1018 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_imdata_set");
1022 if (!data || len <=0)
1024 printf ("input parameters error!!! \n");
1028 if (ctx->klass->input_panel_imdata_set) ctx->klass->input_panel_imdata_set(ctx, data, len);
1032 ecore_imf_context_input_panel_imdata_get (Ecore_IMF_Context *ctx, char * data, int *len)
1034 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1036 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_get_imdata");
1042 printf ("input parameters error!!! \n");
1046 if (ctx->klass->input_panel_imdata_get) ctx->klass->input_panel_imdata_get(ctx, data, len);
1050 ecore_imf_context_input_panel_use_effect_set (Ecore_IMF_Context *ctx, Eina_Bool use_effect)
1052 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1054 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_use_effect_set");
1058 if (ctx->klass->input_panel_use_effect_set) ctx->klass->input_panel_use_effect_set(ctx, use_effect);
1059 ctx->use_effect = use_effect;
1063 ecore_imf_context_input_panel_use_effect_get (Ecore_IMF_Context *ctx)
1065 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1067 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_use_effect_get");
1071 return ctx->use_effect;
1075 ecore_imf_context_input_panel_geometry_get (Ecore_IMF_Context *ctx, int *x, int *y, int *w, int *h)
1077 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1079 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_geometry_get");
1083 if (ctx->klass->input_panel_geometry_get) ctx->klass->input_panel_geometry_get(ctx, x, y, w, h);
1087 ecore_imf_context_input_panel_private_key_set (Ecore_IMF_Context *ctx, int layout_index, int key_index, const char *img_path, const char* label, int key_value, const char* key_string)
1089 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1091 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_private_key_set");
1095 if (label == NULL && img_path == NULL)
1097 printf ("input parameters error!!! \n");
1101 Private_Key_Item *key_item;
1103 Eina_Bool exist = EINA_FALSE;
1105 EINA_LIST_FOREACH(ctx->private_key_list, l, key_item)
1107 if (key_item && key_item->layout_idx == layout_index && key_item->key_idx == key_index)
1109 // if exist in the list
1114 strcpy(key_item->data, label);
1119 strcpy(key_item->data, img_path);
1121 key_item->key_value = key_value;
1122 strcpy(key_item->key_string, key_string);
1128 key_item = calloc(1, sizeof(Private_Key_Item));
1129 if (!key_item) return;
1131 key_item->layout_idx = layout_index;
1132 key_item->key_idx = key_index;;
1136 strcpy(key_item->data, label);
1141 strcpy(key_item->data, img_path);
1143 key_item->key_value = key_value;
1147 strcpy(key_item->key_string, key_string);
1150 ctx->private_key_list = eina_list_append(ctx->private_key_list, key_item);
1153 // if (ctx->klass->input_panel_private_key_set) ctx->klass->input_panel_private_key_set(ctx, layout_index, key_index, img_path, label, value);
1157 ecore_imf_context_input_panel_private_key_list_get (Ecore_IMF_Context *ctx)
1159 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1161 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_private_key_list_get");
1165 return ctx->private_key_list;
1169 ecore_imf_context_input_panel_key_disabled_set (Ecore_IMF_Context *ctx, int layout_index, int key_index, Eina_Bool disabled)
1171 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1173 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_key_disabled_set");
1177 Disable_Key_Item *key_item;
1179 Eina_Bool exist = EINA_FALSE;
1181 EINA_LIST_FOREACH(ctx->disabled_key_list, l, key_item)
1183 if (key_item && key_item->layout_idx == layout_index && key_item->key_idx == key_index)
1185 key_item->disabled = disabled;
1192 key_item = calloc(1, sizeof(Disable_Key_Item));
1193 if (!key_item) return;
1195 key_item->layout_idx = layout_index;
1196 key_item->key_idx = key_index;;
1197 key_item->disabled = disabled;
1199 ctx->disabled_key_list = eina_list_append(ctx->disabled_key_list, key_item);
1202 // if (ctx->klass->input_panel_key_disabled_set) ctx->klass->input_panel_key_disabled_set(ctx, layout_index, key_index, disabled);
1206 ecore_imf_context_input_panel_key_disabled_list_get (Ecore_IMF_Context *ctx)
1208 return ctx->disabled_key_list;
1212 ecore_imf_context_input_panel_layout_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Layout layout)
1214 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1216 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_layout_set");
1220 if (ctx->klass->input_panel_layout_set) ctx->klass->input_panel_layout_set(ctx, layout);
1221 ctx->input_panel_layout = layout;
1224 EAPI Ecore_IMF_Input_Panel_Layout
1225 ecore_imf_context_input_panel_layout_get (Ecore_IMF_Context *ctx)
1227 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1229 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_layout_get");
1230 return ECORE_IMF_INPUT_PANEL_LAYOUT_INVALID;
1233 if (ctx->klass->input_panel_layout_get )
1235 // ctx->klass->input_panel_layout_get (ctx, &layout);
1236 return ctx->input_panel_layout;
1239 return ECORE_IMF_INPUT_PANEL_LAYOUT_INVALID;
1243 ecore_imf_context_input_panel_reset (Ecore_IMF_Context *ctx)
1245 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1247 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_reset");
1251 if (ctx->klass->input_panel_reset) ctx->klass->input_panel_reset(ctx);
1255 ecore_imf_context_input_panel_orient_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Orient orientation)
1257 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1259 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_orient_set");
1263 if (ctx->klass->input_panel_orient_set) ctx->klass->input_panel_orient_set(ctx, orientation*90);
1264 ctx->input_panel_orient = orientation;
1267 EAPI Ecore_IMF_Input_Panel_Orient
1268 ecore_imf_context_input_panel_orient_get (Ecore_IMF_Context *ctx)
1270 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1272 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_orient_get");
1273 return ECORE_IMF_INPUT_PANEL_ORIENT_NONE;
1276 return ctx->input_panel_orient;
1280 ecore_imf_context_ise_get_active_isename (Ecore_IMF_Context *ctx, char* name)
1282 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1284 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_get_active_isename");
1290 printf ("input parameters error!!! \n");
1294 if (ctx->klass->ise_get_active_isename) ctx->klass->ise_get_active_isename(ctx, name);
1298 ecore_imf_context_ise_set_active_ise_by_name (Ecore_IMF_Context *ctx, const char* name)
1300 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1302 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_set_active_ise_by_name");
1307 printf ("input parameters error!!! \n");
1311 if (ctx->klass->ise_set_active_ise_by_name) ctx->klass->ise_set_active_ise_by_name(ctx, name);
1315 ecore_imf_context_ise_set_active_ise_by_uuid (Ecore_IMF_Context *ctx, const char* uuid)
1317 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1319 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_set_active_ise_by_uuid");
1324 printf ("input parameters error!!! \n");
1328 if (ctx->klass->ise_set_active_ise_by_uuid) ctx->klass->ise_set_active_ise_by_uuid(ctx, uuid);
1332 ecore_imf_context_ise_get_iselist (Ecore_IMF_Context *ctx, char*** iselist)
1334 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1336 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_get_iselist");
1340 if (ctx->klass->ise_get_iselist)
1342 return ctx->klass->ise_get_iselist(ctx, iselist);
1348 EAPI Ecore_IMF_Input_Panel_State
1349 ecore_imf_context_input_panel_state_get (Ecore_IMF_Context *ctx)
1351 Ecore_IMF_Input_Panel_State state = ECORE_IMF_INPUT_PANEL_STATE_INVALID;
1352 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1354 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_state_get");
1355 return ECORE_IMF_INPUT_PANEL_STATE_INVALID;
1358 if (ctx->klass->input_panel_state_get)
1360 state = ctx->klass->input_panel_state_get(ctx);
1367 ecore_imf_context_input_panel_event_callback_add (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, void (*pEventCallBackFunc) (void *data, Ecore_IMF_Context *ctx, int value), const void *data)
1369 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1371 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_event_callback_add");
1375 if (ctx->klass->input_panel_event_callback_add)
1377 ctx->klass->input_panel_event_callback_add(ctx, type, pEventCallBackFunc, data);
1382 ecore_imf_context_input_panel_event_callback_del (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, void (*pEventCallBackFunc) (void *data, Ecore_IMF_Context *ctx, int value))
1384 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1386 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_event_callback_del");
1390 if (ctx->klass->input_panel_event_callback_del)
1392 ctx->klass->input_panel_event_callback_del(ctx, type, pEventCallBackFunc);
1397 ecore_imf_context_input_panel_move (Ecore_IMF_Context *ctx, int x, int y)
1399 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1401 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_move");
1405 if (ctx->klass->input_panel_move) ctx->klass->input_panel_move(ctx, x, y);
1406 ctx->input_panel_x = x;
1407 ctx->input_panel_y = y;
1411 ecore_imf_context_input_panel_caps_mode_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Caps_Mode mode)
1413 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1415 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_caps_mode_set");
1419 if (ctx->klass->input_panel_caps_mode_set) ctx->klass->input_panel_caps_mode_set(ctx, mode);