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

highlight candidate (selection without committance) #650

Closed
wants to merge 5 commits into from

Conversation

groverlynn
Copy link
Contributor

Pull request

Allow users to choose a candidate -- selection without committance, serving as shortcuts for select by multiple consecutive navigators. By default, this also enables Alt + select_key as choose whereas select_key remains as select.

Issue tracker

Fixes will automatically close the related issue

Fixes #

Feature

Describe feature of pull request

Unit test

  • Done

Manual test

  • Done

Code Review

  1. Unit and manual test pass
  2. GitHub Action CI pass
  3. At least one contributor reviews and votes
  4. Can be merged clean without conflicts
  5. PR will be merged by rebase upstream base

Additional Info

@mokapsing
Copy link
Contributor

你需要的是fluid_editor吧?

@groverlynn
Copy link
Contributor Author

你需要的是fluid_editor吧?

No. It's for mouse hoover.

@mokapsing
Copy link
Contributor

#620

@groverlynn groverlynn force-pushed the choose branch 2 times, most recently from a30967e to b05e719 Compare July 9, 2023 10:12
@groverlynn
Copy link
Contributor Author

groverlynn commented Jul 16, 2023

#620

peek is a horrible function name choice…
First, this so-called peek function does nothing like peeking in reality. Second and third, it does nothing like peek functions already used in librime, creating confusion on the top.
It also behave inconsistently with arrow_key selection (e.g. failing to set "paging" tag)…

@groverlynn groverlynn changed the title choose candidate (selection without committance) highlight candidate (selection without committance) Dec 20, 2023
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
Copy link
Member

Choose a reason for hiding this comment

The 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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Highlighting a candidate does not necessarily change page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Highlighting a candidate does not necessarily change page.

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 , and .).

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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?

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.

@@ -121,6 +121,20 @@ bool Context::Select(size_t index) {
return false;
}

bool Context::Hilite(size_t index) {
Copy link
Member

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.

@@ -635,6 +638,10 @@ typedef struct rime_api_t {
const char* option_name,
Bool state);

Bool (*hilite_candidate)(RimeSessionId session_id, size_t index);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inserting new members breaks ABI compatibility.
Don't.
Append new members to the end instead.

@groverlynn groverlynn closed this Feb 10, 2024
@groverlynn groverlynn deleted the choose branch February 10, 2024 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants