v0.1.0-alpha
官网Home
components/wordnav
实验与能力验证Labs · 64 / 64

WordNav

ui.widgets.Textarea

跨文字系统的按词移动光标。Word-wise cursor movement across scripts.

BEHAVIOR CONTRACT

按词跳转遵循 Unicode 词边界,跨越希腊文、西里尔文与 emoji。Word jumps follow Unicode word boundaries across Greek, Cyrillic and emoji.

RECORDED INTERACTION

Harness 在文本框内按 ⌥← 逐词移动。The harness moves word by word with ⌥←.

examples/storybook/stories.zig:4575
pub fn buildWordNav(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const c = try col(cx, 12);
    try c.appendChild(a, try label(cx, "Word navigation — Alt+←/→ jumps whole Greek/Cyrillic words; double-click selects the word; family emoji is one cluster"));

    const ta = try W.Textarea(.{
        .label_text = "Mixed-script sample",
        .value = WORDNAV_TEXT,
        .rows = 3,
        .width = 560,
    }).mount(scope, cx);
    ta.meta.ownership.meta.test_id = "story.wordnav.ta";
    try c.appendChild(a, ta);

    try c.appendChild(a, try label(cx, "Expected Alt+Right stops (byte offsets): 7 14 27 34 40 46 72 75"));
    return c;
}
在 GitHub 查看源码View source on GitHubexamples/storybook/stories.zig:4575

这是 Storybook 中该 story 的原样代码(zenit 5f9add5+wip 2026-09-30)。其中 W 即 ui.widgets,col / row / label 是 Storybook 内的布局小工具。The story's verbatim source from the Storybook (zenit 5f9add5+wip 2026-09-30). W is ui.widgets; col / row / label are small Storybook layout helpers.

zenit · 双授权Dual-licensed开源项目可按 GPL-3.0-only 免费使用;闭源或商业产品需要商业授权。Free for open-source projects under GPL-3.0-only; closed-source or commercial products need a commercial license.可联系作者:Contact the author: zongyi.xzy#gmail.com(# 换成 @) (replace # with @)zenit 5f9add5+wip 2026-09-30