diff options
author | Peng Wu <alexepico@gmail.com> | 2022-04-12 12:15:03 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2022-04-12 12:15:03 +0800 |
commit | a029555de877591a4e6502c01d4a338fe9c79591 (patch) | |
tree | fdd58d996692b1140c5c7dc4f430e93a347c50ea | |
parent | 337c1494d01365fca7d35bd67cb471bdcb9f8bbd (diff) | |
download | ibus-libpinyin-a029555de877591a4e6502c01d4a338fe9c79591.tar.gz ibus-libpinyin-a029555de877591a4e6502c01d4a338fe9c79591.tar.xz ibus-libpinyin-a029555de877591a4e6502c01d4a338fe9c79591.zip |
Add double-pinyin-show-raw option
-rw-r--r-- | src/PYConfig.cc | 1 | ||||
-rw-r--r-- | src/PYConfig.h | 2 | ||||
-rw-r--r-- | src/PYPConfig.cc | 6 | ||||
-rw-r--r-- | src/PYPDoublePinyinEditor.cc | 20 |
4 files changed, 21 insertions, 8 deletions
diff --git a/src/PYConfig.cc b/src/PYConfig.cc index b5badca..d92969c 100644 --- a/src/PYConfig.cc +++ b/src/PYConfig.cc @@ -52,6 +52,7 @@ Config::initDefaultValues (void) m_double_pinyin = FALSE; m_double_pinyin_schema = DOUBLE_PINYIN_DEFAULT; + m_double_pinyin_show_raw = FALSE; m_init_chinese = TRUE; m_init_full = FALSE; diff --git a/src/PYConfig.h b/src/PYConfig.h index 1ee509e..d39427d 100644 --- a/src/PYConfig.h +++ b/src/PYConfig.h @@ -65,6 +65,7 @@ public: gboolean autoCommit (void) const { return m_auto_commit; } gboolean doublePinyin (void) const { return m_double_pinyin; } DoublePinyinScheme doublePinyinSchema (void) const { return m_double_pinyin_schema; } + gboolean doublePinyinShowRaw (void) const { return m_double_pinyin_show_raw; } gboolean initChinese (void) const { return m_init_chinese; } gboolean initFull (void) const { return m_init_full; } gboolean initFullPunct (void) const { return m_init_full_punct; } @@ -152,6 +153,7 @@ protected: gboolean m_double_pinyin; DoublePinyinScheme m_double_pinyin_schema; + gboolean m_double_pinyin_show_raw; gboolean m_init_chinese; gboolean m_init_full; diff --git a/src/PYPConfig.cc b/src/PYPConfig.cc index ed8138c..d5db7a9 100644 --- a/src/PYPConfig.cc +++ b/src/PYPConfig.cc @@ -42,6 +42,7 @@ const gchar * const CONFIG_COMMA_PERIOD_PAGE = "comma-period-page"; const gchar * const CONFIG_AUTO_COMMIT = "auto-commit"; const gchar * const CONFIG_DOUBLE_PINYIN = "double-pinyin"; const gchar * const CONFIG_DOUBLE_PINYIN_SCHEMA = "double-pinyin-schema"; +const gchar * const CONFIG_DOUBLE_PINYIN_SHOW_RAW = "double-pinyin-show-raw"; const gchar * const CONFIG_INIT_CHINESE = "init-chinese"; const gchar * const CONFIG_INIT_FULL = "init-full"; const gchar * const CONFIG_INIT_FULL_PUNCT = "init-full-punct"; @@ -144,6 +145,7 @@ LibPinyinConfig::initDefaultValues (void) m_double_pinyin = FALSE; m_double_pinyin_schema = DOUBLE_PINYIN_DEFAULT; + m_double_pinyin_show_raw = FALSE; m_init_chinese = TRUE; m_init_full = FALSE; @@ -560,6 +562,8 @@ PinyinConfig::readDefaultValues (void) } } + m_double_pinyin_show_raw = read (CONFIG_DOUBLE_PINYIN_SHOW_RAW, false); + /* init states */ m_init_chinese = read (CONFIG_INIT_CHINESE, true); m_init_full = read (CONFIG_INIT_FULL, false); @@ -622,6 +626,8 @@ PinyinConfig::valueChanged (const std::string &schema_id, } } } + else if (CONFIG_DOUBLE_PINYIN_SHOW_RAW == name) + m_double_pinyin_show_raw = normalizeGVariant (value, false); /* init states */ else if (CONFIG_INIT_CHINESE == name) m_init_chinese = normalizeGVariant (value, true); diff --git a/src/PYPDoublePinyinEditor.cc b/src/PYPDoublePinyinEditor.cc index ee10b35..cfe7531 100644 --- a/src/PYPDoublePinyinEditor.cc +++ b/src/PYPDoublePinyinEditor.cc @@ -134,14 +134,18 @@ DoublePinyinEditor::updateAuxiliaryText (void) m_buffer.clear (); - gchar * aux_text = NULL; - pinyin_get_double_pinyin_auxiliary_text (m_instance, m_cursor, &aux_text); - m_buffer << aux_text; - g_free(aux_text); - - /* append rest text */ - const gchar * p = m_text.c_str() + m_pinyin_len; - m_buffer << p; + if (m_config.doublePinyinShowRaw ()) { + m_buffer << m_text; + } else { + gchar * aux_text = NULL; + pinyin_get_double_pinyin_auxiliary_text (m_instance, m_cursor, &aux_text); + m_buffer << aux_text; + g_free(aux_text); + + /* append rest text */ + const gchar * p = m_text.c_str() + m_pinyin_len; + m_buffer << p; + } StaticText text (m_buffer); if (DISPLAY_STYLE_TRADITIONAL == m_config.displayStyle () || |