2022-01-09 14:56:43 +01:00
|
|
|
function createTerminal(path) {
|
2022-01-05 03:21:21 +01:00
|
|
|
// vscode-snazzy https://github.com/Tyriar/vscode-snazzy
|
|
|
|
// copied from xterm.js website
|
|
|
|
var baseTheme = {
|
|
|
|
foreground: '#eff0eb',
|
|
|
|
background: '#282a36',
|
|
|
|
selection: '#97979b33',
|
|
|
|
black: '#282a36',
|
|
|
|
brightBlack: '#686868',
|
|
|
|
red: '#ff5c57',
|
|
|
|
brightRed: '#ff5c57',
|
|
|
|
green: '#5af78e',
|
|
|
|
brightGreen: '#5af78e',
|
|
|
|
yellow: '#f3f99d',
|
|
|
|
brightYellow: '#f3f99d',
|
|
|
|
blue: '#57c7ff',
|
|
|
|
brightBlue: '#57c7ff',
|
|
|
|
magenta: '#ff6ac1',
|
|
|
|
brightMagenta: '#ff6ac1',
|
|
|
|
cyan: '#9aedfe',
|
|
|
|
brightCyan: '#9aedfe',
|
|
|
|
white: '#f1f1f0',
|
|
|
|
brightWhite: '#eff0eb'
|
|
|
|
};
|
2022-01-04 21:41:41 +01:00
|
|
|
|
|
|
|
const term = new Terminal({
|
2022-01-13 00:26:21 +01:00
|
|
|
fontFamily: `'Fira Code', ui-monospace,SFMono-Regular,'SF Mono',Menlo,Consolas,'Liberation Mono',monospace`,
|
2022-01-05 03:21:21 +01:00
|
|
|
fontSize: 12,
|
|
|
|
theme: baseTheme,
|
|
|
|
convertEol: true,
|
2022-01-06 21:29:02 +01:00
|
|
|
cursorBlink: true,
|
2022-01-04 21:41:41 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
term.open(document.getElementById('terminal_view'));
|
2022-01-19 00:42:27 +01:00
|
|
|
term.resize(120, 36);
|
2022-01-04 21:41:41 +01:00
|
|
|
|
|
|
|
const weblinksAddon = new WebLinksAddon.WebLinksAddon();
|
2022-01-05 03:21:21 +01:00
|
|
|
term.loadAddon(weblinksAddon);
|
2022-01-04 21:41:41 +01:00
|
|
|
|
|
|
|
// fit the xterm viewpoint to parent element
|
|
|
|
const fitAddon = new FitAddon.FitAddon();
|
|
|
|
term.loadAddon(fitAddon);
|
|
|
|
fitAddon.fit();
|
2022-01-05 03:21:21 +01:00
|
|
|
|
2022-01-04 21:41:41 +01:00
|
|
|
// create the websocket and connect to the server
|
2022-01-09 14:56:43 +01:00
|
|
|
const ws_uri = "wss://" + window.location.host + path;
|
2022-01-05 03:21:21 +01:00
|
|
|
const socket = new WebSocket(ws_uri);
|
2022-01-12 13:33:06 +01:00
|
|
|
socket.binaryType = "arraybuffer";
|
2022-01-05 03:21:21 +01:00
|
|
|
const attachAddon = new AttachAddon.AttachAddon(socket);
|
2022-01-04 21:41:41 +01:00
|
|
|
term.loadAddon(attachAddon);
|
|
|
|
|
|
|
|
return term;
|
2022-01-05 03:21:21 +01:00
|
|
|
}
|