-
Notifications
You must be signed in to change notification settings - Fork 573
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
highlight candidate (selection without committance) #650
Changes from all commits
275b399
960dd0e
76e3ec7
5ab542b
3ba735a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
plugins/*/ | ||
build/ | ||
build-static/ | ||
debug/ | ||
|
@@ -14,3 +15,4 @@ node_modules/ | |
.*.swp | ||
.cache/ | ||
*.7z | ||
*.bz2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.super()) | ||
if (key_event.release() || key_event.super()) | ||
return kNoop; | ||
Context* ctx = engine_->context(); | ||
if (ctx->composition().empty()) | ||
|
@@ -149,7 +149,8 @@ ProcessResult Selector::ProcessKeyEvent(const KeyEvent& key_event) { | |
else if (ch >= XK_KP_0 && ch <= XK_KP_9) | ||
index = ((ch - XK_KP_0) + 9) % 10; | ||
if (index >= 0) { | ||
SelectCandidateAt(ctx, index); | ||
key_event.alt() ? HiliteCandidateAt(ctx, index) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not in favour of this feature. Why would user want to do that with a key combo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
because, when intended to be followed by deleting the candidate, it's faster to use a key combo to jump from highlighting candidate 1 to highlighting candidate 10 than press down/right key 9 times, provided that user does not want to use mouse. |
||
: SelectCandidateAt(ctx, index); | ||
return kAccepted; | ||
} | ||
// not handled | ||
|
@@ -252,6 +253,23 @@ bool Selector::End(Context* ctx) { | |
return Home(ctx); | ||
} | ||
|
||
bool Selector::HiliteCandidateAt(Context* ctx, int index) { | ||
Composition& comp = ctx->composition(); | ||
if (comp.empty()) | ||
return false; | ||
int page_size = engine_->schema()->page_size(); | ||
if (index >= page_size) | ||
return false; | ||
int selected_index = comp.back().selected_index; | ||
int page_start = (selected_index / page_size) * page_size; | ||
// hilite an already hilited candidate -> select this candidate | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's quite hidden logic. The function should do exactly what the name implies. |
||
if (page_start + index == selected_index) | ||
return ctx->Select(selected_index); | ||
comp.back().selected_index = page_start + index; | ||
comp.back().tags.insert("paging"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Highlighting a candidate does not necessarily change page. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But this is consistent with the behavior of navigators—even if there's no turning pages, user is no longer actively composing which means paging keys should take priority over composing keys (e.g. in the case of |
||
return true; | ||
} | ||
|
||
bool Selector::SelectCandidateAt(Context* ctx, int index) { | ||
Composition& comp = ctx->composition(); | ||
if (comp.empty()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,6 +299,9 @@ RIME_API Bool RimeCandidateListFromIndex(RimeSessionId session_id, | |
RIME_API Bool RimeSelectCandidate(RimeSessionId session_id, size_t index); | ||
RIME_API Bool RimeSelectCandidateOnCurrentPage(RimeSessionId session_id, | ||
size_t index); | ||
RIME_API Bool RimeHiliteCandidate(RimeSessionId session_id, size_t index); | ||
RIME_API Bool RimeHiliteCandidateOnCurrentPage(RimeSessionId session_id, | ||
size_t index); | ||
RIME_API Bool RimeDeleteCandidate(RimeSessionId session_id, size_t index); | ||
RIME_API Bool RimeDeleteCandidateOnCurrentPage(RimeSessionId session_id, | ||
size_t index); | ||
|
@@ -635,6 +638,10 @@ typedef struct rime_api_t { | |
const char* option_name, | ||
Bool state); | ||
|
||
Bool (*hilite_candidate)(RimeSessionId session_id, size_t index); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inserting new members breaks ABI compatibility. |
||
Bool (*hilite_candidate_on_current_page)(RimeSessionId session_id, | ||
size_t index); | ||
|
||
//! delete a candidate at the given index in candidate list. | ||
Bool (*delete_candidate)(RimeSessionId session_id, size_t index); | ||
//! delete a candidate from current page. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's spell it
Highlight
.It's one of the option I suggested in Leo's PR.
I would probably took his PR with some modifications.