Skip to content

Commit

Permalink
feat(chord_composer): use Control, Alt, Shift to input chord
Browse files Browse the repository at this point in the history
when enabled by options `chord_composer/use_control: true` etc.
  • Loading branch information
lotem committed Sep 11, 2020
1 parent c498f71 commit f3a2ad0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/rime/gear/chord_composer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ ChordComposer::ChordComposer(const Ticket& ticket) : Processor(ticket) {
string alphabet;
config->GetString("chord_composer/alphabet", &alphabet);
chording_keys_.Parse(alphabet);
config->GetBool("chord_composer/use_control", &use_control_);
config->GetBool("chord_composer/use_alt", &use_alt_);
config->GetBool("chord_composer/use_shift", &use_shift_);
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 @@ -84,6 +87,10 @@ inline static int get_base_layer_key_code(const KeyEvent& key_event) {
ProcessResult ChordComposer::ProcessChordingKey(const KeyEvent& key_event) {
if (key_event.ctrl() || key_event.alt()) {
raw_sequence_.clear();
}
if (key_event.ctrl() && !use_control_ ||
key_event.alt() && !use_alt_ ||
key_event.shift() && !use_shift_) {
ClearChord();
return kNoop;
}
Expand Down
3 changes: 3 additions & 0 deletions src/rime/gear/chord_composer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class ChordComposer : public Processor {
Projection algebra_;
Projection output_format_;
Projection prompt_format_;
bool use_control_ = false;
bool use_alt_ = false;
bool use_shift_ = false;

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

0 comments on commit f3a2ad0

Please sign in to comment.