📄 form.h
字号:
/**************************************************************************** * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************//**************************************************************************** * Author: Juergen Pfeifer, 1995,1997 * ****************************************************************************//* $Id: form.h,v 0.17 2003/11/08 20:39:08 tom Exp $ */#ifndef FORM_H#define FORM_H#include <curses.h>#include <eti.h>#ifdef __cplusplus extern "C" {#endiftypedef int Form_Options;typedef int Field_Options; /********** * _PAGE * **********/typedef struct { short pmin; /* index of first field on page */ short pmax; /* index of last field on page */ short smin; /* index of top leftmost field on page */ short smax; /* index of bottom rightmost field on page */} _PAGE; /********** * FIELD * **********/typedef struct fieldnode { unsigned short status; /* flags */ short rows; /* size in rows */ short cols; /* size in cols */ short frow; /* first row */ short fcol; /* first col */ int drows; /* dynamic rows */ int dcols; /* dynamic cols */ int maxgrow; /* maximum field growth */ int nrow; /* off-screen rows */ short nbuf; /* additional buffers */ short just; /* justification */ short page; /* page on form */ short index; /* into form -> field */ int pad; /* pad character */ chtype fore; /* foreground attribute */ chtype back; /* background attribute */ Field_Options opts; /* options */ struct fieldnode * snext; /* sorted order pointer */ struct fieldnode * sprev; /* sorted order pointer */ struct fieldnode * link; /* linked field chain */ struct formnode * form; /* containing form */ struct typenode * type; /* field type */ void * arg; /* argument for type */ char * buf; /* field buffers */ void * usrptr; /* user pointer */} FIELD; /************** * FIELDTYPE * **************/typedef struct typenode { unsigned short status; /* flags */ long ref; /* reference count */ struct typenode * left; /* ptr to operand for | */ struct typenode * right; /* ptr to operand for | */ void* (*makearg)(va_list *); /* make fieldtype arg */ void* (*copyarg)(const void *); /* copy fieldtype arg */ void (*freearg)(void *); /* free fieldtype arg */ bool (*fcheck)(FIELD *,const void *); /* field validation */ bool (*ccheck)(int,const void *); /* character validation */ bool (*next)(FIELD *,const void *); /* enumerate next value */ bool (*prev)(FIELD *,const void *); /* enumerate prev value */} FIELDTYPE; /********* * FORM * *********/typedef struct formnode { unsigned short status; /* flags */ short rows; /* size in rows */ short cols; /* size in cols */ int currow; /* current row in field window*/ int curcol; /* current col in field window*/ int toprow; /* in scrollable field window */ int begincol; /* in horiz. scrollable field */ short maxfield; /* number of fields */ short maxpage; /* number of pages */ short curpage; /* index into page */ Form_Options opts; /* options */ WINDOW * win; /* window */ WINDOW * sub; /* subwindow */ WINDOW * w; /* window for current field */ FIELD ** field; /* field [maxfield] */ FIELD * current; /* current field */ _PAGE * page; /* page [maxpage] */ void * usrptr; /* user pointer */ void (*forminit)(struct formnode *); void (*formterm)(struct formnode *); void (*fieldinit)(struct formnode *); void (*fieldterm)(struct formnode *);} FORM;typedef void (*Form_Hook)(FORM *); /*************************** * miscellaneous #defines * ***************************//* field justification */#define NO_JUSTIFICATION (0)#define JUSTIFY_LEFT (1)#define JUSTIFY_CENTER (2)#define JUSTIFY_RIGHT (3)/* field options */#define O_VISIBLE (0x0001)#define O_ACTIVE (0x0002)#define O_PUBLIC (0x0004)#define O_EDIT (0x0008)#define O_WRAP (0x0010)#define O_BLANK (0x0020)#define O_AUTOSKIP (0x0040)#define O_NULLOK (0x0080)#define O_PASSOK (0x0100)#define O_STATIC (0x0200)/* form options */#define O_NL_OVERLOAD (0x0001)#define O_BS_OVERLOAD (0x0002)/* form driver commands */#define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */#define REQ_PREV_PAGE (KEY_MAX + 2) /* move to previous page */#define REQ_FIRST_PAGE (KEY_MAX + 3) /* move to first page */#define REQ_LAST_PAGE (KEY_MAX + 4) /* move to last page */#define REQ_NEXT_FIELD (KEY_MAX + 5) /* move to next field */#define REQ_PREV_FIELD (KEY_MAX + 6) /* move to previous field */#define REQ_FIRST_FIELD (KEY_MAX + 7) /* move to first field */#define REQ_LAST_FIELD (KEY_MAX + 8) /* move to last field */#define REQ_SNEXT_FIELD (KEY_MAX + 9) /* move to sorted next field */#define REQ_SPREV_FIELD (KEY_MAX + 10) /* move to sorted prev field */#define REQ_SFIRST_FIELD (KEY_MAX + 11) /* move to sorted first field */#define REQ_SLAST_FIELD (KEY_MAX + 12) /* move to sorted last field */#define REQ_LEFT_FIELD (KEY_MAX + 13) /* move to left to field */#define REQ_RIGHT_FIELD (KEY_MAX + 14) /* move to right to field */#define REQ_UP_FIELD (KEY_MAX + 15) /* move to up to field */#define REQ_DOWN_FIELD (KEY_MAX + 16) /* move to down to field */#define REQ_NEXT_CHAR (KEY_MAX + 17) /* move to next char in field */#define REQ_PREV_CHAR (KEY_MAX + 18) /* move to prev char in field */#define REQ_NEXT_LINE (KEY_MAX + 19) /* move to next line in field */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -