Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add param chord_composer/finish_chord_on_first_key_release for chord_composer, first release to finish chord #828

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/rime/gear/chord_composer.cc
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading