Writing Programs with Ncurses
48 comments
·March 23, 2025cranium
xavierog
> Not gonna lie, it's still not a turnkey solution that transformed my clumsy scripts into a beautiful TUI without work but it's close!
Can you elaborate on that? Are your "clumsy scripts" written in Python, shell or another language? Have you tried Textual-based tools like Trogon [1] and Moulti? [2]
[1] https://github.com/Textualize/trogon [2] https://moulti.run/
cranium
Rereading myself it looks like I'm blaming Textual for being too much work to use but it's not the case! I wanted to say that powerful (T)UIs have inherent complexity coming with the territory: async, events, UI thread, reactivity, render frames, debugging... Works great, but it's UI work on top of the script.
vladsanchez
Wow, I love TUIs but never delved into researching Textualize forks/alternatives.
Thanks a lot for sharing these, especially Trogon, which I think is a clever idea with high ROI.
autoexec
It's kind of crazy how much work it takes to get an interface on the level of ancient software to work on modern systems.
echoangle
It took even more work to get it to work on the ancient systems though, right?
rerdavies
Speaking from experiences, it's kind of amazing how much work you have to do in order to talk to a modern VGA or xterm terminal using ncurses. You really feel each layer of crust that ncurses has accumulated over the entire history of the personal computer since it was first written in order to allow people to play rogue on their personal VT-100 terminals.
Tunneling through the layer of crust accumulated in order to support Unicode (several layers of crust as Unicode evolved) was probably the most interesting of all.
shakna
Turbo TUIs were easy to make. You could make them asynchronous, non-blocking, include sound, and if you were using Borland's C compiler, all of that was built-in for you.
They probably went to efforts to make it work an ancient system. But you really didn't have to.
mbirth
I’ve happily used python-dialog, a wrapper for dialog (and dialog-compatible alternatives) which provides the very basics but is extremely easy to work with.
SoftTalker
Always thought of (N)curses as the conceptual React framework for terminal applications. You tell it what the screen should look like and it figures out how to efficiently write just the changes needed to achieve that on the terminal.
soulofmischief
This is the difference between declarative and imperative design. Frameworks like mithril or React are declarative whereas the DOM is imperative.
codr7
Ncurses has its place, if you're doing a full featured form based app it helps a lot.
That being said, if you're doing something less involved, controlling the terminal via ansi escape sequences is not rocket surgery.
https://en.wikipedia.org/wiki/ANSI_escape_code
https://github.com/codr7/sharpl/blob/main/src/Sharpl/Term.cs
degrees57
I always liked that on SuSE, I had my choice with YaST of either the Ncurses interface or the GUI X Window System. The functionality was identical, but sometimes a GUI is pleasant.
eadmund
> The curses API may seem something of an archaism on UNIX desktops increasingly dominated by X, Motif, and Tcl/Tk.
This sets the document at a particular point in time … in a lot of ways a better point in time.
I really miss the mid-90s computer scene. Things worked, often well, and in comparison to today they were so low-latency!
bashmelek
This is rather timely—I started playing with PDCurses after being inspired by Zed Shaw’s “Rogue is the Best Project”. It has been an interesting experience
matt3210
NCurses is peak ui design
gorjusborg
I mentally bin TUI applications in the same category as 2D video games.
Not all of them are good, but there are way better chances that I like it than the 'other one' (3D game / GUI).
I think the reasons are similar. When you don't have to focus so hard on what it should look like you spend more time on whether it is a pleasure to use.
keyle
If that's the case, the AS/400 terminal was peak UX.
internet101010
AS/400 was definitely peak reliability.
dmd
I agree with that!
jmclnx
Looks good, but curses and I have a hard time.
Ages ago on a mini I use to program, there was a very simple library I could call to format a screen. You told it modifiable field type and its text plus position on the screen. The screen was fixed at 80x24 plus no popups.
I wish there was a simple wrapper for curses like that :)
In the DOS Days, zortech c had a nice set of functions for screen input, disp_*, those were easy for my simple mind to understand to.
MisterTea
I always love the look of a well laid out TUI. In uni there were color IBM terminals everywhere and that bright, colorful UI is burned into my mind.
What I would like is a (n)curses library that uses a graphics back end instead of a TTY, preferably written in Go. I want a GTUI (Graphical-Text User Interface 8-)
Side note, Anyone know a site that curates a list of TUI designs? And not just good ones but examples of bad and weird.
sivanmz
I had a good experience with the Java Lanterna library
didgetmaster
I remember writing something a few decades ago using NCurses. I don't even remember what the program was, but I remember having to go back and forth tweaking the window sizes to make things fit together and look right.
alanjay
Nothing like curses to build an ascii pacman!
DrillShopper
Cracking up at the ghost that gets stuck in the maze wall.
Ncurses has always been on my list of cool things I wanted to learn but couldn't invest the time to actually build something with.
Then I found Textual (Python library, https://textual.textualize.io/) which feels like its modern and prettier child. Not gonna lie, it's still not a turnkey solution that transformed my clumsy scripts into a beautiful TUI without work but it's close!