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?

Saturday, January 9, 2010

trick on MAC OS X

Today I installed the Stardict 3.0.1 on my Macbook. I changed some default settings but it seemed that these changes are lost after I close the application. Then I realized that it could be a very stupid "bug". I don't have the write privilege on the directory where the preference file stores!

running the application as root solved the problem.

1.sudo open .../Stardict.app.
2. change the preference.
3. close the program.

That's it!