Skip to content

Commit

Permalink
feat(chord_composer): finish chord on first release (#828)
Browse files Browse the repository at this point in the history
add param `chord_composer/finish_chord_on_first_key_release`
  • Loading branch information
fxliang committed Mar 6, 2024
1 parent a4ed799 commit 102d421
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/rime/gear/chord_composer.cc
Expand Up @@ -27,6 +27,8 @@ ChordComposer::ChordComposer(const Ticket& ticket) : Processor(ticket) {
config->GetBool("chord_composer/use_shift", &use_shift_);
config->GetBool("chord_composer/use_super", &use_super_);
config->GetBool("chord_composer/use_caps", &use_caps_);
config->GetBool("chord_composer/finish_chord_on_first_key_release",
&finish_chord_on_first_key_release_);
config->GetString("speller/delimiter", &delimiter_);
algebra_.Load(config->GetList("chord_composer/algebra"));
output_format_.Load(config->GetList("chord_composer/output_format"));
Expand Down Expand Up @@ -104,7 +106,12 @@ ProcessResult ChordComposer::ProcessChordingKey(const KeyEvent& key_event) {
editing_chord_ = true;
bool is_key_up = key_event.release();
if (is_key_up) {
if (pressed_.erase(ch) != 0 && pressed_.empty()) {
if (finish_chord_on_first_key_release_) {
if (pressed_.find(ch) != pressed_.end()) {
FinishChord();
pressed_.clear();
}
} else if (pressed_.erase(ch) != 0 && pressed_.empty()) {
FinishChord();
}
} else { // key down
Expand Down
1 change: 1 addition & 0 deletions src/rime/gear/chord_composer.h
Expand Up @@ -43,6 +43,7 @@ class ChordComposer : public Processor {
bool use_shift_ = false;
bool use_super_ = false;
bool use_caps_ = false;
bool finish_chord_on_first_key_release_ = false;

set<int> pressed_;
set<int> chord_;
Expand Down

0 comments on commit 102d421

Please sign in to comment.