3. curses Database WINDOW processing

Source: Internet
Author: User

3. curses Database WINDOW processing

~~~~~~~~~~~~~~~~~~~~~~~~~~~


3.1 What is a window

====================

* A window is an area on the screen. You can perform various outputs and operations on it.

* Windows can be anywhere on the standard screen and overlap between windows.

* The window can contain child windows related to them at the same time. Any change in the overlapping areas of the parent window and Child Window will affect any of them at the same time.


3.2 window operations

==================


3.2.1 create and delete windows

---------------------

/** @ Brief: create a WINDOW and return the WINDOW pointer @ param lines. The total number of rows in the WINDOW to be created @ param cols. The total number of columns in the WINDOW to be created @ param begin_x is the number of rows in the upper left corner of the WINDOW (x coordinates) @ param begin_y the number of columns (y coordinates) in the upper left corner of the WINDOW @ return returns a pointer of the WINDOW type. If creation fails, the function returns NULL @ note if lines or cols is 0, the function automatically creates a window with LINES and COLS. the size of the created window cannot exceed the size of the actual screen. If the size is exceeded, an error is returned. you can use werase () and wclear () to clear windows that are no longer in use. no matter werase () or wclear (), the memory space cannot be cleared. You need to call delwin () to release the memory. */WINDOW * newwin (int lines, int cols, int begin _ X, int begin_y ); /** @ brief Delete WINDOW @ param win pointer to the WINDOW to be deleted @ note all subwindows associated with it must be deleted before the main WINDOW is deleted */int delwin (WINDOW * win ); /** @ breif: Create a subwindow @ param win parent window pointer @ param lines. The total number of rows and columns of the cols subwindow @ param begin_x, the upper left corner of the begin_y subwindow is in the relative position of the standard screen. @ note: the relative position is for * standard screen *, not the parent window !! */WINDOW * subwin (WINDOW * win, int lines, int cols, int begin_x, int begin_y ); /** @ breif: Create a subwindow @ param win parent window pointer @ param lines. The total number of rows and columns of the cols subwindow @ param begin_x, the upper left corner of the begin_y subwindow is located at the relative position of the parent window. @ note: the relative position is for * parent window *, not the standard screen !! */WINDOW * derwin (WINDOW * win, int lines, int cols, int begin_x, int begin_y );

3.2.2 input and output in the window

---------------------------

Int wmove (WINDOW * win, int x, int y);/** move the cursor to the (x, y) position relative to win */int waddch (WINDOW * win, int ch);/** Add the ch character at the current position of the WINDOW */int mvwaddch (WINDOW * win, x, y, ch ); /** move the cursor to x and y in the WINDOW and output ch */int waddstr (WINDOW * win, char * str ); /** output str */int mvwaddstr (WINDOW * win, int x, int y, char * str);/** move the WINDOW cursor to x, y, output str */int wprintw (WINDOW * win, char * fmt [, arg...]) at the same time; /** format the output in the WINDOW */int wgetch (WINDOW * win);/** obtain the input in the WINDOW */int mvwgetch (WINDOW * win, int x, int y); int wgetstr (WINDOW * win); int mvwgetstr (WINDOW * win, int x, int y, char * str); int wscanw (WINDOW * win, char * fmt [, args...]); int mvwscanw (WINDOW * win, int x, int y, char * fmt [, args...]); int winsch (WINDOW * win, int ch);/** insert characters in the WINDOW */int mvwinsch (WINDOW * win, int x, int y, int ch ); int winsertln (WINDOW * win, int x, int y);/** insert a row in the WINDOW */int wdelch (WINDOW * win ); /** delete a character in the WINDOW */int mvwdelch (WINDOW * win, int x, int y); int wdeleteln (WINDOW * win ); int wclear (WINDOW * win); int werase (WINDOW * win); int wclrtoeol (WINDOW * win); int wclrtobot (WINDOW * win); int wstandout (WINDOW * win ); int wstandend (WINDOW * win); int wattrset (WINDOW * win, chtype recognition); int wattroff (WINDOW * win, chtype recognition); int wattron (WINDOW * win, chtype ASD ); /** @ brief copy the content of srcwin to dstwin @ param srcwin pointer of the copied window @ param dstwin accept the pointer of the copied window @ note srcwin and dstwin do not need to be identical in size, if srcwin is greater than the dstwin window, the function simply copies the portion of overlay () suitable for dstwin in srcwin, which is a non-destructive copy and does not copy null characters in the original window, therefore, if a position in the original window is a NULL Character and the position of the target window is not a null character, the original character of the target window will be retained. */int overlay (WINDOW * srcwin, WINDOW * dstwin ); /** @ brief copy the content of srcwin to dstwin @ param srcwin pointer of the copied window @ param dstwin accept the pointer of the copied window @ note srcwin and dstwin do not need to be identical in size, if srcwin is greater than the dstwin window, the function simply copies the portion of overwrite () suitable for dstwin in srcwin, which is a destructive copy that copies all the content in the original window, including null characters */int overwrite (WINDOW * srcwin, WINDOW * dstwin ); /** @ brief copy part of srcwin to the specified part of dstwin @ param srcwin copy source window pointer @ param dstwin copy target window pointer @ param srcminrow, in the srcmincol source window, the coordinates in the upper left corner of the source window to be copied are @ param dstminrow, And the coordinates in the upper left corner of the target window of dstmincol are @ param dstmaxrow, dstmaxcol indicates the size of the region to be copied @ param overlay indicates whether the replication is destructive */int copywin (WINDOW * scrwin, WINDOW * dstwin, int srciminrow, int srcmincol, int dstminrow, int dstmincol, int dstmaxrow, int dstmaxcol, int overlayFlag );


3.2.3 Window refresh

---------------

/** @ Breif: Write the WINDOW content to the virtual screen, which describes the content to be displayed */int wnoutrefresh (WINDOW * win ); /** @ brief refreshes the virtual screen content to the physical screen */int doupdate (WINDOW * win);/** @ brief is equivalent to wnoutrefresh () and doupdate () */int wrefresh (WINDOW * win);/** @ brief re-draw the specified WINDOW */int redrawwin (WINDOW * win ); /** @ brief re-draw the starting line of the specified area @ param beg_line in the specified WINDOW @ param num_lines */int wredrawln (WINDOW * win, int beg_line, int num_lines );


3.2.4 other window attribute operations

-----------------------

/** @ Brief move the window to the specified position @ param win: the window to be moved @ param x, and the target position of y move @ note move the window, remember to use wrefresh to refresh the WINDOW */int mvwin (WINDOW * win, int x, inty);/** @ brief activates the specified WINDOW when the WINDOW overlaps with each other, obtain the focus of the current operation */void touchwin (WINDOW * win ); /** @ brief Add the border @ param win to the window to draw the border's window @ vert vertical direction characters, usually ACS_VLINE @ hort horizontal direction characters, usually ACS_HLINE */int box (WINDOW * win, chtype vert, chtype hort ); /** @ breif: Add a border to the window. @ param win: Specify the border for the window. @ param ls: The character on the left of the window. // left side @ param rs: The character on the right side of the window. // right side @ param ts characters above the window // top side @ param bs characters below the window // buttom side @ param tl characters in the upper left corner of the window // top left @ param tr characters in the upper right corner of the window // top right @ param bl characters in the lower left corner of the WINDOW // buttom left @ param br characters in the lower right corner of the WINDOW // buttom right */int border (WINDOW * win, chtype ls, chtype, rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br ); /** @ brief draw a horizontal line @ param ch on the standard screen for linear payment @ param n to specify the maximum line length */int hline (chtype ch, int n ); /** @ brief draw a vertical line on the standard screen @ param ch linear line character @ param n to specify the maximum length */int vline (chtype ch, int n ); /** @ brief draw a horizontal line @ param win in the specified WINDOW specify a WINDOW @ param ch linear payment @ param n specify the maximum line length */int whline (WINDOW * win, chtype ch, int n);/** @ brief draw a vertical line in the specified WINDOW @ param win specify the WINDOW @ param ch linear line character @ param n specify the maximum line length */int wvline (WINDOW * win, chtype ch, int n);/** @ brief sets the corresponding flag in the WINDOW @ param state TRUE, and FLASE unsets */void leaveok (WINDOW * win, bool state); void scrolok (WINDOW * win, bool state); void clearok (WINDOW * win, bool state );


3.2.5 screen transfer

-----------------

/** @ Brief write all data in win to fp */int putwin (WINDOW * win, FILE * fp ); /** @ brief: WINDOW created by fp content */WINDOW * getwin (FILE * fp);/** @ brief storage standard screen */int scr_dump (const char * filename ); /** @ brief read standard screen */int src_restore (const char * filename );


This article is from the "dark day" blog, please be sure to keep this source http://darksun.blog.51cto.com/3874064/1297283

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.