lxd-demo-server
lxd-demo-server copied to clipboard
Switch to xterm.js
It is impossible to copy/paste instructions into Try it online
console to try things. Context menu doesn't work for this either.
That's why I made it so you can click on any of the commands in the instruction to have it executed into the terminal session.
The javascript terminal library we're using doesn't do so well with copy/paste and I'm not sure that they'll be making much progress on that.
linuxcontainers.org website uses term.js: https://github.com/chjj/term.js
This is not maintained anymore, and as mentioned on the github page, the official successor is: https://github.com/sourcelair/xterm.js
In lxd-webgui, i just exchanged term.js with the sourcelair xterm.js. Everything still worked perfectly, and i had paste support with ctrl-shift-v.
https://github.com/dobin/lxd-webgui/commit/14c4b74bbc738192e65cf3064f13ca390365f9fa
So I just tried to replace term.js with xterm.js and rendering is completely broken...
So if either of you want to volunteer to port github.com/lxc/linuxcontainers.org from term.js to xterm.js, I'd certainly appreciate it. Note that validating the setup is always a bit tricky and it took me a couple of weeks to get term.js to render perfectly on all the setups we care about:
- Chrome on Linux
- Chrome on Windows
- Chrome on Android phone
- Chrome on Android tablet
- Firefox on Linux
- Firefox on Windows
Especially making sure the things render properly in both very wide windows (fullscreen) and very narrow ones. Some of the font-sizing logic needed a fair amount of tweaking to convert the available screen estate in pixels to the number of columns for the terminal.
I'll have a look, as I anyway want to use lxd-demo-server for a private project.
I see that https://github.com/sourcelair/xterm.js is pretty active, so there are chances to fix rendering bugs upstream if somebody is going to report that. Are there any tests to check that is renders perfectly?
Well, I'm not sure that it's an actual upstream bug. It's just that @dobin said that it worked as a drop-in replacement for him, which it didn't for me and suggests there are a bunch of javascript and css changes I'd have to do to get things back to working order.
I don't believe that they pretend to be exactly compatible with term.js, though they mostly are since it's effectively a fork.
If it is a terminal, then all you need is a websocket for stdin and stdout of controlling terminal, which is the browser. Right?
Here is the alternative officially tested and maintained by Chromium team https://chromium.googlesource.com/apps/libapps/+/master/hterm/doc/ChangeLog.md and how to embed https://chromium.googlesource.com/apps/libapps/+/master/hterm/doc/embed.md