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)
215 Ecore_IMF_Input_Panel_State state;
217 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
219 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
220 "ecore_imf_context_del");
224 state = ecore_imf_context_input_panel_state_get(ctx);
226 if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
227 ecore_imf_context_input_panel_hide(ctx);
229 if (ctx->klass->del) ctx->klass->del(ctx);
230 ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE);
232 EINA_LIST_FREE(ctx->private_key_list, data)
235 EINA_LIST_FREE(ctx->disabled_key_list, data)
238 ctx->private_key_list = NULL;
239 ctx->disabled_key_list = NULL;
245 * Set the client window for the Input Method Context; this is the
246 * Ecore_X_Window when using X11, Ecore_Win32_Window when using Win32, etc.
247 * This window is used in order to correctly position status windows, and may
248 * also be used for purposes internal to the Input Method Context.
250 * @param ctx An #Ecore_IMF_Context.
251 * @param window The client window. This may be NULL to indicate
252 * that the previous client window no longer exists.
253 * @ingroup Ecore_IMF_Context_Group
256 ecore_imf_context_client_window_set(Ecore_IMF_Context *ctx, void *window)
258 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
260 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
261 "ecore_imf_context_client_window_set");
264 if (ctx->klass->client_window_set) ctx->klass->client_window_set(ctx, window);
265 ctx->window = window;
269 ecore_imf_context_client_window_get(Ecore_IMF_Context *ctx)
271 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
273 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
274 "ecore_imf_context_client_window_get");
281 * Set the client canvas for the Input Method Context; this is the
282 * canvas in which the input appears.
283 * The canvas type can be determined by using the context canvas type.
284 * Actually only canvas with type "evas" (Evas *) is supported.
285 * This canvas may be used in order to correctly position status windows, and may
286 * also be used for purposes internal to the Input Method Context.
288 * @param ctx An #Ecore_IMF_Context.
289 * @param canvas The client canvas. This may be NULL to indicate
290 * that the previous client canvas no longer exists.
291 * @ingroup Ecore_IMF_Context_Group
294 ecore_imf_context_client_canvas_set(Ecore_IMF_Context *ctx, void *canvas)
296 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
298 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
299 "ecore_imf_context_client_canvas_set");
302 if (ctx->klass->client_canvas_set) ctx->klass->client_canvas_set(ctx, canvas);
303 ctx->client_canvas = canvas;
307 ecore_imf_context_client_canvas_get(Ecore_IMF_Context *ctx)
309 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
311 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
312 "ecore_imf_context_client_canvas_get");
315 return ctx->client_canvas;
319 * Ask the Input Method Context to show itself.
321 * @param ctx An #Ecore_IMF_Context.
322 * @ingroup Ecore_IMF_Context_Group
324 EINA_DEPRECATED EAPI void
325 ecore_imf_context_show(Ecore_IMF_Context *ctx)
327 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
329 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
330 "ecore_imf_context_show");
333 if (ctx->klass->show) ctx->klass->show(ctx);
337 * Ask the Input Method Context to hide itself.
339 * @param ctx An #Ecore_IMF_Context.
340 * @ingroup Ecore_IMF_Context_Group
342 EINA_DEPRECATED EAPI void
343 ecore_imf_context_hide(Ecore_IMF_Context *ctx)
345 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
347 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
348 "ecore_imf_context_hide");
351 if (ctx->klass->hide) ctx->klass->hide(ctx);
355 * Retrieve the current preedit string and cursor position
356 * for the Input Method Context.
358 * @param ctx An #Ecore_IMF_Context.
359 * @param str Location to store the retrieved string. The
360 * string retrieved must be freed with free().
361 * @param cursor_pos Location to store position of cursor (in characters)
362 * within the preedit string.
363 * @ingroup Ecore_IMF_Context_Group
366 ecore_imf_context_preedit_string_get(Ecore_IMF_Context *ctx, char **str, int *cursor_pos)
368 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
370 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
371 "ecore_imf_context_preedit_string_get");
374 if (ctx->klass->preedit_string_get)
375 ctx->klass->preedit_string_get(ctx, str, cursor_pos);
378 if (str) *str = strdup("");
379 if (cursor_pos) *cursor_pos = 0;
384 ecore_imf_context_preedit_string_with_attributes_get(Ecore_IMF_Context *ctx, char **str, Eina_List **attrs, int *cursor_pos)
386 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
388 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
389 "ecore_imf_context_preedit_string_with_attributes_get");
392 if (ctx->klass->preedit_string_with_attributes_get)
393 ctx->klass->preedit_string_with_attributes_get(ctx, str, attrs, cursor_pos);
396 if (str) *str = strdup("");
397 if (attrs) *attrs = NULL;
398 if (cursor_pos) *cursor_pos = 0;
403 * Notify the Input Method Context that the widget to which its
404 * correspond has gained focus.
406 * @param ctx An #Ecore_IMF_Context.
407 * @ingroup Ecore_IMF_Context_Group
410 ecore_imf_context_focus_in(Ecore_IMF_Context *ctx)
412 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
414 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
415 "ecore_imf_context_focus_in");
418 if (ctx->klass->focus_in) ctx->klass->focus_in(ctx);
422 * Notify the Input Method Context that the widget to which its
423 * correspond has lost focus.
425 * @param ctx An #Ecore_IMF_Context.
426 * @ingroup Ecore_IMF_Context_Group
429 ecore_imf_context_focus_out(Ecore_IMF_Context *ctx)
431 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
433 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
434 "ecore_imf_context_focus_out");
437 if (ctx->klass->focus_out) ctx->klass->focus_out(ctx);
441 * Notify the Input Method Context that a change such as a
442 * change in cursor position has been made. This will typically
443 * cause the Input Method Context to clear the preedit state.
445 * @param ctx An #Ecore_IMF_Context.
446 * @ingroup Ecore_IMF_Context_Group
449 ecore_imf_context_reset(Ecore_IMF_Context *ctx)
451 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
453 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
454 "ecore_imf_context_reset");
457 if (ctx->klass->reset) ctx->klass->reset(ctx);
461 * Notify the Input Method Context that a change in the cursor
462 * position has been made.
464 * @param ctx An #Ecore_IMF_Context.
465 * @param cursor_pos New cursor position in characters.
466 * @ingroup Ecore_IMF_Context_Group
469 ecore_imf_context_cursor_position_set(Ecore_IMF_Context *ctx, int cursor_pos)
471 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
473 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
474 "ecore_imf_context_cursor_position_set");
477 if (ctx->klass->cursor_position_set) ctx->klass->cursor_position_set(ctx, cursor_pos);
481 * Set whether the IM context should use the preedit string
482 * to display feedback. If @use_preedit is EINA_FALSE (default
483 * is EINA_TRUE), then the IM context may use some other method to display
484 * feedback, such as displaying it in a child of the root window.
486 * @param ctx An #Ecore_IMF_Context.
487 * @param use_preedit Whether the IM context should use the preedit string.
488 * @ingroup Ecore_IMF_Context_Group
491 ecore_imf_context_use_preedit_set(Ecore_IMF_Context *ctx, Eina_Bool use_preedit)
493 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
495 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
496 "ecore_imf_context_use_preedit_set");
499 if (ctx->klass->use_preedit_set) ctx->klass->use_preedit_set(ctx, use_preedit);
503 * Set the callback to be used on get_surrounding request.
505 * This callback will be called when the Input Method Context
506 * module requests the surrounding context.
508 * @param ctx An #Ecore_IMF_Context.
509 * @param func The callback to be called.
510 * @param data The data pointer to be passed to @p func
511 * @ingroup Ecore_IMF_Context_Group
514 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)
516 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
518 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
519 "ecore_imf_context_retrieve_surrounding_callback_set");
523 ctx->retrieve_surrounding_func = func;
524 ctx->retrieve_surrounding_data = (void *) data;
528 * Set the input mode used by the Ecore Input Context.
530 * The input mode can be one of the input modes defined in
531 * #Ecore_IMF_Input_Mode. The default input mode is
532 * ECORE_IMF_INPUT_MODE_FULL.
534 * @param ctx An #Ecore_IMF_Context.
535 * @param input_mode The input mode to be used by @p ctx.
536 * @ingroup Ecore_IMF_Context_Group
538 EINA_DEPRECATED EAPI void
539 ecore_imf_context_input_mode_set(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode)
541 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
543 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
544 "ecore_imf_context_input_mode_set");
547 if (ctx->klass->input_mode_set) ctx->klass->input_mode_set(ctx, input_mode);
548 ctx->input_mode = input_mode;
552 * Get the input mode being used by the Ecore Input Context.
554 * See @ref ecore_imf_context_input_mode_set for more details.
556 * @param ctx An #Ecore_IMF_Context.
557 * @return The input mode being used by @p ctx.
558 * @ingroup Ecore_IMF_Context_Group
560 EINA_DEPRECATED EAPI Ecore_IMF_Input_Mode
561 ecore_imf_context_input_mode_get(Ecore_IMF_Context *ctx)
563 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
565 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
566 "ecore_imf_context_input_mode_set");
569 return ctx->input_mode;
573 * Allow an Ecore Input Context to internally handle an event.
574 * If this function returns EINA_TRUE, then no further processing
575 * should be done for this event.
577 * Input methods must be able to accept all types of events (simply
578 * returning EINA_FALSE if the event was not handled), but there is no
579 * obligation of any events to be submitted to this function.
581 * @param ctx An #Ecore_IMF_Context.
582 * @param type The type of event defined by #Ecore_IMF_Event_Type.
583 * @param event The event itself.
584 * @return EINA_TRUE if the event was handled; otherwise EINA_FALSE.
585 * @ingroup Ecore_IMF_Context_Group
588 ecore_imf_context_filter_event(Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, Ecore_IMF_Event *event)
590 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
592 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
593 "ecore_imf_context_filter_event");
596 if (ctx->klass->filter_event) return ctx->klass->filter_event(ctx, type, event);
601 * @defgroup Ecore_IMF_Context_Module_Group Ecore Input Method Context Module Functions
603 * Functions that should be used by Ecore Input Method Context modules.
607 * Creates a new Input Method Context with klass specified by @p ctxc.
609 * This method should be used by modules implementing the Input
610 * Method Context interface.
612 * @param ctxc An #Ecore_IMF_Context_Class.
613 * @return A new #Ecore_IMF_Context; on failure it returns NULL.
614 * @ingroup Ecore_IMF_Context_Module_Group
616 EAPI Ecore_IMF_Context *
617 ecore_imf_context_new(const Ecore_IMF_Context_Class *ctxc)
619 Ecore_IMF_Context *ctx;
621 if (!ctxc) return NULL;
622 ctx = calloc(1, sizeof(Ecore_IMF_Context));
623 if (!ctx) return NULL;
624 ECORE_MAGIC_SET(ctx, ECORE_MAGIC_CONTEXT);
627 ctx->retrieve_surrounding_func = NULL;
628 ctx->retrieve_surrounding_data = NULL;
629 ctx->input_panel_x = 0;
630 ctx->input_panel_y = 0;
631 ctx->input_panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
632 ctx->input_panel_orient = ECORE_IMF_INPUT_PANEL_ORIENT_NONE;
633 ctx->use_effect = EINA_TRUE;
634 ctx->callbacks = NULL;
640 * Set the Input Method Context specific data.
642 * Note that this method should be used by modules to set
643 * the Input Method Context specific data and it's not meant to
644 * be used by applications to store application specific data.
646 * @param ctx An #Ecore_IMF_Context.
647 * @param data The Input Method Context specific data.
648 * @return A new #Ecore_IMF_Context; on failure it returns NULL.
649 * @ingroup Ecore_IMF_Context_Module_Group
652 ecore_imf_context_data_set(Ecore_IMF_Context *ctx, void *data)
654 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
656 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
657 "ecore_imf_context_data_set");
664 * Get the Input Method Context specific data.
666 * See @ref ecore_imf_context_data_set for more details.
668 * @param ctx An #Ecore_IMF_Context.
669 * @return The Input Method Context specific data.
670 * @ingroup Ecore_IMF_Context_Module_Group
672 EAPI void *ecore_imf_context_data_get(Ecore_IMF_Context *ctx)
674 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
676 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
677 "ecore_imf_context_data_get");
684 * Retrieve context around insertion point.
686 * This function is implemented by calling the
687 * Ecore_IMF_Context::retrieve_surrounding_func (
688 * set using #ecore_imf_context_retrieve_surrounding_callback_set).
690 * There is no obligation for a widget to respond to the
691 * ::retrieve_surrounding_func, so input methods must be prepared
692 * to function without context.
694 * @param ctx An #Ecore_IMF_Context.
695 * @param text Location to store a UTF-8 encoded string of text
696 * holding context around the insertion point.
697 * If the function returns EINA_TRUE, then you must free
698 * the result stored in this location with free().
699 * @param cursor_pos Location to store the position in characters of
700 * the insertion cursor within @text.
701 * @return EINA_TRUE if surrounding text was provided; otherwise EINA_FALSE.
702 * @ingroup Ecore_IMF_Context_Module_Group
705 ecore_imf_context_surrounding_get(Ecore_IMF_Context *ctx, char **text, int *cursor_pos)
707 int result = EINA_FALSE;
709 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
711 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
712 "ecore_imf_context_surrounding_get");
716 if (ctx->retrieve_surrounding_func)
718 result = ctx->retrieve_surrounding_func(ctx->retrieve_surrounding_data, ctx, text, cursor_pos);
721 if (text) *text = NULL;
722 if (cursor_pos) *cursor_pos = 0;
729 _ecore_imf_event_free_preedit(void *data __UNUSED__, void *event)
735 * Adds ECORE_IMF_EVENT_PREEDIT_START to the event queue.
736 * ECORE_IMF_EVENT_PREEDIT_START should be added when a new preedit sequence starts.
738 * @param ctx An #Ecore_IMF_Context.
739 * @ingroup Ecore_IMF_Context_Module_Group
742 ecore_imf_context_preedit_start_event_add(Ecore_IMF_Context *ctx)
744 Ecore_IMF_Event_Commit *ev;
746 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
748 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
749 "ecore_imf_context_preedit_start_event_add");
753 ev = malloc(sizeof(Ecore_IMF_Event_Preedit_Start));
755 ecore_event_add(ECORE_IMF_EVENT_PREEDIT_START,
756 ev, _ecore_imf_event_free_preedit, NULL);
760 * Adds ECORE_IMF_EVENT_PREEDIT_END to the event queue.
761 * ECORE_IMF_EVENT_PREEDIT_END should be added when a new preedit sequence has been completed or canceled.
763 * @param ctx An #Ecore_IMF_Context.
764 * @ingroup Ecore_IMF_Context_Module_Group
767 ecore_imf_context_preedit_end_event_add(Ecore_IMF_Context *ctx)
769 Ecore_IMF_Event_Commit *ev;
771 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
773 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
774 "ecore_imf_context_preedit_end_event_add");
778 ev = malloc(sizeof(Ecore_IMF_Event_Preedit_End));
780 ecore_event_add(ECORE_IMF_EVENT_PREEDIT_END,
781 ev, _ecore_imf_event_free_preedit, NULL);
785 * Adds ECORE_IMF_EVENT_PREEDIT_CHANGED to the event queue.
787 * @param ctx An #Ecore_IMF_Context.
788 * @ingroup Ecore_IMF_Context_Module_Group
791 ecore_imf_context_preedit_changed_event_add(Ecore_IMF_Context *ctx)
793 Ecore_IMF_Event_Commit *ev;
795 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
797 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
798 "ecore_imf_context_preedit_changed_event_add");
802 ev = malloc(sizeof(Ecore_IMF_Event_Preedit_Changed));
804 ecore_event_add(ECORE_IMF_EVENT_PREEDIT_CHANGED,
805 ev, _ecore_imf_event_free_preedit, NULL);
809 _ecore_imf_event_free_commit(void *data __UNUSED__, void *event)
811 Ecore_IMF_Event_Commit *ev;
814 if (ev->str) free(ev->str);
819 * Adds ECORE_IMF_EVENT_COMMIT to the event queue.
821 * @param ctx An #Ecore_IMF_Context.
822 * @param str The committed string.
823 * @ingroup Ecore_IMF_Context_Module_Group
826 ecore_imf_context_commit_event_add(Ecore_IMF_Context *ctx, const char *str)
828 Ecore_IMF_Event_Commit *ev;
830 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
832 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
833 "ecore_imf_context_commit_event_add");
837 ev = malloc(sizeof(Ecore_IMF_Event_Commit));
839 ev->str = str ? strdup(str) : NULL;
840 ecore_event_add(ECORE_IMF_EVENT_COMMIT,
841 ev, _ecore_imf_event_free_commit, NULL);
846 _ecore_imf_event_free_delete_surrounding(void *data __UNUSED__, void *event)
852 * Asks the widget that the input context is attached to to delete characters around the cursor position
853 * by adding the ECORE_IMF_EVENT_DELETE_SURROUNDING to the event queue.
854 * Note that offset and n_chars are in characters not in bytes.
856 * @param ctx An #Ecore_IMF_Context.
857 * @param offset The start offset of surrounding to be deleted.
858 * @param n_chars The number of characters to be deleted.
859 * @ingroup Ecore_IMF_Context_Module_Group
862 ecore_imf_context_delete_surrounding_event_add(Ecore_IMF_Context *ctx, int offset, int n_chars)
864 Ecore_IMF_Event_Delete_Surrounding *ev;
866 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
868 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
869 "ecore_imf_context_delete_surrounding_event_add");
873 ev = malloc(sizeof(Ecore_IMF_Event_Delete_Surrounding));
876 ev->n_chars = n_chars;
877 ecore_event_add(ECORE_IMF_EVENT_DELETE_SURROUNDING,
878 ev, _ecore_imf_event_free_delete_surrounding, NULL);
881 /*** ImControl Related APIs */
883 ecore_imf_context_input_panel_show(Ecore_IMF_Context *ctx)
885 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
887 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_show");
891 if (ctx->klass->show) ctx->klass->show(ctx);
895 ecore_imf_context_input_panel_hide(Ecore_IMF_Context *ctx)
897 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
899 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_hide");
903 if (ctx->klass->hide) ctx->klass->hide(ctx);
907 ecore_imf_context_control_panel_show (Ecore_IMF_Context *ctx)
909 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
911 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_control_panel_show");
915 if (ctx->klass->control_panel_show) ctx->klass->control_panel_show(ctx);
919 ecore_imf_context_control_panel_hide (Ecore_IMF_Context *ctx)
921 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
923 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_control_panel_hide");
927 if (ctx->klass->control_panel_hide) ctx->klass->control_panel_hide(ctx);
931 ecore_imf_context_input_panel_language_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Lang lang)
933 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
935 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_language_set");
939 if (ctx->klass->input_panel_language_set) ctx->klass->input_panel_language_set(ctx, lang);
940 ctx->input_panel_lang = lang;
943 EAPI Ecore_IMF_Input_Panel_Lang
944 ecore_imf_context_input_panel_language_get (Ecore_IMF_Context *ctx)
946 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
948 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_language_get");
949 return ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC;
952 return ctx->input_panel_lang;
956 ecore_imf_context_ise_get_ise_language (Ecore_IMF_Context *ctx, const char* ise_name, char ***langlist)
958 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
960 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_get_ise_language");
966 printf ("input parameters error!!! \n");
970 if (ctx->klass->ise_get_ise_language)
971 return ctx->klass->ise_get_ise_language(ctx, ise_name, langlist);
977 ecore_imf_context_keyboard_language_set (Ecore_IMF_Context *ctx, Ecore_IMF_Keyboard_Lang lang)
979 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
981 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_keyboard_language_set");
984 // if (ctx->klass->ise_set_language) ctx->klass->ise_set_language(ctx, lang);
987 EAPI Ecore_IMF_Keyboard_Lang
988 ecore_imf_context_keyboard_language_get (Ecore_IMF_Context *ctx)
990 Ecore_IMF_Keyboard_Lang lang = ECORE_IMF_KEYBOARD_LANG_NATIVE;
992 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
994 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_keyboard_language_get");
998 if (ctx->klass->input_panel_language_get)
999 lang = ctx->klass->input_panel_language_get(ctx);
1005 ecore_imf_context_ise_set_isf_language (Ecore_IMF_Context *ctx, const char* lang)
1007 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1009 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_set_isf_language");
1015 printf ("input parameters error!!! \n");
1019 if (ctx->klass->ise_set_isf_language) ctx->klass->ise_set_isf_language(ctx, lang);
1023 ecore_imf_context_input_panel_imdata_set (Ecore_IMF_Context *ctx, const char * data, int len)
1025 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1027 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_imdata_set");
1031 if (!data || len <=0)
1033 printf ("input parameters error!!! \n");
1037 if (ctx->klass->input_panel_imdata_set) ctx->klass->input_panel_imdata_set(ctx, data, len);
1041 ecore_imf_context_input_panel_imdata_get (Ecore_IMF_Context *ctx, char * data, int *len)
1043 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1045 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_get_imdata");
1051 printf ("input parameters error!!! \n");
1055 if (ctx->klass->input_panel_imdata_get) ctx->klass->input_panel_imdata_get(ctx, data, len);
1059 ecore_imf_context_input_panel_use_effect_set (Ecore_IMF_Context *ctx, Eina_Bool use_effect)
1061 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1063 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_use_effect_set");
1067 if (ctx->klass->input_panel_use_effect_set) ctx->klass->input_panel_use_effect_set(ctx, use_effect);
1068 ctx->use_effect = use_effect;
1072 ecore_imf_context_input_panel_use_effect_get (Ecore_IMF_Context *ctx)
1074 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1076 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_use_effect_get");
1080 return ctx->use_effect;
1084 ecore_imf_context_input_panel_geometry_get (Ecore_IMF_Context *ctx, int *x, int *y, int *w, int *h)
1086 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1088 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_geometry_get");
1092 if (ctx->klass->input_panel_geometry_get) ctx->klass->input_panel_geometry_get(ctx, x, y, w, h);
1096 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)
1098 Private_Key_Item *key_item;
1100 Eina_Bool exist = EINA_FALSE;
1102 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1104 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_private_key_set");
1108 if (label == NULL && img_path == NULL)
1110 printf ("input parameters error!!! \n");
1114 EINA_LIST_FOREACH(ctx->private_key_list, l, key_item)
1116 if (key_item && key_item->layout_idx == layout_index &&
1117 key_item->key_idx == key_index)
1119 // if exist in the list
1124 strcpy(key_item->data, label);
1129 strcpy(key_item->data, img_path);
1131 key_item->key_value = key_value;
1132 strcpy(key_item->key_string, key_string);
1138 key_item = calloc(1, sizeof(Private_Key_Item));
1139 if (!key_item) return;
1141 key_item->layout_idx = layout_index;
1142 key_item->key_idx = key_index;;
1146 strcpy(key_item->data, label);
1151 strcpy(key_item->data, img_path);
1153 key_item->key_value = key_value;
1157 strcpy(key_item->key_string, key_string);
1160 ctx->private_key_list = eina_list_append(ctx->private_key_list, key_item);
1163 // if (ctx->klass->input_panel_private_key_set) ctx->klass->input_panel_private_key_set(ctx, layout_index, key_index, img_path, label, value);
1167 ecore_imf_context_input_panel_private_key_list_get (Ecore_IMF_Context *ctx)
1169 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1171 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_private_key_list_get");
1175 return ctx->private_key_list;
1179 ecore_imf_context_input_panel_key_disabled_set (Ecore_IMF_Context *ctx, int layout_index, int key_index, Eina_Bool disabled)
1181 Disable_Key_Item *key_item;
1183 Eina_Bool exist = EINA_FALSE;
1185 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1187 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_key_disabled_set");
1191 EINA_LIST_FOREACH(ctx->disabled_key_list, l, key_item)
1193 if (key_item && key_item->layout_idx == layout_index && key_item->key_idx == key_index)
1195 key_item->disabled = disabled;
1202 key_item = calloc(1, sizeof(Disable_Key_Item));
1203 if (!key_item) return;
1205 key_item->layout_idx = layout_index;
1206 key_item->key_idx = key_index;;
1207 key_item->disabled = disabled;
1209 ctx->disabled_key_list = eina_list_append(ctx->disabled_key_list, key_item);
1212 // if (ctx->klass->input_panel_key_disabled_set) ctx->klass->input_panel_key_disabled_set(ctx, layout_index, key_index, disabled);
1216 ecore_imf_context_input_panel_key_disabled_list_get (Ecore_IMF_Context *ctx)
1218 return ctx->disabled_key_list;
1222 ecore_imf_context_input_panel_layout_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Layout layout)
1224 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1226 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_layout_set");
1230 if (ctx->klass->input_panel_layout_set) ctx->klass->input_panel_layout_set(ctx, layout);
1231 ctx->input_panel_layout = layout;
1234 EAPI Ecore_IMF_Input_Panel_Layout
1235 ecore_imf_context_input_panel_layout_get (Ecore_IMF_Context *ctx)
1237 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1239 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_layout_get");
1240 return ECORE_IMF_INPUT_PANEL_LAYOUT_INVALID;
1243 if (ctx->klass->input_panel_layout_get )
1245 // ctx->klass->input_panel_layout_get (ctx, &layout);
1246 return ctx->input_panel_layout;
1249 return ECORE_IMF_INPUT_PANEL_LAYOUT_INVALID;
1253 ecore_imf_context_input_panel_reset (Ecore_IMF_Context *ctx)
1255 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1257 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_reset");
1261 if (ctx->klass->input_panel_reset) ctx->klass->input_panel_reset(ctx);
1265 ecore_imf_context_input_panel_orient_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Orient orientation)
1267 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1269 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_orient_set");
1273 if (ctx->klass->input_panel_orient_set) ctx->klass->input_panel_orient_set(ctx, orientation*90);
1274 ctx->input_panel_orient = orientation;
1277 EAPI Ecore_IMF_Input_Panel_Orient
1278 ecore_imf_context_input_panel_orient_get (Ecore_IMF_Context *ctx)
1280 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1282 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_orient_get");
1283 return ECORE_IMF_INPUT_PANEL_ORIENT_NONE;
1286 return ctx->input_panel_orient;
1290 ecore_imf_context_ise_get_active_isename (Ecore_IMF_Context *ctx, char* name)
1292 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1294 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_get_active_isename");
1300 printf ("input parameters error!!! \n");
1304 if (ctx->klass->ise_get_active_isename) ctx->klass->ise_get_active_isename(ctx, name);
1308 ecore_imf_context_ise_set_active_ise_by_name (Ecore_IMF_Context *ctx, const char* name)
1310 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1312 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_set_active_ise_by_name");
1318 printf ("input parameters error!!! \n");
1322 if (ctx->klass->ise_set_active_ise_by_name) ctx->klass->ise_set_active_ise_by_name(ctx, name);
1326 ecore_imf_context_ise_set_active_ise_by_uuid (Ecore_IMF_Context *ctx, const char* uuid)
1328 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1330 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_set_active_ise_by_uuid");
1336 printf ("input parameters error!!! \n");
1340 if (ctx->klass->ise_set_active_ise_by_uuid) ctx->klass->ise_set_active_ise_by_uuid(ctx, uuid);
1344 ecore_imf_context_ise_get_iselist (Ecore_IMF_Context *ctx, char*** iselist)
1346 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1348 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_get_iselist");
1352 if (ctx->klass->ise_get_iselist)
1353 return ctx->klass->ise_get_iselist(ctx, iselist);
1358 EAPI Ecore_IMF_Input_Panel_State
1359 ecore_imf_context_input_panel_state_get (Ecore_IMF_Context *ctx)
1361 Ecore_IMF_Input_Panel_State state = ECORE_IMF_INPUT_PANEL_STATE_INVALID;
1362 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1364 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_state_get");
1365 return ECORE_IMF_INPUT_PANEL_STATE_INVALID;
1368 if (ctx->klass->input_panel_state_get)
1369 state = ctx->klass->input_panel_state_get(ctx);
1375 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)
1377 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1379 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_event_callback_add");
1383 if (ctx->klass->input_panel_event_callback_add)
1385 ctx->klass->input_panel_event_callback_add(ctx, type, pEventCallBackFunc, data);
1390 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))
1392 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1394 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_event_callback_del");
1398 if (ctx->klass->input_panel_event_callback_del)
1400 ctx->klass->input_panel_event_callback_del(ctx, type, pEventCallBackFunc);
1405 ecore_imf_context_input_panel_move (Ecore_IMF_Context *ctx, int x, int y)
1407 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1409 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_move");
1413 if (ctx->klass->input_panel_move) ctx->klass->input_panel_move(ctx, x, y);
1414 ctx->input_panel_x = x;
1415 ctx->input_panel_y = y;
1419 ecore_imf_context_input_panel_caps_mode_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Caps_Mode mode)
1421 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1423 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_caps_mode_set");
1427 if (ctx->klass->input_panel_caps_mode_set) ctx->klass->input_panel_caps_mode_set(ctx, mode);