-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell_emterm.html
156 lines (151 loc) · 5.42 KB
/
shell_emterm.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Terminal Application</title>
<link rel="stylesheet" href="node_modules/xterm/css/xterm.css" />
<script src="node_modules/xterm/lib/xterm.js"></script>
<script src="node_modules/xterm-addon-fit/lib/xterm-addon-fit.js"></script>
<style>
html {
height: 100%;
}
body {
font-family: arial;
margin: 0;
padding: none;
height: 100%;
}
#fullscreen {
position: absolute;
top: 1mm;
right: 1mm;
z-index: 5;
}
#output {
width: 100%;
height: 100%;
margin: 0 auto;
border: 0px;
padding: 0px;
overflow: hidden;
}
@-webkit-keyframes rotation {
from {-webkit-transform: rotate(0deg);}
to {-webkit-transform: rotate(360deg);}
}
@-moz-keyframes rotation {
from {-moz-transform: rotate(0deg);}
to {-moz-transform: rotate(360deg);}
}
@-o-keyframes rotation {
from {-o-transform: rotate(0deg);}
to {-o-transform: rotate(360deg);}
}
@keyframes rotation {
from {transform: rotate(0deg);}
to {transform: rotate(360deg);}
}
</style>
</head>
<body>
<a id="fullscreen" href='#' onclick="Module.requestFullscreen(true/*hide/lock mouse*/, true/*resize canvas*/)">
<svg id="fs" version="1.1" viewBox="0 0 8 8" height="8mm" width="8mm">
<defs>
<marker id="fg" overflow="visible" orient="auto">
<path transform="scale(.8) rotate(180) translate(12.5)" d="m0 0l5-5-17.5 5 17.5 5-5-5z" fill-rule="evenodd"/>
</marker>
<marker id="bg" overflow="visible" orient="auto">
<path transform="matrix(-.8 0 0 -.8 -10 0)" d="m0 0 5-5-17.5 5 17.5 5z" fill="#fff" fill-rule="evenodd"/>
</marker>
</defs>
<g transform="translate(0,-289)">
<g>
<path stroke-width="0.2" marker-end="url(#bg)" d="M1.5,290.5 0,289" />
<path stroke-width="0.1" marker-end="url(#fg)" d="M2,291 0.5,289.5" />
</g>
<g transform="matrix(1,0,0,-1,-3e-8,586)" >
<path stroke-width="0.2" marker-end="url(#bg)" d="M1.5,290.5 0,289" />
<path stroke-width="0.1" marker-end="url(#fg)" d="M2,291 0.5,289.5" />
</g>
<g transform="matrix(-1,0,0,1,7.9999999,3.5252395e-7)" >
<path stroke-width="0.2" marker-end="url(#bg)" d="M1.5,290.5 0,289" />
<path stroke-width="0.1" marker-end="url(#fg)" d="M2,291 0.5,289.5" />
</g>
<g transform="rotate(-180,3.9999999,293)">
<path stroke-width="0.2" marker-end="url(#bg)" d="M1.5,290.5 0,289" />
<path stroke-width="0.1" marker-end="url(#fg)" d="M2,291 0.5,289.5" />
</g>
</g>
</svg>
</a>
<div id="output"></div>
<script type='text/javascript'>
const term = new Terminal({convertEol: true, scrollback: 0});
const fitAddon = new FitAddon.FitAddon();
var inputBuf = [];
term.loadAddon(fitAddon);
term.open(document.getElementById('output'));
fitAddon.fit();
window.addEventListener('resize', ()=>fitAddon.fit());
term.onData(data=> inputBuf = inputBuf.concat(intArrayFromString(data)));
function write(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&");
//text = text.replace(/</g, "<");
//text = text.replace(/>/g, ">");
//text = text.replace('\n', '<br>', 'g');
console.log(text);
term.write(text + "\x0d\x0a");
};
var Module = {
tty: {
put_array: function(tty, val) {
term.write(val);
},
get_char: function(tty) {
if (!inputBuf.length) return undefined;
return inputBuf.shift();
},
poll_in: function(tty) {
return inputBuf.length > 0;
},
get_winsize: function(tty, winsize) {
winsize.ws_row = term.rows;
winsize.ws_col = term.cols;
winsize.ws_xpixel = term.element.clientWidth;
winsize.ws_ypixel = term.element.clientHeight;
}
},
preRun: [],
postRun: [],
print: (function() {
return write;
})(),
printErr: write,
canvas: (function() {
return document.getElementById('output');
})(),
setStatus: function(text) {
if (text === '') return;
write((new Date()).toISOString() + ': ' + text);
},
totalDependencies: 0,
monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
Module.setStatus('Downloading...');
window.onerror = function() {
Module.setStatus('Exception thrown, see JavaScript console');
Module.setStatus = function(text) {
if (text) Module.printErr('[post-exception status] ' + text);
};
};
</script>
{{{ SCRIPT }}}
</body>
</html>