Skip to content

Commit

Permalink
feat: always_show_comments option (#220)
Browse files Browse the repository at this point in the history
* feat: add always_show_comments option

* fix: address feedback
Line wraps
  • Loading branch information
ztl8702 authored and lotem committed Aug 22, 2018
1 parent 74e31bc commit 19cea07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/rime/gear/script_translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ ScriptTranslator::ScriptTranslator(const Ticket& ticket)
return;
if (Config* config = engine_->schema()->config()) {
config->GetInt(name_space_ + "/spelling_hints", &spelling_hints_);
config->GetBool(name_space_ + "/always_show_comments",
&always_show_comments_);
}
}

Expand Down Expand Up @@ -345,7 +347,9 @@ an<Candidate> ScriptTranslation::Peek() {
}
if (sentence_->comment().empty()) {
auto spelling = syllabifier_->GetOriginalSpelling(*sentence_);
if (!spelling.empty() && spelling != sentence_->preedit()) {
if (!spelling.empty() &&
(translator_->always_show_comments() ||
spelling != sentence_->preedit())) {
sentence_->set_comment(/*quote_left + */spelling/* + quote_right*/);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/rime/gear/script_translator.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ class ScriptTranslator : public Translator,

// options
int spelling_hints() const { return spelling_hints_; }
bool always_show_comments() const { return always_show_comments_; }

protected:
int spelling_hints_ = 0;
bool always_show_comments_ = false;
};

} // namespace rime
Expand Down

0 comments on commit 19cea07

Please sign in to comment.