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

feat(api): get_state_label returns the state label for UI display #553

Merged
merged 1 commit into from
Jun 10, 2022

Conversation

lotem
Copy link
Member

@lotem lotem commented Jun 9, 2022

enable the frontend to display a message when an arbitrary option defined in the
schema is updated.

Closes #447

the option name eg. ascii_mode is passed to the notification handler function,
there, get_state_label gives IME frontend the access to the human readable label
for the current state of the option defined in .schema:/switches/@/states.

when selection is changed in a radio group, more than one option in the group is
updated so it only returns a non-empty label while querying the selected option.

Pull request

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

@lotem lotem requested a review from LEOYoon-Tsaw June 9, 2022 15:31
@lotem lotem force-pushed the option-update-message branch from c02aa95 to aee5599 Compare June 9, 2022 15:35
@@ -980,95 +980,141 @@ void RimeSetCaretPos(RimeSessionId session_id, size_t caret_pos) {
return ctx->set_caret_pos(caret_pos);
}

RIME_API RimeApi* rime_get_api() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Ignore the indentation change.

Only added a new function to the API at the end of the RimeApi init block.

enable the frontend to display a message when an arbitrary option defined in the
schema is updated.

Closes rime#447

the option name eg. ascii_mode is passed to the notification handler function,
there, get_state_label gives IME frontend the access to the human readable label
for the current state of the option defined in *.schema:/switches/@*/states.

when selection is changed in a radio group, more than one option in the group is
updated so it only returns a non-empty label while querying the selected option.
@lotem lotem force-pushed the option-update-message branch from aee5599 to 28fe1ba Compare June 9, 2022 15:39
@LEOYoon-Tsaw
Copy link
Member

It seems it is non trivial to implement this in squirrel, the session is handled in SquirrelInputController, which is a private class, while notification handling is done in SquirrelApplicationDelegate

@lotem
Copy link
Member Author

lotem commented Jun 10, 2022

It seems it is non trivial to implement this in squirrel, the session is handled in SquirrelInputController, which is a private class, while notification handling is done in SquirrelApplicationDelegate

Session ID is given as an argument of the notification handler callback.
See the example code in tools/rime_api_console.cc

@lotem lotem merged commit 8f9e9c7 into rime:master Jun 10, 2022
@lotem lotem deleted the option-update-message branch June 10, 2022 15:02
@lotem
Copy link
Member Author

lotem commented Jun 10, 2022

应该还有后续啊。

状态选项里的单选状态组现在不支持通过快捷键切换,用不上这么好的文字提示,我准备把快捷键单选功能做好。

另外,我打算把 Control+Shift+2 等快捷键
https://github.com/rime/rime-prelude/blob/master/key_bindings.yaml#L45

    - { when: always, accept: Control+Shift+2, toggle: ascii_mode }
    - { when: always, accept: Control+Shift+3, toggle: full_shape }
    - { when: always, accept: Control+Shift+4, toggle: simplification }
    - { when: always, accept: Control+Shift+5, toggle: extended_charset }

重新定义为

    - { when: always, accept: Control+Shift+2, toggle: '@0' }
    - { when: always, accept: Control+Shift+3, toggle: '@1' }
    - { when: always, accept: Control+Shift+4, toggle: '@2' }
    - { when: always, accept: Control+Shift+5, toggle: '@3' }

指改变方案中 switches/@0 等处定义的状态。这样的配置就通用了。兼容方案自定义的状态。

@x 如果不是开关而是单项选择状态组,最好不必改动词 toggle,让他轮换到下一个状态。免得还得专门改快捷键配置。

@LEOYoon-Tsaw
Copy link
Member

如果是狀態組,可以用set_optionunset_option來設定快捷鍵吧,當然加個輪換功能也是很好的

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.

2 participants