From f6d8d25df6c1d025c898ccf3a1e297e67f8f692c Mon Sep 17 00:00:00 2001 From: shewer Date: Wed, 6 Sep 2023 15:48:19 +0800 Subject: [PATCH 1/5] add option append_in_comment for show_in_comment Signed-off-by: shewer --- src/rime/gear/simplifier.cc | 7 ++++++- src/rime/gear/simplifier.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rime/gear/simplifier.cc b/src/rime/gear/simplifier.cc index d7cba581e0..f62a44d667 100644 --- a/src/rime/gear/simplifier.cc +++ b/src/rime/gear/simplifier.cc @@ -153,6 +153,7 @@ Simplifier::Simplifier(const Ticket& ticket) : kTipsNone; } config->GetBool(name_space_ + "/show_in_comment", &show_in_comment_); + config->GetBool(name_space_ + "/append_in_comment", &append_in_comment_); config->GetBool(name_space_ + "/inherit_comment", &inherit_comment_); comment_formatter_.Load(config->GetList(name_space_ + "/comment_format")); config->GetBool(name_space_ + "/random", &random_); @@ -247,12 +248,16 @@ void Simplifier::PushBack(const an& original, original->text().c_str() + original->text().length()); bool show_tips = (tips_level_ == kTipsChar && length == 1) || tips_level_ == kTipsAll; + string org_comment; if (show_in_comment_) { text = original->text(); if (show_tips) { tips = simplified; comment_formatter_.Apply(&tips); } + if (append_in_comment_) { + org_comment = original->comment(); + } } else { text = simplified; if (show_tips) { @@ -263,7 +268,7 @@ void Simplifier::PushBack(const an& original, } } } - result->push_back(New(original, "simplified", text, tips, + result->push_back(New(original, "simplified", text, org_comment +" " + tips, inherit_comment_)); } diff --git a/src/rime/gear/simplifier.h b/src/rime/gear/simplifier.h index 703f18e605..be17a09a48 100644 --- a/src/rime/gear/simplifier.h +++ b/src/rime/gear/simplifier.h @@ -42,6 +42,7 @@ class Simplifier : public Filter, TagMatching { string opencc_config_; set excluded_types_; bool show_in_comment_ = false; + bool append_in_comment_ = false; bool inherit_comment_ = true; Projection comment_formatter_; bool random_ = false; From af95738b299ef464c761d833da28db368673a951 Mon Sep 17 00:00:00 2001 From: shewer Date: Wed, 6 Sep 2023 15:57:15 +0800 Subject: [PATCH 2/5] add option append_in_comment for show_in_comment Signed-off-by: shewer --- src/rime/gear/simplifier.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rime/gear/simplifier.cc b/src/rime/gear/simplifier.cc index f62a44d667..e2d8ebf440 100644 --- a/src/rime/gear/simplifier.cc +++ b/src/rime/gear/simplifier.cc @@ -268,7 +268,7 @@ void Simplifier::PushBack(const an& original, } } } - result->push_back(New(original, "simplified", text, org_comment +" " + tips, + result->push_back(New(original, "simplified", text, org_comment + " " + tips, inherit_comment_)); } From 3d109e1cdb2da4ec3e3c695c63dd9a1143cf9700 Mon Sep 17 00:00:00 2001 From: shewer Date: Wed, 6 Sep 2023 16:00:09 +0800 Subject: [PATCH 3/5] add option append_in_comment for show_in_comment Signed-off-by: shewer --- src/rime/gear/simplifier.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rime/gear/simplifier.cc b/src/rime/gear/simplifier.cc index e2d8ebf440..b87f471b1e 100644 --- a/src/rime/gear/simplifier.cc +++ b/src/rime/gear/simplifier.cc @@ -268,7 +268,8 @@ void Simplifier::PushBack(const an& original, } } } - result->push_back(New(original, "simplified", text, org_comment + " " + tips, + result->push_back(New(original, "simplified", text, + org_comment + " " + tips, inherit_comment_)); } From a7dd25b4bff2a84fac3f86d07fb2755e5b8e33b7 Mon Sep 17 00:00:00 2001 From: shewer Date: Thu, 7 Sep 2023 08:14:29 +0800 Subject: [PATCH 4/5] add option append_in_comment for show_in_comment Signed-off-by: shewer --- src/rime/gear/simplifier.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rime/gear/simplifier.cc b/src/rime/gear/simplifier.cc index b87f471b1e..e31d08b6d3 100644 --- a/src/rime/gear/simplifier.cc +++ b/src/rime/gear/simplifier.cc @@ -269,8 +269,7 @@ void Simplifier::PushBack(const an& original, } } result->push_back(New(original, "simplified", text, - org_comment + " " + tips, - inherit_comment_)); + org_comment + tips, inherit_comment_)); } bool Simplifier::Convert(const an& original, From 7c7288cd3449e4611244c32808aaf4ccbad3e276 Mon Sep 17 00:00:00 2001 From: Shewer Lu Date: Mon, 16 Oct 2023 00:28:13 +0800 Subject: [PATCH 5/5] fixed code Signed-off-by: Shewer Lu --- src/rime/gear/simplifier.cc | 11 +++++------ src/rime/gear/simplifier.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/rime/gear/simplifier.cc b/src/rime/gear/simplifier.cc index e31d08b6d3..f57b077d64 100644 --- a/src/rime/gear/simplifier.cc +++ b/src/rime/gear/simplifier.cc @@ -153,7 +153,7 @@ Simplifier::Simplifier(const Ticket& ticket) : kTipsNone; } config->GetBool(name_space_ + "/show_in_comment", &show_in_comment_); - config->GetBool(name_space_ + "/append_in_comment", &append_in_comment_); + config->GetBool(name_space_ + "/append_comment", &append_comment_); config->GetBool(name_space_ + "/inherit_comment", &inherit_comment_); comment_formatter_.Load(config->GetList(name_space_ + "/comment_format")); config->GetBool(name_space_ + "/random", &random_); @@ -248,15 +248,14 @@ void Simplifier::PushBack(const an& original, original->text().c_str() + original->text().length()); bool show_tips = (tips_level_ == kTipsChar && length == 1) || tips_level_ == kTipsAll; - string org_comment; if (show_in_comment_) { text = original->text(); if (show_tips) { tips = simplified; comment_formatter_.Apply(&tips); } - if (append_in_comment_) { - org_comment = original->comment(); + if (append_comment_) { + tips = original->comment() + tips; } } else { text = simplified; @@ -268,8 +267,8 @@ void Simplifier::PushBack(const an& original, } } } - result->push_back(New(original, "simplified", text, - org_comment + tips, inherit_comment_)); + result->push_back(New(original, "simplified", text, tips, + inherit_comment_)); } bool Simplifier::Convert(const an& original, diff --git a/src/rime/gear/simplifier.h b/src/rime/gear/simplifier.h index be17a09a48..cb622814d7 100644 --- a/src/rime/gear/simplifier.h +++ b/src/rime/gear/simplifier.h @@ -42,7 +42,7 @@ class Simplifier : public Filter, TagMatching { string opencc_config_; set excluded_types_; bool show_in_comment_ = false; - bool append_in_comment_ = false; + bool append_comment_ = false; bool inherit_comment_ = true; Projection comment_formatter_; bool random_ = false;