()
| 8757 | brightMagenta: v("--term-magenta"), |
| 8758 | brightCyan: v("--term-cyan"), |
| 8759 | brightWhite: v("--term-bright-white") |
| 8760 | }; |
| 8761 | } |
| 8762 | function initTerminal() { |
| 8763 | term = new import_xterm.Terminal({ |
| 8764 | cursorBlink: true, |
| 8765 | cursorStyle: "block", |
| 8766 | fontFamily: "'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'SF Mono', Menlo, Monaco, 'Courier New', monospace", |
| 8767 | fontSize: 14, |
| 8768 | lineHeight: 1.2, |
| 8769 | theme: getTheme(), |
| 8770 | allowProposedApi: true, |
| 8771 | scrollback: 1e4, |
| 8772 | convertEol: true |
| 8773 | }); |
| 8774 | fitAddon = new import_addon_fit.FitAddon(); |
| 8775 | term.loadAddon(fitAddon); |
| 8776 | term.loadAddon(new import_addon_web_links.WebLinksAddon()); |
| 8777 | searchAddon = new import_addon_search.SearchAddon(); |
| 8778 | term.loadAddon(searchAddon); |
| 8779 | const unicode11 = new import_addon_unicode11.Unicode11Addon(); |
| 8780 | term.loadAddon(unicode11); |
| 8781 | term.unicode.activeVersion = "11"; |
| 8782 | term.open(terminalContainer); |
| 8783 | try { |
| 8784 | const webgl = new import_addon_webgl.WebglAddon(); |
| 8785 | webgl.onContextLoss(() => webgl.dispose()); |
| 8786 | term.loadAddon(webgl); |
| 8787 | } catch { |
| 8788 | } |
| 8789 | fitAddon.fit(); |
| 8790 | const resizeObserver = new ResizeObserver(() => fitAddon.fit()); |
| 8791 | resizeObserver.observe(terminalContainer); |
| 8792 | term.onResize(({ cols, rows }) => sendJSON({ type: "resize", cols, rows })); |
| 8793 | term.onData((data) => { |
| 8794 | if ((ws == null ? void 0 : ws.readyState) === WebSocket.OPEN) ws.send(data); |
| 8795 | }); |
| 8796 | term.attachCustomKeyEventHandler((ev) => { |
| 8797 | if (ev.ctrlKey && ev.shiftKey && ev.key === "F") { |
| 8798 | if (ev.type === "keydown") { |
| 8799 | const query = window.prompt("Search terminal:"); |
| 8800 | if (query) searchAddon.findNext(query, { caseSensitive: false, regex: false }); |
| 8801 | } |
| 8802 | return false; |
| 8803 | } |
| 8804 | if (ev.ctrlKey && ev.shiftKey && ev.key === "C") { |
| 8805 | if (ev.type === "keydown") { |
| 8806 | const sel = term.getSelection(); |
| 8807 | if (sel) navigator.clipboard.writeText(sel); |
| 8808 | } |
| 8809 | return false; |
| 8810 | } |
| 8811 | if (ev.ctrlKey && ev.shiftKey && ev.key === "V") { |
| 8812 | if (ev.type === "keydown") { |
| 8813 | navigator.clipboard.readText().then((text) => { |
| 8814 | if ((ws == null ? void 0 : ws.readyState) === WebSocket.OPEN) ws.send(text); |
| 8815 | }); |
| 8816 | } |
no test coverage detected