version 1.2, 2000/04/12 21:46:27 |
version 1.17, 2001/12/02 09:14:21 |
|
|
* 1. Redistributions of source code must retain the above copyright |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* notice, this list of conditions and the following disclaimer. |
* 2. The name of the author may not be used to endorse or promote products |
* 2. The name of the author may not be used to endorse or promote products |
* derived from this software withough specific prior written permission |
* derived from this software without specific prior written permission |
* |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
|
|
* |
* |
*/ |
*/ |
|
|
|
#include <termios.h> |
|
|
/* Private structure definitions for curses. */ |
/* Private structure definitions for curses. */ |
/* |
/* |
* A window an array of __LINE structures pointed to by the 'lines' pointer. |
* A window an array of __LINE structures pointed to by the 'lines' pointer. |
|
|
struct __ldata { |
struct __ldata { |
wchar_t ch; /* Character */ |
wchar_t ch; /* Character */ |
attr_t attr; /* Attributes */ |
attr_t attr; /* Attributes */ |
|
wchar_t bch; /* Background character */ |
|
attr_t battr; /* Background attributes */ |
}; |
}; |
|
|
#define __LDATASIZE (sizeof(__LDATA)) |
#define __LDATASIZE (sizeof(__LDATA)) |
|
|
struct __line { |
struct __line { |
#define __ISDIRTY 0x01 /* Line is dirty. */ |
#define __ISDIRTY 0x01 /* Line is dirty. */ |
#define __ISPASTEOL 0x02 /* Cursor is past end of line */ |
#define __ISPASTEOL 0x02 /* Cursor is past end of line */ |
#define __FORCEPAINT 0x04 /* Force a repaint of the line */ |
|
unsigned int flags; |
unsigned int flags; |
unsigned int hash; /* Hash value for the line. */ |
unsigned int hash; /* Hash value for the line. */ |
int *firstchp, *lastchp; /* First and last chngd columns ptrs */ |
int *firstchp, *lastchp; /* First and last chngd columns ptrs */ |
Line 82 struct __window { /* Window structure. |
|
Line 85 struct __window { /* Window structure. |
|
unsigned int flags; |
unsigned int flags; |
int delay; /* delay for getch() */ |
int delay; /* delay for getch() */ |
attr_t wattr; /* Character attributes */ |
attr_t wattr; /* Character attributes */ |
wchar_t bchar; /* Background character */ |
wchar_t bch; /* Background character */ |
attr_t battr; /* Background attributes */ |
attr_t battr; /* Background attributes */ |
|
int scr_t, scr_b; /* Scrolling region top, bottom */ |
|
}; |
|
|
|
/* Set of attributes unset by 'me' - 'mb', 'md', 'mh', 'mk', 'mp' and 'mr'. */ |
|
#define __TERMATTR \ |
|
(__REVERSE | __BLINK | __DIM | __BOLD | __BLANK | __PROTECT) |
|
|
|
struct __winlist { |
|
struct __window *winp; /* The window. */ |
|
struct __winlist *nextp; /* Next window. */ |
|
}; |
|
|
|
struct __color { |
|
short num; |
|
short red; |
|
short green; |
|
short blue; |
|
int flags; |
|
}; |
|
|
|
/* List of colour pairs */ |
|
struct __pair { |
|
short fore; |
|
short back; |
|
int flags; |
}; |
}; |
|
|
|
/* Maximum colours */ |
|
#define MAX_COLORS 64 |
|
/* Maximum colour pairs - determined by number of colour bits in attr_t */ |
|
#define MAX_PAIRS 64 /* PAIR_NUMBER(__COLOR) + 1 */ |
|
|
|
typedef struct keymap keymap_t; |
|
|
|
/* this is the encapsulation of the terminal definition, one for |
|
* each terminal that curses talks to. |
|
*/ |
|
struct __screen { |
|
FILE *infd, *outfd; /* input and output file descriptors */ |
|
WINDOW *curscr; /* Current screen. */ |
|
WINDOW *stdscr; /* Standard screen. */ |
|
WINDOW *__virtscr; /* Virtual screen (for doupdate()). */ |
|
int curwin; /* current window for refresh */ |
|
short lx, ly; /* loop parameters for refresh */ |
|
int COLS; /* Columns on the screen. */ |
|
int LINES; /* Lines on the screen. */ |
|
int COLORS; /* Maximum colors on the screen */ |
|
int COLOR_PAIRS; /* Maximum color pairs on the screen */ |
|
int My_term; /* Use Def_term regardless. */ |
|
char GT; /* Gtty indicates tabs. */ |
|
char NONL; /* Term can't hack LF doing a CR. */ |
|
char UPPERCASE; /* Terminal is uppercase only. */ |
|
|
|
/* BEWARE!!! The order of the following terminal capabilities */ |
|
/* (tc_foo) is important - do not update without fixing the zap */ |
|
/* function in setterm.c */ |
|
char tc_am, tc_bs, tc_cc, tc_da, tc_eo, tc_hc, tc_hl, tc_in, tc_mi, |
|
tc_ms, tc_nc, tc_ns, tc_os, tc_ul, tc_ut, tc_xb, tc_xn, tc_xt, |
|
tc_xs, tc_xx; |
|
int flag_count; |
|
int tc_pa, tc_Co, tc_NC; |
|
int int_count; |
|
char *tc_AB, *tc_ac, *tc_ae, *tc_AF, *tc_AL, |
|
*tc_al, *tc_as, *tc_bc, *tc_bl, *tc_bt, |
|
*tc_cd, *tc_ce, *tc_cl, *tc_cm, *tc_cr, |
|
*tc_cs, *tc_dc, *tc_DL, *tc_dl, *tc_dm, |
|
*tc_DO, *tc_do, *tc_eA, *tc_ed, *tc_ei, |
|
*tc_ho, *tc_Ic, *tc_ic, *tc_im, *tc_Ip, |
|
*tc_ip, *tc_k0, *tc_k1, *tc_k2, *tc_k3, |
|
*tc_k4, *tc_k5, *tc_k6, *tc_k7, *tc_k8, |
|
*tc_k9, *tc_kd, *tc_ke, *tc_kh, *tc_kl, |
|
*tc_kr, *tc_ks, *tc_ku, *tc_LE, *tc_ll, |
|
*tc_ma, *tc_mb, *tc_md, *tc_me, *tc_mh, |
|
*tc_mk, *tc_mm, *tc_mo, *tc_mp, *tc_mr, |
|
*tc_nd, *tc_nl, *tc_oc, *tc_op, *tc_pc, |
|
*tc_rc, *tc_RI, *tc_Sb, *tc_sc, *tc_se, |
|
*tc_SF, *tc_Sf, *tc_sf, *tc_so, *tc_sp, |
|
*tc_SR, *tc_sr, *tc_ta, *tc_te, *tc_ti, |
|
*tc_uc, *tc_ue, *tc_UP, *tc_up, *tc_us, |
|
*tc_vb, *tc_ve, *tc_vi, *tc_vs; |
|
char CA; |
|
int str_count; |
|
chtype acs_char[NUM_ACS]; |
|
struct __color colours[MAX_COLORS]; |
|
struct __pair colour_pairs[MAX_PAIRS]; |
|
attr_t nca; |
|
|
|
/* Style of colour manipulation */ |
|
#define COLOR_NONE 0 |
|
#define COLOR_ANSI 1 /* ANSI/DEC-style colour manipulation */ |
|
#define COLOR_HP 2 /* HP-style colour manipulation */ |
|
#define COLOR_TEK 3 /* Tektronix-style colour manipulation */ |
|
#define COLOR_OTHER 4 /* None of the others but can set fore/back */ |
|
int color_type; |
|
|
|
attr_t mask_op; |
|
attr_t mask_me; |
|
attr_t mask_ue; |
|
attr_t mask_se; |
|
struct tinfo *cursesi_genbuf; |
|
int old_mode; /* old cursor visibility state for terminal */ |
|
keymap_t *base_keymap; |
|
int echoit; |
|
int pfast; |
|
int rawmode; |
|
int noqch; |
|
int clearok; |
|
int useraw; |
|
struct __winlist *winlistp; |
|
struct termios cbreakt, rawt, *curt, save_termios; |
|
struct termios orig_termios, baset, savedtty; |
|
int ovmin; |
|
int ovtime; |
|
char *stdbuf; |
|
unsigned int len; |
|
int meta_state; |
|
char pad_char; |
|
char ttytype[1024]; |
|
int endwin; |
|
}; |
|
|
|
|
|
extern char __GT; /* Gtty indicates tabs. */ |
|
extern char __NONL; /* Term can't hack LF doing a CR. */ |
|
extern char __UPPERCASE; /* Terminal is uppercase only. */ |
|
extern int My_term; /* Use Def_term regardless. */ |
|
extern const char *Def_term; /* Default terminal type. */ |
|
extern SCREEN *_cursesi_screen; /* The current screen in use */ |
|
|
/* Private functions. */ |
/* Private functions. */ |
#ifdef DEBUG |
#ifdef DEBUG |
void __CTRACE __P((const char *, ...)); |
void __CTRACE(const char *fmt, ...); |
#endif |
#endif |
int __delay __P((void)); |
void _cursesi_free_keymap(keymap_t *map); |
unsigned int __hash __P((char *, int)); |
int _cursesi_gettmode(SCREEN *screen); |
void __id_subwins __P((WINDOW *)); |
void _cursesi_reset_acs(SCREEN *screen); |
void __init_getch __P((char *)); |
void _cursesi_resetterm(SCREEN *screen); |
void __init_acs __P((void)); |
int _cursesi_setterm(char *type, SCREEN *screen); |
char *__longname __P((char *, char *)); /* Original BSD version */ |
int __delay(void); |
int __mvcur __P((int, int, int, int, int)); |
unsigned int __hash(char *s, int len); |
int __nodelay __P((void)); |
void __id_subwins(WINDOW *orig); |
int __notimeout __P((void)); |
void __init_getch(SCREEN *screen); |
char *__parse_cap __P((const char *, ...)); |
void __init_acs(SCREEN *screen); |
void __restartwin __P((void)); |
char *__longname(char *bp, char *def); /* Original BSD version */ |
void __restore_colors __P((void)); |
int __mvcur(int ly, int lx, int y, int x, int in_refresh); |
void __restore_termios __P((void)); |
WINDOW *__newwin(SCREEN *screen, int lines, int cols, int y, int x); |
void __restore_stophandler __P((void)); |
int __nodelay(void); |
void __save_termios __P((void)); |
int __notimeout(void); |
void __set_color __P((attr_t)); |
char *__parse_cap(const char *, ...); |
void __set_stophandler __P((void)); |
void __restartwin(void); |
void __set_subwin __P((WINDOW *, WINDOW *)); |
void __restore_colors(void); |
void __startwin __P((void)); |
void __restore_cursor_vis(void); |
void __stop_signal_handler __P((int)); |
void __restore_meta_state(void); |
int __stopwin __P((void)); |
void __restore_termios(void); |
void __swflags __P((WINDOW *)); |
void __restore_stophandler(void); |
int __timeout __P((int)); |
void __save_termios(void); |
int __touchline __P((WINDOW *, int, int, int, int)); |
void __set_color(attr_t attr); |
int __touchwin __P((WINDOW *)); |
void __set_stophandler(void); |
char *__tscroll __P((const char *, int, int)); |
void __set_subwin(WINDOW *orig, WINDOW *win); |
int __waddch __P((WINDOW *, __LDATA *)); |
void __startwin(SCREEN *screen); |
|
void __stop_signal_handler(int signo); |
|
int __stopwin(void); |
|
void __swflags(WINDOW *win); |
|
int __timeout(int delay); |
|
int __touchline(WINDOW *win, int y, int sx, int ex); |
|
int __touchwin(WINDOW *win); |
|
char *__tscroll(const char *cap, int n1, int n2); |
|
void __unsetattr(int); |
|
int __waddch(WINDOW *win, __LDATA *dp); |
|
int __wgetnstr(WINDOW *, char *, int); |
|
|
/* Private #defines. */ |
/* Private #defines. */ |
#define min(a,b) (a < b ? a : b) |
#define min(a,b) (a < b ? a : b) |
#define max(a,b) (a > b ? a : b) |
#define max(a,b) (a > b ? a : b) |
|
|
/* Private externs. */ |
/* Private externs. */ |
extern int __echoit; |
extern int __echoit; |
extern int __endwin; |
extern int __endwin; |
extern int __pfast; |
extern int __pfast; |
extern int __rawmode; |
extern int __rawmode; |
extern int __noqch; |
extern int __noqch; |
extern attr_t __nca; |
extern attr_t __nca; |
|
extern attr_t __mask_op, __mask_me, __mask_ue, __mask_se; |
|
extern struct __winlist *__winlistp; |
|
extern WINDOW *__virtscr; |