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

Enable Hyper/Fn modifier key #639

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/rime/gear/ascii_composer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rime/gear/editor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 9 additions & 6 deletions src/rime/gear/punctuator.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// encoding: utf-8
// encoding: utf-8
//
// Copyright RIME Developers
// Distributed under the BSD License
Expand Down Expand Up @@ -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)
Expand All @@ -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());
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -211,10 +212,12 @@ an<Candidate> 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);
Expand Down
2 changes: 1 addition & 1 deletion src/rime/gear/recognizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/rime/gear/selector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions src/rime/gear/shape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/rime/gear/speller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/rime/key_event.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// encoding: utf-8
// encoding: utf-8
//
// Copyright RIME Developers
// Distributed under the BSD License
Expand All @@ -8,9 +8,9 @@
#ifndef RIME_KEY_EVENT_H_
#define RIME_KEY_EVENT_H_

#include <iostream>
#include <rime/common.h>
#include <rime/key_table.h>
#include <iostream>

namespace rime {

Expand All @@ -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; }
// 按鍵表示為形如「狀態+鍵名」的文字
// 若無鍵名,則以四位或六位十六进制数形式的文字來標識
Expand Down