Skip to content

feat(keys): set_mode:english/chinese verbs for global key bindings - #324

Open
mystery4f wants to merge 5 commits into
huanfeng:mainfrom
mystery4f:feat/set-mode-switch-keys
Open

mystery4f wants to merge 5 commits into
huanfeng:mainfrom
mystery4f:feat/set-mode-switch-keys

Conversation

@mystery4f

Copy link
Copy Markdown

What

  • keys.key_actions accepts two new verbs: set_mode:english / set_mode:chinese — a modifier key can now switch to a specific mode instead of toggling.
  • New CapsCancelSwitch::Directed(bool) variant: when CapsLock is on, a directed switch cancels the lock and lands on the requested target; the plain toggle_mode path keeps the existing mode_after_cancel semantics unchanged (factory behavior untouched).
  • Design doc table (schema-key-actions.md §A) updated with the two verbs.

Why

With CapsLock on, the factory mode_after_cancel = chinese rewrote set_mode:english back to Chinese — users saw "press has no effect". Directed switches now bypass the rewrite; toggle keys keep their old behavior. Note input.capslock.cancel_on_mode_switch stays off by default; nothing changed about factory defaults.

Tests

  • cargo test -p wind-config: 758 passed (verb parse tests added: case-insensitivity, bad payloads rejected, modifier-only classification)
  • cargo test -p wind-coordinator --lib: 1439 passed (matrix test extended with Directed assertions; 2 pre-existing failures in handle_candidate::expand_stop_tests are unrelated data-fixture issues present on main)
  • cargo test -p wind-coordinator --test set_mode_binding: 4 passed (new integration test: lshift→english, rshift→chinese, idempotence, factory toggle untouched, mid-composition commit)

Live-verified on a real TSF host: CapsLock on + LShift tap → lock cancelled, lands on English; repeated taps stay idempotent.

- DISPATCH_ACTIONS 新增 set_mode:english / set_mode:chinese 两个动词,
  限修饰键(keyup 轻敲通路),与 toggle_mode 同族但不在中文态限定内
- handle_toggle_mode_cased 泛化为 handle_switch_mode_cased(target: Option<bool>),
  None 维持翻转语义,Some(x) 定向置态(已在目标态幂等无操作)
- coordinator 新增 set_mode_with_commit:编码中途按下先上屏再切,
  与切中英既有收口路径共用 take_input_on_mode_switch_cased
- 出厂默认不变(lshift/rshift 仍为 toggle);keys.key_actions 绑定经由
  既有「绑定优先于出厂 toggle」通路生效,无需新开关
- 新增 tests/set_mode_binding.rs:定向切换、幂等、未绑侧保持 toggle、
  编码中上屏四条契约
此前 caps 取消分支恒走 CapsCancelSwitch::Toggle,出厂 mode_after_cancel=chinese
会把 set_mode:english 按回中文,用户看来是「按了没反应」。新增 Directed 变体:
带明确目标的切换取消锁定的同时直达目标,归位配置只管没有方向的翻转。
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@mystery4f

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@mystery4f

Copy link
Copy Markdown
Author

recheck

github-actions Bot added a commit that referenced this pull request Nov 12, 2026
`bare_function_key_needs_chinese` 的豁免清单只认 toggle_mode / switch_engine /
toggle_schema:* / switch_schema:*,没有 set_mode:*。于是把 set_mode:chinese 绑到
F1–F12 时,编译期就给它打上 CHINESE_ONLY,英文态下按键在 TSF 侧被直接放行、到不了
协调器——该绑定在英文态等于没有,在中文态则等于没按。

改为按动词显式判定的 match,并把 set_mode:* 一并豁免;补 f6/f7 两条断言与组合键
策略表两行。
- `mode_after_caps_cancel_matrix` 之前删掉了 `chinese/Toggle` 那条断言,出厂默认档
  只剩 bogus/空串兜底,补回。
- 新增 `set_mode_keeps_caps_when_cancel_disabled`:cancel_on_mode_switch 关闭时,
  大写态下调用 set_mode:chinese 只置位中英态、不动 CapsLock(由配置决定是否解锁)。
- 纠正 `set_mode_with_commit` 的文档:目标中文时余码是丢弃而非上屏,状态泡文案相同
  时也不会刷新;删掉 message_handler 里重复的一行注释。

This branch has not been deployed

No deployments
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.

1 participant