in src/widgets/dialogs/PodsTerminal/index.tsx [105:149]
function setupTerminal(containerRef: HTMLElement, xterm: XTerminal, fitAddon: FitAddon) {
if (!containerRef) {
return;
}
xterm.open(containerRef);
xterm.onData((data) => {
send(0, data);
});
xterm.onResize((size) => {
send(4, `{"Width":${size.cols},"Height":${size.rows}}`);
});
// Allow copy/paste in terminal
xterm.attachCustomKeyEventHandler((arg) => {
if (arg.ctrlKey && arg.type === 'keydown') {
if (arg.code === 'KeyC') {
const selection = xterm.getSelection();
if (selection) {
return false;
}
}
if (arg.code === 'KeyV') {
return false;
}
}
if (!isAttach && arg.type === 'keydown' && arg.code === 'Enter') {
if (xtermRef.current?.reconnectOnEnter) {
setShells((shells) => ({
...shells,
currentIdx: 0,
}));
xtermRef.current!.reconnectOnEnter = false;
return false;
}
}
return true;
});
fitAddon.fit();
}