clipboard support

This commit is contained in:
b1ek 2023-03-17 16:08:13 +10:00
parent 1e90b97973
commit 747b94f103
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,37 @@
import { Terminal } from "xterm"
import copy from 'copy-to-clipboard';
/** @type { Terminal } */
let terminal;
const zsh = require('./zsh');
/**
*
* @param {{ key: string, domEvent: KeyboardEvent }} e
*/
async function keyHandler(e) {
const dom = e.domEvent;
if (!dom.altKey)
return;
if (dom.key.length != 1)
return;
switch (dom.key.toLowerCase()) {
case 'c':
if (!terminal.hasSelection()) break;
copy(terminal.getSelection())
break;
case 'v':
zsh.pr_char(prompt("Paste your text:"), {key: 'a'})
}
}
module.exports = (t, d) => {
terminal = t;
terminal.onKey(keyHandler);
}