Skip to content

Commit 71e5c64

Browse files
committed
feat: add clipboard support for terminal input and output
1 parent 0baec5b commit 71e5c64

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

view/app/terminal/utils/useTerminal.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,32 @@ export const useTerminal = (
160160
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'j') {
161161
return false;
162162
}
163+
164+
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'c') {
165+
if (event.shiftKey) {
166+
sendJsonMessage({
167+
action: 'terminal',
168+
data: { value: CTRL_C, terminalId }
169+
});
170+
return false;
171+
}
172+
const selection = term.getSelection();
173+
if (selection) {
174+
navigator.clipboard.writeText(selection);
175+
}
176+
return false;
177+
}
178+
179+
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'v') {
180+
navigator.clipboard.readText().then((text) => {
181+
sendJsonMessage({
182+
action: 'terminal',
183+
data: { value: text, terminalId }
184+
});
185+
});
186+
return false;
187+
}
188+
163189
return true;
164190
});
165191

0 commit comments

Comments
 (0)