Skip to content

Commit

Permalink
General support for navigating in vertical mode
Browse files Browse the repository at this point in the history
  • Loading branch information
LEOYoon-Tsaw committed Aug 22, 2020
1 parent 7c08a90 commit 5d0ffd9
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 25 deletions.
8 changes: 8 additions & 0 deletions src/rime/gear/navigator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ ProcessResult Navigator::ProcessKeyEvent(const KeyEvent& key_event) {
Context* ctx = engine_->context();
if (!ctx->IsComposing())
return kNoop;
if (ctx->get_option("_vertical")) {
Bind({XK_Up, 0}, &Navigator::Rewind);
Bind({XK_Up, kControlMask}, &Navigator::LeftBySyllable);
Bind({XK_KP_Up, 0}, &Navigator::LeftByChar);
Bind({XK_Down, 0}, &Navigator::RightByChar);
Bind({XK_Down, kControlMask}, &Navigator::RightBySyllable);
Bind({XK_KP_Down, 0}, &Navigator::RightByChar);
}
return KeyBindingProcessor::ProcessKeyEvent(key_event, ctx);
}

Expand Down
80 changes: 55 additions & 25 deletions src/rime/gear/selector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,50 +38,80 @@ ProcessResult Selector::ProcessKeyEvent(const KeyEvent& key_event) {
return kAccepted;
}
if (ch == XK_Up || ch == XK_KP_Up) {
if (ctx->get_option("_horizontal")) {
PageUp(ctx);
if (ctx->get_option("_vertical")) {
if (!key_event.ctrl() &&
!key_event.shift() &&
ctx->caret_pos() == ctx->input().length() &&
ctx->get_option("_horizontal") &&
CursorUp(ctx)) {
return kAccepted;
}
return kNoop;
} else {
CursorUp(ctx);
if (ctx->get_option("_horizontal")) {
PageUp(ctx);
} else {
CursorUp(ctx);
}
return kAccepted;
}
return kAccepted;
}
if (ch == XK_Down || ch == XK_KP_Down) {
if (ctx->get_option("_horizontal")) {
PageDown(ctx);
if (ctx->get_option("_vertical")) {
if (!key_event.ctrl() &&
!key_event.shift() &&
ctx->caret_pos() == ctx->input().length() &&
ctx->get_option("_horizontal")) {
CursorDown(ctx);
return kAccepted;
}
return kNoop;
} else {
CursorDown(ctx);
if (ctx->get_option("_horizontal")) {
PageDown(ctx);
} else {
CursorDown(ctx);
}
return kAccepted;
}
return kAccepted;
}
if (ch == XK_Left || ch == XK_KP_Left) {
if (!key_event.ctrl() &&
!key_event.shift() &&
ctx->caret_pos() == ctx->input().length()) {
if (ctx->get_option("_horizontal") &&
CursorUp(ctx)) {
return kAccepted;
}
if (ctx->get_option("_vertical")) {
if (ctx->get_option("_vertical")) {
if (ctx->get_option("_horizontal")) {
PageDown(ctx);
} else {
CursorDown(ctx);
}
return kAccepted;
} else {
if (!key_event.ctrl() &&
!key_event.shift() &&
ctx->caret_pos() == ctx->input().length() &&
ctx->get_option("_horizontal") &&
CursorUp(ctx)) {
return kAccepted;
}
return kNoop;
}
return kNoop;
}
if (ch == XK_Right || ch == XK_KP_Right) {
if (!key_event.ctrl() &&
!key_event.shift() &&
ctx->caret_pos() == ctx->input().length()) {
if (ctx->get_option("_vertical")) {
if (ctx->get_option("_horizontal")) {
CursorDown(ctx);
return kAccepted;
PageUp(ctx);
} else {
CursorUp(ctx);
}
if (ctx->get_option("_vertical") &&
CursorUp(ctx)) {
return kAccepted;
} else {
if (!key_event.ctrl() &&
!key_event.shift() &&
ctx->caret_pos() == ctx->input().length() &&
ctx->get_option("_horizontal")) {
CursorDown(ctx);
return kAccepted;
}
return kNoop;
}
return kNoop;
}
if (ch == XK_Home || ch == XK_KP_Home) {
return Home(ctx) ? kAccepted : kNoop;
Expand Down

0 comments on commit 5d0ffd9

Please sign in to comment.