-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.ts
45 lines (41 loc) · 1.54 KB
/
template.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
export const template = `
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="./static/xterm/xterm.css" />
<script src="./static/xterm/xterm.js"></script>
<script src="./static/xterm/fitAddon.js"></script>
<style>
.terminal {
padding: ##PADDING##;
}
</style>
</head>
<body style="margin: 0;">
<div id="snap-terminal" style="visibility: hidden;"></div>
<script>
var term = new Terminal({rows: 1, cols: 1});
var fitAddon = new this.fitAddon();
term.loadAddon(fitAddon);
term.setOption('theme', '##THEME##');
// ##FONTFAMILY##
// ##FONTSIZE##
term.open(document.getElementById('snap-terminal'));
fitAddon.fit();
const text = '##TERMINAL_CONTENT##';
term.write(text.replace(/\\n/g, '\\r\\n'));
setTimeout(() =>{
const outHeight = document.getElementsByClassName('xterm-scroll-area')[0].offsetHeight;
console.log(outHeight);
console.log(document.getElementById('snap-terminal'));
document.getElementById('snap-terminal').style.height = \`\${outHeight}px\`;
document.getElementById('snap-terminal').style.visibility = \`unset\`;
fitAddon.fit();
fitAddon.fit();
const done = document.createElement('span');
done.setAttribute('id', 'done');
document.getElementById('snap-terminal').appendChild(done);
}, 500); // TODO wait for actual print
</script>
</body>
</html>`;