12 ms·
Writing Programs with Ncurses
- CJefferson 5y agoWhile discussing ncurses, has anyone ever seen any attempt to make accessible interfaces? Nowadays when making a quick interface I tend to use a web-based interface -- while they are much heavier it's fairly easy to make fully blind accessible interfaces, I (very briefly) looked to see if any terminal based libraries supported anything similar, and the only thing which seems to be trying is emacs, with emacsspeak (which I've heard good things about but haven't tried, as I'm not an emacs user).
- caf 5y agoI have met some blind users who were using terminal-based IRC clients. I believe they were using the scripting interface to assist in integrating it with their input/output hardware.
- tyingq 5y agoIt would be nice if curses programs all had a standard keymapping or signal that would invoke one of curses screen dump functions. Lacking that, a screenreader would have to jump through a lot of hoops to even know what's on the screen. I suppose you could use tmux instead...it seems to be able to dump the current screen. Either way, still a lot of work to do after you have the raw data.
- tspivey 5y agoYou don't need to dump the screen, the screen reader takes care of letting you explore the screen by line, word, character, etc. Some curses programs work reasonably well with screen readers (e.g. Mutt and WeeChat). One useful way to make them more accessible is to put the hardware cursor somewhere useful, even if hidden. Mutt puts it on the same line as the currently-selected message, and if braille_friendly is set, onto the first line of message content when opening one. WeeChat puts it on the input line. Where this goes wrong is when trying to use fset, where I have no way to move it to the list of options.
- zozbot234 5y ago> One useful way to make them more accessible is to put the hardware cursor somewhere useful, even if hidden. You should be doing this anyway to account for hardware terminals where the cursor is always visible, including the traditional VGA/VESA text console that still gets used by default on PC hardware.
- caf 5y agoCan you give any more guidance on what might constitute "somewhere useful"? Is the hardware cursor position the default place to start reading from?
- tspivey 5y agoSomewhere useful depends on the app. In an editor, it's the line of text I'm editing. In a file manager, it's the currently focused file. The hardware cursor is where it will start reading when I press read current line, word, etc.
- caf 5y agoThat makes sense. It's a little harder to determine where it should go for something like a chat client where the UI changes asynchronously.
- deleted 5y ago[deleted]
- ho_schi 5y agoI love TUIs. They are clear, quick and easy to use. Probably because they require straightforward design. I just read the following links to build up foundation of knowledge first - low-level: http://%CA%9E.cc/irl/term.html http://%CA%9E.cc/irl/term.html https://viewsourcecode.org/snaptoken/kilo/02.enteringRawMode.html https://viewsourcecode.org/snaptoken/kilo/02.enteringRawMode... https://en.wikipedia.org/wiki/ANSI_escape_code#Colors https://en.wikipedia.org/wiki/ANSI_escape_code#Colors Other libraries: # C, C++, Python and Rust https://github.com/dankamongmen/notcurses https://github.com/dankamongmen/notcurses # Python, more polished presentation - but I cannot judge the technical foundation https://github.com/willmcgugan/rich https://github.com/willmcgugan/rich
- nix23 5y agoTrue, i worked in a insurance company, the main CRM was a TUI with a Mainframe in the background, fast and reliable as hell/heaven. Then everyone (Management) wanted to go away from mainframe (because it's 60's technology and expensive), so we developed a Java application with a GUI and Oracle in the background..and i was just ashamed about the whole project when it was finished. It was slower for the user, less reliable and counting the dev-cost would gave us 10years of "free" mainframe-time.
- tyingq 5y agoI had a similar experience. And it would have been simple to pay attention to tab traversal, field highlighting, key bindings, etc, to have made the new application more familiar and faster. Wasn't to be though.
- sseagull 5y agoSimilar experience (as a user) at a medium-sized college. The information system (class registration, bursar, etc) could be accessed via a TUI over telnet/ssh. It was amazingly fast, and all the older professors could move around that thing fast as hell, since all the shortcuts were in muscle memory. Force-adding a student to a class could literally take <5s if they had all the numbers. Students could use it, too. And those of us who knew about it would do so, since it was so much better. Then the web frontend came out…
- ivanalejandro0 5y agoI can't access the site... Access Denied - Sucuri Website Firewall Block reason: Access from your Country was disabled by the administrator. In case someone else experience the same and wants an alternate link: http://web.archive.org/web/20210531163620/https://invisible-island.net/ncurses/ncurses-intro.html http://web.archive.org/web/20210531163620/https://invisible-...
- tyingq 5y agoI don't know why that WAF is in front of it, but there seems to be an intentionally maintained mirror that doesn't have the Securi headers: https://invisible-mirror.net/ https://invisible-mirror.net/ So, the mirrored copy of this article would be: https://invisible-mirror.net/ncurses/ncurses-intro.html https://invisible-mirror.net/ncurses/ncurses-intro.html
- livre 5y ago> Block reason: Access from your Country was disabled by the administrator. Thanks for that mirror, I occasionally use the lynx web browser that is also hosted there and being blocked has always been a problem.
- ToddWBurgess 5y agoHearing the word ncurses brings back memories of second year computer science for me. Once upon a time. In a galaxy far far away
- gonzus 5y agoI have looked into this in the past, and have always felt discouraged by the lack of good support for modern keyboards and mice. With ncurses and similar, you can only detect (a subset of) keys modified by Ctrl and Alt; I would like a portable way of finding about multiple combinations of modifiers, with any key in the keyboard, including function keys, home, end, up, down, etc. Ideally, I would also like to detect mouse events (including "window" clicked position) and even mouse events when holding Ctrl, Alt, etc. And I would like to do all this without having to parse multiple escape codes, implement timers or whatnot. https://sw.kovidgoyal.net/kitty/keyboard-protocol/ https://sw.kovidgoyal.net/kitty/keyboard-protocol/ is a very promising step on this direction. Maybe next time I have to work on a TUI I will look into it.
- randomswede 5y agoI think part of it is that what good is your TUI if it doesn't work with, you know, a terminal, hooked up on a serial port? Where you will be unable to have anything but "shifted" and "control" characters easily recognisable. Some terminals did have a "meta"-equivalent key that simply forced the highest bit on, making them INSTANTLY incompatible with anything but US ASCII. Sure, you can write a TUI library that allows you to interact with "idealised terminal of choice", but I'd prefer one that works with one of the serial terminals I actually have, somewhere, around the place.
- ivars 5y agoAny examples of modern apps with rich terminal GUI?
- michaelsbradley 5y agoTake a look at the latest Notcurses demo video to see what that library makes possible: https://www.youtube.com/watch?v=dcjkezf1ARY https://www.youtube.com/watch?v=dcjkezf1ARY https://notcurses.com/ https://notcurses.com/
- _benj 5y agonot sure how you define modern but things like neovim, neomutt and ranger come to mind. I enjoy r/unixporn (it's actually sfw), they LOVE console apps there, everything from music to email to file manager to everything console! There are also a few modern terminal emulators that are doing some pretty fun stuff with the terminal, some examples are alacritty, kitty and hyper
- gspr 5y agoI love mu4e. I don't know if running in Emacs qualifies as "terminal GUI" though. https://www.djcbsoftware.nl/code/mu/mu4e.html https://www.djcbsoftware.nl/code/mu/mu4e.html
- stjohnswarts 5y agoIt certainly qualifies. TUI stands for text UI not terminal UI
- dankamongmen 5y agotake a look at growlight: https://github.com/dankamongmen/growlight https://github.com/dankamongmen/growlight
- epilys 5y agoI don't know if it counts as rich, but I rolled my own terminal UI in my email client meli [0]. There's a web demo here: https://meli.delivery/wasm2.html https://meli.delivery/wasm2.html that is the client compiled to webassembly and the ANSI escape codes translated to equivalent SVG drawing so that you can try it on your browser. [0] https://github.com/meli/meli/ https://github.com/meli/meli/
- bo1024 5y agoOne really nice thing about ncurses (which I used in python to make an email user agent) —- you can run ncurses apps in an ssh session.
- ape4 5y agoThe "n" in "ncurses" is for new. Its not so new any more ;)
- CobrastanJorji 5y agoThis naming problem is not specific to programming. The name "Carthage," for example, is derivative of Phoenician for "new city."
- taviso 5y agoThat's funny, I had this tab open this weekend while I was trying to make a silly terminal game, where each sprite is an ncurses window. I didn't really make much progress, but got the physics and sprite drawing working. https://lock.cmpxchg8b.com/img/ncurses.gif https://lock.cmpxchg8b.com/img/ncurses.gif
- fit2rule 5y agoKeep going!
- dmux 5y agoPlain old HTML + forms can go a long way when accessed through the Lynx or w3 web browsers. I think the first time I encountered a system where this was the preferred path was in Kannel [0]. https://kannel.org/download/1.4.5/userguide-1.4.5/userguide.html#AEN993 https://kannel.org/download/1.4.5/userguide-1.4.5/userguide....
- _benj 5y agoI've never thought about this! I tried to write a simple TUI with ncurses, but it turned anything but simple real quick! I don't think that this is inherent to ncurses but to any UI programming. Keeping state on the UI can be "simple" until is not. Thanks for the idea, I'll give it a try!
- dankamongmen 5y agowhy merely write programs with NCURSES when you can hack the planet with notcurses? enjoy the free book: https://nick-black.com/htp-notcurses.pdf https://nick-black.com/htp-notcurses.pdf
- codedokode 5y agoI don't like text UIs. They try to emulate GUI but do it poorly. You should either make a classic console program, that can be scripted, piped, etc., or a real GUI.
- 10000truths 5y agoSame here. Never liked using console text editors, in particular. When editing remote files, I always prefer using something like sshfs/WinSCP + Sublime Text.
- ComputerGuru 5y agoHard disagree. What’s wrong with htop? Do you propose installing a full desktop environment on your servers and then using X forwarding just to monitor live CPU usage? It’s just a live-refreshing ps. With colors to make it easier to grok at a glance. Then making it slightly interactive so you can click on column headers with the mouse to sort accordingly?
- stjohnswarts 5y agoEh there is plenty room for all gray areas of tui. You are talking about CLI and not TUI, completely different world. TUI is great if you work remote and can present a lot of information quickly in such situations. Plus some people prefer them and that's all it really requires for there to be some awesome TUI programs. All you really have to do is ignore them if you don't like them.
- veddox 5y ago> They try to emulate GUI but do it poorly I dispute that point. Firstly, because TUIs and GUIs were developed pretty much in parallel, as far as I‘m aware. But secondly (and more importantly), because TUIs fill a different niche and follow a different philosophy to GUIs. TUIs are primarily intended for environments where GUIs are either not available (e.g. SSH), unnecessary (e.g. servers), or overkill (e.g. very old computers). In terms of design and UX philosophy, they are much more concentrated on keybased rather than mousebased interaction, and bring their own set of conventions that are markedly different from GUI design philosophy. So, while you are entitled not to like TUIs (they can be difficult to work with), calling them a bad emulation of GUIs really misses the point.
- floor_ 5y agoI wish there was a list of all the quirkiness of ncurses back when I wrote a win32 port of it for a game.
- incanus77 5y agoI had always wanted to write something in this and got my chance last year when I finally decided to write a utility for Safari tab management: https://github.com/incanus/fari https://github.com/incanus/fari Since then, however, I’ve switched to the Min browser. But it was super empowering to make a console-based interface and I’m looking forward to trying it again soon.
- CyberShadow 5y agoFor whatever reason, my country is banned from accessing this website. https://dump.cy.md/7065a236c07f22558d3f1422c986a243/1630343129.713585664.png https://dump.cy.md/7065a236c07f22558d3f1422c986a243/16303431...
- jmclnx 5y agoI checked your country, very odd to me. Maybe try this link https://webcache.googleusercontent.com/search?q=cache:6a4RZk9qLmEJ:https://invisible-island.net/ncurses/ncurses-intro.html+&cd=1&hl=en&ct=clnk&gl=ca https://webcache.googleusercontent.com/search?q=cache:6a4RZk...
- mprovost 5y agoThomas Dickey has been maintaining this code by himself for years (decades?). Along with the timezone database, the terminal info database is a huge SPOF. It's too bad that this effort is mostly unrecognised.
- dTal 5y agoFor a low-mental-overhead alternative to curses, I just discovered this lovely little library: https://github.com/termbox/termbox/ https://github.com/termbox/termbox/
- deleted 5y ago[deleted]
- nathias 5y agocurses are awesome, there is also a react wrapper that makes it easier to implement