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 HanjaList* ibus_hangul_engine_lookup_hanja_table (const char* key, int method) { HanjaList* list; if (key == NULL) return NULL; switch (method) { case LOOKUP_METHOD_EXACT: if (symbol_table != NULL) list = hanja_table_match_exact (symbol_table, key); if (list == NULL) list = hanja_table_match_exact (hanja_table, key); break; case LOOKUP_METHOD_PREFIX: if (symbol_table != NULL) list = hanja_table_match_prefix (symbol_table, key); if (list == NULL) list = hanja_table_match_prefix (hanja_table, key); break; case LOOKUP_METHOD_SUFFIX: if (symbol_table != NULL) list = hanja_table_match_suffix (symbol_table, key); if (list == NULL) list = hanja_table_match_suffix (hanja_table, key); break; } return list; }
bool QHangulPlatformInputContext::popupCandidateList() { const ucschar *text = hangul_ic_get_preedit_string(m_hic); if (text != NULL && *text != 0) { QString str; str += QChar(text[0]); HanjaList *list = hanja_table_match_suffix(hanjaTable, str.toUtf8()); if (m_candidateList == NULL) m_candidateList = new CandidateList(); QPoint p(0, 0); QWidget *focus = qobject_cast<QWidget *>(m_focusObject); if (focus != NULL) { QVariant v = focus->inputMethodQuery(Qt::ImMicroFocus); QRect r = v.toRect(); p = focus->mapToGlobal(QPoint(r.right(), r.bottom())); } m_candidateList->open(list, p.x(), p.y()); } return false; }