hterm vs xterm.js

posted 2017-11-05, filed under "piece of shit"

many people throughout the ages have wondered “why the fuck does a terminal emulator exists that is written in javascript.” after realizing that javascript is widely used for things it should never be used for they then wonder “which terminal emulator written in javascript should i use in my build of chrome with no toolbar which is configured to load a specific bundled page of mine on startup which i’m telling people is a desktop app.” i’ve created this page in the hope that it will help you make this decision, as it sort of did for me.

both terminals are shown here with entirely default settings and with all input echoed directly to output. the result is you can type over stuff for as long as you want, when you get to the end it wraps around, when you press enter it goes to the beginning of the line, and you can move the cursor using the arrow keys, since thanks to a happy coincidence the character sequence send when you press the arrow keys is the same as the escape sequence that moves the cursor.

hterm

hterm was written by google, therefore it has to be the best. NO THAT’S NOT TRUE AT ALL. google loves to write every single thing they use from scratch. for example, they don’t use npm. on the one hand this is good because npm and everything that surrounds it is really fucking annoying. on the other hand this is bad because everything not written by google is on npm and after a bit of pain ends up working reasonably well with everything else on npm. you will not be able to find an up to date version of hterm on npm. enough said.

that said, hterm doesn’t put whitespace where nothing has been written at all, so selection behaves a little more sanely than xterm.js. i have no idea if you care about that, in fact you probably don’t.

xterm.js

xterm.js on the other hand is a fork by a faceless entity of a thing written by a random guy. all parties involved like npm and use it for things. in fact, xterm.js’s readme literally says “we ship exclusively through npm.”

i’ve heard from around that it is better at chinese, japanese, and korean than hterm. i have no idea if this is true since i do not speak chinese, japanese, or korean.

it uses a textarea for all keyboard input instead of key events, and defines focus on the terminal as focus on the text area. this is annoying if what you want to do is use xterm.js in an ios app, and write your own native input code. the terminal will not render as focused unless the textarea is focused, and if the textarea is focused the webview is first responder instead of your custom view. monkey patching can fix this, but MONKEY PATCHING IS BAD or something so i don’t know really if i want to do that.