void focus_out_then_focus_in_with_aux_text_test()
{
    gboolean cleanBufferFocusOut=ibus_chewing_pre_edit_get_property_boolean(engine->icPreEdit, "clean-buffer-focus-out");
    ibus_chewing_engine_set_capabilite(engine, IBUS_CAP_AUXILIARY_TEXT);
    ibus_chewing_engine_focus_in(engine);
    ibus_chewing_engine_enable(engine);
    ibus_chewing_engine_process_key_event(IBUS_ENGINE(engine), 'j', 0x24,
					  0);
    ibus_chewing_engine_process_key_event(IBUS_ENGINE(engine), 'j', 0x24,
					  IBUS_RELEASE_MASK);
    check_output("", "ㄨ", "ㄨ");

    /* focus out should not touch Texts
     */
    printf("########### cleanBufferFocusOut: %d\n", cleanBufferFocusOut);
    ibus_chewing_engine_focus_out(engine);
    g_assert(cleanBufferFocusOut==ibus_chewing_pre_edit_get_property_boolean(engine->icPreEdit, "clean-buffer-focus-out"));
    if (cleanBufferFocusOut){
	check_output("", "", "");
    }else{
	check_output("", "ㄨ", "ㄨ");
    }

    /* all should be clean */
    ibus_chewing_engine_focus_in(engine);
    check_output("", "", "");

    ibus_chewing_pre_edit_clear(engine->icPreEdit);
    check_output("", "", "");
}
void
ibus_sunpinyin_engine_init(IBusEngine *py_engine)
{
    if (g_object_is_floating (py_engine))
        g_object_ref_sink (py_engine);
    GET_PY_ENGINE(py_engine) = new SunPinyinEngine(IBUS_ENGINE(py_engine));
}
void focus_out_then_focus_in_with_aux_text_test()
{
    gboolean cleanBufferFocusOut = ibus_chewing_pre_edit_get_property_boolean
        (engine->icPreEdit, "clean-buffer-focus-out");

    ibus_chewing_pre_edit_save_property_boolean(engine->icPreEdit,
                                                "add-phrase-direction", TRUE);

    ibus_chewing_engine_set_capabilite(engine, IBUS_CAP_AUXILIARY_TEXT);
    ibus_chewing_engine_focus_in(engine);
    ibus_chewing_engine_enable(engine);
    ibus_chewing_engine_process_key_event(IBUS_ENGINE(engine), 'j', 0x24, 0);
    ibus_chewing_engine_process_key_event(IBUS_ENGINE(engine),
                                          'j', 0x24, IBUS_RELEASE_MASK);
    ibus_chewing_engine_process_key_event(IBUS_ENGINE(engine), '3', 0x04, 0);
    ibus_chewing_engine_process_key_event(IBUS_ENGINE(engine),
                                          '3', 0x04, IBUS_RELEASE_MASK);
    ibus_chewing_engine_process_key_event(IBUS_ENGINE(engine), 'j', 0x24, 0);
    ibus_chewing_engine_process_key_event(IBUS_ENGINE(engine),
                                          'j', 0x24, IBUS_RELEASE_MASK);
    ibus_chewing_engine_process_key_event(IBUS_ENGINE(engine), '3', 0x04, 0);
    ibus_chewing_engine_process_key_event(IBUS_ENGINE(engine),
                                          '3', 0x04, IBUS_RELEASE_MASK);
    ibus_chewing_engine_process_key_event(IBUS_ENGINE(engine),
                                          '2', 0x03, IBUS_CONTROL_MASK);
    ibus_chewing_engine_process_key_event(IBUS_ENGINE(engine),
                                          '2', 0x03, IBUS_RELEASE_MASK);
    check_output("", "五五", "已有:五五");

    /* focus out should not touch Texts */
    ibus_chewing_engine_focus_out(engine);
    g_assert(cleanBufferFocusOut == ibus_chewing_pre_edit_get_property_boolean
             (engine->icPreEdit, "clean-buffer-focus-out"));

    if (cleanBufferFocusOut) {
        check_output("", "", "");
    } else {
        check_output("", "五五", "已有:五五");
    }

    /* all should be clean */
    ibus_chewing_engine_focus_in(engine);
    check_output("", "", "");

    ibus_chewing_pre_edit_clear(engine->icPreEdit);
    check_output("", "", "");
}
void update_aux_text(IBusChewingEngine * self)
{
    IBUS_CHEWING_LOG(DEBUG, "update_aux_text()");
    if (!ibus_chewing_engine_has_capabilite(self, IBUS_CAP_AUXILIARY_TEXT)) {
	return;
    }
    refresh_aux_text(self);
    parent_update_auxiliary_text(IBUS_ENGINE(self), self->auxText, TRUE);
}
void commit_text(IBusChewingEngine * self)
{
    refresh_outgoing_text(self);
    if (!ibus_text_is_empty(self->outgoingText)
	|| !ibus_chewing_engine_has_status_flag(self,
						ENGINE_FLAG_FOCUS_IN)) {
	parent_commit_text(IBUS_ENGINE(self));
    }

    ibus_chewing_pre_edit_clear_outgoing(self->icPreEdit);
}
Exemplo n.º 6
0
static void
FcitxThaiGetPrevCell(FcitxThai* thai, struct thcell_t* res)
{
    th_init_cell(res);

    if (is_client_support_surrounding(IBUS_ENGINE(libthai_engine))) {
        IBusText* surrounding;
        guint     cursor_pos;
        guint     anchor_pos;
        const gchar* s;
        gchar*    tis_text = NULL;

        ibus_engine_get_surrounding_text(IBUS_ENGINE(libthai_engine),
                                         &surrounding, &cursor_pos, &anchor_pos);
        s = ibus_text_get_text(surrounding);
        cursor_pos = g_utf8_offset_to_pointer(s, cursor_pos) - s;
        while (*s) {
            const gchar* t;

            tis_text = g_convert(s, cursor_pos, "TIS-620", "UTF-8",
                                 NULL, NULL, NULL);
            if (tis_text)
                break;

            t = g_utf8_next_char(s);
            cursor_pos -= (t - s);
            s = t;
        }
        if (tis_text) {
            gint char_index;

            char_index = g_utf8_pointer_to_offset(s, s + cursor_pos);
            th_prev_cell((thchar_t*) tis_text, char_index, res, TRUE);
            g_free(tis_text);
        }
    } else {
        /* retrieve from the fallback buffer */
        th_prev_cell(libthai_engine->char_buff, libthai_engine->buff_tail,
                     res, TRUE);
    }
}
void update_lookup_table(IBusChewingEngine * self)
{
    IBUS_CHEWING_LOG(DEBUG, "update_lookup_table() CurrentPage=%d",
		     chewing_cand_CurrentPage(self->icPreEdit->context));

    gboolean isShow =
	ibus_chewing_pre_edit_has_flag(self->icPreEdit, FLAG_TABLE_SHOW);

    if (isShow) {
#ifndef UNIT_TEST
	ibus_engine_update_lookup_table(IBUS_ENGINE(self),
					self->icPreEdit->iTable, isShow);
	ibus_engine_show_lookup_table(IBUS_ENGINE(self));
#endif
    } else {
#ifndef UNIT_TEST
	ibus_engine_update_lookup_table(IBUS_ENGINE(self),
					self->icPreEdit->iTable, isShow);
	ibus_engine_hide_lookup_table(IBUS_ENGINE(self));
#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
}
void update_pre_edit_text(IBusChewingEngine * self)
{
    refresh_pre_edit_text(self);
    gboolean visible = TRUE;

    IBusPreeditFocusMode mode;
    if (STRING_IS_EMPTY(self->preEditText->text)) {
	mode = IBUS_ENGINE_PREEDIT_CLEAR;
	visible = FALSE;
    } else {
	mode = IBUS_ENGINE_PREEDIT_COMMIT;
    }

    parent_update_pre_edit_text_with_mode(IBUS_ENGINE(self),
					  self->preEditText,
					  cursor_current, visible, mode);
}
Exemplo n.º 10
0
gboolean ibus_handwrite_engine_commit_text(IBusHandwriteEngine * engine , int index)
{
	MatchedChar * matched;

	int number = ibus_handwrite_recog_getmatch(engine->engine,&matched,0);

	if(number > index )
	{
		ibus_engine_commit_text(IBUS_ENGINE(engine),ibus_text_new_from_string(matched[index].chr));
		ibus_handwrite_recog_clear_stroke(engine->engine);
		engine->needclear = TRUE;
		engine->currentstroke.segments = 0;
		g_free(engine->currentstroke.points);
		engine->currentstroke.points = NULL;
		return TRUE;
	}
	engine->needclear = FALSE;
	return FALSE;
}
Exemplo n.º 11
0
static void ibus_handwrite_engine_focus_in(IBusHandwriteEngine *engine)
{
	UI_show_ui(engine);

	IBusPropList * pl = ibus_prop_list_new();

	IBusProperty * p = ibus_property_new("choose-color", PROP_TYPE_NORMAL,
			ibus_text_new_from_static_string(_("color")), GTK_STOCK_COLOR_PICKER,
			ibus_text_new_from_static_string(_("click to set color")), TRUE, TRUE,
			PROP_STATE_UNCHECKED, NULL);

	ibus_prop_list_append(pl, p);

#ifdef WITH_ZINNIA
	if( strcmp(lang,"jp") ==0 || strcmp(lang,"ja"))
	{
		extern char icondir[4096];

		gchar * iconfile = g_strdup_printf("%s/switch.svg",icondir);

		g_debug("icon file is %s",iconfile);

		p = ibus_property_new("choose-engine", PROP_TYPE_NORMAL,
				ibus_text_new_from_static_string(_("engine")), iconfile,
				ibus_text_new_from_static_string(_("click to set engine")), TRUE, TRUE,
				PROP_STATE_UNCHECKED, NULL);

		g_free(iconfile);

		ibus_prop_list_append(pl, p);
	}
#endif

	ibus_engine_register_properties(IBUS_ENGINE(engine), pl);

}
Exemplo n.º 12
0
static GObject*
ibus_lanxang_engine_constructor (GType                  type,
                                 guint                  n_construct_params,
                                 GObjectConstructParam *construct_params)
{
  IBusLanXangEngine *engine;
  const gchar *name;

  engine = (IBusLanXangEngine *)
             G_OBJECT_CLASS (ibus_lanxang_engine_parent_class)->constructor (
               type, n_construct_params, construct_params);
  name = ibus_engine_get_name (IBUS_ENGINE (engine));

  if (name && strcmp (name, "lanxang-tham") == 0)
    {
      engine->lx_iengine = g_object_new (LX_TYPE_THAM_ENGINE, NULL);
    }
  else if (name && strcmp (name, "lanxang-tn") == 0)
    {
      engine->lx_iengine = g_object_new (LX_TYPE_TN_ENGINE, NULL);
    }

  return G_OBJECT (engine);
}