void parent_update_auxiliary_text(IBusEngine * iEngine, IBusText * iText, gboolean visible) { #ifdef UNIT_TEST printf ("* parent_update_auxiliary_text(-, %s, %x)\n", (iText) ? iText->text : "NULL", visible); #else if (!visible) { ibus_engine_hide_auxiliary_text(iEngine); return; } if (ibus_text_is_empty(iText)) { ibus_engine_hide_auxiliary_text(iEngine); return; } ibus_engine_show_auxiliary_text(iEngine); #endif }
/** * ibus_chewing_engine_reset: * @self: IBusChewingEngine instance. * * Reset the outgoing and pre_edit buffer and cursor * chewing_reset will NOT called here, as it will chnage the KBType and input mode. */ void ibus_chewing_engine_reset(IBusChewingEngine * self) { IBUS_CHEWING_LOG(MSG, "* reset"); /* Always clean buffer */ ibus_chewing_pre_edit_clear(self->icPreEdit); #ifndef UNIT_TEST IBusEngine *engine = IBUS_ENGINE(self); ibus_engine_hide_auxiliary_text(engine); ibus_engine_hide_lookup_table(engine); ibus_engine_update_preedit_text(engine, SELF_GET_CLASS(self)->emptyText, 0, FALSE); #endif }
static void ibus_hangul_engine_focus_out (IBusEngine *engine) { IBusHangulEngine *hangul = (IBusHangulEngine *) engine; if (hangul->hanja_list == NULL) { // ibus-hangul uses // ibus_engine_update_preedit_text_with_mode() function which makes // the preedit string committed automatically when the focus is out. // So we don't need to commit the preedit here. hangul_ic_reset (hangul->context); } else { ibus_engine_hide_lookup_table (engine); ibus_engine_hide_auxiliary_text (engine); } parent_class->focus_out ((IBusEngine *) hangul); }
static void ibus_hangul_engine_hide_lookup_table (IBusHangulEngine *hangul) { gboolean is_visible; is_visible = lookup_table_is_visible (hangul->table); // Sending hide lookup table message when the lookup table // is not visible results wrong behavior. So I have to check // whether the table is visible or not before to hide. if (is_visible) { ibus_engine_hide_lookup_table ((IBusEngine *)hangul); ibus_engine_hide_auxiliary_text ((IBusEngine *)hangul); lookup_table_set_visible (hangul->table, FALSE); } if (hangul->hanja_list != NULL) { hanja_list_delete (hangul->hanja_list); hangul->hanja_list = NULL; } }
static void ibus_m17n_engine_callback (MInputContext *context, MSymbol command) { IBusM17NEngine *m17n = NULL; m17n = context->arg; g_return_if_fail (m17n != NULL); /* the callback may be called in minput_create_ic, in the time * m17n->context has not be assigned, so need assign it. */ if (m17n->context == NULL) { m17n->context = context; } if (command == Minput_preedit_start) { ibus_engine_hide_preedit_text ((IBusEngine *)m17n); } else if (command == Minput_preedit_draw) { ibus_m17n_engine_update_preedit (m17n); } else if (command == Minput_preedit_done) { ibus_engine_hide_preedit_text ((IBusEngine *)m17n); } else if (command == Minput_status_start) { ibus_engine_hide_preedit_text ((IBusEngine *)m17n); } else if (command == Minput_status_draw) { gchar *status; status = ibus_m17n_mtext_to_utf8 (m17n->context->status); if (status && strlen (status)) { IBusText *text; text = ibus_text_new_from_string (status); ibus_property_set_label (m17n->status_prop, text); ibus_property_set_visible (m17n->status_prop, TRUE); } else { ibus_property_set_label (m17n->status_prop, NULL); ibus_property_set_visible (m17n->status_prop, FALSE); } ibus_engine_update_property ((IBusEngine *)m17n, m17n->status_prop); g_free (status); } else if (command == Minput_status_done) { } else if (command == Minput_candidates_start) { ibus_engine_hide_lookup_table ((IBusEngine *) m17n); ibus_engine_hide_auxiliary_text ((IBusEngine *) m17n); } else if (command == Minput_candidates_draw) { ibus_m17n_engine_update_lookup_table (m17n); } else if (command == Minput_candidates_done) { ibus_engine_hide_lookup_table ((IBusEngine *) m17n); ibus_engine_hide_auxiliary_text ((IBusEngine *) m17n); } else if (command == Minput_set_spot) { } else if (command == Minput_toggle) { } else if (command == Minput_reset) { } /* ibus_engine_get_surrounding_text is only available in the current git master (1.3.99+) */ #ifdef HAVE_IBUS_ENGINE_GET_SURROUNDING_TEXT else if (command == Minput_get_surrounding_text && (((IBusEngine *) m17n)->client_capabilities & IBUS_CAP_SURROUNDING_TEXT) != 0) { IBusText *text; guint cursor_pos, nchars, nbytes; MText *mt, *surround; int len, pos; ibus_engine_get_surrounding_text ((IBusEngine *) m17n, &text, &cursor_pos); nchars = ibus_text_get_length (text); nbytes = g_utf8_offset_to_pointer (text->text, nchars) - text->text; mt = mconv_decode_buffer (Mcoding_utf_8, text->text, nbytes); g_object_unref (text); len = (long) mplist_value (m17n->context->plist); if (len < 0) { pos = cursor_pos + len; if (pos < 0) pos = 0; surround = mtext_duplicate (mt, pos, cursor_pos); } else if (len > 0) { pos = cursor_pos + len; if (pos > nchars) pos = nchars; surround = mtext_duplicate (mt, cursor_pos, pos); } else { surround = mtext (); } m17n_object_unref (mt); mplist_set (m17n->context->plist, Mtext, surround); m17n_object_unref (surround); } #endif /* !HAVE_IBUS_ENGINE_GET_SURROUNDING_TEXT */ else if (command == Minput_delete_surrounding_text && (((IBusEngine *) m17n)->client_capabilities & IBUS_CAP_SURROUNDING_TEXT) != 0) { int len; len = (long) mplist_value (m17n->context->plist); if (len < 0) ibus_engine_delete_surrounding_text ((IBusEngine *) m17n, len, -len); else if (len > 0) ibus_engine_delete_surrounding_text ((IBusEngine *) m17n, 0, len); } }
static void ibus_m17n_engine_update_lookup_table (IBusM17NEngine *m17n) { ibus_lookup_table_clear (m17n->table); if (m17n->context->candidate_list && m17n->context->candidate_show) { IBusText *text; MPlist *group; group = m17n->context->candidate_list; gint i = 0; gint page = 1; IBusM17NEngineClass *klass = (IBusM17NEngineClass *) G_OBJECT_GET_CLASS (m17n); while (1) { gint len; if (mplist_key (group) == Mtext) len = mtext_len ((MText *) mplist_value (group)); else len = mplist_length ((MPlist *) mplist_value (group)); if (i + len > m17n->context->candidate_index) break; i += len; group = mplist_next (group); page ++; } if (mplist_key (group) == Mtext) { MText *mt; gunichar *buf; glong nchars, i; mt = (MText *) mplist_value (group); ibus_lookup_table_set_page_size (m17n->table, mtext_len (mt)); buf = ibus_m17n_mtext_to_ucs4 (mt, &nchars); for (i = 0; i < nchars; i++) { ibus_lookup_table_append_candidate (m17n->table, ibus_text_new_from_unichar (buf[i])); } g_free (buf); } else { MPlist *p; p = (MPlist *) mplist_value (group); ibus_lookup_table_set_page_size (m17n->table, mplist_length (p)); for (; mplist_key (p) != Mnil; p = mplist_next (p)) { MText *mtext; gchar *buf; mtext = (MText *) mplist_value (p); buf = ibus_m17n_mtext_to_utf8 (mtext); if (buf) { ibus_lookup_table_append_candidate (m17n->table, ibus_text_new_from_string (buf)); g_free (buf); } } } ibus_lookup_table_set_cursor_pos (m17n->table, m17n->context->candidate_index - i); ibus_lookup_table_set_orientation (m17n->table, klass->lookup_table_orientation); text = ibus_text_new_from_printf ("( %d / %d )", page, mplist_length (m17n->context->candidate_list)); ibus_engine_update_lookup_table ((IBusEngine *)m17n, m17n->table, TRUE); ibus_engine_update_auxiliary_text ((IBusEngine *)m17n, text, TRUE); } else { ibus_engine_hide_lookup_table ((IBusEngine *)m17n); ibus_engine_hide_auxiliary_text ((IBusEngine *)m17n); } }