mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 20:26:48 +00:00
build: xterm 6.0.0 for the serial console
@xterm/xterm 6.0.0 and @xterm/addon-fit 0.11.0 replace xterm 3.6.0; the page reads typed and pasted input with onData, and no longer writes every key and all terminal output to the browser console. The unused fullscreen addon goes.
This commit is contained in:
parent
f5ec757d1a
commit
9b0c6e2d8e
11 changed files with 153 additions and 8709 deletions
|
|
@ -5,9 +5,8 @@
|
|||
{% block head %}
|
||||
<title>WebVirtCloud - XTerm</title>
|
||||
<link rel="stylesheet" href="{% static 'css/xterm.css' %}"/>
|
||||
<script src="{% static 'js/xterm@3.6.0/xterm.js' %}"></script>
|
||||
<script src="{% static 'js/xterm@3.6.0/addons/fit/fit.js' %}"></script>
|
||||
<script src="{% static 'js/xterm@3.6.0/addons/fullscreen/fullscreen.js' %}"></script>
|
||||
<script src="{% static 'js/xterm/xterm.js' %}"></script>
|
||||
<script src="{% static 'js/xterm/addon-fit.js' %}"></script>
|
||||
|
||||
<script src="{% static 'js/socket.io.js' %}"></script>
|
||||
|
||||
|
|
@ -20,8 +19,6 @@
|
|||
|
||||
<div style="width: 100%; height:100%;" id="terminal"></div>
|
||||
<script crossorigin="anonymous">
|
||||
Terminal.applyAddon(fit);
|
||||
|
||||
let host = readQueryVariable('host', '{{ socketio_host|escapejs }}');
|
||||
let port = readQueryVariable('port', '{{ socketio_port|escapejs }}');
|
||||
let path = readQueryVariable('path', '{{ socketio_path|escapejs }}');
|
||||
|
|
@ -47,16 +44,17 @@
|
|||
var term = new Terminal({
|
||||
cursorBlink: true,
|
||||
});
|
||||
var fitAddon = new FitAddon.FitAddon();
|
||||
term.loadAddon(fitAddon);
|
||||
|
||||
term.open(document.getElementById('terminal'));
|
||||
|
||||
term.on('key', (key, ev) => {
|
||||
console.log("pressed key", key)
|
||||
socket.emit("pty_input", {"input": key})
|
||||
// typed and pasted input
|
||||
term.onData((data) => {
|
||||
socket.emit("pty_input", {"input": data})
|
||||
});
|
||||
|
||||
socket.on("pty_output", function(output){
|
||||
console.log(output["output"])
|
||||
term.write(output["output"])
|
||||
})
|
||||
|
||||
|
|
@ -81,7 +79,7 @@
|
|||
}
|
||||
|
||||
function resize(){
|
||||
term.fit()
|
||||
fitAddon.fit()
|
||||
socket.emit("resize", {"cols": term.cols, "rows": term.rows})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue