1.Curses function library is a important standard.It is the bridge between the text and X-window.
2.You can examine your curses config by the command :”ls -l /usr/include/*curses.h” for the head file , ”ls -l /usr/include/*curses*” for the lib file.
3.Curses work on the screen, windows and child windows.
4.Curses for screen, there are two function named 'stdscr' and 'curscr' to indicate the terminal screen. ”stdscr” will be refreshed when there is any output for the curses, and before the 'refresh' , curses will compare the stdscr(the screen will be) and curscr(the screen now), and then refresh for the difference between the two.
5.The step to output a word :
1.Refresh the logic screen by the curses;
2.Refresh the real screen by the cruses;
6.The layout of the logic screen is seemed as a two dimension array, and the number is composed by the line num and the column num.
7.The curses usually create some temp construction during working, so we should make use of the functions named 'initscr' and 'endwin' to initialize the lib and recover the lib. As we can see, all of the curses program should begin with initscr() and end with endwin().
8.Generally, the construction of window is used to save the display content will be of the screen.
9.Curses have its own char type as unsigned long. The functions heading as 'add' are used to add some string on the cursor. 'Printw' is used as 'printf' to format the output to the right point. 'box' is used to draw a rectangle on the current window. 'insch' is used to insert char, and move the string right, the opposite function named 'delete', 'beep' function can make sound.
10.Function 'inch' is used to read the char type of the right point and the instr will be return array of char(string).
11.Function 'erase' is used to clean the screen(write the blank char to the whole screen ). Function 'clear' to clean the screen is the reliablest method.
12.Function 'move' to move the logic cursor; the flag 'leaveok' is false as default, in this case, the real cursor will be at the position of logic cursor after refreshing; if true, the real cursor will be anywhere of the screen by random.
13.The default input mode is the pre-process mode, it means that text line is base unit of the input. You can set the word interrupt mode by the function named 'cbreak', in this case, all the keys you pressed will be recognized as the input.
14.Standard screen stdscr is a special one of WINDOW construction.
15.The prefix “w” of function means that the operating object is window and prefix “mv” means to move the cursor.
16.To optimize the widow refresh, we need two functions: wnoutrefresh (to decide which char to be sent to window) and doupdate (send char to the window).
17.Sub window is almost the same as the new window, but it do not have its own character set, its characters belongs to its parent window. Usually, we make use of it for furling the part of window.
18.Every functional key is pressed, its transferred meaning string will be saved as terminfo, and the head file define a group of heading with ‘KEY_’ variable to deal with the string.
浙公网安备 33010602011771号