int main(int argc, char *argv[]) { char* hanja_table_file = NULL; char buf[256] = { '\0', }; if (argc > 1) hanja_table_file = argv[1]; HanjaTable *table; table = hanja_table_load(hanja_table_file); while (fgets(buf, sizeof(buf), stdin) != NULL) { char* p = strchr(buf, '\n'); if (p != NULL) *p = '\0'; HanjaList *list = hanja_table_match_prefix(table, buf); int i, n; n = hanja_list_get_size(list); for (i = 0; i < n; i++) { const char* key = hanja_list_get_nth_key(list, i); const char* value = hanja_list_get_nth_value(list, i); const char* comment = hanja_list_get_nth_comment(list, i); printf("%s:%s:%s\n", key, value, comment); } hanja_list_delete(list); } hanja_table_delete(table); return 0; }
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(); } }
static void ibus_hangul_engine_update_lookup_table_ui (IBusHangulEngine *hangul) { guint cursor_pos; const char* comment; IBusText* text; // update aux text cursor_pos = ibus_lookup_table_get_cursor_pos (hangul->table); comment = hanja_list_get_nth_comment (hangul->hanja_list, cursor_pos); text = ibus_text_new_from_string (comment); ibus_engine_update_auxiliary_text ((IBusEngine *)hangul, text, TRUE); // update lookup table ibus_engine_update_lookup_table ((IBusEngine *)hangul, hangul->table, TRUE); }