feat(terminal): clipboard paste with bracketed-paste support

Pasting (Ctrl-V or browser menu) now sends clipboard text to the PTY.

- on:paste reads clipboard_data().get_data("text"); newlines normalized
  to CR (the line-submit byte) via the pure, unit-tested prepare_paste()
- when the app enabled bracketed paste (DECSET 2004, exposed via the new
  TerminalCore::bracketed_paste() proxy), the text is wrapped in
  ESC[200~ / ESC[201~ so vim et al. don't auto-indent each pasted line
- pasting returns the view to live mode + scrolls to bottom, matching the
  keydown handler
- Cargo.toml: add ClipboardEvent/DataTransfer (and explicit WheelEvent)
  to the web-sys feature allowlist
- right-click is left to the browser's default menu (avoids requiring
  clipboard-read permission); Ctrl-V is the primary path

Adds a prepare_paste unit test (14 terminal tests total) and marks paste
done in TERMINAL_ROADMAP.md. Also fixes a clippy manual_contains lint in
an existing test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
zhangheng
2026-06-11 20:59:03 +08:00
parent a018609a28
commit c886befac7
4 changed files with 96 additions and 9 deletions

View File

@@ -39,8 +39,10 @@ wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
web-sys = { version = "0.3", default-features = false, features = [
"BinaryType",
"ClipboardEvent",
"CloseEvent",
"console",
"DataTransfer",
"Document",
"DomRectReadOnly",
"Element",
@@ -54,6 +56,7 @@ web-sys = { version = "0.3", default-features = false, features = [
"ResizeObserver",
"ResizeObserverEntry",
"WebSocket",
"WheelEvent",
"Window",
] }