Files
qingjian/apps/windows/server/tests/engine_loop/shortcuts.rs
T
yenharvey b6319013e8 feat: 候选右键菜单:置顶、降权、删除(#749)
macOS、Windows 右键候选(macOS 也可 ⌃ 点按)弹出菜单,菜单由青简自己画:
bamboo-slip 新增 PopupMenu 组件(与设置页下拉菜单同一套样式),
qingjian-render 的 render_menu 出位图,壳只给不抢焦点的弹出窗、管悬停与点击。

- 置顶:给当前输入码加一条比同码短语都高的自定义短语(封顶 999),可在设置里看到、改、删;取消置顶删掉它
- 降权:记进学习数据 user-demoted.tsv,每降一次往后挪一格,词库词也能降;可取消
- 删除:原来 Shift + 数字删候选的那套,挪进菜单;Shift + 数字删候选去掉,回到普通符号
- 菜单项与动作在平台层 candidate_menu,两个壳共用;Esc 只关菜单,敲键、候选窗重画或收起时关
- Linux 候选窗由 Fcitx 画,暂无此菜单
2026-10-22 14:39:00 +08:00

66 lines
2.6 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! 组句中「修饰键 + 数字」:译词上屏。
use crate::composing::SentenceTranslator;
use crate::support::*;
#[test]
fn alt_digit_commits_first_translation() {
let mut router = router();
let (_, _, frame) = type_letters(&mut router, "nihao");
let slot = slot_of(&frame, "你好");
// 缺省译词键(mac ⌥ / Windows Ctrl)+ 数字:上屏那个候选的第一个译词,组句结束。
let (outcome, commit, after) = press(&mut router, digit_with(slot, TRANSLATE));
assert_eq!(
(outcome, commit.as_deref()),
(KeyOutcome::Consumed, Some("hello"))
);
assert!(after.is_empty());
}
#[test]
fn alt_digit_commits_a_sentence_translation() {
let submitted = Arc::new(Mutex::new(Vec::new()));
let mut router = router_with(RouterConfig {
sentence_translation: true,
..RouterConfig::default()
});
router
.engine_mut()
.set_predictor(Box::new(SentenceTranslator::new(submitted)));
let (_, _, frame) = type_letters(&mut router, "xiangkaifa");
let slot = slot_of(&frame, "想开发");
let (outcome, commit, after) = press(&mut router, digit_with(slot, TRANSLATE));
assert_eq!(
(outcome, commit.as_deref()),
(KeyOutcome::Consumed, Some("It seems not to work."))
);
assert!(after.is_empty());
}
#[test]
fn second_translation_key_without_second_sense_is_swallowed() {
let mut router = router();
let (_, _, frame) = type_letters(&mut router, "nihao");
let slot = slot_of(&frame, "你好");
// 样例释义表里「你好」只有一条译文:第二个译词键(Shift+译词键)+ 数字吞掉不动,组句还在。
let (outcome, commit, after) = press(&mut router, digit_with(slot, TRANSLATE_SECOND));
assert_eq!((outcome, commit), (KeyOutcome::Consumed, None));
assert_eq!(preedit(&after), "ni'hao");
}
#[test]
fn unconfigured_modifier_digit_is_not_a_selection() {
// Shift+4 就是普通的 `$`;Win+1 没配到快捷键,归应用。
let mut router = router_with(RouterConfig {
// 组句中标点进直输段的老行为(`punct_commits` 关),`$` 才会留在拼音行里
punct_commits: false,
..RouterConfig::default()
});
type_letters(&mut router, "nihao");
let (outcome, commit, frame) = press(&mut router, digit_with(4, SHIFT));
assert_eq!((outcome, commit), (KeyOutcome::Consumed, None));
assert!(preedit(&frame).contains('$'), "{}", preedit(&frame));
let (outcome, commit, _) = press(&mut router, digit_with(1, WIN));
assert_eq!((outcome, commit), (KeyOutcome::Passthrough, None));
}