diff --git a/src/rime/gear/ascii_composer.cc b/src/rime/gear/ascii_composer.cc index bba38a035..8cd45911f 100644 --- a/src/rime/gear/ascii_composer.cc +++ b/src/rime/gear/ascii_composer.cc @@ -57,7 +57,7 @@ AsciiComposer::~AsciiComposer() { ProcessResult AsciiComposer::ProcessKeyEvent(const KeyEvent& key_event) { if ((key_event.shift() && key_event.ctrl()) || key_event.alt() || - key_event.super()) { + key_event.hypershift() || key_event.super()) { shift_key_pressed_ = ctrl_key_pressed_ = false; return kNoop; } diff --git a/src/rime/gear/editor.cc b/src/rime/gear/editor.cc index 7247be029..ed195fcfb 100644 --- a/src/rime/gear/editor.cc +++ b/src/rime/gear/editor.cc @@ -56,7 +56,7 @@ ProcessResult Editor::ProcessKeyEvent(const KeyEvent& key_event) { } } if (char_handler_ && !key_event.ctrl() && !key_event.alt() && - !key_event.super() && ch > 0x20 && ch < 0x7f) { + !key_event.super() && !key_event.hypershift() && ch > 0x20 && ch < 0x7f) { DLOG(INFO) << "input char: '" << (char)ch << "', " << ch << ", '" << key_event.repr() << "'"; return RIME_THIS_CALL(char_handler_)(ctx, ch); diff --git a/src/rime/gear/punctuator.cc b/src/rime/gear/punctuator.cc index a391b8515..b2ef5d359 100644 --- a/src/rime/gear/punctuator.cc +++ b/src/rime/gear/punctuator.cc @@ -1,4 +1,4 @@ -// encoding: utf-8 +// encoding: utf-8 // // Copyright RIME Developers // Distributed under the BSD License @@ -60,7 +60,7 @@ static bool punctuation_is_translated(Context* ctx) { ProcessResult Punctuator::ProcessKeyEvent(const KeyEvent& key_event) { if (key_event.release() || key_event.ctrl() || key_event.alt() || - key_event.super()) + key_event.hypershift() || key_event.super()) return kNoop; int ch = key_event.keycode(); if (ch < 0x20 || ch >= 0x7f) @@ -72,7 +72,8 @@ ProcessResult Punctuator::ProcessKeyEvent(const KeyEvent& key_event) { if (!use_space_ && ch == XK_space && ctx->IsComposing()) { return kNoop; } - if (ch == '.' || ch == ':') { // 3.14, 12:30 + if (ch == '.' || ch == ':' || ch == ',' || + ch == '\'') { // 3.14 12:30 4'999,95 const CommitHistory& history(ctx->commit_history()); if (!history.empty()) { const CommitRecord& cr(history.back()); @@ -166,7 +167,7 @@ bool PunctSegmentor::Proceed(Segmentation* segmentation) { const string& input = segmentation->input(); int k = segmentation->GetCurrentStartPosition(); if (k == input.length()) - return false; // no chance for others too + return false; // no chance for others either char ch = input[k]; if (ch < 0x20 || ch >= 0x7f) return true; @@ -211,10 +212,12 @@ an CreatePunctCandidate(const string& punct, bool is_hangul = (ch >= 0x3131 && ch <= 0x3164); bool is_half_shape_hangul = (ch >= 0xFFA0 && ch <= 0xFFDC); bool is_full_shape_narrow_symbol = - (ch == 0xFF5F || ch == 0xFF60 || (ch >= 0xFFE0 && ch <= 0xFFE6)); + ((ch >= 0x3008 && ch <= 0x300B) || (ch >= 0x3018 && ch <= 0x301B) || + ch == 0xFF5F || ch == 0xFF60 || (ch >= 0xFFE0 && ch <= 0xFFE6)); bool is_narrow_symbol = (ch == 0x00A2 || ch == 0x00A3 || ch == 0x00A5 || ch == 0x00A6 || - ch == 0x00AC || ch == 0x00AF || ch == 0x2985 || ch == 0x2986); + ch == 0x00AC || ch == 0x00AF || ch == 0x20A9 || + (ch >= 0x27E6 && ch <= 0x27ED) || ch == 0x2985 || ch == 0x2986); bool is_half_shape_wide_symbol = (ch >= 0xFFE8 && ch <= 0xFFEE); bool is_wide_symbol = ((ch >= 0x2190 && ch <= 0x2193) || ch == 0x2502 || ch == 0x25A0 || ch == 0x25CB); diff --git a/src/rime/gear/recognizer.cc b/src/rime/gear/recognizer.cc index 6ceffd603..65aab9404 100644 --- a/src/rime/gear/recognizer.cc +++ b/src/rime/gear/recognizer.cc @@ -80,7 +80,7 @@ Recognizer::Recognizer(const Ticket& ticket) : Processor(ticket) { ProcessResult Recognizer::ProcessKeyEvent(const KeyEvent& key_event) { if (patterns_.empty() || key_event.ctrl() || key_event.alt() || - key_event.super() || key_event.release()) { + key_event.hypershift() || key_event.super() || key_event.release()) { return kNoop; } int ch = key_event.keycode(); diff --git a/src/rime/gear/selector.cc b/src/rime/gear/selector.cc index 06874103d..063adfb33 100644 --- a/src/rime/gear/selector.cc +++ b/src/rime/gear/selector.cc @@ -116,7 +116,8 @@ inline static bool is_linear_layout(Context* ctx) { } ProcessResult Selector::ProcessKeyEvent(const KeyEvent& key_event) { - if (key_event.release() || key_event.alt() || key_event.super()) + if (key_event.release() || key_event.alt() || key_event.hypershift() || + key_event.super()) return kNoop; Context* ctx = engine_->context(); if (ctx->composition().empty()) diff --git a/src/rime/gear/shape.cc b/src/rime/gear/shape.cc index 37a078896..6ed82f86a 100644 --- a/src/rime/gear/shape.cc +++ b/src/rime/gear/shape.cc @@ -39,8 +39,8 @@ ProcessResult ShapeProcessor::ProcessKeyEvent(const KeyEvent& key_event) { if (!engine_->context()->get_option("full_shape")) { return kNoop; } - if (key_event.ctrl() || key_event.alt() || key_event.super() || - key_event.release()) { + if (key_event.ctrl() || key_event.alt() || key_event.hypershift() || + key_event.super() || key_event.release()) { return kNoop; } int ch = key_event.keycode(); diff --git a/src/rime/gear/speller.cc b/src/rime/gear/speller.cc index 8abcb83d3..074c19b02 100644 --- a/src/rime/gear/speller.cc +++ b/src/rime/gear/speller.cc @@ -93,7 +93,7 @@ Speller::Speller(const Ticket& ticket) ProcessResult Speller::ProcessKeyEvent(const KeyEvent& key_event) { if (key_event.release() || key_event.ctrl() || key_event.alt() || - key_event.super()) + key_event.hypershift() || key_event.super()) return kNoop; int ch = key_event.keycode(); if (ch < 0x20 || ch >= 0x7f) // not a valid key for spelling diff --git a/src/rime/key_event.h b/src/rime/key_event.h index 22e48ae01..18d1084b3 100644 --- a/src/rime/key_event.h +++ b/src/rime/key_event.h @@ -1,4 +1,4 @@ -// encoding: utf-8 +// encoding: utf-8 // // Copyright RIME Developers // Distributed under the BSD License @@ -8,9 +8,9 @@ #ifndef RIME_KEY_EVENT_H_ #define RIME_KEY_EVENT_H_ -#include #include #include +#include namespace rime { @@ -31,6 +31,7 @@ class KeyEvent { bool alt() const { return (modifier_ & kAltMask) != 0; } bool caps() const { return (modifier_ & kLockMask) != 0; } bool super() const { return (modifier_ & kSuperMask) != 0; } + bool hypershift() const { return (modifier_ & kHyperMask) != 0; } bool release() const { return (modifier_ & kReleaseMask) != 0; } // 按鍵表示為形如「狀態+鍵名」的文字 // 若無鍵名,則以四位或六位十六进制数形式的文字來標識