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");
93 //printf ("id is %s \n", id);
96 if (strcmp(id, "none") == 0) return NULL;
97 if (ecore_imf_module_get(id)) return id;
100 modules = ecore_imf_module_available_get();
101 if (!modules) return NULL;
103 locale = setlocale(LC_CTYPE, NULL);
104 if (!locale) return NULL;
106 locale = strdup(locale);
108 tmp = strchr(locale, '.');
109 if (tmp) *tmp = '\0';
110 tmp = strchr(locale, '@');
111 if (tmp) *tmp = '\0';
115 EINA_LIST_FREE(modules, module)
118 strcmp(module->info->canvas_type, canvas_type) == 0)
121 const char *p = module->info->default_locales;
124 const char *q = strchr(p, ':');
125 int goodness = _ecore_imf_context_match_locale(locale, p, q ? (size_t)(q - p) : strlen (p));
127 if (goodness > best_goodness)
129 id = module->info->id;
130 best_goodness = goodness;
133 p = q ? q + 1 : NULL;
142 * Retrieve the info for the Input Method Context with @p id.
144 * @param id The Input Method Context id to query for.
145 * @return Return a #Ecore_IMF_Context_Info for the Input Method Context with @p id;
146 * on failure it returns NULL.
147 * @ingroup Ecore_IMF_Context_Group
149 EAPI const Ecore_IMF_Context_Info *
150 ecore_imf_context_info_by_id_get(const char *id)
152 Ecore_IMF_Module *module;
154 if (!id) return NULL;
155 module = ecore_imf_module_get(id);
156 if (!module) return NULL;
161 * Create a new Input Method Context defined by the given id.
163 * @param id The Input Method Context id.
164 * @return A newly allocated Input Method Context;
165 * on failure it returns NULL.
166 * @ingroup Ecore_IMF_Context_Group
168 EAPI Ecore_IMF_Context *
169 ecore_imf_context_add(const char *id)
171 Ecore_IMF_Context *ctx;
173 if (!id) return NULL;
174 ctx = ecore_imf_module_context_create(id);
175 if (!ctx || !ctx->klass) return NULL;
176 if (ctx->klass->add) ctx->klass->add(ctx);
177 /* default use_preedit is EINA_TRUE, so let's make sure it's
178 * set on the immodule */
179 ecore_imf_context_use_preedit_set(ctx, EINA_TRUE);
180 /* default input_mode is ECORE_IMF_INPUT_MODE_FULL, so let's make sure it's
181 * set on the immodule */
182 ecore_imf_context_input_mode_set(ctx, ECORE_IMF_INPUT_MODE_FULL);
187 * Retrieve the info for the given Input Method Context.
189 * @param ctx An #Ecore_IMF_Context.
190 * @return Return a #Ecore_IMF_Context_Info for the given Input Method Context;
191 * on failure it returns NULL.
192 * @ingroup Ecore_IMF_Context_Group
194 EAPI const Ecore_IMF_Context_Info *
195 ecore_imf_context_info_get(Ecore_IMF_Context *ctx)
197 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
199 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
200 "ecore_imf_context_info_get");
203 return ctx->module->info;
207 * Delete the given Input Method Context and free its memory.
209 * @param ctx An #Ecore_IMF_Context.
210 * @ingroup Ecore_IMF_Context_Group
213 ecore_imf_context_del(Ecore_IMF_Context *ctx)
217 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
219 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
220 "ecore_imf_context_del");
223 if (ctx->klass->del) ctx->klass->del(ctx);
224 ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE);
226 EINA_LIST_FREE(ctx->private_key_list, data)
229 EINA_LIST_FREE(ctx->disabled_key_list, data)
232 ctx->private_key_list = NULL;
233 ctx->disabled_key_list = NULL;
239 * Set the client window for the Input Method Context; this is the
240 * Ecore_X_Window when using X11, Ecore_Win32_Window when using Win32, etc.
241 * This window is used in order to correctly position status windows, and may
242 * also be used for purposes internal to the Input Method Context.
244 * @param ctx An #Ecore_IMF_Context.
245 * @param window The client window. This may be NULL to indicate
246 * that the previous client window no longer exists.
247 * @ingroup Ecore_IMF_Context_Group
250 ecore_imf_context_client_window_set(Ecore_IMF_Context *ctx, void *window)
252 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
254 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
255 "ecore_imf_context_client_window_set");
258 if (ctx->klass->client_window_set) ctx->klass->client_window_set(ctx, window);
259 ctx->window = window;
263 ecore_imf_context_client_window_get(Ecore_IMF_Context *ctx)
265 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
267 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
268 "ecore_imf_context_client_window_get");
275 * Set the client canvas for the Input Method Context; this is the
276 * canvas in which the input appears.
277 * The canvas type can be determined by using the context canvas type.
278 * Actually only canvas with type "evas" (Evas *) is supported.
279 * This canvas may be used in order to correctly position status windows, and may
280 * also be used for purposes internal to the Input Method Context.
282 * @param ctx An #Ecore_IMF_Context.
283 * @param canvas The client canvas. This may be NULL to indicate
284 * that the previous client canvas no longer exists.
285 * @ingroup Ecore_IMF_Context_Group
288 ecore_imf_context_client_canvas_set(Ecore_IMF_Context *ctx, void *canvas)
290 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
292 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
293 "ecore_imf_context_client_canvas_set");
296 if (ctx->klass->client_canvas_set) ctx->klass->client_canvas_set(ctx, canvas);
297 ctx->client_canvas = canvas;
301 ecore_imf_context_client_canvas_get(Ecore_IMF_Context *ctx)
303 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
305 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
306 "ecore_imf_context_client_canvas_get");
309 return ctx->client_canvas;
313 * Ask the Input Method Context to show itself.
315 * @param ctx An #Ecore_IMF_Context.
316 * @ingroup Ecore_IMF_Context_Group
318 EINA_DEPRECATED EAPI void
319 ecore_imf_context_show(Ecore_IMF_Context *ctx)
321 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
323 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
324 "ecore_imf_context_show");
327 if (ctx->klass->show) ctx->klass->show(ctx);
331 * Ask the Input Method Context to hide itself.
333 * @param ctx An #Ecore_IMF_Context.
334 * @ingroup Ecore_IMF_Context_Group
336 EINA_DEPRECATED EAPI void
337 ecore_imf_context_hide(Ecore_IMF_Context *ctx)
339 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
341 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
342 "ecore_imf_context_hide");
345 if (ctx->klass->hide) ctx->klass->hide(ctx);
349 * Retrieve the current preedit string and cursor position
350 * for the Input Method Context.
352 * @param ctx An #Ecore_IMF_Context.
353 * @param str Location to store the retrieved string. The
354 * string retrieved must be freed with free().
355 * @param cursor_pos Location to store position of cursor (in characters)
356 * within the preedit string.
357 * @ingroup Ecore_IMF_Context_Group
360 ecore_imf_context_preedit_string_get(Ecore_IMF_Context *ctx, char **str, int *cursor_pos)
362 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
364 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
365 "ecore_imf_context_preedit_string_get");
368 if (ctx->klass->preedit_string_get)
369 ctx->klass->preedit_string_get(ctx, str, cursor_pos);
372 if (str) *str = strdup("");
373 if (cursor_pos) *cursor_pos = 0;
378 ecore_imf_context_preedit_string_with_attributes_get(Ecore_IMF_Context *ctx, char **str, Eina_List **attrs, int *cursor_pos)
380 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
382 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
383 "ecore_imf_context_preedit_string_with_attributes_get");
386 if (ctx->klass->preedit_string_with_attributes_get)
387 ctx->klass->preedit_string_with_attributes_get(ctx, str, attrs, cursor_pos);
390 if (str) *str = strdup("");
391 if (attrs) *attrs = NULL;
392 if (cursor_pos) *cursor_pos = 0;
397 * Notify the Input Method Context that the widget to which its
398 * correspond has gained focus.
400 * @param ctx An #Ecore_IMF_Context.
401 * @ingroup Ecore_IMF_Context_Group
404 ecore_imf_context_focus_in(Ecore_IMF_Context *ctx)
406 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
408 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
409 "ecore_imf_context_focus_in");
412 if (ctx->klass->focus_in) ctx->klass->focus_in(ctx);
416 * Notify the Input Method Context that the widget to which its
417 * correspond has lost focus.
419 * @param ctx An #Ecore_IMF_Context.
420 * @ingroup Ecore_IMF_Context_Group
423 ecore_imf_context_focus_out(Ecore_IMF_Context *ctx)
425 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
427 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
428 "ecore_imf_context_focus_out");
431 if (ctx->klass->focus_out) ctx->klass->focus_out(ctx);
435 * Notify the Input Method Context that a change such as a
436 * change in cursor position has been made. This will typically
437 * cause the Input Method Context to clear the preedit state.
439 * @param ctx An #Ecore_IMF_Context.
440 * @ingroup Ecore_IMF_Context_Group
443 ecore_imf_context_reset(Ecore_IMF_Context *ctx)
445 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
447 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
448 "ecore_imf_context_reset");
451 if (ctx->klass->reset) ctx->klass->reset(ctx);
455 * Notify the Input Method Context that a change in the cursor
456 * position has been made.
458 * @param ctx An #Ecore_IMF_Context.
459 * @param cursor_pos New cursor position in characters.
460 * @ingroup Ecore_IMF_Context_Group
463 ecore_imf_context_cursor_position_set(Ecore_IMF_Context *ctx, int cursor_pos)
465 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
467 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
468 "ecore_imf_context_cursor_position_set");
471 if (ctx->klass->cursor_position_set) ctx->klass->cursor_position_set(ctx, cursor_pos);
475 * Set whether the IM context should use the preedit string
476 * to display feedback. If @use_preedit is EINA_FALSE (default
477 * is EINA_TRUE), then the IM context may use some other method to display
478 * feedback, such as displaying it in a child of the root window.
480 * @param ctx An #Ecore_IMF_Context.
481 * @param use_preedit Whether the IM context should use the preedit string.
482 * @ingroup Ecore_IMF_Context_Group
485 ecore_imf_context_use_preedit_set(Ecore_IMF_Context *ctx, Eina_Bool use_preedit)
487 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
489 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
490 "ecore_imf_context_use_preedit_set");
493 if (ctx->klass->use_preedit_set) ctx->klass->use_preedit_set(ctx, use_preedit);
497 * Set the callback to be used on get_surrounding request.
499 * This callback will be called when the Input Method Context
500 * module requests the surrounding context.
502 * @param ctx An #Ecore_IMF_Context.
503 * @param func The callback to be called.
504 * @param data The data pointer to be passed to @p func
505 * @ingroup Ecore_IMF_Context_Group
508 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)
510 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
512 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
513 "ecore_imf_context_retrieve_surrounding_callback_set");
517 ctx->retrieve_surrounding_func = func;
518 ctx->retrieve_surrounding_data = (void *) data;
522 * Set the input mode used by the Ecore Input Context.
524 * The input mode can be one of the input modes defined in
525 * #Ecore_IMF_Input_Mode. The default input mode is
526 * ECORE_IMF_INPUT_MODE_FULL.
528 * @param ctx An #Ecore_IMF_Context.
529 * @param input_mode The input mode to be used by @p ctx.
530 * @ingroup Ecore_IMF_Context_Group
532 EINA_DEPRECATED EAPI void
533 ecore_imf_context_input_mode_set(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode)
535 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
537 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
538 "ecore_imf_context_input_mode_set");
541 if (ctx->klass->input_mode_set) ctx->klass->input_mode_set(ctx, input_mode);
542 ctx->input_mode = input_mode;
546 * Get the input mode being used by the Ecore Input Context.
548 * See @ref ecore_imf_context_input_mode_set for more details.
550 * @param ctx An #Ecore_IMF_Context.
551 * @return The input mode being used by @p ctx.
552 * @ingroup Ecore_IMF_Context_Group
554 EINA_DEPRECATED EAPI Ecore_IMF_Input_Mode
555 ecore_imf_context_input_mode_get(Ecore_IMF_Context *ctx)
557 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
559 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
560 "ecore_imf_context_input_mode_set");
563 return ctx->input_mode;
567 * Allow an Ecore Input Context to internally handle an event.
568 * If this function returns EINA_TRUE, then no further processing
569 * should be done for this event.
571 * Input methods must be able to accept all types of events (simply
572 * returning EINA_FALSE if the event was not handled), but there is no
573 * obligation of any events to be submitted to this function.
575 * @param ctx An #Ecore_IMF_Context.
576 * @param type The type of event defined by #Ecore_IMF_Event_Type.
577 * @param event The event itself.
578 * @return EINA_TRUE if the event was handled; otherwise EINA_FALSE.
579 * @ingroup Ecore_IMF_Context_Group
582 ecore_imf_context_filter_event(Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, Ecore_IMF_Event *event)
584 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
586 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
587 "ecore_imf_context_filter_event");
590 if (ctx->klass->filter_event) return ctx->klass->filter_event(ctx, type, event);
595 * @defgroup Ecore_IMF_Context_Module_Group Ecore Input Method Context Module Functions
597 * Functions that should be used by Ecore Input Method Context modules.
601 * Creates a new Input Method Context with klass specified by @p ctxc.
603 * This method should be used by modules implementing the Input
604 * Method Context interface.
606 * @param ctxc An #Ecore_IMF_Context_Class.
607 * @return A new #Ecore_IMF_Context; on failure it returns NULL.
608 * @ingroup Ecore_IMF_Context_Module_Group
610 EAPI Ecore_IMF_Context *
611 ecore_imf_context_new(const Ecore_IMF_Context_Class *ctxc)
613 Ecore_IMF_Context *ctx;
615 if (!ctxc) return NULL;
616 ctx = calloc(1, sizeof(Ecore_IMF_Context));
617 if (!ctx) return NULL;
618 ECORE_MAGIC_SET(ctx, ECORE_MAGIC_CONTEXT);
621 ctx->retrieve_surrounding_func = NULL;
622 ctx->retrieve_surrounding_data = NULL;
623 ctx->input_panel_x = 0;
624 ctx->input_panel_y = 0;
625 ctx->input_panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
626 ctx->input_panel_orient = ECORE_IMF_INPUT_PANEL_ORIENT_NONE;
627 ctx->use_effect = EINA_TRUE;
628 ctx->callbacks = NULL;
634 * Set the Input Method Context specific data.
636 * Note that this method should be used by modules to set
637 * the Input Method Context specific data and it's not meant to
638 * be used by applications to store application specific data.
640 * @param ctx An #Ecore_IMF_Context.
641 * @param data The Input Method Context specific data.
642 * @return A new #Ecore_IMF_Context; on failure it returns NULL.
643 * @ingroup Ecore_IMF_Context_Module_Group
646 ecore_imf_context_data_set(Ecore_IMF_Context *ctx, void *data)
648 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
650 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
651 "ecore_imf_context_data_set");
658 * Get the Input Method Context specific data.
660 * See @ref ecore_imf_context_data_set for more details.
662 * @param ctx An #Ecore_IMF_Context.
663 * @return The Input Method Context specific data.
664 * @ingroup Ecore_IMF_Context_Module_Group
666 EAPI void *ecore_imf_context_data_get(Ecore_IMF_Context *ctx)
668 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
670 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
671 "ecore_imf_context_data_get");
678 * Retrieve context around insertion point.
680 * This function is implemented by calling the
681 * Ecore_IMF_Context::retrieve_surrounding_func (
682 * set using #ecore_imf_context_retrieve_surrounding_callback_set).
684 * There is no obligation for a widget to respond to the
685 * ::retrieve_surrounding_func, so input methods must be prepared
686 * to function without context.
688 * @param ctx An #Ecore_IMF_Context.
689 * @param text Location to store a UTF-8 encoded string of text
690 * holding context around the insertion point.
691 * If the function returns EINA_TRUE, then you must free
692 * the result stored in this location with free().
693 * @param cursor_pos Location to store the position in characters of
694 * the insertion cursor within @text.
695 * @return EINA_TRUE if surrounding text was provided; otherwise EINA_FALSE.
696 * @ingroup Ecore_IMF_Context_Module_Group
699 ecore_imf_context_surrounding_get(Ecore_IMF_Context *ctx, char **text, int *cursor_pos)
701 int result = EINA_FALSE;
703 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
705 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
706 "ecore_imf_context_surrounding_get");
710 if (ctx->retrieve_surrounding_func)
712 result = ctx->retrieve_surrounding_func(ctx->retrieve_surrounding_data, ctx, text, cursor_pos);
715 if (text) *text = NULL;
716 if (cursor_pos) *cursor_pos = 0;
723 _ecore_imf_event_free_preedit(void *data __UNUSED__, void *event)
729 * Adds ECORE_IMF_EVENT_PREEDIT_START to the event queue.
730 * ECORE_IMF_EVENT_PREEDIT_START should be added when a new preedit sequence starts.
732 * @param ctx An #Ecore_IMF_Context.
733 * @ingroup Ecore_IMF_Context_Module_Group
736 ecore_imf_context_preedit_start_event_add(Ecore_IMF_Context *ctx)
738 Ecore_IMF_Event_Commit *ev;
740 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
742 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
743 "ecore_imf_context_preedit_start_event_add");
747 ev = malloc(sizeof(Ecore_IMF_Event_Preedit_Start));
749 ecore_event_add(ECORE_IMF_EVENT_PREEDIT_START,
750 ev, _ecore_imf_event_free_preedit, NULL);
754 * Adds ECORE_IMF_EVENT_PREEDIT_END to the event queue.
755 * ECORE_IMF_EVENT_PREEDIT_END should be added when a new preedit sequence has been completed or canceled.
757 * @param ctx An #Ecore_IMF_Context.
758 * @ingroup Ecore_IMF_Context_Module_Group
761 ecore_imf_context_preedit_end_event_add(Ecore_IMF_Context *ctx)
763 Ecore_IMF_Event_Commit *ev;
765 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
767 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
768 "ecore_imf_context_preedit_end_event_add");
772 ev = malloc(sizeof(Ecore_IMF_Event_Preedit_End));
774 ecore_event_add(ECORE_IMF_EVENT_PREEDIT_END,
775 ev, _ecore_imf_event_free_preedit, NULL);
779 * Adds ECORE_IMF_EVENT_PREEDIT_CHANGED to the event queue.
781 * @param ctx An #Ecore_IMF_Context.
782 * @ingroup Ecore_IMF_Context_Module_Group
785 ecore_imf_context_preedit_changed_event_add(Ecore_IMF_Context *ctx)
787 Ecore_IMF_Event_Commit *ev;
789 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
791 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
792 "ecore_imf_context_preedit_changed_event_add");
796 ev = malloc(sizeof(Ecore_IMF_Event_Preedit_Changed));
798 ecore_event_add(ECORE_IMF_EVENT_PREEDIT_CHANGED,
799 ev, _ecore_imf_event_free_preedit, NULL);
803 _ecore_imf_event_free_commit(void *data __UNUSED__, void *event)
805 Ecore_IMF_Event_Commit *ev;
808 if (ev->str) free(ev->str);
813 * Adds ECORE_IMF_EVENT_COMMIT to the event queue.
815 * @param ctx An #Ecore_IMF_Context.
816 * @param str The committed string.
817 * @ingroup Ecore_IMF_Context_Module_Group
820 ecore_imf_context_commit_event_add(Ecore_IMF_Context *ctx, const char *str)
822 Ecore_IMF_Event_Commit *ev;
824 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
826 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
827 "ecore_imf_context_commit_event_add");
831 ev = malloc(sizeof(Ecore_IMF_Event_Commit));
833 ev->str = str ? strdup(str) : NULL;
834 ecore_event_add(ECORE_IMF_EVENT_COMMIT,
835 ev, _ecore_imf_event_free_commit, NULL);
840 _ecore_imf_event_free_delete_surrounding(void *data __UNUSED__, void *event)
846 * Asks the widget that the input context is attached to to delete characters around the cursor position
847 * by adding the ECORE_IMF_EVENT_DELETE_SURROUNDING to the event queue.
848 * Note that offset and n_chars are in characters not in bytes.
850 * @param ctx An #Ecore_IMF_Context.
851 * @param offset The start offset of surrounding to be deleted.
852 * @param n_chars The number of characters to be deleted.
853 * @ingroup Ecore_IMF_Context_Module_Group
856 ecore_imf_context_delete_surrounding_event_add(Ecore_IMF_Context *ctx, int offset, int n_chars)
858 Ecore_IMF_Event_Delete_Surrounding *ev;
860 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
862 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
863 "ecore_imf_context_delete_surrounding_event_add");
867 ev = malloc(sizeof(Ecore_IMF_Event_Delete_Surrounding));
870 ev->n_chars = n_chars;
871 ecore_event_add(ECORE_IMF_EVENT_DELETE_SURROUNDING,
872 ev, _ecore_imf_event_free_delete_surrounding, NULL);
875 /*** ImControl Related APIs */
877 ecore_imf_context_input_panel_show(Ecore_IMF_Context *ctx)
879 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
881 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_show");
885 if (ctx->klass->show) ctx->klass->show(ctx);
889 ecore_imf_context_input_panel_hide(Ecore_IMF_Context *ctx)
891 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
893 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_hide");
897 if (ctx->klass->hide) ctx->klass->hide(ctx);
901 ecore_imf_context_control_panel_show (Ecore_IMF_Context *ctx)
903 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
905 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_control_panel_show");
909 if (ctx->klass->control_panel_show) ctx->klass->control_panel_show(ctx);
913 ecore_imf_context_control_panel_hide (Ecore_IMF_Context *ctx)
915 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
917 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_control_panel_hide");
921 if (ctx->klass->control_panel_hide) ctx->klass->control_panel_hide(ctx);
925 ecore_imf_context_input_panel_language_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Lang lang)
927 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
929 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_language_set");
932 if (ctx->klass->input_panel_language_set) ctx->klass->input_panel_language_set(ctx, lang);
933 ctx->input_panel_lang = lang;
936 EAPI Ecore_IMF_Input_Panel_Lang
937 ecore_imf_context_input_panel_language_get (Ecore_IMF_Context *ctx)
939 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
941 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_language_get");
942 return ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC;
945 return ctx->input_panel_lang;
949 ecore_imf_context_ise_get_ise_language (Ecore_IMF_Context *ctx, const char* ise_name, char ***langlist)
951 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
953 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_get_ise_language");
959 printf ("input parameters error!!! \n");
963 if (ctx->klass->ise_get_ise_language)
965 return ctx->klass->ise_get_ise_language(ctx, ise_name, langlist);
971 EAPI void ecore_imf_context_keyboard_language_set (Ecore_IMF_Context *ctx, Ecore_IMF_Keyboard_Lang lang)
973 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
975 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_keyboard_language_set");
978 // if (ctx->klass->ise_set_language) ctx->klass->ise_set_language(ctx, lang);
981 EAPI Ecore_IMF_Keyboard_Lang ecore_imf_context_keyboard_language_get (Ecore_IMF_Context *ctx)
983 Ecore_IMF_Keyboard_Lang lang = ECORE_IMF_KEYBOARD_LANG_NATIVE;
984 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
986 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_keyboard_language_get");
990 if (ctx->klass->input_panel_language_get)
991 lang = ctx->klass->input_panel_language_get(ctx);
997 ecore_imf_context_ise_set_isf_language (Ecore_IMF_Context *ctx, const char* lang)
999 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1001 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_set_isf_language");
1007 printf ("input parameters error!!! \n");
1011 if (ctx->klass->ise_set_isf_language) ctx->klass->ise_set_isf_language(ctx, lang);
1015 ecore_imf_context_input_panel_imdata_set (Ecore_IMF_Context *ctx, const char * data, int len)
1017 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1019 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_imdata_set");
1023 if (!data || len <=0)
1025 printf ("input parameters error!!! \n");
1029 if (ctx->klass->input_panel_imdata_set) ctx->klass->input_panel_imdata_set(ctx, data, len);
1033 ecore_imf_context_input_panel_imdata_get (Ecore_IMF_Context *ctx, char * data, int *len)
1035 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1037 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_get_imdata");
1043 printf ("input parameters error!!! \n");
1047 if (ctx->klass->input_panel_imdata_get) ctx->klass->input_panel_imdata_get(ctx, data, len);
1051 ecore_imf_context_input_panel_use_effect_set (Ecore_IMF_Context *ctx, Eina_Bool use_effect)
1053 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1055 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_use_effect_set");
1059 if (ctx->klass->input_panel_use_effect_set) ctx->klass->input_panel_use_effect_set(ctx, use_effect);
1060 ctx->use_effect = use_effect;
1064 ecore_imf_context_input_panel_use_effect_get (Ecore_IMF_Context *ctx)
1066 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1068 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_use_effect_get");
1072 return ctx->use_effect;
1076 ecore_imf_context_input_panel_geometry_get (Ecore_IMF_Context *ctx, int *x, int *y, int *w, int *h)
1078 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1080 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_geometry_get");
1084 if (ctx->klass->input_panel_geometry_get) ctx->klass->input_panel_geometry_get(ctx, x, y, w, h);
1088 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)
1090 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1092 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_private_key_set");
1096 if (label == NULL && img_path == NULL)
1098 printf ("input parameters error!!! \n");
1102 Private_Key_Item *key_item;
1104 Eina_Bool exist = EINA_FALSE;
1106 EINA_LIST_FOREACH(ctx->private_key_list, l, key_item)
1108 if (key_item && key_item->layout_idx == layout_index && key_item->key_idx == key_index)
1110 // if exist in the list
1115 strcpy(key_item->data, label);
1120 strcpy(key_item->data, img_path);
1122 key_item->key_value = key_value;
1123 strcpy(key_item->key_string, key_string);
1129 key_item = calloc(1, sizeof(Private_Key_Item));
1130 if (!key_item) return;
1132 key_item->layout_idx = layout_index;
1133 key_item->key_idx = key_index;;
1137 strcpy(key_item->data, label);
1142 strcpy(key_item->data, img_path);
1144 key_item->key_value = key_value;
1148 strcpy(key_item->key_string, key_string);
1151 ctx->private_key_list = eina_list_append(ctx->private_key_list, key_item);
1154 // if (ctx->klass->input_panel_private_key_set) ctx->klass->input_panel_private_key_set(ctx, layout_index, key_index, img_path, label, value);
1158 ecore_imf_context_input_panel_private_key_list_get (Ecore_IMF_Context *ctx)
1160 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1162 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_private_key_list_get");
1166 return ctx->private_key_list;
1170 ecore_imf_context_input_panel_key_disabled_set (Ecore_IMF_Context *ctx, int layout_index, int key_index, Eina_Bool disabled)
1172 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1174 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_key_disabled_set");
1178 Disable_Key_Item *key_item;
1180 Eina_Bool exist = EINA_FALSE;
1182 EINA_LIST_FOREACH(ctx->disabled_key_list, l, key_item)
1184 if (key_item && key_item->layout_idx == layout_index && key_item->key_idx == key_index)
1186 key_item->disabled = disabled;
1193 key_item = calloc(1, sizeof(Disable_Key_Item));
1194 if (!key_item) return;
1196 key_item->layout_idx = layout_index;
1197 key_item->key_idx = key_index;;
1198 key_item->disabled = disabled;
1200 ctx->disabled_key_list = eina_list_append(ctx->disabled_key_list, key_item);
1203 // if (ctx->klass->input_panel_key_disabled_set) ctx->klass->input_panel_key_disabled_set(ctx, layout_index, key_index, disabled);
1207 ecore_imf_context_input_panel_key_disabled_list_get (Ecore_IMF_Context *ctx)
1209 return ctx->disabled_key_list;
1213 ecore_imf_context_input_panel_layout_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Layout layout)
1215 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1217 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_layout_set");
1221 if (ctx->klass->input_panel_layout_set) ctx->klass->input_panel_layout_set(ctx, layout);
1222 ctx->input_panel_layout = layout;
1225 EAPI Ecore_IMF_Input_Panel_Layout
1226 ecore_imf_context_input_panel_layout_get (Ecore_IMF_Context *ctx)
1228 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1230 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_layout_get");
1231 return ECORE_IMF_INPUT_PANEL_LAYOUT_INVALID;
1234 if (ctx->klass->input_panel_layout_get )
1236 // ctx->klass->input_panel_layout_get (ctx, &layout);
1237 return ctx->input_panel_layout;
1240 return ECORE_IMF_INPUT_PANEL_LAYOUT_INVALID;
1244 ecore_imf_context_input_panel_reset (Ecore_IMF_Context *ctx)
1246 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1248 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_reset");
1252 if (ctx->klass->input_panel_reset) ctx->klass->input_panel_reset(ctx);
1256 ecore_imf_context_input_panel_orient_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Orient orientation)
1258 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1260 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_orient_set");
1264 if (ctx->klass->input_panel_orient_set) ctx->klass->input_panel_orient_set(ctx, orientation*90);
1265 ctx->input_panel_orient = orientation;
1268 EAPI Ecore_IMF_Input_Panel_Orient
1269 ecore_imf_context_input_panel_orient_get (Ecore_IMF_Context *ctx)
1271 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1273 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_orient_get");
1274 return ECORE_IMF_INPUT_PANEL_ORIENT_NONE;
1277 return ctx->input_panel_orient;
1281 ecore_imf_context_ise_get_active_isename (Ecore_IMF_Context *ctx, char* name)
1283 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1285 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_get_active_isename");
1291 printf ("input parameters error!!! \n");
1295 if (ctx->klass->ise_get_active_isename) ctx->klass->ise_get_active_isename(ctx, name);
1299 ecore_imf_context_ise_set_active_ise_by_name (Ecore_IMF_Context *ctx, const char* name)
1301 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1303 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_set_active_ise_by_name");
1308 printf ("input parameters error!!! \n");
1312 if (ctx->klass->ise_set_active_ise_by_name) ctx->klass->ise_set_active_ise_by_name(ctx, name);
1316 ecore_imf_context_ise_set_active_ise_by_uuid (Ecore_IMF_Context *ctx, const char* uuid)
1318 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1320 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_set_active_ise_by_uuid");
1325 printf ("input parameters error!!! \n");
1329 if (ctx->klass->ise_set_active_ise_by_uuid) ctx->klass->ise_set_active_ise_by_uuid(ctx, uuid);
1333 ecore_imf_context_ise_get_iselist (Ecore_IMF_Context *ctx, char*** iselist)
1335 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1337 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_get_iselist");
1341 if (ctx->klass->ise_get_iselist)
1343 return ctx->klass->ise_get_iselist(ctx, iselist);
1349 EAPI Ecore_IMF_Input_Panel_State
1350 ecore_imf_context_input_panel_state_get (Ecore_IMF_Context *ctx)
1352 Ecore_IMF_Input_Panel_State state = ECORE_IMF_INPUT_PANEL_STATE_INVALID;
1353 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1355 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_state_get");
1356 return ECORE_IMF_INPUT_PANEL_STATE_INVALID;
1359 if (ctx->klass->input_panel_state_get)
1361 state = ctx->klass->input_panel_state_get(ctx);
1368 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)
1370 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1372 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_event_callback_add");
1376 if (ctx->klass->input_panel_event_callback_add)
1378 ctx->klass->input_panel_event_callback_add(ctx, type, pEventCallBackFunc, data);
1383 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))
1385 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1387 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_event_callback_del");
1391 if (ctx->klass->input_panel_event_callback_del)
1393 ctx->klass->input_panel_event_callback_del(ctx, type, pEventCallBackFunc);
1398 ecore_imf_context_input_panel_move (Ecore_IMF_Context *ctx, int x, int y)
1400 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1402 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_move");
1406 if (ctx->klass->input_panel_move) ctx->klass->input_panel_move(ctx, x, y);
1407 ctx->input_panel_x = x;
1408 ctx->input_panel_y = y;
1412 ecore_imf_context_input_panel_caps_mode_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Caps_Mode mode)
1414 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1416 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_caps_mode_set");
1420 if (ctx->klass->input_panel_caps_mode_set) ctx->klass->input_panel_caps_mode_set(ctx, mode);