void QinPinyin::update_preedit_string(const IPreeditString& preedit) { const int len = preedit.size(); if (len > 0) { preeditStr = TWCHAR2str(preedit.string(), preedit.size()); } else { preeditStr.clear(); } }
void decorate_preedit_string_using_caret_pos(IBusText *text, const IPreeditString& preedit, int caret) { if (caret < preedit.size()) { // add underline, otherwise gtk app won't have the same color scheme with that of x11 apps ibus_text_append_attribute(text, IBUS_ATTR_TYPE_UNDERLINE, IBUS_ATTR_UNDERLINE_SINGLE, caret, preedit.size()); ibus_text_append_attribute(text, IBUS_ATTR_TYPE_FOREGROUND, WHITE, caret, preedit.size()); ibus_text_append_attribute(text, IBUS_ATTR_TYPE_BACKGROUND, GRAY_BLUE, caret, preedit.size()); } }
void SunPinyinEngine::update_preedit_string(const IPreeditString& preedit) { const int len = preedit.size(); if (len > 0) { IBusText *text = ibus_text_new_from_ucs4((const gunichar*) preedit.string()); const int caret = preedit.caret(); if (caret < len) { decorate_preedit_string_using_caret_pos(text, preedit, caret); } else { decorate_preedit_string_using_char_type(text, preedit); } ibus_engine_update_preedit_text(m_engine, text, caret, TRUE); } else { ibus_engine_hide_preedit_text(m_engine); } }