forked from AnswerDotAI/gpu.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_shell.html
More file actions
53 lines (52 loc) · 1.58 KB
/
custom_shell.html
File metadata and controls
53 lines (52 loc) · 1.58 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>gpu.cpp</title>
<!-- Include xterm.js CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/xterm/css/xterm.css" />
<style>
body, html {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
#terminal {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<!-- Terminal container -->
<div id="terminal"></div>
<!-- Include xterm.js and xterm-addon-fit libraries -->
<script src="https://cdn.jsdelivr.net/npm/xterm/lib/xterm.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xterm-addon-fit/lib/xterm-addon-fit.js"></script>
<script type="text/javascript">
// Initialize xterm.js
const terminal = new Terminal();
const fitAddon = new FitAddon.FitAddon();
terminal.loadAddon(fitAddon);
terminal.open(document.getElementById('terminal'));
fitAddon.fit();
// This function captures stdout and displays it in the xterm.js terminal
var Module = {
preRun: [],
postRun: [],
print: function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
console.log(text); // Log to the console
terminal.writeln(text); // Write to the terminal
},
printErr: function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
console.error(text); // Log to the console as an error
terminal.writeln(text); // Write to the terminal as well
}
};
</script>
{{{ SCRIPT }}}
</body>
</html>