Ask HN: Recommendations for Good TUI Libraries (Text User Interface)?
Anyone seen anything exciting/interesting in the field of TUI's? Any language, as long as the library is interesting with good examples or screen shots/videos.
For those unfamiliar, a TUI is a text mode user interface library, for building user interfaces within character oriented plain text consoles.
63 comments
[ 4.1 ms ] story [ 126 ms ] threadhttps://github.com/dheera/python-termgraphics
I used it in ROSshow, which visualizes robot sensor data inside a terminal:
https://github.com/dheera/rosshow
Terminal.Gui - Terminal GUI toolkit for .NET
https://github.com/migueldeicaza/gui.cs
Written by Miguel de Icaza.
Hanselman wrote on it here:
https://www.hanselman.com/blog/Its2020AndItIsTimeForTextMode...
and here:
https://www.hanselman.com/blog/DotnetDependsIsAGreatTextMode...
I can't recall exactly what my issue was with it however, it has been a few months.
Other/better .NET libraries include:
https://github.com/spectresystems/spectre.console
https://github.com/TomaszRewak/C-sharp-console-gui-framework
https://github.com/elw00d/consoleframework
Edit: found one https://github.com/vinibiavatti1/TuiCss
[0]: https://github.com/prompt-toolkit/python-prompt-toolkit
[1]: https://click.palletsprojects.com/en/7.x/
[2]: https://www.pgcli.com/
https://en.wikipedia.org/wiki/Turbo_Vision
From the developer's perspective, it was a joy to work with. I made some projects using pascal and C++ if I remember correctly.
Liked using this. I wrote a TUI for my company's api with it. I dont use the website much any more.
I was a beginner Haskell programmer when I first used brick, and it's great exposure to building a real world application (something a lot of Haskell beginners crave learning). Docs are very good too.
Code for anyone that might find it useful: https://github.com/2mol/pboy
edit: forgot to mention that it's very "Elm architecture", so if you like modern frontend development, then you might feel right at home in that paradigm.
[1] https://aerc-mail.org/
[2] https://git.sr.ht/~sircmpwn/aerc
https://github.com/gdamore/tcell/
https://github.com/rivo/tview
https://gitlab.com/tslocum/cview
Here are some examples how it can look in action: https://github.com/peterbrittain/asciimatics/wiki
It is immediate mode so you render the entire UI every tick, though it is smart enough to not actually redraw things that didn't change.
[0] https://blog.repl.it/clui
https://github.com/vadimdemedes/ink for writing TUIs with react. Here's a project I wrote using that: https://github.com/zephraph/solitaire. It's not as powerful as ncurses, but it works rather well.
If you want something more on par with ncurses try https://github.com/cronvel/terminal-kit
This is the one that most catches my attention.
Currently actively maintained plus it has something analagous to a document object model https://github.com/cronvel/terminal-kit/blob/master/doc/docu...
Also Ink is incredibly interesting as it enables ReactJS for creating TUI apps - mind bending!
https://github.com/vadimdemedes/ink
I can imagine the things above being combined with a sandbox plus Fabrice Bellard's QuickJS https://bellard.org/quickjs/ into a new type of application ..... the "pure text mode browser".
A "pure text mode browser" would not be designed to render ordinary HTML web pages, but would instead be a minimal browser designed only for text mode.
This would be a browser that targets only text mode user interfaces. So pages would need to be written specifically to be rendered in such an environment.
Why? Because text mode browsers are really trying to do the impossible - to render modern web pages as text is essentially not doable in all cases. Instead make a browser for the text mode use case specifically designed for the medium.
A mashup of a web browser and ANSI/VT100/teletext. It would need a sandbox and a JavaScript interpreter.
Maybe call it the "Trowser".
https://en.m.wikipedia.org/wiki/Gopher_(protocol)
There was a sliver of time in the 1990s, in academic settings, where it was very easy to get onto an Internet-connected Unix computer, but before HTML existed. There were many plain text Internet applications.
Also check out the list of applications built with Urwid [2]. Probably the two most popular applications that use Urwid are bpython [3] (an alternative Python REPL that is really nice), and PUDB [4] (a nice Python debugger that is reminiscent of Borland's Turbo Pascal). I use bpython all the time, it's a lifesaver, and I occasionally fire up PUDB when I am really stuck on something.
I've used Urwid in a couple of projects (most notably Zeitzono [5]), it's nice in that it's fairly high level and gives you a number of helpful widgets to work with. Starting with it from scratch is a little daunting, so you should look at existing projects to see how they are using the library. Also, I believe Urwid development has slowed down somewhat in the last few years (although other folks maybe stepping up to take over from the original author, I haven't follow up on this in a while).
Also definitely take a look at Python Prompt Toolkit [6]. They started off as library for writing line-oriented command interpreters, but now can also be used for building full screen applications. I've not yet built an application using it, but it looks really good and is actively developed. ptpython [7] is a REPL built using this library and gives bpython a run for its money.
[1] https://pypistats.org/packages/urwid
[2] https://github.com/urwid/urwid/wiki/Application-list
[3] https://bpython-interpreter.org/
[4] https://github.com/inducer/pudb
[5] https://zeitzono.org/
[6] https://github.com/prompt-toolkit/python-prompt-toolkit
[7] https://github.com/prompt-toolkit/ptpython
I realize, with abit of shame, urwid is thousands of times more popular than my own pip-chill tool.
Either way, it is an extremely minimalistic library that has well documented code, so it's very possible to tailor it to whatever needs you have.
The terminal is not meant to be existing. You are emulating 80 year old technology at the base of it.
http://xn--rpa.cc/irl/term.html
Here's how it starts:
"so here's a short tutorial on ansi escape codes and terminal control, because you philistines won't stop using ncurses and oh my god WHY ARE WE STILL USING NCURSES IT IS THE TWENTY FIRST FUCKING CENTURY"
- [commanderjs] lets you easily build ergonomic CLI apps (wires up --help and usage descriptions) --- https://github.com/tj/commander.js/
- [chalk] colors in the terminal --- https://github.com/chalk/chalk
- [figlet] big splash text --- https://www.npmjs.com/package/figlet
https://ifcomp.org/comp/2019
Two libraries for writing these games:
https://en.wikipedia.org/wiki/Inform
https://en.wikipedia.org/wiki/TADS