Previous ,
Next Ncurses-Site-List
wmove(WINDOW *,int,int)
This funtion is used to move the cursor to a particular location in the WINDOW. It is relative to the top left cell of the WINDOW in question. The first argument is the WINDOW, the second argument is the y co-ordinate of the location to move to and the third argument is the x co-ordinate of the location to move to.
move(y,x) is equivalent to wmove(stdscr,y,x) .
wprintw(WINDOW *,char *)
This function is used to add text to a WINDOW. Every time the WINDOW is refreshed the text is also displayed. The first argument accepts the WINDOW and the second argument accepts the text string.
printw(char *) is equivalent to wprintw(stdscr,char *) .
werase(WINDOW *)
This function is used to erase all coontents in the WINDOW. It it does this by printing blanks over all text. It is faster than wclear(WINDOW *) which performs the same function in a different manner.
getch()
This function obtains a character input and is extremely useful in interactive programming. The getch() function can be used to detect arrow keys and other non-ascii keys. For this, another function called keypad(WINDOW *,bool) should be called in the following fashion.
int ch;
/*ch has to be an integer if it has to accept non-ascii keys*/
keypad(stdscr,TRUE);
/*accept all keys*/
ch=getch();
/*accept a key press and store return value in ch*/
if(ch==KEY_UP) exit(1);
/*exit if UP arrow key is pressed*/
All key definitions such as KEY_UP (Up arrow key) can be obtained from the man page of ncurses library. Similar definitions are found in the file keys.h which comes along with the code of ed!. It can be downloaded from the homepage.
wgetch(WINDOW *)
It does the same function as getch() except it uses the properties of the particular window passed to it. The keypad function has to called explicitly for each WINDOW.
ESCDELAY
Ususally when the ESC key is pressed, getch() waits for 1 second before accepting it. To remove this delay ESCDELAY, a global constant should be equated to zero.
start_color()
This function is used to initailize aall the colors and should be called before initializing any color-pair. A color-pair is a number that stands for a selected foreground and background color which can be applied to any WINDOW.
init_pair(int,??,??)
This function is used to initialise color pairs. There are 7 pre-defined colors that can be used to define the color pairs. They are COLOR_WHITE, COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_YELLOW, COLOR_RED and COLOR_MAGENTA available in both light and dark shades making a total of 14 colors. The background can only have the darker shades.
The first argument is the pair number, the second argument is the foreground color and the third argument is the background color.
wbkgd(WINDOW *,COLOR_PAIR(color_pair_number))
This function sets the color-pair asssociated with a particular WINDOW.
Previous ,
Next