Tuesday, January 12, 2010

An example of curses/ncurses

What is curses?

curses is a terminal control library for Unix-like systems, enabling the construction of text user interface (TUI) applications.

curses is a pun on the term “cursor optimization”. It is a library of functions that manage an application's display on character-cell terminals (e.g., VT100). (from WiKi)

ncurses is the so-called new curses. you can install either curses or ncurses.
On ubuntu, the installation is like:
sudo apt-get install libncurses5-dev

------------------------------------------------------------------
Here is a simple example:

#include"ncurses.h"

int main()
{
initscr();
box(stdscr,ACS_VLINE,ACS_HLINE);
move(LINES/2, COLS/2);
waddstr(stdscr, "Hello, world!");
refresh();
getch();
endwin();
return 0;
}

Here is the result, kinda cool, huh?

No comments: