📄 interface.h
字号:
/* * $File: interface.h * $Author: Jiakai -- gy_jk@126.com * $Date: Thu Mar 26 19:47:02 2009*//*Copyright (C) (2008) (Jiakai) <gy_jk@126.com>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/#ifndef HEADER_INTERFACE#define HEADER_INTERFACEnamespace ncurses{ enum Ncurses_color{NCOLOR_BLACK = 1, NCOLOR_RED, NCOLOR_GREEN, NCOLOR_YELLOW, NCOLOR_BLUE, NCOLOR_MAGENTA, NCOLOR_CYAN, NCOLOR_WHITE}; const int ENTER = 10; void init(); void end(); void update(); // update the virtual screen and the physical screen. int get_str_nlines(const char *str, int cols = 0); // cols == 0 means the width of the screen void report_err(const char *msg, const char *func, int line); void read_input(const char *msg, char *data, const char *default_val = 0, const char *start_val = 0, int maxlen = 0); // if @maxlen is equal to 0, it will be set to STRING_MAX_LEN int message_box(const char *msg, const char *title = 0); // return value is the key pressed. int get_ncols(); int get_nlines(); int get_key(); class Window; class Menu; class Menu { struct Vars; Vars *v; public: Menu(); ~Menu(); void set_arg(Window &win, const char *const items[], const int *key_allowable, const char *msg = 0, int height = 0, int width = 0, int starty = -1, int startx = -1, int ncols = 1); // the menu's position is based on @win. // if @height or @width is equal to 0, the height or width of @win will be assigned to it. // if @startx or @starty is equal to -1, the menu which is @width wide and @height high will be put in the middle of @win. // @items and @key_allowable should end with a value of 0 int wait_key(); // wait until a key in @key_allowable is pressed. // return value is the key pressed. bool wait_move_key(int &key_pressed); // wait until a key in @key_allowable is pressed or the current item is changed. // return value is true if the current item is changed , or false if a key in @key_allowable is pressed. int get_choice(); int multiple_choice(bool *result, char *items[]); // @result should be able to hold as many bools as the number of items. // @key_allowable: // [0] - choose one ; [1] - choose all ; [2..n] - return // @items should be the arg @items passed in set_arg, and begin with a space. // return value is the key pressed. void free(); }; class Window { struct Vars; Vars *v; void init(int, int, int, int, bool); public: Window(int height, int width, int starty = -1, int startx = -1, bool border = true); // if @height or @width is equal to 0, the height or width of the screen will be assigned to it. // if @startx or @starty is equal to -1, the menu will be put in the middle of the screen. Window(const Window &win, int heigt, int width, int starty = -1, int startx = -1, bool border = false); // the window's position is based on @win. // if @startx or @starty is equal to -1, the menu will be put in the middle of the screen. Window(); // a full screen window int get_nlines() const; int get_ncols() const; void printf(const char *fmt, ...); void printf_color(Ncurses_color color, const char *fmt, ...); void mvprintf(int y, int x, const char *fmt, ...); void clean(); void get_str(char *str, int pos_y, int maxlen); // The default value will be set to @str; int print_longmsg(const char *msg, int key_return = -1); // keys such as UP and DOWN can be used to scroll the screen. @key_return == -1 means any key. // return value is the key pressed. void free(); void set_title(const char *str); // the window must has a border void set_scroll(bool val); void draw_hline(int starty); ~Window(); friend void ncurses::Menu::set_arg(Window &, const char *const [], const int *, const char *, int, int, int, int, int); }; struct Error{char *msg; Error(const char *msg, const char *func, int line); }; // remember to delete []msg}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -