From 765ca9848485017fc5f53b962b94c08d1db98fee Mon Sep 17 00:00:00 2001 From: WhiteGiverMa Date: Wed, 4 Nov 2026 00:57:07 +0800 Subject: [PATCH] fix: notify Windows bracketed-paste apps without clipboard text --- docs/en_us/features.md | 1 + docs/zh_cn/features.md | 1 + src/term/pointer.rs | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/en_us/features.md b/docs/en_us/features.md index 22d9d814..fd811914 100644 --- a/docs/en_us/features.md +++ b/docs/en_us/features.md @@ -9,6 +9,7 @@ English / [中文](../zh_cn/features.md) - Speed: rows with many colors draw about three times as fast, plain output reaches the screen about 30% faster, and kitty graphics payloads decode with SIMD. - Image tools size their pictures on every system: the terminal answers a cell's size in pixels, CSI 16 t, which yazi asks on Windows. - A scrollbar along the terminal's right edge scrolls its history, even while a program takes the wheel. +- On Windows, a paste with no text still notifies a program using bracketed paste, so apps such as OpenCode can read a clipboard image themselves. - Shell integration for zsh, bash, fish and PowerShell, on Windows for Git for Windows' bash and `sh` too, and for the bash, zsh or fish a Shell of `wsl` starts, so Files and Git follow a WSL or Git Bash session: each prompt reports its folder and title, and OSC 133 marks each prompt, each command and its exit status. On Windows PowerShell's `cd` also takes Git Bash's drive paths where no such path lies on the current drive: `cd /e` goes to `E:\`, `cd /c/Users` to `C:\Users`. On Wayland, Shift and Ctrl+Shift shortcuts hold when an input method such as fcitx5 forwards a modifier key without the compositor's modifier state. zsh's prompt, drawn again as the window resizes, leaves no copy in the history. A cmd session, or `cmd` typed at PowerShell's prompt, marks its prompts and reports its folder, and a command's start clears the last one's failure, so the row and Ely stay calm while ssh or a nested shell runs. - Ely peeks over the window's top edge, or up from its bottom left when the window leaves her no room above it, and moves all the time: she breathes, sways and blinks. She follows your sessions: she hops when a program waits on you, shakes at an error, cheers a finish, reads along while a program works, and dozes when all is calm for long. Press her and she winks, waking her from a doze. Drag her along the edge to move her. Settings › Terminal › Ely turns her off. - Sessions: new, close and switch. A right press on a row duplicates it, in the shell it runs and the folder it last reported, or closes it, and a drag moves a row to another place; Settings › Terminal turns either off. The arrow beside + opens profiles, as Windows Terminal's: your own, each a name, a command line with its arguments and a folder, set in Settings › Terminal › Profiles, then the shells this system holds, on Windows PowerShell, cmd, Git Bash and each WSL distribution but Docker Desktop's, elsewhere each shell `/etc/shells` lists. A profile that names a program alone, or `wsl -d NAME`, keeps its shell integration; other arguments run as written, and that session reports no folder. A bell marks a hidden session's row and makes no sound. A row's mark shows what its programs report through OSC 7501, OSC 9;4 or herdr: waiting on you, an error, work with its progress, done or idle, else a failed last command. The mark is 3 by 3 dots: work ripples and waiting dips while they last. Hover over the mark lists each report. diff --git a/docs/zh_cn/features.md b/docs/zh_cn/features.md index be76601c..f448ef3b 100644 --- a/docs/zh_cn/features.md +++ b/docs/zh_cn/features.md @@ -8,6 +8,7 @@ - 回滚历史在静止时压缩,滚动、查找或选择时再解开:我们测量的 10,000 行 shell 输出少用 85% 到 95% 的内存;每个字符都换颜色的行压缩得很少。 - 速度:颜色很多的行绘制快了约三倍,纯文本输出到屏幕快了约 30%,kitty 图形数据用 SIMD 解码。 - 终端右缘的滚动条滚动历史,即使程序占用了滚轮。 +- Windows 上,剪贴板没有文本时,仍向开启括号粘贴的程序发送空粘贴通知,让 OpenCode 等应用自行读取剪贴板中的图片。 - 各系统上的图片工具都能按正确尺寸显示图片:终端回答以像素计的单元格尺寸 CSI 16 t,Windows 上的 yazi 会询问它。 - zsh、bash、fish 和 PowerShell 的 shell 集成,在 Windows 上也包括 Git for Windows 的 bash 和 `sh`,以及 Shell 为 `wsl` 时启动的 bash、zsh 或 fish,所以文件和 Git 能跟上 WSL 或 Git Bash 会话:每个提示符报告其文件夹和标题,OSC 133 标记每个提示符、每条命令及其退出状态。在 Windows 上,当前盘没有这一路径时,PowerShell 的 `cd` 也接受 Git Bash 的盘符路径:`cd /e` 进入 `E:\`,`cd /c/Users` 进入 `C:\Users`。在 Wayland 上,fcitx5 等输入法转发修饰键却不带合成器的修饰状态时,Shift 和 Ctrl+Shift 快捷键照常工作。 窗口缩放时 zsh 重画的提示符不再在历史里留下副本。cmd 会话,或在 PowerShell 提示符下输入的 `cmd`,会标记提示符并报告文件夹;命令一开始就清掉上一条命令的失败,所以 ssh 或嵌套 shell 运行时,会话行和 Ely 保持平静。 - Ely 从窗口上缘探出头,窗口上方没有她的位置时则从左下角探上来,并且一直在动:呼吸、摇摆、眨眼。她跟着会话走:程序等你时她跳,出错时她抖,完成时她欢呼,程序工作时她顺着读,长久平静时她打盹。点按她,她眨眼,并把她从盹里叫醒。沿边缘拖动可挪她。设置 › 终端 › Ely 关掉她。 diff --git a/src/term/pointer.rs b/src/term/pointer.rs index 716fe5dd..fd4b9728 100644 --- a/src/term/pointer.rs +++ b/src/term/pointer.rs @@ -383,11 +383,20 @@ impl TerminalView { if self.pty.term.lock().mode().contains(TermMode::PASTE_EVENTS) { return self.paste_event(cx); } - let Some(text) = cx.read_from_clipboard().and_then(|item| item.text()) else { - log::debug!("terminal {}: no text to paste", self.pty.pid); - return; - }; - self.paste_text(&text, cx); + match cx.read_from_clipboard().and_then(|item| item.text()) { + Some(text) => self.paste_text(&text, cx), + None if cfg!(windows) + && self + .pty + .term + .lock() + .mode() + .contains(TermMode::BRACKETED_PASTE) => + { + self.paste_text("", cx); + } + None => log::debug!("terminal {}: no text to paste", self.pty.pid), + } } /// `text` to the program as a paste, bracketed when it asked.