fix(app): add Ctrl+C/V clipboard support for Windows/Linux terminal
On non-Mac platforms, Ctrl+C now copies selected text to clipboard (falling through to SIGINT when nothing is selected) and Ctrl+V pastes from clipboard into the terminal.
This commit is contained in:
@@ -286,6 +286,25 @@ export class TerminalEmulatorRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isMac && event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey) {
|
if (!isMac && event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey) {
|
||||||
|
const key = event.key.toLowerCase();
|
||||||
|
|
||||||
|
// Ctrl+C: copy selection to clipboard if text is selected, otherwise let xterm send SIGINT
|
||||||
|
if (key === "c" && terminal.hasSelection()) {
|
||||||
|
void navigator.clipboard.writeText(terminal.getSelection());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctrl+V: paste from clipboard into terminal
|
||||||
|
if (key === "v") {
|
||||||
|
event.preventDefault();
|
||||||
|
void navigator.clipboard.readText().then((text) => {
|
||||||
|
if (text) {
|
||||||
|
terminal.paste(text);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user