Skip to content

Commit dbb35c6

Browse files
committed
feat(selector): support vertical UI
read context option "_vertical" and change Left, Right key behaviour accordingly.
1 parent 166f1ef commit dbb35c6

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/rime/gear/selector.cc

+18-8
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,30 @@ ProcessResult Selector::ProcessKeyEvent(const KeyEvent& key_event) {
5656
if (ch == XK_Left || ch == XK_KP_Left) {
5757
if (!key_event.ctrl() &&
5858
!key_event.shift() &&
59-
ctx->caret_pos() == ctx->input().length() &&
60-
ctx->get_option("_horizontal") &&
61-
CursorUp(ctx)) {
62-
return kAccepted;
59+
ctx->caret_pos() == ctx->input().length()) {
60+
if (ctx->get_option("_horizontal") &&
61+
CursorUp(ctx)) {
62+
return kAccepted;
63+
}
64+
if (ctx->get_option("_vertical")) {
65+
CursorDown(ctx);
66+
return kAccepted;
67+
}
6368
}
6469
return kNoop;
6570
}
6671
if (ch == XK_Right || ch == XK_KP_Right) {
6772
if (!key_event.ctrl() &&
6873
!key_event.shift() &&
69-
ctx->caret_pos() == ctx->input().length() &&
70-
ctx->get_option("_horizontal")) {
71-
CursorDown(ctx);
72-
return kAccepted;
74+
ctx->caret_pos() == ctx->input().length()) {
75+
if (ctx->get_option("_horizontal")) {
76+
CursorDown(ctx);
77+
return kAccepted;
78+
}
79+
if (ctx->get_option("_vertical") &&
80+
CursorUp(ctx)) {
81+
return kAccepted;
82+
}
7383
}
7484
return kNoop;
7585
}

0 commit comments

Comments
 (0)