Live data from Hacker News

Things I've learned building a modern TUI Framework (2022)

textualize.io

61–70 of 127 posts

Re: Things I've learned building a modern TUI Framework (2022)

#61
post #13

If you're going to run kitty it can do a lot more than that: https://m.youtube.com/watch?v=ft1Q-DwGWIs https://notcurses.com/

I prefer WezTerm over Kitty, because of the Kitty's author attitude towards feature requests and even pull requests. And yes, you can do graphics on both, using the same protocols. If you really need graphics, a terminal is hardly a right solution. It's occasionally useful for tiny stuff like icons though.

Re: Things I've learned building a modern TUI Framework (2022)

#62
post #3

> The first trick is "overwrite, don't clear" This is how games were written back in the day before DirectX was a thing. You'd write directly to the frame buffer and instead of clearing and redrawing, you'd redraw what changed and what was around and under it (because there was no time to refresh the entire view in time in addition to everything else you need to do)

There were at least two other techniques back then.

The first is to write to another buffer (possibly in normal RAM, not video RAM), then when the frame is done copy the whole buffer at once, so every pixel gets changed only once.

The second is to write to another buffer that must be in video RAM too, then change the registers of the graphics hardware to use that buffer to generate pixels for the monitor to show.

They had different tradeoffs. Copying the whole buffer when done was expensive, changing an address register was cheap. But the details of the register were possibly hardware-dependent, and there was no real graphics driver framework in place. Also, to just "flip buffers" (as changing the address register was called), rendering to the off-screen buffer meant sending pixels to video RAM, which was (IIRC) slower to access than normal RAM (basically a NUMA architecture), so depending on how often a pixel gets overdrawn, rendering in normal RAM could be faster overall even with the final copy taken into account.

Re: Things I've learned building a modern TUI Framework (2022)

#63
post #59
post #27

Earlier quoted context omitted.

I guess, mainly because of nostalgia, back from the days TUIs were the only way to interact with computers. Turbo Vision, curses and dialog were cool back in the 1990's. Having started with computers in 1986, I really don't get the TUI fetisch, not even remote access is an issue, given X Windows, VNC, RDP, Citrix,... exist for decades.

Having run X programs over network connections quite a bit, I'd say that they make sense for graphics stuff, and textual interfaces over SSH are significantly more responsive. But once a fixed-width text grid stops being the right tool for the job, it's likely better to have a web UI.

I used xterm for such purposes.

Yes, I do agree the browser is the new X Windows / RDP client, on the modern timesharing systems.

Re: Things I've learned building a modern TUI Framework (2022)

#64
post #17

My big complaint with textual is that it wants to be react. I can see why it would want to be react, that's a very popular framework that a lot of people are already familiar with, but I don't think it's actually a good way of doing user interfaces. But the basic reactive design is a well trod road, and basing your system design on something that's known to work is a great way to derisk the project. Sure, we'll draw…

> Last I tried it, you do have to use CSS. You don't have to use CSS (actually you never did). Every style can be set in code, and the docs have CSS + Python equivalent for every style. > There are no good standard components I guess its been a while since you checked https://textual.textualize.io/widget_gallery/

Yeah, it does seem like things have changed a lot since I last used it, which I think was probably a few years ago. Time flies.

Re: Things I've learned building a modern TUI Framework (2022)

#65
post #58

My big complaint with textual is that it wants to be react. I can see why it would want to be react, that's a very popular framework that a lot of people are already familiar with, but I don't think it's actually a good way of doing user interfaces. But the basic reactive design is a well trod road, and basing your system design on something that's known to work is a great way to derisk the project. Sure, we'll draw…

If you think that react (and FRP in general) is not a good way to build UIs, what is, in your opinion?

I don't agree that React is FRP. FRP is a generic solution that builds data-UI synchronization around data, and assumes that incremental UI updates will be written in UI code. React puts data-UI synchronization code inside UI components and provides an Immediate Mode-like API to avoid writing incremental updates in UI code.

Re: Things I've learned building a modern TUI Framework (2022)

#66
post #62
post #3

> The first trick is "overwrite, don't clear" This is how games were written back in the day before DirectX was a thing. You'd write directly to the frame buffer and instead of clearing and redrawing, you'd redraw what changed and what was around and under it (because there was no time to refresh the entire view in time in addition to everything else you need to do)

There were at least two other techniques back then. The first is to write to another buffer (possibly in normal RAM, not video RAM), then when the frame is done copy the whole buffer at once, so every pixel gets changed only once. The second is to write to another buffer that must be in video RAM too, then change the registers of the graphics hardware to use that buffer to generate pixels for the monitor to show. The…

> But the details of the register were possibly hardware-dependent, and there was no real graphics driver framework in place

Did this change with 3dfx's Glide (or subsequently Direct3D once Windows got a foothold into the gaming industry)?

Re: Things I've learned building a modern TUI Framework (2022)

#67
post #38

Earlier quoted context omitted.

> Textual internally keeps a browser like DOM structure, which means it could in theory offer browser-like support for screen readers while keeping all the features offered to sighted user. But it would require a protocol to allow the app to send structured information so that the screen reader has more to work with than a matrix of characters. Isn't it possible to expose this content via a publicly accessible API th…

De nada! > Isn't it possible to expose this content via a publicly accessible API that screen readers could simply hook into? Definitely possible from a technical standpoint, but I don't know of anyone who has done that. Maybe one day, Textual could provide that solution.

It’s more in the Rust ecosystem but AccessKit looks really promising from this standpoint. I’m not sure if it could work in the context of a TUI but it might be a great starting point! https://github.com/AccessKit/accesskit

Re: Things I've learned building a modern TUI Framework (2022)

#68
post #49

Earlier quoted context omitted.

The state of the art here is to detect mode 2027, and enable it when supported. This lets you know the terminal will handle graphemes properly. I maintain two TUI libraries which use this technique and emoji support has been (nearly) great. (One of which uses your uniseg library!) https://mitchellh.com/writing/grapheme-clusters-in-terminals

really great read, thanks. Im a little disappointed that no terminal emulator both implements the Kitty image protocol, and mode 2027. I wish there would be a terminal project that would just pick the best standards we have at the moment. Im not a fan of sixel for a lot of reasons. Im looking forward to trying Ghostty, though.

wezterm has both according to the above article

Re: Things I've learned building a modern TUI Framework (2022)

#70

Why do software engineers care so much about TUI? I really don't get it. I love a good command line program. But TUI just doesn't appeal to me.

There isn't much obvious benefit in using TUIs, but writing TUIs has a big upside: it's easier in most ways. It's trivially cross-platform, you don't have to make pixel-perfect GUIs (because it's impossible), you don't need icons or graphics (because you can't show graphics), etc.
Post reply on HN