📄 curlib.h
字号:
#ifndef CURLIB_H#define CURLIB_H#define M_TERMINFO#define SCO_UNIX/* * System header files. */#include <curses.h>#include <ctype.h>#include <math.h>#include <string.h>#include <varargs.h>#include <memory.h>#include <errno.h>#include <signal.h>#include <malloc.h>#include <fcntl.h>#include <time.h>#include <sys/timeb.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/msg.h>#include "strlib.h"/* * Macros define. */#ifndef TRUE #define TRUE 1#endif#ifndef FALSE #define FALSE 0#endif/*** 视 频 特 性 定 义 ***/#define REV A_REVERSE#define NOR A_NORMAL#define UNL A_UNLINE#define EXTRA_COLOR 0x80#define COLOR_NUM 8#define COL(fg,bg) ((fg&EXTRA_COLOR)||(bg&EXTRA_COLOR))?COLOR_PAIR((fg&~EXTRA_COLOR)+(bg&~EXTRA_COLOR)*COLOR_NUM)|A_BOLD:COLOR_PAIR(fg+bg*COLOR_NUM)#define BLACK 0 /* 黑色 */#define RED 1 /* 红色 */#define GREEN 2 /* 绿色 */#define BROWN 3 /* 棕色 */#define BLUE 4 /* 蓝色 */ #define MAGENTA 5 /* 紫色 */#define CYAN 6 /* 青色 */#define WHITE 7 /* 白色 */#define GRAY BLACK|EXTRA_COLOR /* 灰色 */#define LT_RED RED|EXTRA_COLOR /* 高红色 */#define LT_GREEN GREEN|EXTRA_COLOR /* 高绿色 */#define YELLOW BROWN|EXTRA_COLOR /* 黄色 */#define LT_BLUE BLUE|EXTRA_COLOR /* 高蓝色 */ #define LT_MAGENTA MAGENTA|EXTRA_COLOR /* 高紫色 */#define LT_CYAN CYAN|EXTRA_COLOR /* 高青色 */#define HI_WHITE WHITE|EXTRA_COLOR /* 高白色 *//* 输入选项定义 */#define ACCEPT_DIGIT 0x0001#define ACCEPT_ALPHA 0x0002#define ACCEPT_FIXLEN 0x0004#define ACCEPT_DISP 0x0008#define ACCEPT_SPEC 0x0010#define ACCEPT_ALL ACCEPT_DIGIT|ACCEPT_ALPHA/* 键盘值定义 */#define KeyEsc 27 /* ESC KEY */#define KeyF1 77 /* F1 KEY */#define KeyTab 9 /* TAB KEY */#define KeyBkSpace 8 /* BACKSPACE KEY */#define KeyEnter 13 /* ENTER KEY */#define KeySpace 32 /* SPACE KEY */ #define KeyUp 65 /* UP KEY */#define KeyDown 66 /* DOWN KEY */#define KeyRight 67 /* RIGHT KEY */#define KeyLeft 68 /* LEFT KEY */#define KeyHome 72 /* HOME KEY */#define KeyEnd 70 /* END KEY */#define KeyPgUp 73 /* PgUp KEY */#define KeyPgDn 71 /* PgDn KEY */#define KeyIns 76 /* INSERT KEY */#define CUR_DISABLE 0#define CUR_ENABLE 1/* window style */#define WINDOW_CHINESE 0x0004#define WINDOW_ENGLISH 0x0008#define WINDOW_SHADE 0x0010#define WINDOW_NO_BOARD 0x1000#define WINDOW_NUM 10/* Message box sytle */#define MSG_OK 1#define MSG_OC 2 /* OK CANCEL */#define MSG_YN 3 /* YES NO */#define MSG_YNC 4 /* YES NO CANCEL */#define MSG_RC 5 /* RETRY CANCEL */#define MSG_ARI 6 /* ABOUT RETRY IGNORE */#define MSG_AK 7 /* ANY KEY */#define ID_OK 0x01#define ID_NO 0x02#define ID_YES 0x04#define ID_CANCEL 0x08#define ID_ABORT 0x10#define ID_RETRY 0x20#define ID_IGNORE 0x40#define ID_ANYKEY 0x80/* * Type define. */#ifndef UCHAR #define UCHAR typedef unsigned char uchar;#endif#if 0#ifndef ULONG #define ULONG typedef unsigned long ulong;#endif#endif/* * 该结构都是基于stdscr屏幕. */typedef struct vs_s { int sy; int sx; int row; int col; chtype buf[25][80];} vs_t;typedef struct window_s { uchar sy; uchar sx; uchar row; uchar col; chtype tattr; chtype battr; chtype style; chtype *buf; /* save screen content */} window_t;/* 系统各种颜色属性和风格 */typedef struct attr_s { chtype title; /* 标题颜色 COL(前景色,背景色) */ chtype text; /* 文本颜色 COL(前景色,背景色) */ chtype board; /* 边框颜色 COL(前景色,背景色) */ chtype client; /* 菜单客户区颜色 COL(前景色,背景色) */ chtype select; /* 选项颜色 COL(前景色,背景色) */ chtype hotkey; /* 热键颜色 COL(前景色,背景色) */ chtype shade; /* 阴影颜色 COL(前景色,背景色) */ chtype prompt; /* 提示颜色 COL(前景色,背景色) */ chtype edit; /* 编辑颜色 COL(前景色,背景色) */ chtype wstyle; /* 窗口风格 */ chtype mstyle; /* 菜单风格 */} attr_t;/* * Extern variable decleare. */extern int is_tty_flag; /* 1.终端 0.主机控制台*/extern int not_color; /* 1.不支持颜色 0.支持颜色 *///extern int argc;//extern char **argv;extern uchar screen_starty;/* screen 左上角 starty */extern uchar screen_startx;/* screen 左上角 startx */extern uchar screen_endy;/* screen 右下角 endy */extern uchar screen_endx;/* screen 右下角 endx */extern uchar screen_maxrow;/* screen 最大行 */extern uchar screen_maxcol;/* screen 最大列 */extern attr_t screen; /* 屏幕属性 *//* * Extern function decleare. *//****************************************************************************** * <第一章> 屏幕窗口函数. * ******************************************************************************//*----------------------------------------------------------------------------* * Function: Initialize screen. * Argument: * None. * Return : * TRUE: successed. * FALSE: failured. *----------------------------------------------------------------------------*/extern int begin_work(void);/*----------------------------------------------------------------------------* * Function: End screen. * Argument: * None. * Return : * None. *----------------------------------------------------------------------------*/extern void end_work();/*----------------------------------------------------------------------------* * Function: 关闭或打开光标(目前只支持终端). * Argument: * int flag - 0.CUR_DISABLE 1.CUR_ENABLE. * Return : * None. *----------------------------------------------------------------------------*/extern void cursor_control(int flag);/*----------------------------------------------------------------------------* * FUNCTION: 保存一块屏幕区域, 显示一个窗口. * Argument: * uchar sy - 开始行. * uchar sx - 开始列. * uchar row - 行数. * uchar col - 列数. * Return : * TRUE - 成功. * FALSE - 失败. * 说 明: * 同 restore_window() 成对使用. *----------------------------------------------------------------------------*/extern save_window(uchar sy,uchar sx,uchar row,uchar col);/*----------------------------------------------------------------------------* * FUNCTION: 恢复save_window保存的屏幕区域. * Argument: * 无. * Return : * TRUE - 成功. * 说 明: * 同 save_window() 成对使用. *----------------------------------------------------------------------------*/extern restore_window();/*----------------------------------------------------------------------------* * Function: 画一个box. * Argument: * uchar sy - 指定box的开始行坐标. * uchar sx - 指定box的开始列坐标. * uchar row - 指定box的行数. * uchar col - 指定box的列数. * Return : * TRUE. *----------------------------------------------------------------------------*/extern int draw_box(uchar sy,uchar sx,uchar row,uchar col);/*----------------------------------------------------------------------------* * Function: 用某种颜色清除屏幕. * Argument: * short sy - 开始行.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -