From db700bee2038c4b970d073b747dc14c9aaa8ebfe Mon Sep 17 00:00:00 2001 From: groverlynn Date: Mon, 13 Mar 2023 22:05:30 +0100 Subject: [PATCH 1/6] hyper/fn --- src/rime/gear/ascii_composer.cc | 2 +- src/rime/gear/editor.cc | 4 ++-- src/rime/gear/punctuator.cc | 12 ++++++------ src/rime/gear/recognizer.cc | 5 ++--- src/rime/gear/selector.cc | 4 ++-- src/rime/gear/shape.cc | 4 ++-- src/rime/gear/speller.cc | 4 ++-- src/rime/key_event.h | 1 + 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/rime/gear/ascii_composer.cc b/src/rime/gear/ascii_composer.cc index 20919396c..8c7bbf6b2 100644 --- a/src/rime/gear/ascii_composer.cc +++ b/src/rime/gear/ascii_composer.cc @@ -60,7 +60,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.alt() || key_event.hyper() || 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 d20198382..b37e4c86d 100644 --- a/src/rime/gear/editor.cc +++ b/src/rime/gear/editor.cc @@ -58,8 +58,8 @@ ProcessResult Editor::ProcessKeyEvent(const KeyEvent& key_event) { return result; } } - if (char_handler_ && - !key_event.ctrl() && !key_event.alt() && !key_event.super() && + if (char_handler_ && !key_event.ctrl() && !key_event.alt() && + !key_event.super() && !key_event.hyper() && ch > 0x20 && ch < 0x7f) { DLOG(INFO) << "input char: '" << (char)ch << "', " << ch << ", '" << key_event.repr() << "'"; diff --git a/src/rime/gear/punctuator.cc b/src/rime/gear/punctuator.cc index 8a01eda02..dde89dd17 100644 --- a/src/rime/gear/punctuator.cc +++ b/src/rime/gear/punctuator.cc @@ -59,8 +59,8 @@ 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()) + if (key_event.release() || key_event.ctrl() || key_event.alt() || + key_event.hyper() || key_event.super()) return kNoop; int ch = key_event.keycode(); if (ch < 0x20 || ch >= 0x7f) @@ -72,7 +72,7 @@ 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()); @@ -170,7 +170,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; @@ -213,8 +213,8 @@ CreatePunctCandidate(const string& punct, const Segment& segment) { bool is_half_shape_kana = (ch >= 0xFF61 && ch <= 0xFF9F); 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)); - bool is_narrow_symbol = (ch == 0x00A2 || ch == 0x00A3 || ch == 0x00A5 || ch == 0x00A6 || ch == 0x00AC || ch == 0x00AF || ch == 0x2985 || ch == 0x2986); + bool is_full_shape_narrow_symbol = ((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 == 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); is_half_shape = is_ascii || is_half_shape_kana || is_half_shape_hangul || is_narrow_symbol || is_half_shape_wide_symbol; diff --git a/src/rime/gear/recognizer.cc b/src/rime/gear/recognizer.cc index 0582379ef..91971a8eb 100644 --- a/src/rime/gear/recognizer.cc +++ b/src/rime/gear/recognizer.cc @@ -79,9 +79,8 @@ 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()) { + if (patterns_.empty() || key_event.ctrl() || key_event.alt() || + key_event.hyper() || 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 f55719c04..18b8023e4 100644 --- a/src/rime/gear/selector.cc +++ b/src/rime/gear/selector.cc @@ -118,8 +118,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.hyper() || 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 937346c48..1ac899a5a 100644 --- a/src/rime/gear/shape.cc +++ b/src/rime/gear/shape.cc @@ -41,8 +41,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.hyper() || + 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 ff1457f62..34e3ac2e5 100644 --- a/src/rime/gear/speller.cc +++ b/src/rime/gear/speller.cc @@ -90,8 +90,8 @@ Speller::Speller(const Ticket& ticket) : Processor(ticket), } ProcessResult Speller::ProcessKeyEvent(const KeyEvent& key_event) { - if (key_event.release() || - key_event.ctrl() || key_event.alt() || key_event.super()) + if (key_event.release() || key_event.ctrl() || key_event.alt() || + key_event.hyper() || 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 8910fae25..c710a5424 100644 --- a/src/rime/key_event.h +++ b/src/rime/key_event.h @@ -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 hyper() const { return (modifier_ & kHyperMask) != 0; } bool release() const { return (modifier_ & kReleaseMask) != 0; } // 按鍵表示為形如「狀態+鍵名」的文字 // 若無鍵名,則以四位或六位十六进制数形式的文字來標識 From bc6b530977244d6fcebdb1c4f7c90594550d6c13 Mon Sep 17 00:00:00 2001 From: groverlynn Date: Sat, 22 Apr 2023 18:21:16 +0200 Subject: [PATCH 2/6] Update xcode.mk --- xcode.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode.mk b/xcode.mk index 27d473ced..c174b683a 100644 --- a/xcode.mk +++ b/xcode.mk @@ -11,7 +11,7 @@ endif export SDKROOT ?= $(shell xcrun --sdk macosx --show-sdk-path) # https://cmake.org/cmake/help/latest/envvar/MACOSX_DEPLOYMENT_TARGET.html -export MACOSX_DEPLOYMENT_TARGET ?= $$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET) +export MACOSX_DEPLOYMENT_TARGET ?= $(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET) ifdef BUILD_UNIVERSAL # https://cmake.org/cmake/help/latest/envvar/CMAKE_OSX_ARCHITECTURES.html From cfeef466fe2a5b0cf4b49ace44d69f9b8cb4cd52 Mon Sep 17 00:00:00 2001 From: groverlynn Date: Mon, 13 Mar 2023 22:05:30 +0100 Subject: [PATCH 3/6] hyper/fn --- src/rime/gear/ascii_composer.cc | 2 +- src/rime/gear/editor.cc | 4 ++-- src/rime/gear/punctuator.cc | 12 ++++++------ src/rime/gear/recognizer.cc | 5 ++--- src/rime/gear/selector.cc | 4 ++-- src/rime/gear/shape.cc | 4 ++-- src/rime/gear/speller.cc | 4 ++-- src/rime/key_event.h | 1 + 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/rime/gear/ascii_composer.cc b/src/rime/gear/ascii_composer.cc index 20919396c..8c7bbf6b2 100644 --- a/src/rime/gear/ascii_composer.cc +++ b/src/rime/gear/ascii_composer.cc @@ -60,7 +60,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.alt() || key_event.hyper() || 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 d20198382..b37e4c86d 100644 --- a/src/rime/gear/editor.cc +++ b/src/rime/gear/editor.cc @@ -58,8 +58,8 @@ ProcessResult Editor::ProcessKeyEvent(const KeyEvent& key_event) { return result; } } - if (char_handler_ && - !key_event.ctrl() && !key_event.alt() && !key_event.super() && + if (char_handler_ && !key_event.ctrl() && !key_event.alt() && + !key_event.super() && !key_event.hyper() && ch > 0x20 && ch < 0x7f) { DLOG(INFO) << "input char: '" << (char)ch << "', " << ch << ", '" << key_event.repr() << "'"; diff --git a/src/rime/gear/punctuator.cc b/src/rime/gear/punctuator.cc index 8a01eda02..ba6222d64 100644 --- a/src/rime/gear/punctuator.cc +++ b/src/rime/gear/punctuator.cc @@ -59,8 +59,8 @@ 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()) + if (key_event.release() || key_event.ctrl() || key_event.alt() || + key_event.hyper() || key_event.super()) return kNoop; int ch = key_event.keycode(); if (ch < 0x20 || ch >= 0x7f) @@ -72,7 +72,7 @@ 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()); @@ -170,7 +170,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; @@ -213,8 +213,8 @@ CreatePunctCandidate(const string& punct, const Segment& segment) { bool is_half_shape_kana = (ch >= 0xFF61 && ch <= 0xFF9F); 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)); - bool is_narrow_symbol = (ch == 0x00A2 || ch == 0x00A3 || ch == 0x00A5 || ch == 0x00A6 || ch == 0x00AC || ch == 0x00AF || ch == 0x2985 || ch == 0x2986); + bool is_full_shape_narrow_symbol = ((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 == 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); is_half_shape = is_ascii || is_half_shape_kana || is_half_shape_hangul || is_narrow_symbol || is_half_shape_wide_symbol; diff --git a/src/rime/gear/recognizer.cc b/src/rime/gear/recognizer.cc index 0582379ef..91971a8eb 100644 --- a/src/rime/gear/recognizer.cc +++ b/src/rime/gear/recognizer.cc @@ -79,9 +79,8 @@ 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()) { + if (patterns_.empty() || key_event.ctrl() || key_event.alt() || + key_event.hyper() || 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 f55719c04..18b8023e4 100644 --- a/src/rime/gear/selector.cc +++ b/src/rime/gear/selector.cc @@ -118,8 +118,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.hyper() || 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 937346c48..1ac899a5a 100644 --- a/src/rime/gear/shape.cc +++ b/src/rime/gear/shape.cc @@ -41,8 +41,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.hyper() || + 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 ff1457f62..34e3ac2e5 100644 --- a/src/rime/gear/speller.cc +++ b/src/rime/gear/speller.cc @@ -90,8 +90,8 @@ Speller::Speller(const Ticket& ticket) : Processor(ticket), } ProcessResult Speller::ProcessKeyEvent(const KeyEvent& key_event) { - if (key_event.release() || - key_event.ctrl() || key_event.alt() || key_event.super()) + if (key_event.release() || key_event.ctrl() || key_event.alt() || + key_event.hyper() || 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 8910fae25..c710a5424 100644 --- a/src/rime/key_event.h +++ b/src/rime/key_event.h @@ -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 hyper() const { return (modifier_ & kHyperMask) != 0; } bool release() const { return (modifier_ & kReleaseMask) != 0; } // 按鍵表示為形如「狀態+鍵名」的文字 // 若無鍵名,則以四位或六位十六进制数形式的文字來標識 From 6b5d901b458f83761487e303c1b78b343f7bc046 Mon Sep 17 00:00:00 2001 From: groverlynn Date: Sat, 15 Jul 2023 02:16:33 +0200 Subject: [PATCH 4/6] Update key_event.h --- src/rime/key_event.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rime/key_event.h b/src/rime/key_event.h index c710a5424..9a1af8584 100644 --- a/src/rime/key_event.h +++ b/src/rime/key_event.h @@ -15,7 +15,7 @@ namespace rime { class KeyEvent { - public: +public: KeyEvent() = default; KeyEvent(int keycode, int modifier) : keycode_(keycode), modifier_(modifier) {} @@ -51,14 +51,14 @@ class KeyEvent { return modifier_ < other.modifier_; } - private: +private: int keycode_ = 0; int modifier_ = 0; }; // 按鍵序列 class KeySequence : public vector { - public: +public: KeySequence() = default; RIME_API KeySequence(const string& repr); From 816e14b05c132f67670739b686735866be14c2e4 Mon Sep 17 00:00:00 2001 From: groverlynn Date: Sat, 15 Jul 2023 02:21:39 +0200 Subject: [PATCH 5/6] resolve conflicts --- src/rime/gear/ascii_composer.cc | 4 ++-- src/rime/gear/editor.cc | 7 +++---- src/rime/gear/punctuator.cc | 12 +++++++++--- src/rime/gear/selector.cc | 4 ++-- src/rime/key_event.h | 8 ++++---- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/rime/gear/ascii_composer.cc b/src/rime/gear/ascii_composer.cc index c8194351d..91b809f3b 100644 --- a/src/rime/gear/ascii_composer.cc +++ b/src/rime/gear/ascii_composer.cc @@ -56,8 +56,8 @@ AsciiComposer::~AsciiComposer() { } ProcessResult AsciiComposer::ProcessKeyEvent(const KeyEvent& key_event) { - if ((key_event.shift() && key_event.ctrl()) || - key_event.alt() || key_event.hyper() || key_event.super()) { + if ((key_event.shift() && key_event.ctrl()) || key_event.alt() || + key_event.hyper() || 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 f150b820b..bec8ae1ff 100644 --- a/src/rime/gear/editor.cc +++ b/src/rime/gear/editor.cc @@ -56,10 +56,9 @@ ProcessResult Editor::ProcessKeyEvent(const KeyEvent& key_event) { } } if (char_handler_ && !key_event.ctrl() && !key_event.alt() && - !key_event.super() && !key_event.hyper() && - ch > 0x20 && ch < 0x7f) { - DLOG(INFO) << "input char: '" << (char)ch << "', " << ch - << ", '" << key_event.repr() << "'"; + !key_event.super() && !key_event.hyper() && ch > 0x20 && ch < 0x7f) { + DLOG(INFO) << "input char: '" << (char)ch << "', " << ch << ", '" + << key_event.repr() << "'"; return RIME_THIS_CALL(char_handler_)(ctx, ch); } // not handled diff --git a/src/rime/gear/punctuator.cc b/src/rime/gear/punctuator.cc index bb4ee91b3..096caef60 100644 --- a/src/rime/gear/punctuator.cc +++ b/src/rime/gear/punctuator.cc @@ -72,7 +72,8 @@ ProcessResult Punctuator::ProcessKeyEvent(const KeyEvent& key_event) { if (!use_space_ && ch == XK_space && ctx->IsComposing()) { return kNoop; } - if (ch == '.' || ch == ':' || ch == ',' || ch == '\'') { // 3.14 12:30 4'999,95 + 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()); @@ -210,8 +211,13 @@ an CreatePunctCandidate(const string& punct, bool is_half_shape_kana = (ch >= 0xFF61 && ch <= 0xFF9F); bool is_hangul = (ch >= 0x3131 && ch <= 0x3164); bool is_half_shape_hangul = (ch >= 0xFFA0 && ch <= 0xFFDC); - bool is_full_shape_narrow_symbol = ((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 == 0x20A9 || (ch >= 0x27E6 && ch <= 0x27ED) || ch == 0x2985 || ch == 0x2986); + bool is_full_shape_narrow_symbol = + ((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 == 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/selector.cc b/src/rime/gear/selector.cc index d26bd9359..70a1a9f67 100644 --- a/src/rime/gear/selector.cc +++ b/src/rime/gear/selector.cc @@ -116,8 +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.hyper() || key_event.super()) + if (key_event.release() || key_event.alt() || key_event.hyper() || + key_event.super()) return kNoop; Context* ctx = engine_->context(); if (ctx->composition().empty()) diff --git a/src/rime/key_event.h b/src/rime/key_event.h index 30582dc0b..58b34305f 100644 --- a/src/rime/key_event.h +++ b/src/rime/key_event.h @@ -8,14 +8,14 @@ #ifndef RIME_KEY_EVENT_H_ #define RIME_KEY_EVENT_H_ -#include #include #include +#include namespace rime { class KeyEvent { -public: + public: KeyEvent() = default; KeyEvent(int keycode, int modifier) : keycode_(keycode), modifier_(modifier) {} @@ -51,14 +51,14 @@ class KeyEvent { return modifier_ < other.modifier_; } -private: + private: int keycode_ = 0; int modifier_ = 0; }; // 按鍵序列 class KeySequence : public vector { -public: + public: KeySequence() = default; RIME_API KeySequence(const string& repr); From 34cd4cf14a6e2ce7e447a5e0af0ce67aa436cf0a Mon Sep 17 00:00:00 2001 From: groverlynn Date: Mon, 9 Oct 2023 03:19:56 +0200 Subject: [PATCH 6/6] rename hyper as hypershift to bypass naming conflict in Win --- src/rime/gear/ascii_composer.cc | 2 +- src/rime/gear/editor.cc | 2 +- src/rime/gear/punctuator.cc | 4 ++-- src/rime/gear/recognizer.cc | 2 +- src/rime/gear/selector.cc | 2 +- src/rime/gear/shape.cc | 2 +- src/rime/gear/speller.cc | 2 +- src/rime/key_event.h | 4 ++-- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/rime/gear/ascii_composer.cc b/src/rime/gear/ascii_composer.cc index 91b809f3b..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.hyper() || 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 bec8ae1ff..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() && !key_event.hyper() && 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 096caef60..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.hyper() || key_event.super()) + key_event.hypershift() || key_event.super()) return kNoop; int ch = key_event.keycode(); if (ch < 0x20 || ch >= 0x7f) diff --git a/src/rime/gear/recognizer.cc b/src/rime/gear/recognizer.cc index aa8583a84..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.hyper() || 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 70a1a9f67..063adfb33 100644 --- a/src/rime/gear/selector.cc +++ b/src/rime/gear/selector.cc @@ -116,7 +116,7 @@ inline static bool is_linear_layout(Context* ctx) { } ProcessResult Selector::ProcessKeyEvent(const KeyEvent& key_event) { - if (key_event.release() || key_event.alt() || key_event.hyper() || + if (key_event.release() || key_event.alt() || key_event.hypershift() || key_event.super()) return kNoop; Context* ctx = engine_->context(); diff --git a/src/rime/gear/shape.cc b/src/rime/gear/shape.cc index c90ca4568..6ed82f86a 100644 --- a/src/rime/gear/shape.cc +++ b/src/rime/gear/shape.cc @@ -39,7 +39,7 @@ 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.hyper() || + if (key_event.ctrl() || key_event.alt() || key_event.hypershift() || key_event.super() || key_event.release()) { return kNoop; } diff --git a/src/rime/gear/speller.cc b/src/rime/gear/speller.cc index 85c13d17b..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.hyper() || 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 58b34305f..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 @@ -31,7 +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 hyper() const { return (modifier_ & kHyperMask) != 0; } + bool hypershift() const { return (modifier_ & kHyperMask) != 0; } bool release() const { return (modifier_ & kReleaseMask) != 0; } // 按鍵表示為形如「狀態+鍵名」的文字 // 若無鍵名,則以四位或六位十六进制数形式的文字來標識