diff --git a/server/MetasequoiaImeEngine b/server/MetasequoiaImeEngine index a2aef22d..3c988923 160000 --- a/server/MetasequoiaImeEngine +++ b/server/MetasequoiaImeEngine @@ -1 +1 @@ -Subproject commit a2aef22dbb5ed5eb6e03ed5f015f953fb30b8f93 +Subproject commit 3c9889231abde1184dc11416911979c52f9a35d0 diff --git a/server/assets/config/config.toml b/server/assets/config/config.toml index fec9fdee..70bbb488 100644 --- a/server/assets/config/config.toml +++ b/server/assets/config/config.toml @@ -69,7 +69,7 @@ schema = "shuangpin" shuangpin_preedit_mode = "shuangpin" # 双拼方案,可选:"xiaohe", "ziranma" # shuangpin_schema = "xiaohe" -shuangpin_schema = "ziranma" +shuangpin_schema = "xiaohe" # 五笔方案,可选:"wubi86", "wubi98" wubi_schema = "wubi86" @@ -81,7 +81,7 @@ wubi_schema = "wubi86" # 双拼辅助码 shuangpin_helpcode = true # 双拼辅助码方案,可选:"lantian", "ziranma" -shuangpin_helpcode_schema = "lantian" +shuangpin_helpcode_schema = "ziranma" # 是否在候选窗口中显示双拼辅助码 show_sp_helpcode_in_candidate_window = true # 全拼辅助码 diff --git a/server/src/config/ime_config.cpp b/server/src/config/ime_config.cpp index f48534c1..fa32b4ee 100644 --- a/server/src/config/ime_config.cpp +++ b/server/src/config/ime_config.cpp @@ -17,6 +17,8 @@ std::string g_wubi_schema = "wubi86"; std::string g_shuangpin_preedit_mode = "quanpin"; bool g_shuangpin_helpcode_enabled = true; bool g_quanpin_helpcode_enabled = true; +std::string g_shuangpin_helpcode_schema = "lantian"; +std::string g_quanpin_helpcode_schema = "lantian"; bool g_show_shuangpin_helpcode_in_candidate_window = true; bool g_show_quanpin_helpcode_in_candidate_window = true; bool g_floating_toolbar_enabled = true; @@ -233,6 +235,12 @@ bool LoadImeConfig() g_shuangpin_preedit_mode = tbl["input"]["shuangpin_preedit_mode"].value_or(std::string("quanpin")); g_shuangpin_helpcode_enabled = tbl["helpcode"]["shuangpin_helpcode"].value_or(true); g_quanpin_helpcode_enabled = tbl["helpcode"]["quanpin_helpcode"].value_or(true); + const std::string shuangpin_helpcode_schema = + tbl["helpcode"]["shuangpin_helpcode_schema"].value_or(std::string("lantian")); + g_shuangpin_helpcode_schema = shuangpin_helpcode_schema == "ziranma" ? "ziranma" : "lantian"; + const std::string quanpin_helpcode_schema = + tbl["helpcode"]["quanpin_helpcode_schema"].value_or(std::string("lantian")); + g_quanpin_helpcode_schema = quanpin_helpcode_schema == "ziranma" ? "ziranma" : "lantian"; g_show_shuangpin_helpcode_in_candidate_window = tbl["helpcode"]["show_sp_helpcode_in_candidate_window"].value_or(true); g_show_quanpin_helpcode_in_candidate_window = @@ -459,6 +467,21 @@ bool SetConfiguredShuangpinHelpcodeEnabled(bool enabled) return true; } +const std::string &GetConfiguredShuangpinHelpcodeSchema() +{ + return g_shuangpin_helpcode_schema; +} + +bool SetConfiguredShuangpinHelpcodeSchema(const std::string &schema) +{ + if (schema != "lantian" && schema != "ziranma") + return false; + if (!WriteConfiguredValue("helpcode", "shuangpin_helpcode_schema", EscapeTomlBasicString(schema))) + return false; + g_shuangpin_helpcode_schema = schema; + return true; +} + bool GetConfiguredQuanpinHelpcodeEnabled() { return g_quanpin_helpcode_enabled; @@ -474,6 +497,21 @@ bool SetConfiguredQuanpinHelpcodeEnabled(bool enabled) return true; } +const std::string &GetConfiguredQuanpinHelpcodeSchema() +{ + return g_quanpin_helpcode_schema; +} + +bool SetConfiguredQuanpinHelpcodeSchema(const std::string &schema) +{ + if (schema != "lantian" && schema != "ziranma") + return false; + if (!WriteConfiguredValue("helpcode", "quanpin_helpcode_schema", EscapeTomlBasicString(schema))) + return false; + g_quanpin_helpcode_schema = schema; + return true; +} + bool GetConfiguredShowShuangpinHelpcodeInCandidateWindow() { return g_show_shuangpin_helpcode_in_candidate_window; diff --git a/server/src/config/ime_config.h b/server/src/config/ime_config.h index 75e64f60..8831488d 100644 --- a/server/src/config/ime_config.h +++ b/server/src/config/ime_config.h @@ -19,8 +19,12 @@ bool SetConfiguredWubiSchema(const std::string &schema); const std::string &GetConfiguredShuangpinPreeditMode(); bool GetConfiguredShuangpinHelpcodeEnabled(); bool SetConfiguredShuangpinHelpcodeEnabled(bool enabled); +const std::string &GetConfiguredShuangpinHelpcodeSchema(); +bool SetConfiguredShuangpinHelpcodeSchema(const std::string &schema); bool GetConfiguredQuanpinHelpcodeEnabled(); bool SetConfiguredQuanpinHelpcodeEnabled(bool enabled); +const std::string &GetConfiguredQuanpinHelpcodeSchema(); +bool SetConfiguredQuanpinHelpcodeSchema(const std::string &schema); bool GetConfiguredShowShuangpinHelpcodeInCandidateWindow(); bool SetConfiguredShowShuangpinHelpcodeInCandidateWindow(bool enabled); bool GetConfiguredShowQuanpinHelpcodeInCandidateWindow(); diff --git a/server/src/session/engine_input_session.cpp b/server/src/session/engine_input_session.cpp index a63472ad..b70988ee 100644 --- a/server/src/session/engine_input_session.cpp +++ b/server/src/session/engine_input_session.cpp @@ -9,6 +9,13 @@ namespace { +void SelectConfiguredHelpcodeSchema(SchemeType scheme) +{ + HelpcodeUtils::select_helpcode_schema(scheme == SchemeType::Quanpin + ? GetConfiguredQuanpinHelpcodeSchema() + : GetConfiguredShuangpinHelpcodeSchema()); +} + std::string remove_delimiters(const std::string &segmented) { std::string normalized; @@ -106,12 +113,14 @@ EngineInputSession::EngineInputSession(SchemeType scheme_type, const ShuangpinPr : shuangpin_profile_(shuangpin_profile), session_(scheme_type, shuangpin_profile), shuangpin_dictionary_(shuangpin_profile) { + SelectConfiguredHelpcodeSchema(scheme_type); session_.set_shuangpin_helpcode_enabled(GetConfiguredShuangpinHelpcodeEnabled()); session_.set_quanpin_helpcode_enabled(GetConfiguredQuanpinHelpcodeEnabled()); } void EngineInputSession::handle_key(UINT vk, UINT modifiers_down, WCHAR wch) { + SelectConfiguredHelpcodeSchema(current_scheme_type()); session_.set_shuangpin_helpcode_enabled(GetConfiguredShuangpinHelpcodeEnabled()); session_.set_quanpin_helpcode_enabled(GetConfiguredQuanpinHelpcodeEnabled()); session_.handle_key(vk, modifiers_down, wch); @@ -119,6 +128,7 @@ void EngineInputSession::handle_key(UINT vk, UINT modifiers_down, WCHAR wch) void EngineInputSession::recompute_candidates() { + SelectConfiguredHelpcodeSchema(current_scheme_type()); session_.set_shuangpin_helpcode_enabled(GetConfiguredShuangpinHelpcodeEnabled()); session_.set_quanpin_helpcode_enabled(GetConfiguredQuanpinHelpcodeEnabled()); if (has_pending_pinyin_sequence_ || has_pending_pinyin_sequence_with_cases_) @@ -137,6 +147,7 @@ SchemeType EngineInputSession::current_scheme_type() const void EngineInputSession::switch_scheme(SchemeType scheme_type) { clear_pending_sequence(); + SelectConfiguredHelpcodeSchema(scheme_type); session_.switch_scheme(scheme_type); } diff --git a/server/src/settings/settings_app.cpp b/server/src/settings/settings_app.cpp index f176034b..4506ee80 100644 --- a/server/src/settings/settings_app.cpp +++ b/server/src/settings/settings_app.cpp @@ -168,7 +168,9 @@ void PostConfig() {"appearance", {{"candidate_window_layout", GetConfiguredCandidateWindowLayout()}}}, {"helpcode", {{"shuangpin_helpcode", GetConfiguredShuangpinHelpcodeEnabled()}, + {"shuangpin_helpcode_schema", GetConfiguredShuangpinHelpcodeSchema()}, {"quanpin_helpcode", GetConfiguredQuanpinHelpcodeEnabled()}, + {"quanpin_helpcode_schema", GetConfiguredQuanpinHelpcodeSchema()}, {"show_sp_helpcode_in_candidate_window", GetConfiguredShowShuangpinHelpcodeInCandidateWindow()}, {"show_qp_helpcode_in_candidate_window", GetConfiguredShowQuanpinHelpcodeInCandidateWindow()}}}}}}; const std::wstring message = string_to_wstring(payload.dump()); @@ -222,8 +224,12 @@ bool ApplyConfigUpdate(const json::object &data) return SetConfiguredShowShuangpinHelpcodeInCandidateWindow(json::value_to(data.at("value"))); if (path == "helpcode.shuangpin_helpcode") return SetConfiguredShuangpinHelpcodeEnabled(json::value_to(data.at("value"))); + if (path == "helpcode.shuangpin_helpcode_schema") + return SetConfiguredShuangpinHelpcodeSchema(json::value_to(data.at("value"))); if (path == "helpcode.quanpin_helpcode") return SetConfiguredQuanpinHelpcodeEnabled(json::value_to(data.at("value"))); + if (path == "helpcode.quanpin_helpcode_schema") + return SetConfiguredQuanpinHelpcodeSchema(json::value_to(data.at("value"))); if (path == "helpcode.show_qp_helpcode_in_candidate_window") return SetConfiguredShowQuanpinHelpcodeInCandidateWindow(json::value_to(data.at("value"))); return false; diff --git a/server/src/webview2/windows_webview2.cpp b/server/src/webview2/windows_webview2.cpp index 3b2d85c8..b5fdd436 100644 --- a/server/src/webview2/windows_webview2.cpp +++ b/server/src/webview2/windows_webview2.cpp @@ -1150,6 +1150,14 @@ HRESULT OnControllerCreatedSettingsWnd( // PostSettingsConfig(); } } + else if (path == "helpcode.shuangpin_helpcode_schema") + { + const std::string value = json::value_to(data.at("value")); + if (SetConfiguredShuangpinHelpcodeSchema(value)) + { + PostSettingsConfig(); + } + } else if (path == "helpcode.quanpin_helpcode") { const bool value = json::value_to(data.at("value")); @@ -1158,6 +1166,14 @@ HRESULT OnControllerCreatedSettingsWnd( // PostSettingsConfig(); } } + else if (path == "helpcode.quanpin_helpcode_schema") + { + const std::string value = json::value_to(data.at("value")); + if (SetConfiguredQuanpinHelpcodeSchema(value)) + { + PostSettingsConfig(); + } + } else if (path == "helpcode.show_qp_helpcode_in_candidate_window") { const bool value = json::value_to(data.at("value")); @@ -1261,7 +1277,9 @@ void PostSettingsConfig() {"appearance", {{"candidate_window_layout", GetConfiguredCandidateWindowLayout()}}}, {"helpcode", {{"shuangpin_helpcode", GetConfiguredShuangpinHelpcodeEnabled()}, + {"shuangpin_helpcode_schema", GetConfiguredShuangpinHelpcodeSchema()}, {"quanpin_helpcode", GetConfiguredQuanpinHelpcodeEnabled()}, + {"quanpin_helpcode_schema", GetConfiguredQuanpinHelpcodeSchema()}, {"show_sp_helpcode_in_candidate_window", GetConfiguredShowShuangpinHelpcodeInCandidateWindow()}, {"show_qp_helpcode_in_candidate_window",