예제 #1
0
파일: QinPinyin.cpp 프로젝트: drradwan/Qin
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();
  }
}
예제 #2
0
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());
    }
}
예제 #3
0
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);
    }
}