forked from chromium/hterm
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhterm.html
More file actions
166 lines (155 loc) · 5.06 KB
/
Copy pathhterm.html
File metadata and controls
166 lines (155 loc) · 5.06 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
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
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html>
<html>
<head>
<title>hterm test page</title>
<meta charset='utf-8'/>
<script src='../dist/js/hterm_deps.js'></script>
<script src='../dist/js/hterm_resources.js'></script>
<!-- Dist version.
<script src='../dist/js/hterm.js'></script>
-->
<!-- Live version. -->
<script src='../js/hterm.js'></script>
<script src='../js/hterm_accessibility_reader.js'></script>
<script src='../js/hterm_contextmenu.js'></script>
<script src='../js/hterm_find_bar.js'></script>
<script src='../js/hterm_frame.js'></script>
<script src='../js/hterm_keyboard.js'></script>
<script src='../js/hterm_keyboard_bindings.js'></script>
<script src='../js/hterm_keyboard_keymap.js'></script>
<script src='../js/hterm_keyboard_keypattern.js'></script>
<script src='../js/hterm_notifications.js'></script>
<script src='../js/hterm_options.js'></script>
<script src='../js/hterm_parser.js'></script>
<script src='../js/hterm_parser_identifiers.js'></script>
<script src='../js/hterm_preference_manager.js'></script>
<script src='../js/hterm_pubsub.js'></script>
<script src='../js/hterm_screen.js'></script>
<script src='../js/hterm_scrollport.js'></script>
<script src='../js/hterm_terminal.js'></script>
<script src='../js/hterm_terminal_io.js'></script>
<script src='../js/hterm_text_attributes.js'></script>
<script src='../js/hterm_vt.js'></script>
<script src='../js/hterm_vt_character_map.js'></script>
<style>
html {
height: 100%;
}
body {
position: absolute;
height: 100%;
width: 100%;
overflow: hidden;
margin: 0px;
padding: 0px;
}
#terminal {
display: block;
position: relative;
height: 100%;
width: 100%;
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<div id='terminal'></div>
<script>
function initContent(io) {
const ver = lib.resource.getData('hterm/changelog/version');
const date = lib.resource.getData('hterm/changelog/date');
const pkg = `hterm ${ver} (${date})`;
/* eslint-disable quotes */
io.println("\r\n\
.--~~~~~~~~~~~~~------.\r\n\
/--===============------\\\r\n\
| |```````````````| |\r\n\
| | | |\r\n\
| | >_< | |\r\n\
| | | |\r\n\
| |_______________| |\r\n\
| ::::|\r\n\
'======================='\r\n\
//-'-'-'-'-'-'-'-'-'-'-\\\\\r\n\
//_'_'_'_'_'_'_'_'_'_'_'_\\\\\r\n\
[-------------------------]\r\n\
\\_________________________/\r\n\
\r\n\
Welcome to hterm!\r\n\
Press F11 to go fullscreen to use all shortcuts.\r\n\
Running " + pkg + ".\r\n\
");
/* eslint-enable quotes */
}
// Load translations if available.
lib.registerInit('load messages', async () => {
// Try to load the messages database from nassh. This isn't strictly needed
// (so if it fails, it should be fine), but does help when testing locally.
// $1 here means we search the user's language. Change it to 'en' or another
// specific language to test those specifically.
const lang = '$1';
await hterm.messageManager.findAndLoadMessages(
lib.f.getURL(`../../nassh/_locales/${lang}/messages.json`));
});
function setupHterm() {
const term = new hterm.Terminal();
term.onTerminalReady = function() {
const io = this.io.push();
function printPrompt() {
io.print(
'\x1b[38:2:51:105:232mh' +
'\x1b[38:2:213:15:37mt' +
'\x1b[38:2:238:178:17me' +
'\x1b[38:2:51:105:232mr' +
'\x1b[38:2:0:153:37mm' +
'\x1b[38:2:213:15:37m>' +
'\x1b[0m ');
}
io.onVTKeystroke = (string) => {
switch (string) {
case '\r':
io.println('');
printPrompt();
break;
case '\x7f':
// \x08 = backspace, \x1b[K = 'Erase in line'.
io.print('\x08\x1b[K');
break;
default:
io.print(string);
break;
}
};
io.sendString = io.print;
initContent(io);
printPrompt();
this.setCursorVisible(true);
this.keyboard.bindings.addBinding('F11', 'PASS');
this.keyboard.bindings.addBinding('Ctrl+R', 'PASS');
};
term.decorate(document.querySelector('#terminal'));
term.installKeyboard();
term.contextMenu.setItems([
{name: 'Terminal Reset', action: () => term.reset()},
{name: 'Terminal Clear', action: () => term.clear()},
{name: hterm.ContextMenu.SEPARATOR},
{name: 'Homepage', action: function() {
lib.f.openWindow(
'https://chromium.googlesource.com/apps/libapps/+/HEAD/hterm/README.md',
'_blank');
}},
{name: 'FAQ', action: function() {
lib.f.openWindow('https://goo.gl/muppJj', '_blank');
}},
]);
// Useful for console debugging.
window.term_ = term;
}
window.onload = async function() {
await lib.init();
setupHterm();
};
</script>
</body>
</html>