From 5a9fa844efd42522eb5739f3ba12913ab80437a5 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 4 Aug 2015 14:17:01 +0800 Subject: add candidates after cursor option --- src/ZYConfig.cc | 1 + src/ZYConfig.h | 2 ++ src/ZYZConfig.cc | 5 +++++ src/ZYZPhoneticSection.cc | 6 +++++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ZYConfig.cc b/src/ZYConfig.cc index fcc717e..bc6fad5 100644 --- a/src/ZYConfig.cc +++ b/src/ZYConfig.cc @@ -55,6 +55,7 @@ Config::initDefaultValues (void) m_always_input_numbers = FALSE; m_space_show_candidates = FALSE; + m_candidates_after_cursor = TRUE; m_easy_symbol = TRUE; m_user_symbol = TRUE; diff --git a/src/ZYConfig.h b/src/ZYConfig.h index cba5f78..8a1c5d6 100644 --- a/src/ZYConfig.h +++ b/src/ZYConfig.h @@ -51,6 +51,7 @@ public: gboolean initTradChinese (void) const { return m_init_trad_chinese; } gboolean alwaysInputNumbers (void) const { return m_always_input_numbers; } gboolean spaceShowCandidates (void) const { return m_space_show_candidates; } + gboolean candidatesAfterCursor (void) const { return m_candidates_after_cursor; } std::string candidateKeys (void) const { return m_candidate_keys; } gboolean easySymbol (void) const { return m_easy_symbol; } @@ -90,6 +91,7 @@ protected: gboolean m_always_input_numbers; gboolean m_space_show_candidates; + gboolean m_candidates_after_cursor; std::string m_candidate_keys; diff --git a/src/ZYZConfig.cc b/src/ZYZConfig.cc index 17a6a34..db785e6 100644 --- a/src/ZYZConfig.cc +++ b/src/ZYZConfig.cc @@ -36,6 +36,7 @@ const gchar * const CONFIG_INIT_FULL_PUNCT = "fullhalfpunct"; const gchar * const CONFIG_INIT_TRAD_CHINESE = "traditionalchinese"; const gchar * const CONFIG_ALWAYS_INPUT_NUMBERS = "alwaysinputnum"; const gchar * const CONFIG_SPACE_SHOW_CANDIDATES = "spaceshowcandidates"; +const gchar * const CONFIG_CANDIDATES_AFTER_CURSOR = "candidatesaftercursor"; const gchar * const CONFIG_KEYBOARD_LAYOUT = "keyboardlayout"; const gchar * const CONFIG_CANDIDATE_KEYS = "candidatekeys"; @@ -96,6 +97,7 @@ ZhuyinConfig::initDefaultValues (void) m_always_input_numbers = FALSE; m_space_show_candidates = FALSE; + m_candidates_after_cursor = TRUE; m_candidate_keys = "1234567890"; @@ -188,6 +190,7 @@ ZhuyinConfig::readDefaultValues (void) m_always_input_numbers = read (CONFIG_ALWAYS_INPUT_NUMBERS, false); m_space_show_candidates = read (CONFIG_SPACE_SHOW_CANDIDATES, false); + m_candidates_after_cursor = read (CONFIG_CANDIDATES_AFTER_CURSOR, true); gint layout = read (CONFIG_KEYBOARD_LAYOUT, 0); m_keyboard_layout = CHEWING_DEFAULT; @@ -246,6 +249,8 @@ ZhuyinConfig::valueChanged (const std::string §ion, m_always_input_numbers = normalizeGVariant (value, false); else if (CONFIG_SPACE_SHOW_CANDIDATES == name) m_space_show_candidates = normalizeGVariant (value, false); + else if (CONFIG_CANDIDATES_AFTER_CURSOR == name) + m_candidates_after_cursor = normalizeGVariant (value, true); else if (CONFIG_KEYBOARD_LAYOUT == name) { gint layout = normalizeGVariant (value, 0); m_keyboard_layout = CHEWING_DEFAULT; diff --git a/src/ZYZPhoneticSection.cc b/src/ZYZPhoneticSection.cc index 99d6213..f8bfe7d 100644 --- a/src/ZYZPhoneticSection.cc +++ b/src/ZYZPhoneticSection.cc @@ -21,6 +21,7 @@ #include "ZYZPhoneticSection.h" #include +#include "ZYConfig.h" #include "ZYZhuyinProperties.h" #include "ZYTradSimpConverter.h" @@ -47,7 +48,10 @@ PhoneticSection::initCandidates (zhuyin_instance_t * instance, zhuyin_get_zhuyin_key_rest_offset (instance, cursor, &offset); - zhuyin_guess_candidates (m_instance, offset); + if (m_editor.m_config.candidatesAfterCursor ()) + zhuyin_guess_candidates_after_cursor (m_instance, offset); + else + zhuyin_guess_candidates_before_cursor (m_instance, offset); return true; } -- cgit