Skip to content

Commit 9e5fac1

Browse files
committed
Updated web terminal
1 parent 1ffc890 commit 9e5fac1

File tree

6 files changed

+31
-8657
lines changed

6 files changed

+31
-8657
lines changed

app/src/main/assets/web/css/xterm.css

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
*/
3737

3838
.xterm {
39-
font-family: courier-new, courier, monospace;
4039
font-feature-settings: "liga" 0;
4140
position: relative;
4241
user-select: none;
@@ -56,7 +55,7 @@
5655
* The z-index of the helpers must be higher than the canvases in order for
5756
* IMEs to appear on top.
5857
*/
59-
z-index: 10;
58+
z-index: 5;
6059
}
6160

6261
.xterm .xterm-helper-textarea {
@@ -70,7 +69,7 @@
7069
top: 0;
7170
width: 0;
7271
height: 0;
73-
z-index: -10;
72+
z-index: -5;
7473
/** Prevent wrapping so the IME appears against the textarea at the correct position */
7574
white-space: nowrap;
7675
overflow: hidden;
@@ -139,7 +138,7 @@
139138
cursor: pointer;
140139
}
141140

142-
.xterm.xterm-cursor-crosshair {
141+
.xterm.column-select.focus {
143142
/* Column selection mode */
144143
cursor: crosshair;
145144
}
@@ -151,7 +150,7 @@
151150
top: 0;
152151
bottom: 0;
153152
right: 0;
154-
z-index: 100;
153+
z-index: 10;
155154
color: transparent;
156155
}
157156

@@ -162,3 +161,11 @@
162161
height: 1px;
163162
overflow: hidden;
164163
}
164+
165+
.xterm-dim {
166+
opacity: 0.5;
167+
}
168+
169+
.xterm-underline {
170+
text-decoration: underline;
171+
}

app/src/main/assets/web/js/fit.js

Lines changed: 0 additions & 51 deletions
This file was deleted.

app/src/main/assets/web/js/main.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,43 +46,45 @@ window.onload = function () {
4646
var socketURL = protocol + location.hostname + ((port) ? (':' + port) : '');
4747
var socket = new WebSocket(socketURL);
4848

49-
Terminal.applyAddon(fit);
50-
51-
var xterm = new Terminal({ cursorBlink: true, fontSize: getQueryParams('size') });
52-
xterm.open(document.getElementById('terminal'));
53-
xterm.fit();
49+
var terminal = new Terminal({
50+
cursorBlink: true,
51+
fontSize: getQueryParams('size') || 16
52+
});
53+
var fitAddon = new FitAddon.FitAddon();
54+
terminal.loadAddon(fitAddon);
55+
terminal.open(document.getElementById('terminal'));
56+
fitAddon.fit();
5457

5558
socket.addEventListener('message', function (ev) {
5659
blobToText(ev.data, function (str) {
5760
if (!pty) {
5861
var match = str.match(/\/dev\/pts\/\d+/);
5962
if (match) {
6063
pty = match[0];
61-
resizePty(pty, xterm.rows, xterm.cols);
64+
resizePty(pty, terminal.rows, terminal.cols);
6265
}
6366
}
6467
str = str.replace(/([^\r])\n|\r$/g, '\r\n');
65-
xterm.write(str);
68+
terminal.write(str);
6669
});
6770
});
6871

69-
xterm.on('data', function (data) {
72+
terminal.onData(function (data) {
7073
socket.send(textToBlob(data));
7174
});
7275

73-
xterm.on('resize', function (e) {
76+
terminal.onResize(function (e) {
7477
resizePty(pty, e.rows, e.cols);
7578
});
7679

7780
window.addEventListener('resize', function () {
78-
xterm.fit();
81+
fitAddon.fit();
7982
});
8083

8184
// Hot key for resize: Ctrl + Alt + r
8285
window.addEventListener('keydown', function (e) {
8386
if (e.ctrlKey && e.altKey && e.keyCode == 82) {
84-
resizePty(pty, xterm.rows, xterm.cols, true);
87+
resizePty(pty, terminal.rows, terminal.cols, true);
8588
}
8689
});
8790
};
88-

app/src/main/assets/web/js/xterm-addon-fit.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)