mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
enable copy/paste via Cmd:Shift:C and Cmd:Shift:V in the terminal
This commit is contained in:
parent
b2e12e4171
commit
bd2bb5293f
@ -110,6 +110,8 @@ const Tab = forwardRef<HTMLDivElement, TabProps>(
|
||||
function handleContextMenu(e: React.MouseEvent<HTMLDivElement, MouseEvent>) {
|
||||
e.preventDefault();
|
||||
let menu: ContextMenuItem[] = [];
|
||||
menu.push({ label: "Copy TabId", click: () => navigator.clipboard.writeText(id) });
|
||||
menu.push({ type: "separator" });
|
||||
menu.push({ label: "Close Tab", click: () => onClose(null) });
|
||||
ContextMenuModel.showContextMenu(menu, e);
|
||||
}
|
||||
|
@ -282,8 +282,28 @@ const TerminalView = ({ blockId }: { blockId: string }) => {
|
||||
blockId: blockId,
|
||||
};
|
||||
|
||||
function handleKeyDown(e: React.KeyboardEvent<HTMLDivElement>) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const waveEvent = keyutil.adaptFromReactOrNativeKeyEvent(e);
|
||||
if (keyutil.checkKeyPressed(waveEvent, "Cmd:Shift:v")) {
|
||||
const p = navigator.clipboard.readText();
|
||||
p.then((text) => {
|
||||
termRef.current?.handleTermData(text);
|
||||
});
|
||||
return true;
|
||||
} else if (keyutil.checkKeyPressed(waveEvent, "Cmd:Shift:c")) {
|
||||
const sel = termRef.current?.terminal.getSelection();
|
||||
navigator.clipboard.writeText(sel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={clsx("view-term", "term-mode-" + termMode, isFocused ? "is-focused" : null)}>
|
||||
<div
|
||||
className={clsx("view-term", "term-mode-" + termMode, isFocused ? "is-focused" : null)}
|
||||
onKeyDown={handleKeyDown}
|
||||
>
|
||||
<TermStickers config={stickerConfig} />
|
||||
<div key="conntectElem" className="term-connectelem" ref={connectElemRef}></div>
|
||||
<div
|
||||
|
Loading…
Reference in New Issue
Block a user