10 #include <ecore_private.h>
12 #include "Ecore_IMF.h"
13 #include "ecore_imf_private.h"
16 * @defgroup Ecore_IMF_Context_Group Ecore Input Method Context Functions
18 * Functions that operate on Ecore Input Method Context objects.
22 * Get the list of the available Input Method Context ids.
24 * Note that the caller is responsible for freeing the Eina_List
25 * when finished with it. There is no need to finish the list strings.
27 * @return Return an Eina_List of strings;
28 * on failure it returns NULL.
29 * @ingroup Ecore_IMF_Context_Group
32 ecore_imf_context_available_ids_get(void)
34 return ecore_imf_module_context_ids_get();
38 ecore_imf_context_available_ids_by_canvas_type_get(const char *canvas_type)
40 return ecore_imf_module_context_ids_by_canvas_type_get(canvas_type);
44 * Match @locale against @against.
46 * 'en_US' against 'en_US' => 4
47 * 'en_US' against 'en' => 3
48 * 'en', 'en_UK' against 'en_US' => 2
49 * all locales, against '*' => 1
52 _ecore_imf_context_match_locale(const char *locale, const char *against, int against_len)
54 if (strcmp(against, "*") == 0)
57 if (strcasecmp(locale, against) == 0)
60 if (strncasecmp(locale, against, 2) == 0)
61 return (against_len == 2) ? 3 : 2;
67 * Get the id of the default Input Method Context.
68 * The id may to used to create a new instance of an Input Method
71 * @return Return a string containing the id of the default Input
72 * Method Context; on failure it returns NULL.
73 * @ingroup Ecore_IMF_Context_Group
76 ecore_imf_context_default_id_get(void)
78 return ecore_imf_context_default_id_by_canvas_type_get(NULL);
82 ecore_imf_context_default_id_by_canvas_type_get(const char *canvas_type)
86 Ecore_IMF_Module *module;
89 int best_goodness = 0;
91 id = getenv("ECORE_IMF_MODULE");
94 if (strcmp(id, "none") == 0) return NULL;
95 if (ecore_imf_module_get(id)) return id;
98 modules = ecore_imf_module_available_get();
99 if (!modules) return NULL;
101 locale = setlocale(LC_CTYPE, NULL);
102 if (!locale) return NULL;
104 locale = strdup(locale);
106 tmp = strchr(locale, '.');
107 if (tmp) *tmp = '\0';
108 tmp = strchr(locale, '@');
109 if (tmp) *tmp = '\0';
113 EINA_LIST_FREE(modules, module)
116 strcmp(module->info->canvas_type, canvas_type) == 0)
119 const char *p = module->info->default_locales;
122 const char *q = strchr(p, ':');
123 int goodness = _ecore_imf_context_match_locale(locale, p, q ? (size_t)(q - p) : strlen (p));
125 if (goodness > best_goodness)
127 id = module->info->id;
128 best_goodness = goodness;
131 p = q ? q + 1 : NULL;
140 * Retrieve the info for the Input Method Context with @p id.
142 * @param id The Input Method Context id to query for.
143 * @return Return a #Ecore_IMF_Context_Info for the Input Method Context with @p id;
144 * on failure it returns NULL.
145 * @ingroup Ecore_IMF_Context_Group
147 EAPI const Ecore_IMF_Context_Info *
148 ecore_imf_context_info_by_id_get(const char *id)
150 Ecore_IMF_Module *module;
152 if (!id) return NULL;
153 module = ecore_imf_module_get(id);
154 if (!module) return NULL;
159 * Create a new Input Method Context defined by the given id.
161 * @param id The Input Method Context id.
162 * @return A newly allocated Input Method Context;
163 * on failure it returns NULL.
164 * @ingroup Ecore_IMF_Context_Group
166 EAPI Ecore_IMF_Context *
167 ecore_imf_context_add(const char *id)
169 Ecore_IMF_Context *ctx;
171 if (!id) return NULL;
172 ctx = ecore_imf_module_context_create(id);
173 if (!ctx || !ctx->klass) return NULL;
174 if (ctx->klass->add) ctx->klass->add(ctx);
175 /* default use_preedit is EINA_TRUE, so let's make sure it's
176 * set on the immodule */
177 ecore_imf_context_use_preedit_set(ctx, EINA_TRUE);
178 /* default input_mode is ECORE_IMF_INPUT_MODE_FULL, so let's make sure it's
179 * set on the immodule */
180 ecore_imf_context_input_mode_set(ctx, ECORE_IMF_INPUT_MODE_FULL);
185 * Retrieve the info for the given Input Method Context.
187 * @param ctx An #Ecore_IMF_Context.
188 * @return Return a #Ecore_IMF_Context_Info for the given Input Method Context;
189 * on failure it returns NULL.
190 * @ingroup Ecore_IMF_Context_Group
192 EAPI const Ecore_IMF_Context_Info *
193 ecore_imf_context_info_get(Ecore_IMF_Context *ctx)
195 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
197 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
198 "ecore_imf_context_info_get");
201 return ctx->module->info;
205 * Delete the given Input Method Context and free its memory.
207 * @param ctx An #Ecore_IMF_Context.
208 * @ingroup Ecore_IMF_Context_Group
211 ecore_imf_context_del(Ecore_IMF_Context *ctx)
213 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
215 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
216 "ecore_imf_context_del");
219 if (ctx->klass->del) ctx->klass->del(ctx);
220 ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE);
225 * Set the client window for the Input Method Context; this is the
226 * Ecore_X_Window when using X11, Ecore_Win32_Window when using Win32, etc.
227 * This window is used in order to correctly position status windows, and may
228 * also be used for purposes internal to the Input Method Context.
230 * @param ctx An #Ecore_IMF_Context.
231 * @param window The client window. This may be NULL to indicate
232 * that the previous client window no longer exists.
233 * @ingroup Ecore_IMF_Context_Group
236 ecore_imf_context_client_window_set(Ecore_IMF_Context *ctx, void *window)
238 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
240 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
241 "ecore_imf_context_client_window_set");
244 if (ctx->klass->client_window_set) ctx->klass->client_window_set(ctx, window);
245 ctx->window = window;
249 * Get the client window of the Input Method Context
251 * See @ref ecore_imf_context_client_window_set for more details.
253 * @param ctx An #Ecore_IMF_Context.
254 * @return Return the client window.
255 * @ingroup Ecore_IMF_Context_Group
259 ecore_imf_context_client_window_get(Ecore_IMF_Context *ctx)
261 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
263 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
264 "ecore_imf_context_client_window_get");
271 * Set the client canvas for the Input Method Context; this is the
272 * canvas in which the input appears.
273 * The canvas type can be determined by using the context canvas type.
274 * Actually only canvas with type "evas" (Evas *) is supported.
275 * This canvas may be used in order to correctly position status windows, and may
276 * also be used for purposes internal to the Input Method Context.
278 * @param ctx An #Ecore_IMF_Context.
279 * @param canvas The client canvas. This may be NULL to indicate
280 * that the previous client canvas no longer exists.
281 * @ingroup Ecore_IMF_Context_Group
284 ecore_imf_context_client_canvas_set(Ecore_IMF_Context *ctx, void *canvas)
286 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
288 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
289 "ecore_imf_context_client_canvas_set");
292 if (ctx->klass->client_canvas_set) ctx->klass->client_canvas_set(ctx, canvas);
293 ctx->client_canvas = canvas;
297 * Get the client canvas of the Input Method Context.
299 * See @ref ecore_imf_context_client_canvas_set for more details.
301 * @param ctx An #Ecore_IMF_Context.
302 * @return Return the client canvas.
303 * @ingroup Ecore_IMF_Context_Group
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
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
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 * Retrieve the current preedit string, atrributes and
385 * cursor position for the Input Method Context.
387 * @param ctx An #Ecore_IMF_Context.
388 * @param str Location to store the retrieved string. The
389 * string retrieved must be freed with free().
390 * @param attrs an Eina_List of attributes
391 * @param cursor_pos Location to store position of cursor (in characters)
392 * within the preedit string.
393 * @ingroup Ecore_IMF_Context_Group
397 ecore_imf_context_preedit_string_with_attributes_get(Ecore_IMF_Context *ctx, char **str, Eina_List **attrs, int *cursor_pos)
399 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
401 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
402 "ecore_imf_context_preedit_string_with_attributes_get");
405 if (ctx->klass->preedit_string_with_attributes_get)
406 ctx->klass->preedit_string_with_attributes_get(ctx, str, attrs, cursor_pos);
409 if (str) *str = strdup("");
410 if (attrs) *attrs = NULL;
411 if (cursor_pos) *cursor_pos = 0;
416 * Notify the Input Method Context that the widget to which its
417 * correspond has gained focus.
419 * @param ctx An #Ecore_IMF_Context.
420 * @ingroup Ecore_IMF_Context_Group
423 ecore_imf_context_focus_in(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_in");
431 if (ctx->klass->focus_in) ctx->klass->focus_in(ctx);
435 * Notify the Input Method Context that the widget to which its
436 * correspond has lost focus.
438 * @param ctx An #Ecore_IMF_Context.
439 * @ingroup Ecore_IMF_Context_Group
442 ecore_imf_context_focus_out(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_focus_out");
450 if (ctx->klass->focus_out) ctx->klass->focus_out(ctx);
454 * Notify the Input Method Context that a change such as a
455 * change in cursor position has been made. This will typically
456 * cause the Input Method Context to clear the preedit state.
458 * @param ctx An #Ecore_IMF_Context.
459 * @ingroup Ecore_IMF_Context_Group
462 ecore_imf_context_reset(Ecore_IMF_Context *ctx)
464 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
466 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
467 "ecore_imf_context_reset");
470 if (ctx->klass->reset) ctx->klass->reset(ctx);
474 * Notify the Input Method Context that a change in the cursor
475 * position has been made.
477 * @param ctx An #Ecore_IMF_Context.
478 * @param cursor_pos New cursor position in characters.
479 * @ingroup Ecore_IMF_Context_Group
482 ecore_imf_context_cursor_position_set(Ecore_IMF_Context *ctx, int cursor_pos)
484 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
486 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
487 "ecore_imf_context_cursor_position_set");
490 if (ctx->klass->cursor_position_set) ctx->klass->cursor_position_set(ctx, cursor_pos);
494 * Set whether the IM context should use the preedit string
495 * to display feedback. If @use_preedit is EINA_FALSE (default
496 * is EINA_TRUE), then the IM context may use some other method to display
497 * feedback, such as displaying it in a child of the root window.
499 * @param ctx An #Ecore_IMF_Context.
500 * @param use_preedit Whether the IM context should use the preedit string.
501 * @ingroup Ecore_IMF_Context_Group
504 ecore_imf_context_use_preedit_set(Ecore_IMF_Context *ctx, Eina_Bool use_preedit)
506 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
508 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
509 "ecore_imf_context_use_preedit_set");
512 if (ctx->klass->use_preedit_set) ctx->klass->use_preedit_set(ctx, use_preedit);
516 * Set the callback to be used on get_surrounding request.
518 * This callback will be called when the Input Method Context
519 * module requests the surrounding context.
521 * @param ctx An #Ecore_IMF_Context.
522 * @param func The callback to be called.
523 * @param data The data pointer to be passed to @p func
524 * @ingroup Ecore_IMF_Context_Group
527 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)
529 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
531 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
532 "ecore_imf_context_retrieve_surrounding_callback_set");
536 ctx->retrieve_surrounding_func = func;
537 ctx->retrieve_surrounding_data = (void *) data;
541 * Set the input mode used by the Ecore Input Context.
543 * The input mode can be one of the input modes defined in
544 * #Ecore_IMF_Input_Mode. The default input mode is
545 * ECORE_IMF_INPUT_MODE_FULL.
547 * @param ctx An #Ecore_IMF_Context.
548 * @param input_mode The input mode to be used by @p ctx.
549 * @ingroup Ecore_IMF_Context_Group
552 ecore_imf_context_input_mode_set(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode)
554 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
556 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
557 "ecore_imf_context_input_mode_set");
560 if (ctx->klass->input_mode_set) ctx->klass->input_mode_set(ctx, input_mode);
561 ctx->input_mode = input_mode;
565 * Get the input mode being used by the Ecore Input Context.
567 * See @ref ecore_imf_context_input_mode_set for more details.
569 * @param ctx An #Ecore_IMF_Context.
570 * @return The input mode being used by @p ctx.
571 * @ingroup Ecore_IMF_Context_Group
573 EAPI Ecore_IMF_Input_Mode
574 ecore_imf_context_input_mode_get(Ecore_IMF_Context *ctx)
576 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
578 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
579 "ecore_imf_context_input_mode_set");
582 return ctx->input_mode;
586 * Allow an Ecore Input Context to internally handle an event.
587 * If this function returns EINA_TRUE, then no further processing
588 * should be done for this event.
590 * Input methods must be able to accept all types of events (simply
591 * returning EINA_FALSE if the event was not handled), but there is no
592 * obligation of any events to be submitted to this function.
594 * @param ctx An #Ecore_IMF_Context.
595 * @param type The type of event defined by #Ecore_IMF_Event_Type.
596 * @param event The event itself.
597 * @return EINA_TRUE if the event was handled; otherwise EINA_FALSE.
598 * @ingroup Ecore_IMF_Context_Group
601 ecore_imf_context_filter_event(Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, Ecore_IMF_Event *event)
603 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
605 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
606 "ecore_imf_context_filter_event");
609 if (ctx->klass->filter_event) return ctx->klass->filter_event(ctx, type, event);
614 * @defgroup Ecore_IMF_Context_Module_Group Ecore Input Method Context Module Functions
616 * Functions that should be used by Ecore Input Method Context modules.
620 * Creates a new Input Method Context with klass specified by @p ctxc.
622 * This method should be used by modules implementing the Input
623 * Method Context interface.
625 * @param ctxc An #Ecore_IMF_Context_Class.
626 * @return A new #Ecore_IMF_Context; on failure it returns NULL.
627 * @ingroup Ecore_IMF_Context_Module_Group
629 EAPI Ecore_IMF_Context *
630 ecore_imf_context_new(const Ecore_IMF_Context_Class *ctxc)
632 Ecore_IMF_Context *ctx;
634 if (!ctxc) return NULL;
635 ctx = calloc(1, sizeof(Ecore_IMF_Context));
636 if (!ctx) return NULL;
637 ECORE_MAGIC_SET(ctx, ECORE_MAGIC_CONTEXT);
640 ctx->retrieve_surrounding_func = NULL;
641 ctx->retrieve_surrounding_data = NULL;
646 * Set the Input Method Context specific data.
648 * Note that this method should be used by modules to set
649 * the Input Method Context specific data and it's not meant to
650 * be used by applications to store application specific data.
652 * @param ctx An #Ecore_IMF_Context.
653 * @param data The Input Method Context specific data.
654 * @return A new #Ecore_IMF_Context; on failure it returns NULL.
655 * @ingroup Ecore_IMF_Context_Module_Group
658 ecore_imf_context_data_set(Ecore_IMF_Context *ctx, void *data)
660 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
662 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
663 "ecore_imf_context_data_set");
670 * Get the Input Method Context specific data.
672 * See @ref ecore_imf_context_data_set for more details.
674 * @param ctx An #Ecore_IMF_Context.
675 * @return The Input Method Context specific data.
676 * @ingroup Ecore_IMF_Context_Module_Group
678 EAPI void *ecore_imf_context_data_get(Ecore_IMF_Context *ctx)
680 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
682 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
683 "ecore_imf_context_data_get");
690 * Retrieve context around insertion point.
692 * This function is implemented by calling the
693 * Ecore_IMF_Context::retrieve_surrounding_func (
694 * set using #ecore_imf_context_retrieve_surrounding_callback_set).
696 * There is no obligation for a widget to respond to the
697 * ::retrieve_surrounding_func, so input methods must be prepared
698 * to function without context.
700 * @param ctx An #Ecore_IMF_Context.
701 * @param text Location to store a UTF-8 encoded string of text
702 * holding context around the insertion point.
703 * If the function returns EINA_TRUE, then you must free
704 * the result stored in this location with free().
705 * @param cursor_pos Location to store the position in characters of
706 * the insertion cursor within @text.
707 * @return EINA_TRUE if surrounding text was provided; otherwise EINA_FALSE.
708 * @ingroup Ecore_IMF_Context_Module_Group
711 ecore_imf_context_surrounding_get(Ecore_IMF_Context *ctx, char **text, int *cursor_pos)
713 int result = EINA_FALSE;
715 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
717 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
718 "ecore_imf_context_surrounding_get");
722 if (ctx->retrieve_surrounding_func)
724 result = ctx->retrieve_surrounding_func(ctx->retrieve_surrounding_data, ctx, text, cursor_pos);
727 if (text) *text = NULL;
728 if (cursor_pos) *cursor_pos = 0;
735 _ecore_imf_event_free_preedit(void *data __UNUSED__, void *event)
741 * Adds ECORE_IMF_EVENT_PREEDIT_START to the event queue.
743 * @param ctx An #Ecore_IMF_Context.
744 * @ingroup Ecore_IMF_Context_Module_Group
747 ecore_imf_context_preedit_start_event_add(Ecore_IMF_Context *ctx)
749 Ecore_IMF_Event_Commit *ev;
751 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
753 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
754 "ecore_imf_context_preedit_start_event_add");
758 ev = malloc(sizeof(Ecore_IMF_Event_Preedit_Start));
760 ecore_event_add(ECORE_IMF_EVENT_PREEDIT_START,
761 ev, _ecore_imf_event_free_preedit, NULL);
765 * Adds ECORE_IMF_EVENT_PREEDIT_END to the event queue.
767 * @param ctx An #Ecore_IMF_Context.
768 * @ingroup Ecore_IMF_Context_Module_Group
771 ecore_imf_context_preedit_end_event_add(Ecore_IMF_Context *ctx)
773 Ecore_IMF_Event_Commit *ev;
775 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
777 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
778 "ecore_imf_context_preedit_end_event_add");
782 ev = malloc(sizeof(Ecore_IMF_Event_Preedit_End));
784 ecore_event_add(ECORE_IMF_EVENT_PREEDIT_END,
785 ev, _ecore_imf_event_free_preedit, NULL);
789 * Adds ECORE_IMF_EVENT_PREEDIT_CHANGED to the event queue.
791 * @param ctx An #Ecore_IMF_Context.
792 * @ingroup Ecore_IMF_Context_Module_Group
795 ecore_imf_context_preedit_changed_event_add(Ecore_IMF_Context *ctx)
797 Ecore_IMF_Event_Commit *ev;
799 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
801 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
802 "ecore_imf_context_preedit_changed_event_add");
806 ev = malloc(sizeof(Ecore_IMF_Event_Preedit_Changed));
808 ecore_event_add(ECORE_IMF_EVENT_PREEDIT_CHANGED,
809 ev, _ecore_imf_event_free_preedit, NULL);
813 _ecore_imf_event_free_commit(void *data __UNUSED__, void *event)
815 Ecore_IMF_Event_Commit *ev;
818 if (ev->str) free(ev->str);
823 * Adds ECORE_IMF_EVENT_COMMIT to the event queue.
825 * @param ctx An #Ecore_IMF_Context.
826 * @param str The committed string.
827 * @ingroup Ecore_IMF_Context_Module_Group
830 ecore_imf_context_commit_event_add(Ecore_IMF_Context *ctx, const char *str)
832 Ecore_IMF_Event_Commit *ev;
834 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
836 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
837 "ecore_imf_context_commit_event_add");
841 ev = malloc(sizeof(Ecore_IMF_Event_Commit));
843 ev->str = str ? strdup(str) : NULL;
844 ecore_event_add(ECORE_IMF_EVENT_COMMIT,
845 ev, _ecore_imf_event_free_commit, NULL);
850 _ecore_imf_event_free_delete_surrounding(void *data __UNUSED__, void *event)
856 * Adds ECORE_IMF_EVENT_DELETE_SURROUNDING to the event queue.
858 * @param ctx An #Ecore_IMF_Context.
859 * @param offset The start offset of surrounding to be deleted.
860 * @param n_chars The number of characters to be deleted.
861 * @ingroup Ecore_IMF_Context_Module_Group
864 ecore_imf_context_delete_surrounding_event_add(Ecore_IMF_Context *ctx, int offset, int n_chars)
866 Ecore_IMF_Event_Delete_Surrounding *ev;
868 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
870 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
871 "ecore_imf_context_delete_surrounding_event_add");
875 ev = malloc(sizeof(Ecore_IMF_Event_Delete_Surrounding));
878 ev->n_chars = n_chars;
879 ecore_event_add(ECORE_IMF_EVENT_DELETE_SURROUNDING,
880 ev, _ecore_imf_event_free_delete_surrounding, NULL);