News: 0000815475

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Hacking the planet with Notcurses

([Development] Mar 19, 2020 18:38 UTC (Thu) (corbet))


Author Nick Black has written an extensive book on the creation of textual user interfaces using the notcurses library; it's [1]available under the Apache license [PDF] . " Many people asked how such a thing was useful. My usual response was that numerous devices don’t present a bitmap interface, that X11 GUIs run remotely over SSH are effectively unusable, that plenty of machines don’t have a GUI environment installed, that there are obvious applications for large outdoor displays, and that Sixel isn’t well-supported across different terminal emulators. It seems impossible in an age of gigatransistor graphics cards, but the text environment still presents perceivably less latency than most GUI toolkits. "



[1] https://nick-black.com/htp-notcurses.pdf

Hacking the planet with Notcurses

For the readers that would like to use the mouse under the Linux console, I can offer some [1]consolation .

[1] https://salsa.debian.org/consolation-team/consolation/

Hacking the planet with Notcurses

For the readers that would like to use the mouse under the Linux console, I can offer some [1]consolation .

[1] https://salsa.debian.org/consolation-team/consolation/

questionable licence combination

The book starts with a picture under “CCASA4” licence. This is probably CC-BY-SA 4.0, but the “SA” in it kinda means copyleft.

This generally means that the book, as derived work, has to be under CC-BY-SA 4.0 or later. If any provisions of the Apache 2 licence are incompatible with that (the NOTICE file one might be a candidate, but I didn’t analyse this in detail), the result is illegal and nōn-distributable…

Also wondering what the “notcurses” library is. Turns out it’s been written by the author of the book, and it isn’t even packaged in Debian. Perhaps this is an attempt at getting publicity.

On the flip side, kudos for bringing more eyes on terminal programs.

Hacking the planet with Notcurses

I love text-based graphical interfaces. I've stayed for many years on Windows because of FAR Manager ( [1]https://www.farmanager.com/screenshots.php?l=en ). I've tried to do something like it on Linux but got severely disappointed. It just didn't work at all.

First, input in text mode is screwed up. For example, FAR Manager changes the bottom bar when I press "shift", "ctrl" or "alt". This is not possible in Unix terminals, as they don't transmit modifier key states, only key presses. There's also no way to distinguish between key up/key down events. You need to go out of your way to get special events for the numpad keys (FAR used "+" key on numpad for file selection, for example). Mouse is completely fucked up. And so on.

But this is all tolerable. You can make do with emacs-style key chords in the worst case. Whatever.

The main problem for me turned out to be the fact that terminal in Unix is a fucked up mess. It started its life as a way to interface with literal line printers and barely grew since then. The protocol is entirely unidirectional (from application to the terminal emulator) as a result, and there is no way to get feedback from the terminal emulator back to the application.

This turned out to be lethal for a fluent text-based shell like FAR. If I tried to launch arbitrary programs from inside of it, it was way too easy for them to mess up the terminal state completely. I found that even trying to reset everything doesn't always work (resize events and mouse also complicated things).

I then tried to go with the terminal emulator within terminal emulator approach that screen/tmux use (I actually used tmux as my display layer). This actually worked fairly well, creating a robust layer that allowed me to at least guarantee that I can guarantee that my program's internal state corresponds to what is actually on the screen. Unfortunately, this approach fundamentally messes up the scrollback in terminal which I consider to be critical. It also was a bit bandwidth-heavy (for 2006).

I've been on a lookout for projects that try to improve text UI experience on Linux, but nobody seems to be working on the really fundamental terminal emulation layer.

As of now, I'm supporting iTerm2 on Patreon as it seems to be the only project that tries to do something about the basic terminal emulation layer. Its direct tmux support is not perfect, but it's probably something that can be evolved into a next-gen terminal emulation experience.

[1] https://www.farmanager.com/screenshots.php?l=en

Mummy dust to make me old;
To shroud my clothes, the black of night;
To age my voice, an old hag's cackle;
To whiten my hair, a scream of fright;
A blast of wind to fan my hate;
A thunderbolt to mix it well --
Now begin thy magic spell!
-- Walter Disney, "Snow White"