1. Compile the program containing the NCURSES function
#include<ncurses.h>
Compile and link commands: gcc <program file> -lncurses
2. "Hello!" program
#include<ncurses.h>//包含stdio.h
#include <locale.h> //Chinese library
intmain()
{
initsrc(); //Initialize, enter NCURSES mode
setlocale(LC_ALL,""); //Support Chinese
printfw("Hello!"); //Print to the virtual display
refresh(); //Write the content on the virtual screen to the display and refresh
getch(); //Wait for the user to enter any character
endwin(); //Exit NCURSES mode
return 0;
}
3. Window mechanism
1. Create a new window
WINDOW* create_newwin(int height, int width, int starty, int startx)
{ WINDOW* local_win; local_win = newwin(height, width, starty, startx); box(local_win,'|','-'); //窗口边界,---- |||| wrefresh(local_win); //显示边界 return local_win; }
parameter:
height: window height
width: window width
starty: window start ordinate
startx: the starting abscissa of the window