📄 cursesw.h
字号:
#endif#ifdef wattrsetinline int UNDEF(wattrset)(WINDOW *win, int att) { return wattrset(win, att); }#undef wattrset#define wattrset UNDEF(wattrset)#endif#ifdef winchinline chtype UNDEF(winch)(const WINDOW* win) { return winch(win); }#undef winch#define winch UNDEF(winch)#endif#ifdef mvwaddchinline int UNDEF(mvwaddch)(WINDOW *win, int y, int x, const chtype ch){ return mvwaddch(win, y, x, ch); }#undef mvwaddch#define mvwaddch UNDEF(mvwaddch)#endif#ifdef mvwaddchnstrinline int UNDEF(mvwaddchnstr)(WINDOW *win, int y, int x, chtype *str, int n){ return mvwaddchnstr(win, y, x, str, n); }#undef mvwaddchnstr#define mvwaddchnstr UNDEF(mvwaddchnstr)#endif#ifdef mvwaddchstrinline int UNDEF(mvwaddchstr)(WINDOW *win, int y, int x, chtype *str){ return mvwaddchstr(win, y, x, str); }#undef mvwaddchstr#define mvwaddchstr UNDEF(mvwaddchstr)#endif#ifdef addnstrinline int UNDEF(addnstr)(const char *str, int n){ return addnstr(str, n); }#undef addnstr#define addnstr UNDEF(addnstr)#endif#ifdef mvwaddnstrinline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n){ return mvwaddnstr(win, y, x, str, n); }#undef mvwaddnstr#define mvwaddnstr UNDEF(mvwaddnstr)#endif#ifdef mvwaddstrinline int UNDEF(mvwaddstr)(WINDOW *win, int y, int x, const char * str){ return mvwaddstr(win, y, x, str); }#undef mvwaddstr#define mvwaddstr UNDEF(mvwaddstr)#endif#ifdef mvwdelchinline int UNDEF(mvwdelch)(WINDOW *win, int y, int x){ return mvwdelch(win, y, x); }#undef mvwdelch#define mvwdelch UNDEF(mvwdelch)#endif#ifdef mvwgetchinline int UNDEF(mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);}#undef mvwgetch#define mvwgetch UNDEF(mvwgetch)#endif#ifdef mvwgetstrinline int UNDEF(mvwgetstr)(WINDOW *win, int y, int x, char *str){return mvwgetstr(win, y, x, str);}#undef mvwgetstr#define mvwgetstr UNDEF(mvwgetstr)#endif#ifdef mvwgetnstrinline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n){return mvwgetnstr(win, y, x, str, n);}#undef mvwgetnstr#define mvwgetnstr UNDEF(mvwgetnstr)#endif#ifdef mvwinchinline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) { return mvwinch(win, y, x);}#undef mvwinch#define mvwinch UNDEF(mvwinch)#endif#ifdef mvwinschinline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c){ return mvwinsch(win, y, x, c); }#undef mvwinsch#define mvwinsch UNDEF(mvwinsch)#endif#ifdef mvaddchinline int UNDEF(mvaddch)(int y, int x, chtype ch){ return mvaddch(y, x, ch); }#undef mvaddch#define mvaddch UNDEF(mvaddch)#endif#ifdef mvaddnstrinline int UNDEF(mvaddnstr)(int y, int x, const char *str, int n){ return mvaddnstr(y, x, str, n); }#undef mvaddnstr#define mvaddnstr UNDEF(mvaddnstr)#endif#ifdef mvaddstrinline int UNDEF(mvaddstr)(int y, int x, const char * str){ return mvaddstr(y, x, str); }#undef mvaddstr#define mvaddstr UNDEF(mvaddstr)#endif#ifdef mvdelchinline int UNDEF(mvdelch)(int y, int x) { return mvdelch(y, x);}#undef mvdelch#define mvdelch UNDEF(mvdelch)#endif#ifdef mvgetchinline int UNDEF(mvgetch)(int y, int x) { return mvgetch(y, x);}#undef mvgetch#define mvgetch UNDEF(mvgetch)#endif#ifdef mvgetstrinline int UNDEF(mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);}#undef mvgetstr#define mvgetstr UNDEF(mvgetstr)#endif#ifdef mvgetnstrinline int UNDEF(mvgetnstr)(int y, int x, char *str, int n) { return mvgetnstr(y, x, str, n);}#undef mvgetnstr#define mvgetnstr UNDEF(mvgetnstr)#endif#ifdef mvinchinline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);}#undef mvinch#define mvinch UNDEF(mvinch)#endif#ifdef mvinschinline int UNDEF(mvinsch)(int y, int x, chtype c){ return mvinsch(y, x, c); }#undef mvinsch#define mvinsch UNDEF(mvinsch)#endif#ifdef napmsinline void UNDEF(napms)(unsigned long x) { napms(x); }#undef napms#define napms UNDEF(napms)#endif#ifdef fixterminline int UNDEF(fixterm)(void) { return fixterm(); }#undef fixterm#define fixterm UNDEF(fixterm)#endif#ifdef resetterminline int UNDEF(resetterm)(void) { return resetterm(); }#undef resetterm#define resetterm UNDEF(resetterm)#endif#ifdef saveterminline int UNDEF(saveterm)(void) { return saveterm(); }#undef saveterm#define saveterm UNDEF(saveterm)#endif#ifdef crmodeinline int UNDEF(crmode)(void) { return crmode(); }#undef crmode#define crmode UNDEF(crmode)#endif#ifdef nocrmodeinline int UNDEF(nocrmode)(void) { return nocrmode(); }#undef nocrmode#define nocrmode UNDEF(nocrmode)#endif#ifdef getbkgdinline chtype UNDEF(getbkgd)(const WINDOW *win) { return getbkgd(win); }#undef getbkgd#define getbkgd UNDEF(getbkgd)#endif#ifdef bkgdinline int UNDEF(bkgd)(chtype ch) { return bkgd(ch); }#undef bkgd#define bkgd UNDEF(bkgd)#endif#ifdef bkgdsetinline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); }#undef bkgdset#define bkgdset UNDEF(bkgdset)#endif/* * * C++ class for windows. * */extern "C" int _nc_ripoffline(int, int (*init)(WINDOW*, int));extern "C" int _nc_xx_ripoff_init(WINDOW *, int);extern "C" int _nc_has_mouse(void);class NCURSES_IMPEXP NCursesWindow{ friend class NCursesMenu; friend class NCursesForm;private: static bool b_initialized; static void initialize(); friend int _nc_xx_ripoff_init(WINDOW *, int); void init(); short getcolor(int getback) const; static int setpalette(short fore, short back, short pair); static int colorInitialized; // This private constructor is only used during the initialization // of windows generated by ripoffline() calls. NCursesWindow(WINDOW* win, int ncols);protected: virtual void err_handler(const char *) const THROWS(NCursesException); // Signal an error with the given message text. static long count; // count of all active windows: // We rely on the c++ promise that // all otherwise uninitialized // static class vars are set to 0 WINDOW* w; // the curses WINDOW bool alloced; // TRUE if we own the WINDOW NCursesWindow* par; // parent, if subwindow NCursesWindow* subwins; // head of subwindows list NCursesWindow* sib; // next subwindow of parent void kill_subwindows(); // disable all subwindows // Destroy all subwindows. /* Only for use by derived classes. They are then in charge to fill the member variables correctly. */ NCursesWindow();public: NCursesWindow(WINDOW* &window); // useful only for stdscr NCursesWindow(int nlines, // number of lines int ncols, // number of columns int begin_y, // line origin int begin_x); // col origin NCursesWindow(NCursesWindow& par,// parent window int nlines, // number of lines int ncols, // number of columns int begin_y, // absolute or relative int begin_x, // origins: char absrel = 'a');// if `a', begin_y & begin_x are // absolute screen pos, else if `r', they are relative to par origin NCursesWindow(NCursesWindow& par,// parent window bool do_box = TRUE); // this is the very common case that we want to create the subwindow that // is two lines and two columns smaller and begins at (1,1). // We may automatically request the box around it. NCursesWindow& operator=(const NCursesWindow& rhs) { if (this != &rhs) *this = rhs; return *this; } NCursesWindow(const NCursesWindow& rhs) : w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib) { } virtual ~NCursesWindow(); NCursesWindow Clone(); // Make an exact copy of the window. // Initialization. static void useColors(void); // Call this routine very early if you want to have colors. static int ripoffline(int ripoff_lines, int (*init)(NCursesWindow& win)); // This function is used to generate a window of ripped-of lines. // If the argument is positive, lines are removed from the top, if it // is negative lines are removed from the bottom. This enhances the // lowlevel ripoffline() function because it uses the internal // implementation that allows to remove more than just a single line. // This function must be called before any other ncurses function. The // creation of the window is deferred until ncurses gets initialized. // The initialization function is then called. // ------------------------------------------------------------------------- // terminal status // ------------------------------------------------------------------------- int lines() const { initialize(); return LINES; } // Number of lines on terminal, *not* window int cols() const { initialize(); return COLS; } // Number of cols on terminal, *not* window int tabsize() const { initialize(); return TABSIZE; } // Size of a tab on terminal, *not* window static int NumberOfColors(); // Number of available colors int colors() const { return NumberOfColors(); } // Number of available colors // ------------------------------------------------------------------------- // window status // ------------------------------------------------------------------------- int height() const { return maxy() + 1; } // Number of lines in this window int width() const { return maxx() + 1; } // Number of columns in this window int begx() const { return w->_begx; } // Column of top left corner relative to stdscr int begy() const { return w->_begy; } // Line of top left corner relative to stdscr int maxx() const { return w->_maxx; } // Largest x coord in window int maxy() const { return w->_maxy; } // Largest y coord in window short getcolor() const; // Actual color pair short foreground() const { return getcolor(0); } // Actual foreground color short background() const { return getcolor(1); } // Actual background color int setpalette(short fore, short back); // Set color palette entry int setcolor(short pair); // Set actually used palette entry // ------------------------------------------------------------------------- // window positioning // ------------------------------------------------------------------------- virtual int mvwin(int begin_y, int begin_x) { return ::mvwin(w, begin_y, begin_x); } // Move window to new position with the new position as top left corner. // This is virtual because it is redefined in NCursesPanel. // ------------------------------------------------------------------------- // coordinate positioning // ------------------------------------------------------------------------- int move(int y, int x) { return ::wmove(w, y, x); } // Move cursor the this position void getyx(int& y, int& x) const { ::getyx(w, y, x); } // Get current position of the cursor int mvcur(int oldrow, int oldcol, int newrow, int newcol) const { return ::mvcur(oldrow, oldcol, newrow, newcol); } // Perform lowlevel cursor motion that takes effect immediately. // ------------------------------------------------------------------------- // input // ------------------------------------------------------------------------- int getch() { return ::wgetch(w); } // Get a keystroke from the window. int getch(int y, int x) { return ::mvwgetch(w, y, x); } // Move cursor to position and get a keystroke from the window int getstr(char* str, int n=-1) { return ::wgetnstr(w, str, n); } // Read a series of characters into str until a newline or carriage return // is received. Read at most n characters. If n is negative, the limit is // ignored. int getstr(int y, int x, char* str, int n=-1) { return ::mvwgetnstr(w, y, x, str, n); } // Move the cursor to the requested position and then perform the getstr() // as described above. int instr(char *s, int n=-1) { return ::winnstr(w, s, n); } // Get a string of characters from the window into the buffer s. Retrieve // at most n characters, if n is negative retrieve all characters up to the // end of the current line. Attributes are stripped from the characters. int instr(int y, int x, char *s, int n=-1) { return ::mvwinnstr(w, y, x, s, n); } // Move the cursor to the requested position and then perform the instr() // as described above. int scanw(const char* fmt, ...) // Perform a scanw function from the window.#if __GNUG__ >= 2 __attribute__ ((format (scanf, 2, 3)));#else ;#endif int scanw(int y, int x, const char* fmt, ...) // Move the cursor to the requested position and then perform a scanw // from the window.#if __GNUG__ >= 2 __attribute__ ((format (scanf, 4, 5)));#else ;#endif // ------------------------------------------------------------------------- // output // ------------------------------------------------------------------------- int addch(const chtype ch) { return ::waddch(w, ch); } // Put attributed character to the window. int addch(int y, int x, const chtype ch) { return ::mvwaddch(w, y, x, ch); } // Move cursor to the requested position and then put attributed character // to the window. int echochar(const chtype ch) { return ::wechochar(w, ch); } // Put attributed character to the window and refresh it immediately. int addstr(const char* str, int n=-1) { return ::waddnstr(w, str, n); } // Write the string str to the window, stop writing if the terminating // NUL or the limit n is reached. If n is negative, it is ignored. int addstr(int y, int x, const char * str, int n=-1) { return ::mvwaddnstr(w, y, x, str, n); } // Move the cursor to the requested position and then perform the addstr // as described above. int printw(const char* fmt, ...) // Do a formatted print to the window.#if (__GNUG__ >= 2) && !defined(printf) __attribute__ ((format (printf, 2, 3)));#else ;#endif int printw(int y, int x, const char * fmt, ...) // Move the cursor and then do a formatted print to the window.#if (__GNUG__ >= 2) && !defined(printf) __attribute__ ((format (printf, 4, 5)));#else ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -