💾 Archived View for dioskouroi.xyz › thread › 29450900 captured on 2021-12-05 at 23:47:19. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Hacking the planet with Notcurses: a guide to TUIs (2020) [pdf]

Author: Tomte

Score: 120

Comments: 27

Date: 2021-12-05 17:26:10

Web Link

________________________________________________________________________________

akkartik wrote at 2021-12-05 21:30:50:

From page 8:

_"We don’t switch from blue to some other specified color, because we don’t know the background color of the

terminal. Some people, possibly aliens, don’t favor a dark terminal background. If the terminal background

were white, and we had just used e.g. ncdirect_fg(n, 0xffffff), text following “house” would be invisible._

_"One might observe that a user with a blue background will have invisible “house” text. This is a real issue,

one lacking a perfect solution. It is not generally possible to discover the RGB values of the default colors.

I suppose all one can do is rest easy, serene in the belief that white backgrounds are one thing, but people

with chromatic backgrounds deserve whatever happens to them."_

That's a lot of cognitive dissonance in a work about UI design. Let's try to do better in making TUIs mainstream. That requires encouraging people to use the few features terminals _do_ provide. Like chromatic backgrounds.

I've been doing a fair amount of ncurses hacking recently[1], and I prefer to always explicitly specify colors. People won't get their preferred colors by default, but they'll always get a legible configuration by default.

[1]

https://github.com/akkartik/teliva

dankamongmen wrote at 2021-12-06 04:12:34:

WITH THAT SAID, Notcurses can now acquire the default background from the terminal (this was not true when I wrote the book, sigh), and I fully support @akkartik's approach given this fact. Using NCALPHA_HIGHCONTRAST together with explicit reproduction of the user's chosen background is a complete and general solution to this problem, and I really ought update the book. Thanks, @akkartik!

akkartik wrote at 2021-12-06 04:42:05:

<3 TUI FTW

paulryanrogers wrote at 2021-12-05 21:35:51:

This same problem has plagued the web for decades. I used to change default colors to ease my eyes, and whenever foreground CSS lacked a background color it often became impossible to read. Accessibility modes came soon after but were too binary for me.

These days we have dark modes and more elaborate extensions. Still sometimes things don't align.

So thanks for at least specifying both.

akkartik wrote at 2021-12-05 21:41:02:

Yeah, it's a hard problem, and I liked that OP acknowledged that. But I liked less how it made a virtue of the bad situation. There's really no way to rest easy or be serene here.

gadrev wrote at 2021-12-05 19:47:11:

Ok, if you're looking into notcurses, you may want to watch this:

https://www.youtube.com/watch?v=dcjkezf1ARY

(~ 6')

the WTF effect that video had on me lasted quite a while.

I still can't describe it.

dankamongmen wrote at 2021-12-06 04:20:30:

that makes me so happy to hear. you have no idea how much of a pain in the ass that video was to make, lol--i'm really glad to hear it's been effective in carrying forth The Message.

i'm working on a new one now which is going to be some absolute Wizard of Oz shit; stay tuned. =] hack on!

actually_a_dog wrote at 2021-12-05 20:34:57:

Nice! This really makes me want to play with notcurses. :) BTW, did you notice the image of a coronavirus in there?

marcodiego wrote at 2021-12-05 19:15:35:

Curses and notcurses have their place but I still miss the simplicity of borland's conio.h implementation. Also remember that visual basic was initially written for DOS. Having a open source multiplatform text mode visual basic would be interesting.

cout wrote at 2021-12-05 20:39:20:

AFAIK vbdos came after the Windows version. It was fun to play with but a little slow.

michaelsbradley wrote at 2021-12-05 19:44:24:

Not exactly what you’re describing, but check out Final Cut:

https://github.com/gansm/finalcut

marcodiego wrote at 2021-12-05 20:02:35:

Screenshot are cool! I remember someone had maintained the open source implementation of turbo vision. I don't hear about it for a long time, so I think it was abandoned and it had to make a few changes to workaround turbo vision unsafeness. This one seems cool!

michaelsbradley wrote at 2021-12-05 20:23:25:

A modern port of Turbo Vision 2.0:

https://github.com/magiblot/tvision

ripley12 wrote at 2021-12-05 19:35:04:

I’ve been reading this recently to get up to speed with Notcurses, it’s fantastic. Funny, engaging, and a surprisingly good general overview of how terminals work.

One thing to note: it was written for an older version of Notcurses. So some of the details aren’t 100% up to date, but it covers the fundamentals.

gorgoiler wrote at 2021-12-05 20:16:45:

Happy was the day I gave up on curses and just started splatting crap at the terminal with my own control codes.

For too long did I think that curses was the one and only way to do anything with a terminal.

slicktux wrote at 2021-12-06 03:55:10:

Care to elaborate on the control codes over curses?

I’m curious :]

gorgoiler wrote at 2021-12-06 04:24:01:

At its simplest, manage screen state yourself and redraw it by moving the cursor and colouring with ANSI codes:

https://gist.github.com/fnky/458719343aabd01cfb17a3a4f729679...

Turning the cursor on and off, 24 bit color, etc. A lot is possible though you potential sacrifice portability (which in 2021 translates to “don’t expect your stuff to render properly if your at the Linux console, and everywhere else it is fine.”)

shakna wrote at 2021-12-06 04:22:59:

I 'maintain' a shell script/library that can do a lot of the basic things like color controls, control getch, move the screen cursor, etc. [0]

Taking a peek under covers to see how easy it is. A couple printfs from whatever language is way way less overhead than bundling in the whole of curses.

[0]

https://git.sr.ht/~shakna/damned

akkartik wrote at 2021-12-05 23:44:17:

Yes, it's unquestionably always good to know how things work.

rsync wrote at 2021-12-05 23:56:24:

Somewhat related ...

Is there a proper name for a "top-like interface" ?

I _think_ that "TUI" refers very broadly to any terminal user interface and both 'vim' and 'alpine' and 'top' would fall under this broad category.

But is there a specific name for a refresh-every-second, full page status output - like 'top' ?

Is there a standard library for creating such an interface, or do people always use curses ? Presumably curses did not exist in the early 80s when 'top' was first written ...

throwawayboise wrote at 2021-12-06 01:30:29:

Very crudely, on linux you can do that with almost any CLI progam and the "watch" utility.

michaelsbradley wrote at 2021-12-06 00:28:43:

TUI generally refers to a program that’s “full screen” with respect to the terminal it’s running in.

Programs that don’t drive the whole terminal screen, instead generating output that may be mixed with other output in the same terminal, are often referred to as CLIs.

curses dates back to around 1980:

https://en.wikipedia.org/wiki/Ncurses#History

rsync wrote at 2021-12-06 03:48:17:

I guess but ... again, 'vim' or 'alpine' are very different than a constantly updating status like 'top'.

I guess I'll just keep calling it a "top-like interface".

michaelsbradley wrote at 2021-12-05 19:42:26:

The author of Notcurses released version 3.0.0 several days ago, a ton of work went into that!

https://github.com/dankamongmen/notcurses/releases/tag/v3.0....

3np wrote at 2021-12-06 02:56:07:

These release notes are such a joy to read.

dankamongmen wrote at 2021-12-06 04:10:56:

thank you; i take pride in my documentation =]. and it's a lot of work; one ought have fun in the places you can.

nickdothutton wrote at 2021-12-05 20:24:35:

We have to go back.

entelechy0 wrote at 2021-12-05 19:17:23:

TIL of notcurses

"Notcurses is licensed under Apache2, a demonstration that I have transcended your petty world of material goods, fiat currencies, and closed sources. Implement Microsoft Bob in it. Charge rubes for it. Put it in your ballistic missiles so that you have a nice LED display of said missile's speed and projected yield; right before impact, scroll "FUCK YOU" in all the world's languages, and close it out with a smart palette fade. Carve the compiled objects onto bricks and mail them to Richard Stallman, taunting him through a bullhorn as you do so."

This inspires me