void
HangulInstance::update_candidates ()
{
    m_lookup_table.clear ();
    m_candidate_comments.clear ();

    HanjaList* list = NULL;

    // search for symbol character
    // key string for symbol character is like:
    //  'ㄱ', 'ㄴ', 'ㄷ', etc
    WideString preeditw = get_preedit_string();
    if (preeditw.length() == 1) {
	String key = utf8_wcstombs(preeditw);
	list = hanja_table_match_suffix(m_factory->m_symbol_table, key.c_str());
    }

    // search for hanja
    if (list == NULL) {
	String str = get_candidate_string();
	SCIM_DEBUG_IMENGINE(1) << "candidate string: " << str << "\n";

	if (str.length() > 0) {
	    if (is_hanja_mode() || m_factory->m_commit_by_word) {
		list = hanja_table_match_prefix(m_factory->m_hanja_table,
						    str.c_str());
	    } else {
		list = hanja_table_match_suffix(m_factory->m_hanja_table,
						    str.c_str());
	    }
	}
    } 
    
    if (list != NULL) {
	int n = hanja_list_get_size(list);
	for (int i = 0; i < n; ++i) {
	    const char* value = hanja_list_get_nth_value(list, i);
	    const char* comment = hanja_list_get_nth_comment(list, i);
	    WideString candidate = utf8_mbstowcs(value, -1);
	    m_lookup_table.append_candidate(candidate);
	    m_candidate_comments.push_back(String(comment));
	}

	m_lookup_table.set_page_size (9);
	m_lookup_table.show_cursor ();

	update_lookup_table (m_lookup_table);
	show_lookup_table ();

	hangul_update_aux_string ();

	hanja_list_delete(list);
    }

    if (m_lookup_table.number_of_candidates() <= 0) {
	delete_candidates();
    }
}
void
HangulInstance::lookup_table_page_up ()
{
    if (!m_lookup_table.number_of_candidates () || !m_lookup_table.get_current_page_start ())
        return;

    SCIM_DEBUG_IMENGINE(2) << "lookup_table_page_up.\n";

    m_lookup_table.page_up ();

    update_lookup_table (m_lookup_table);

    hangul_update_aux_string ();
}
void
HangulInstance::lookup_table_page_down ()
{
    if (m_lookup_table.number_of_candidates () <= 0 ||
        m_lookup_table.get_current_page_start () + m_lookup_table.get_current_page_size () >=
          (int)m_lookup_table.number_of_candidates ())
        return;

    SCIM_DEBUG_IMENGINE(2) << "lookup_table_page_down.\n";

    m_lookup_table.page_down ();

    update_lookup_table (m_lookup_table);

    hangul_update_aux_string ();
}
Beispiel #4
0
void
HangulInstance::focus_in ()
{
    SCIM_DEBUG_IMENGINE(2) << "focus_in.\n";

    register_all_properties();

    if (m_lookup_table.number_of_candidates ()) {
        update_lookup_table (m_lookup_table);
        show_lookup_table ();
    } else {
        hide_lookup_table ();
    }

    hangul_update_aux_string ();
}
void
HangulInstance::focus_in ()
{
    SCIM_DEBUG_IMENGINE(2) << "focus_in.\n";

    register_all_properties();

    hangul_ic_select_keyboard(m_hic, m_factory->m_keyboard_layout.c_str());

    if (m_lookup_table.number_of_candidates ()) {
        update_lookup_table (m_lookup_table);
        show_lookup_table ();
    } else {
        hide_lookup_table ();
    }

    hangul_update_aux_string ();
}
bool
HangulInstance::candidate_key_event (const KeyEvent &key)
{
    switch (key.code) {
        case SCIM_KEY_Return:
        case SCIM_KEY_KP_Enter:
            select_candidate (m_lookup_table.get_cursor_pos_in_current_page ());
            break;
        case SCIM_KEY_KP_Subtract:
	    m_lookup_table.cursor_up ();
	    update_lookup_table (m_lookup_table);
	    hangul_update_aux_string ();
            break;
        case SCIM_KEY_space:
	    if (is_hanja_mode())
		return false;
        case SCIM_KEY_KP_Add:
	    m_lookup_table.cursor_down ();
	    update_lookup_table (m_lookup_table);
	    hangul_update_aux_string ();
	    break;
        case SCIM_KEY_Page_Up:
	    lookup_table_page_up();
            break;
        case SCIM_KEY_Page_Down:
        case SCIM_KEY_KP_Tab:
	    lookup_table_page_down();
            break;
        case SCIM_KEY_h:
	    if (is_hanja_mode())
		return false;
        case SCIM_KEY_Left:
	    if (m_factory->m_lookup_table_vertical) {
		lookup_table_page_up();
	    } else {
		m_lookup_table.cursor_up ();
		update_lookup_table (m_lookup_table);
		hangul_update_aux_string ();
	    }
            break;
        case SCIM_KEY_l:
	    if (is_hanja_mode())
		return false;
        case SCIM_KEY_Right:
	    if (m_factory->m_lookup_table_vertical) {
		lookup_table_page_down();
	    } else {
		m_lookup_table.cursor_down ();
		update_lookup_table (m_lookup_table);
		hangul_update_aux_string ();
	    }
            break;
        case SCIM_KEY_k:
	    if (is_hanja_mode())
		return false;
        case SCIM_KEY_Up:
	    if (m_factory->m_lookup_table_vertical) {
		m_lookup_table.cursor_up ();
		update_lookup_table (m_lookup_table);
		hangul_update_aux_string ();
	    } else {
		lookup_table_page_up();
	    }
            break;
        case SCIM_KEY_j:
	    if (is_hanja_mode())
		return false;
        case SCIM_KEY_Down:
	    if (m_factory->m_lookup_table_vertical) {
		m_lookup_table.cursor_down ();
		update_lookup_table (m_lookup_table);
		hangul_update_aux_string ();
	    } else {
		lookup_table_page_down();
	    }
            break;
        case SCIM_KEY_Escape:
            delete_candidates ();
            break;
        case SCIM_KEY_1: 
        case SCIM_KEY_2: 
        case SCIM_KEY_3: 
        case SCIM_KEY_4: 
        case SCIM_KEY_5: 
        case SCIM_KEY_6: 
        case SCIM_KEY_7: 
        case SCIM_KEY_8: 
        case SCIM_KEY_9: 
            select_candidate (key.code - SCIM_KEY_1);
            break;
        default:
	    return !is_hanja_mode();
    }

    return true;
}