Curses: man page




Examples:

 

Ø hello : prints “hello Hussein”  in the middle of the window

(Position: line 10, column 20).

 


#include <curses.h>

main()

{

initscr();

clear();

move(10,20);

addstr("Hello Hussein");

refresh();

endwin();

}

 

 

Ø motion : prints “hello Hussein”  in the middle of the window and move it across the line

(from position line 10, column 0 to column 30).

 


#include <curses.h>

main()

{

int i;

initscr();

clear();

for (i=0; i<30;i++){

        move(10,i);

        addstr("Hello Hussein");

        refresh();

        usleep(100000); /* sleep 100 milli sconds */

        move(10,i);

        addstr("             ");

}

getch();

endwin();

}

 

 

 

Ø move : prints “hello Hussein”  in the middle of the window and move it across the line

(from position line 10, column 0 to column 30). If the user type “z”, it move to next line.

 

 


#include <curses.h>

main()

{

int i;

int row;

char ch;

 

initscr();

clear();

nodelay(stdscr, TRUE); /* non block input for getch() */

row=10;

noecho(); /* stop echo of input */

 

for (i=0; i<30;i++){

        move(row,i);

        addstr("Hello Hussein");

        refresh();

        usleep(100000);

        move(row,i);

        addstr("             ");

        ch=getch();

        if (ch == 'z') {

            row++;

            i=0;

        }

}

getch();

endwin();

}