Skip to content

Commit

Permalink
fix(chord_composer): commit raw input with uppercase letters
Browse files Browse the repository at this point in the history
  • Loading branch information
lotem committed Aug 23, 2020
1 parent 94cf479 commit cc983d5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/rime/gear/chord_composer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ inline static int get_base_layer_key_code(const KeyEvent& key_event) {
}

ProcessResult ChordComposer::ProcessChordingKey(const KeyEvent& key_event) {
bool chording = !chord_.empty();
if (key_event.ctrl() || key_event.alt()) {
raw_sequence_.clear();
ClearChord();
return chording ? kAccepted : kNoop;
return kNoop;
}
int ch = get_base_layer_key_code(key_event);
// non chording key
if (std::find(chording_keys_.begin(),
chording_keys_.end(),
KeyEvent{ch, 0}) == chording_keys_.end()) {
return chording ? kAccepted : kNoop;
ClearChord();
return kNoop;
}
// chording key
bool is_key_up = key_event.release();
Expand All @@ -111,6 +111,10 @@ ProcessResult ChordComposer::ProcessChordingKey(const KeyEvent& key_event) {
return kAccepted;
}

inline static bool is_composing_text(Context* ctx) {
return ctx->IsComposing() && ctx->input() != kZeroWidthSpace;
}

ProcessResult ChordComposer::ProcessKeyEvent(const KeyEvent& key_event) {
if (engine_->context()->get_option("ascii_mode")) {
return kNoop;
Expand All @@ -122,7 +126,7 @@ ProcessResult ChordComposer::ProcessKeyEvent(const KeyEvent& key_event) {
int ch = key_event.keycode();
if (!is_key_up && ch >= 0x20 && ch <= 0x7e) {
// save raw input
if (!engine_->context()->IsComposing() || !raw_sequence_.empty()) {
if (!is_composing_text(engine_->context()) || !raw_sequence_.empty()) {
raw_sequence_.push_back(ch);
DLOG(INFO) << "update raw sequence: " << raw_sequence_;
}
Expand Down Expand Up @@ -209,7 +213,7 @@ void ChordComposer::ClearChord() {
}

void ChordComposer::OnContextUpdate(Context* ctx) {
if (ctx->IsComposing() && ctx->input() != kZeroWidthSpace) {
if (is_composing_text(ctx)) {
composing_ = true;
}
else if (composing_) {
Expand Down

0 comments on commit cc983d5

Please sign in to comment.