Discovering ncurses, the GUI for the Linux Console
ncurses, a GUI for the Linux Console
The CLI versus GUI debate is well-known, but sometimes, drawing a hard line between text-only interfaces and graphical interfaces is too restrictive. Most of the time, if you're using a terminal (whether over SSH or on the console), the CLI and text-only interface works great. Sometimes, though, it can be a real advantage to be able to use at least some graphical logic, without having to fire up an X server. Not all servers run X; you don't always want to forward X to your remote terminal; or you may be at a stage of system or hardware install that prevents you from running a regular graphical interface.
This is where ncurses comes in. The ncurses library allows you to write programs that work in a GUI-like way, but which will run within a normal terminal emulator. You've almost certainly already encountered programs that use ncurses, including:
- screen, which allows you to run multiple screens in a single terminal window (this uses the terminfo information from ncurses but does its own screen-handling).
- make menuconfig, a tool which gives you a menu-driven user interface when configuring the Linux kernel before building it. This is a massive improvement over the older question-and-answer style configuration tool, as you'll know if you've ever missed a question with the older tool and had to start all over again.
- The email program mutt.
- The terminal-based web browsers lynx and w3m.
- aptitude, which provides a menu-driven interface to apt-get on Debian and Ubuntu systems.
- The visual file manager GNU Midnight Commander.
- The SuSE system management tool yast, when run in ncurses mode.
- A variety of MP3-player and IRC interfaces available via Sourceforge and other sites.
Midnight Commander, the powerful ncurses-based file manager
ncurses is a C library which provides a variety of functions for handling screen drawing, cursor management, mouse management, and so on. It isn't released under the GPL, but under a specific free software copyright notice which is discussed in the FAQ.
As a programmer, using ncurses means that you don't have to deal with the massive variety of slightly different terminal codes that exist. Instead, you can just deal with the more abstract concept of a display with multiple windows, and ncurses will handle the translation into control codes for whichever terminal emulator it detects that the program is running under. It can also handle mouse events, so if you have a mouse handler running (either on console or via X), you can use links and clickable menus within your terminal.
w3m, the ncurses Web browser. It take the same colors as your X terminal
There are ways of interacting with ncurses in numerous languages other than C itself (including Python, Perl, and C++), so anything you learn in one language will transfer with reasonable ease to another. If you're interested in writing your own ncurses programs, there's an introduction here (technically obsolete, but still useful as a starting point), and a HOWTO.
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.