无障碍功能

放大终端窗格

选择 View → Magnify Pane,或按 Ctrl+Alt+= 放大,按 Ctrl+Alt+− 缩小,按 Ctrl+Alt+0 恢复原始大小。用 Ctrl+Alt+方向键 平移已放大的窗格,用 Ctrl+Alt+C 将文字光标移到视图中央。支持直接触摸事件的触屏可用双指张开或捏合来缩放,双指同向移动可平移。窗格已放大时,触控板上的捏合手势以指针为中心缩放。

放大保留程序的行数、列数和文本布局。Silkie 按所选分辨率重新栅格化字形和矢量图形,实际分辨率受渲染器和硬件约束。

默认情况下,缩放时一旦显示光栅图像,Silkie 就按向上取整的倍数报告像素尺寸,最高为原始尺寸的三倍。缩放倍率大于 1× 且不超过 2× 时报告 2×,大于 2× 时报告 3×。恢复原始大小时报告基础分辨率。报告的倍率发生变化时,Silkie 会更新 PTY 像素尺寸。在支持像素尺寸变更信号的系统上,这会触发 SIGWINCH;启用了带内尺寸报告的应用也会收到报告。程序可用 CSI 16 t 查询报告的单元格尺寸,再按相应像素密度发送图像,同时保持图像占用的单元格数量。Silkie 会在本地将现有图像缩放到所选倍率。

如需节省带宽,可在 silkie.conf 中设置 magnify_raster_resolution,使报告的像素尺寸保持为原始值:

magnify_raster_resolution no

在 silkie.conf 中绑定 magnify_pane 可自定义操作。数字参数指定放大倍率,也可指定从 1 开始计数的行和列,作为可见终端网格中的中心。例如:

map kitty_mod+f11 magnify_pane 3 12 40
map kitty_mod+f12 magnify_pane reset

Silkie 在已有的显示器监测唤醒中读取桌面缩放状态,包括 GNOME Zoom 的设置、支持报告目标倍率的 KWin 版本以及 macOS 辅助功能缩放是否启用。macOS 的缩放倍率取决于系统可提供的信息。使用桌面缩放时,最终清晰度取决于合成器如何缩放窗口。在 X11 或 Wayland 会话中运行 Silkie 的 Android 平板可使用窗格放大功能。Android 系统放大镜由 Android 主机管理,Android 辅助功能服务可获取其倍率。

查看终端图像

选择 View → Review Images,或按 kitty_mod+alt+i,即可阅读当前窗格视口内的图像说明。在 macOS 或使用 Linux GTK 后端时,查看器会打开可选择文本的只读视图。原生后端不可用时,Silkie 会使用已配置的回滚分页器。关闭查看器后,键盘焦点返回终端窗格。

查看器按从上到下、从左到右的顺序列出图像,包括核心、补充说明和未分类的图像。每项会标明用途和位置,并显示程序提供的名称、说明和详情。要查看装饰性图像,选择 Review All Images。要查看此前输出中的图像,请先滚动终端窗格。

可以在 silkie.conf 中为这两个操作绑定快捷键:

map kitty_mod+alt+i review_images
map kitty_mod+alt+o review_all_images

描述图像放置

任何使用 kitty 图形协议 的程序都可以为图像放置添加注释。此功能适用于光栅图像和 矢量图像,包括 SVG。请分别为图像和放置指定非零的 i 和 p,并在完成放置后发出注释。

发送 扩展能力协议 查询,并检查 ext 中是否包含 a11y.1,即可探测支持情况。此选择器使用 OSC 777 扩展封装。

<OSC> 777 ; a11y ; v=1 : op=set-image : i=17 : p=3 : purpose=essential : name=Latency%20by%20request%20rate <ST>

set-image 会整体替换注释。clear-image 接受同一组放置 ID 并移除注释。set-image 中省略的说明字段会清除相应旧值。

字段

取值

i

图像 ID,必填。大于零的 32 位无符号整数。

p

放置 ID,必填。大于零的 32 位无符号整数。

purpose

essential 表示承载主题或结果的核心图像,informative 表示提供补充说明的图像,decorative 表示装饰性图像。省略此字段时,用途为未分类。

name

可选的简短单行名称。

description

可选,概述图像传达的信息。

details

可选,可提供较长的纯文本解释、数据表或参考网址。查看器以可复制的文本显示网址。

id

可选,用于关联回复的 ID,范围为 0 到 2147483647。

对三个文本字段的 UTF-8 字节进行百分号编码,尤其是冒号、百分号和非 ASCII 字节。转义符由百分号和两位十六进制数字组成。无效转义、无效 UTF-8 或控制字符会导致整条更新被拒绝。说明和详情可分别用 %09 和 %0A 表示制表符和换行。

请求包含 id 时,更新成功会回复 OK。图像或放置不存在时回复 ENOENT。内存分配失败时可能回复 ENOMEM。格式有误的请求不会收到回复。

<OSC> 777 ; a11y ; v=1 : op=ack : id=42 : status=OK <ST>
<OSC> 777 ; a11y ; v=1 : op=clear-image : i=17 : p=3 : id=43 <ST>

注释属于当前屏幕,并随对应的放置进入回滚缓冲区。移动已有的放置时,注释随之保留。删除放置或替换图像数据时,相应放置及其注释也会移除。虚拟放置的注释用于描述其 Unicode 占位符的可见部分。查看器为每个可见的虚拟放置列出一项。

Label text and make announcements

Look for a11y.2 in the 扩展能力协议 reply to discover text labels and announcements. Image operations also accept version 2.

After drawing text, send set-text to label a range of terminal cells:

<OSC> 777 ; a11y ; v=2 : op=set-text : range=7 : row=2 : column=1 : end_row=2 : end_column=4 : role=prompt : label=Search <ST>

range is a nonzero unsigned 32-bit ID local to the pane. The start is inclusive and the end is exclusive. Rows and columns are one-based coordinates on the active terminal screen, independent of user scrollback position. The end column may be one past the last column. role is prompt, status, completion, or decorative. An optional percent-encoded UTF-8 label replaces the text exposed to screen readers. Decorative ranges are omitted from accessible text.

A new range replaces any overlapping ranges. An annotation expires when its cells change, the pane is resized, or it switches terminal screens. Use clear-text with the same range ID to remove it explicitly.

Send announce when an event occurs:

<OSC> 777 ; a11y ; v=2 : op=announce : text=Search%20failed : priority=assertive <ST>

text is percent-encoded, nonempty, single-line UTF-8. The default priority=polite requests a normal announcement. assertive requests an interruption. Each command requests one announcement. Repainting the pane or updating a text label never requests it again.

An optional id requests a version-2 acknowledgment. Statuses are OK, EINVAL for coordinates outside the grid, ENOENT for an unknown range ID, ENOTSUP when native announcements are unavailable, and ENOMEM if allocating text fails. Malformed requests receive no reply.

Speech over the terminal

Programs can queue speech with per-utterance voice settings. Silkie uses AVSpeechSynthesizer on macOS and Speech Dispatcher on Linux. The interface supports queued and interruptible speech, character echo, and reusable voice styles as in Emacspeak Voice Lock.

Look for speech.1 in the 扩展能力协议 reply and query the terminal host for its backend:

<OSC> 777 ; speech ; v=1 : op=query : id=17 <ST>
<OSC> 777 ; speech ; v=1 : op=cap : id=17 : available=1 : engine=avspeech : pitch_range=0 <ST>

available=1 indicates that a native speech backend is installed. engine is avspeech, speech_dispatcher, or none. pitch_range=1 means the backend accepts pitch-range settings. The protocol uses OSC 777 扩展封装. Percent-encode text and names as with the accessibility protocol above.

To speak a styled sequence, define styles and queue text using them:

<OSC> 777 ; speech ; v=1 : op=set-style : style=comment : pitch=-25 : rate=-10 <ST>
<OSC> 777 ; speech ; v=1 : op=queue : text=Line%2017 <ST>
<OSC> 777 ; speech ; v=1 : op=queue : style=comment : text=Save%20the%20buffer <ST>
<OSC> 777 ; speech ; v=1 : op=dispatch <ST>

speak adds text to playback without a separate dispatch. character takes a single Unicode character for key echo. Set interrupt=1 to clear the pane's speech before adding new output. sound takes a native sound name and silence takes a duration in milliseconds. Use queued=1 with either to include it in a later dispatch.

stop interrupts playback and clears the pane's queues. pause and resume control playback. reset also clears the pane's styles. clear-style removes the named style. A style can set any subset of voice, language, rate, pitch, pitch_range, volume, punctuation, and split_caps. An individual utterance can override those fields. Rate, pitch, and pitch range are from −100 to 100 with zero neutral. Volume is from 0 to 100. Punctuation is none, some or all. split_caps=1 separates words in mixed-case identifiers. Voice identifiers and speech rendering depend on the installed synthesizer. An optional id requests an acknowledgment of the command.

SVG 示例

此 Python 程序会放置一张小型 SVG 图表,并描述图表结果。请将标准输出发送到支持 SVG 和图像注释的 Silkie 终端:

from base64 import b64encode
from urllib.parse import quote

svg = (
    '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 48">'
    '<path d="M4 42 H116 M4 42 V4" stroke="#879581"/>'
    '<path d="M4 34 L78 33 L112 7" fill="none" stroke="#77bb42" stroke-width="3"/>'
    '</svg>'
)
print(f'\x1b_Ga=T,f=201,i=17,p=3;{b64encode(svg.encode()).decode()}\x1b\\', end='')
name = quote('Latency by request rate', safe='')
summary = quote('Latency stays below 20 ms through 800 requests per second, then rises sharply.', safe='')
print(f'\x1b]777;a11y;v=1:op=set-image:i=17:p=3:purpose=essential:name={name}:description={summary}\x1b\\', end='', flush=True)

查看器中的说明由应用程序提供。将来,按需解读功能可以用放置 ID 识别用户选中的图像。