-
Notifications
You must be signed in to change notification settings - Fork 41
Description
When clipboard contains non-text data (images, files), pasting does nothing. TUI apps like vim, Claude Code read images directly from system clipboard via pbpaste/xclip/wl-paste - they just need the \x16 (Ctrl+V) signal to know to read it.
Two related issues:
1. Paste event handler returns early when no text
In Terminal class, the textarea paste handler only handles text:
this.textarea.addEventListener("paste", (e) => {
const text = e.clipboardData?.getData("text");
if (text) {
this.paste(text);
}
// Does nothing for non-text clipboard content
});Proposed fix - send \x16 when clipboard has non-text data:
this.textarea.addEventListener("paste", (e) => {
const text = e.clipboardData?.getData("text");
if (text) {
this.paste(text);
} else if (e.clipboardData && e.clipboardData.types.length > 0) {
this.dataEmitter.fire("\x16");
}
});2. Ctrl+V keydown returns early without sending character
In InputHandler.handleKeyDown:
if ((event.ctrlKey || event.metaKey) && event.code === "KeyV") {
return; // Returns without sending anything
}xterm.js sends \x16 for Ctrl+V (via String.fromCharCode(keyCode - 64)).
Proposed fix - send \x16 for Ctrl+V:
if (event.ctrlKey && event.code === "KeyV") {
this.onDataCallback("\x16");
return;
}
if (event.metaKey && event.code === "KeyV" || event.metaKey && event.code === "KeyC") {
return;
}Note: These fixes were developed during an AI-assisted session and are currently used as patches in our application. Due to time constraints we're unable to submit a proper PR, but wanted to share the findings.