From fe375eb12b08eb032dcc810a38d18a87a7958e67 Mon Sep 17 00:00:00 2001 From: Jens Staal Date: Tue, 6 Mar 2018 11:45:53 +0100 Subject: [PATCH 1/9] updated variant of Plan9 port of PDCurses --- README.Plan9 | 10 + demos/mkfile | 31 + mkfile | 106 ++++ plan9/README | 21 + plan9/curses.h | 1399 ++++++++++++++++++++++++++++++++++++++++++++++ plan9/pdcclip.c | 67 +++ plan9/pdcdisp.c | 58 ++ plan9/pdcgetsc.c | 28 + plan9/pdckbd.c | 52 ++ plan9/pdcplan9.c | 348 ++++++++++++ plan9/pdcplan9.h | 10 + plan9/pdcscrn.c | 114 ++++ plan9/pdcsetsc.c | 33 ++ plan9/pdcutil.c | 24 + 14 files changed, 2301 insertions(+) create mode 100644 README.Plan9 create mode 100644 demos/mkfile create mode 100644 mkfile create mode 100644 plan9/README create mode 100644 plan9/curses.h create mode 100644 plan9/pdcclip.c create mode 100644 plan9/pdcdisp.c create mode 100644 plan9/pdcgetsc.c create mode 100644 plan9/pdckbd.c create mode 100644 plan9/pdcplan9.c create mode 100644 plan9/pdcplan9.h create mode 100644 plan9/pdcscrn.c create mode 100644 plan9/pdcsetsc.c create mode 100644 plan9/pdcutil.c diff --git a/README.Plan9 b/README.Plan9 new file mode 100644 index 000000000..59cb35b8d --- /dev/null +++ b/README.Plan9 @@ -0,0 +1,10 @@ +This is William McBrine PDCurses 3.4 +ported and repackaged for Plan 9. +See README & maintain.er. + +Federico G. Benavento +January 2008 +benavento@gmail.com + +Jens Staal +July 2015 diff --git a/demos/mkfile b/demos/mkfile new file mode 100644 index 000000000..076481ed2 --- /dev/null +++ b/demos/mkfile @@ -0,0 +1,31 @@ +APE=/sys/src/ape +<$APE/config + +TARG=\ + firework\ + newdemo\ + ptest\ + rain\ + testcurs\ + tuidemo\ + worm\ + xmas\ + +HFILES=\ + /sys/include/ape/curses.h\ + /sys/include/ape/panel.h\ + +UPDATE=\ + mkfile\ + $HFILES\ + ${OFILES:%.$O=%.c}\ + /$objtype/ape/lib/libcurses.a + + +#include +#include /* Required by X/Open usage below */ + +#ifdef PDC_WIDE +# include +#endif + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +extern "C" +{ +# define bool _bool +#endif + +/*---------------------------------------------------------------------- + * + * PDCurses Manifest Constants + * + */ + +#ifndef FALSE +# define FALSE 0 +#endif +#ifndef TRUE +# define TRUE 1 +#endif +#ifndef NULL +# define NULL (void *)0 +#endif +#ifndef ERR +# define ERR (-1) +#endif +#ifndef OK +# define OK 0 +#endif + +/*---------------------------------------------------------------------- + * + * PDCurses Type Declarations + * + */ + +typedef unsigned char bool; /* PDCurses Boolean type */ + +#ifdef CHTYPE_LONG +# if _LP64 +typedef unsigned int chtype; +# else +typedef unsigned long chtype; /* 16-bit attr + 16-bit char */ +# endif +#else +typedef unsigned short chtype; /* 8-bit attr + 8-bit char */ +#endif + +#ifdef PDC_WIDE +typedef chtype cchar_t; +#endif + +typedef chtype attr_t; + +/*---------------------------------------------------------------------- + * + * PDCurses Mouse Interface -- SYSVR4, with extensions + * + */ + +typedef struct +{ + int x; /* absolute column, 0 based, measured in characters */ + int y; /* absolute row, 0 based, measured in characters */ + short button[3]; /* state of each button */ + int changes; /* flags indicating what has changed with the mouse */ +} MOUSE_STATUS; + +#define BUTTON_RELEASED 0x0000 +#define BUTTON_PRESSED 0x0001 +#define BUTTON_CLICKED 0x0002 +#define BUTTON_DOUBLE_CLICKED 0x0003 +#define BUTTON_TRIPLE_CLICKED 0x0004 +#define BUTTON_MOVED 0x0005 /* PDCurses */ +#define WHEEL_SCROLLED 0x0006 /* PDCurses */ +#define BUTTON_ACTION_MASK 0x0007 /* PDCurses */ + +#define PDC_BUTTON_SHIFT 0x0008 /* PDCurses */ +#define PDC_BUTTON_CONTROL 0x0010 /* PDCurses */ +#define PDC_BUTTON_ALT 0x0020 /* PDCurses */ +#define BUTTON_MODIFIER_MASK 0x0038 /* PDCurses */ + +#define MOUSE_X_POS (Mouse_status.x) +#define MOUSE_Y_POS (Mouse_status.y) + +/* + * Bits associated with the .changes field: + * 3 2 1 0 + * 210987654321098765432109876543210 + * 1 <- button 1 has changed + * 10 <- button 2 has changed + * 100 <- button 3 has changed + * 1000 <- mouse has moved + * 10000 <- mouse position report + * 100000 <- mouse wheel up + * 1000000 <- mouse wheel down + * 10000000 <- mouse wheel left + * 100000000 <- mouse wheel right + */ + +#define PDC_MOUSE_MOVED 0x0008 +#define PDC_MOUSE_POSITION 0x0010 +#define PDC_MOUSE_WHEEL_UP 0x0020 +#define PDC_MOUSE_WHEEL_DOWN 0x0040 +#define PDC_MOUSE_WHEEL_LEFT 0x0080 +#define PDC_MOUSE_WHEEL_RIGHT 0x0100 + +#define A_BUTTON_CHANGED (Mouse_status.changes & 7) +#define MOUSE_MOVED (Mouse_status.changes & PDC_MOUSE_MOVED) +#define MOUSE_POS_REPORT (Mouse_status.changes & PDC_MOUSE_POSITION) +#define BUTTON_CHANGED(x) (Mouse_status.changes & (1 << ((x) - 1))) +#define BUTTON_STATUS(x) (Mouse_status.button[(x) - 1]) +#define MOUSE_WHEEL_UP (Mouse_status.changes & PDC_MOUSE_WHEEL_UP) +#define MOUSE_WHEEL_DOWN (Mouse_status.changes & PDC_MOUSE_WHEEL_DOWN) +#define MOUSE_WHEEL_LEFT (Mouse_status.changes & PDC_MOUSE_WHEEL_LEFT) +#define MOUSE_WHEEL_RIGHT (Mouse_status.changes & PDC_MOUSE_WHEEL_RIGHT) + +/* mouse bit-masks */ + +#define BUTTON1_RELEASED 0x00000001L +#define BUTTON1_PRESSED 0x00000002L +#define BUTTON1_CLICKED 0x00000004L +#define BUTTON1_DOUBLE_CLICKED 0x00000008L +#define BUTTON1_TRIPLE_CLICKED 0x00000010L +#define BUTTON1_MOVED 0x00000010L /* PDCurses */ + +#define BUTTON2_RELEASED 0x00000020L +#define BUTTON2_PRESSED 0x00000040L +#define BUTTON2_CLICKED 0x00000080L +#define BUTTON2_DOUBLE_CLICKED 0x00000100L +#define BUTTON2_TRIPLE_CLICKED 0x00000200L +#define BUTTON2_MOVED 0x00000200L /* PDCurses */ + +#define BUTTON3_RELEASED 0x00000400L +#define BUTTON3_PRESSED 0x00000800L +#define BUTTON3_CLICKED 0x00001000L +#define BUTTON3_DOUBLE_CLICKED 0x00002000L +#define BUTTON3_TRIPLE_CLICKED 0x00004000L +#define BUTTON3_MOVED 0x00004000L /* PDCurses */ + +/* For the ncurses-compatible functions only, BUTTON4_PRESSED and + BUTTON5_PRESSED are returned for mouse scroll wheel up and down; + otherwise PDCurses doesn't support buttons 4 and 5 */ + +#define BUTTON4_RELEASED 0x00008000L +#define BUTTON4_PRESSED 0x00010000L +#define BUTTON4_CLICKED 0x00020000L +#define BUTTON4_DOUBLE_CLICKED 0x00040000L +#define BUTTON4_TRIPLE_CLICKED 0x00080000L + +#define BUTTON5_RELEASED 0x00100000L +#define BUTTON5_PRESSED 0x00200000L +#define BUTTON5_CLICKED 0x00400000L +#define BUTTON5_DOUBLE_CLICKED 0x00800000L +#define BUTTON5_TRIPLE_CLICKED 0x01000000L + +#define MOUSE_WHEEL_SCROLL 0x02000000L /* PDCurses */ +#define BUTTON_MODIFIER_SHIFT 0x04000000L /* PDCurses */ +#define BUTTON_MODIFIER_CONTROL 0x08000000L /* PDCurses */ +#define BUTTON_MODIFIER_ALT 0x10000000L /* PDCurses */ + +#define ALL_MOUSE_EVENTS 0x1fffffffL +#define REPORT_MOUSE_POSITION 0x20000000L + +/* ncurses mouse interface */ + +typedef unsigned long mmask_t; + +typedef struct +{ + short id; /* unused, always 0 */ + int x, y, z; /* x, y same as MOUSE_STATUS; z unused */ + mmask_t bstate; /* equivalent to changes + button[], but + in the same format as used for mousemask() */ +} MEVENT; + +#ifdef NCURSES_MOUSE_VERSION +# define BUTTON_SHIFT BUTTON_MODIFIER_SHIFT +# define BUTTON_CONTROL BUTTON_MODIFIER_CONTROL +# define BUTTON_CTRL BUTTON_MODIFIER_CONTROL +# define BUTTON_ALT BUTTON_MODIFIER_ALT +#else +# define BUTTON_SHIFT PDC_BUTTON_SHIFT +# define BUTTON_CONTROL PDC_BUTTON_CONTROL +# define BUTTON_ALT PDC_BUTTON_ALT +#endif + +/*---------------------------------------------------------------------- + * + * PDCurses Structure Definitions + * + */ + +typedef struct _win /* definition of a window */ +{ + int _cury; /* current pseudo-cursor */ + int _curx; + int _maxy; /* max window coordinates */ + int _maxx; + int _begy; /* origin on screen */ + int _begx; + int _flags; /* window properties */ + chtype _attrs; /* standard attributes and colors */ + chtype _bkgd; /* background, normally blank */ + bool _clear; /* causes clear at next refresh */ + bool _leaveit; /* leaves cursor where it is */ + bool _scroll; /* allows window scrolling */ + bool _nodelay; /* input character wait flag */ + bool _immed; /* immediate update flag */ + bool _sync; /* synchronise window ancestors */ + bool _use_keypad; /* flags keypad key mode active */ + chtype **_y; /* pointer to line pointer array */ + int *_firstch; /* first changed character in line */ + int *_lastch; /* last changed character in line */ + int _tmarg; /* top of scrolling region */ + int _bmarg; /* bottom of scrolling region */ + int _delayms; /* milliseconds of delay for getch() */ + int _parx, _pary; /* coords relative to parent (0,0) */ + struct _win *_parent; /* subwin's pointer to parent win */ +} WINDOW; + +/* Avoid using the SCREEN struct directly -- use the corresponding + functions if possible. This struct may eventually be made private. */ + +typedef struct +{ + bool alive; /* if initscr() called, and not endwin() */ + bool autocr; /* if cr -> lf */ + bool cbreak; /* if terminal unbuffered */ + bool echo; /* if terminal echo */ + bool raw_inp; /* raw input mode (v. cooked input) */ + bool raw_out; /* raw output mode (7 v. 8 bits) */ + bool audible; /* FALSE if the bell is visual */ + bool mono; /* TRUE if current screen is mono */ + bool resized; /* TRUE if TERM has been resized */ + bool orig_attr; /* TRUE if we have the original colors */ + short orig_fore; /* original screen foreground color */ + short orig_back; /* original screen foreground color */ + int cursrow; /* position of physical cursor */ + int curscol; /* position of physical cursor */ + int visibility; /* visibility of cursor */ + int orig_cursor; /* original cursor size */ + int lines; /* new value for LINES */ + int cols; /* new value for COLS */ + unsigned long _trap_mbe; /* trap these mouse button events */ + unsigned long _map_mbe_to_key; /* map mouse buttons to slk */ + int mouse_wait; /* time to wait (in ms) for a + button release after a press, in + order to count it as a click */ + int slklines; /* lines in use by slk_init() */ + WINDOW *slk_winptr; /* window for slk */ + int linesrippedoff; /* lines ripped off via ripoffline() */ + int linesrippedoffontop; /* lines ripped off on + top via ripoffline() */ + int delaytenths; /* 1/10ths second to wait block + getch() for */ + bool _preserve; /* TRUE if screen background + to be preserved */ + int _restore; /* specifies if screen background + to be restored, and how */ + bool save_key_modifiers; /* TRUE if each key modifiers saved + with each key press */ + bool return_key_modifiers; /* TRUE if modifier keys are + returned as "real" keys */ + bool key_code; /* TRUE if last key is a special key; + used internally by get_wch() */ +#ifdef XCURSES + int XcurscrSize; /* size of Xcurscr shared memory block */ + bool sb_on; + int sb_viewport_y; + int sb_viewport_x; + int sb_total_y; + int sb_total_x; + int sb_cur_y; + int sb_cur_x; +#endif + short line_color; /* color of line attributes - default -1 */ + attr_t termattrs; /* attribute capabilities */ +} SCREEN; + +/*---------------------------------------------------------------------- + * + * PDCurses External Variables + * + */ + +#ifdef PDC_DLL_BUILD +# ifdef CURSES_LIBRARY +# define PDCEX __declspec(dllexport) extern +# else +# define PDCEX __declspec(dllimport) +# endif +#else +# define PDCEX extern +#endif + +PDCEX int LINES; /* terminal height */ +PDCEX int COLS; /* terminal width */ +PDCEX WINDOW *stdscr; /* the default screen window */ +PDCEX WINDOW *curscr; /* the current screen image */ +PDCEX SCREEN *SP; /* curses variables */ +PDCEX MOUSE_STATUS Mouse_status; +PDCEX int COLORS; +PDCEX int COLOR_PAIRS; +PDCEX int TABSIZE; +PDCEX chtype acs_map[]; /* alternate character set map */ +PDCEX char ttytype[]; /* terminal name/description */ + +/*man-start************************************************************** + +PDCurses Text Attributes +======================== + +Originally, PDCurses used a short (16 bits) for its chtype. To include +color, a number of things had to be sacrificed from the strict Unix and +System V support. The main problem was fitting all character attributes +and color into an unsigned char (all 8 bits!). + +Today, PDCurses by default uses a long (32 bits) for its chtype, as in +System V. The short chtype is still available, by undefining CHTYPE_LONG +and rebuilding the library. + +The following is the structure of a win->_attrs chtype: + +short form: + + +-----------------------------------------------+ + |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0| + +-----------------------------------------------+ + color number | attrs | character eg 'a' + +The available non-color attributes are bold, reverse and blink. Others +have no effect. The high order char is an index into an array of +physical colors (defined in color.c) -- 32 foreground/background color +pairs (5 bits) plus 3 bits for other attributes. + +long form: + + +--------------------------------------------------------------------+ + |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|..| 2| 1| 0| + +--------------------------------------------------------------------+ + color number | modifiers | character eg 'a' + +The available non-color attributes are bold, underline, right-line, +left-line, italic, reverse and blink, plus the alternate character set +indicator. 256 color pairs (8 bits), 8 bits for other attributes, and 16 +bits for character data. + +**man-end****************************************************************/ + +/*** Video attribute macros ***/ + +#define A_NORMAL (chtype)0 + +#ifdef CHTYPE_LONG +# define A_ALTCHARSET (chtype)0x00010000 +# define A_RIGHT (chtype)0x00020000 +# define A_LEFT (chtype)0x00040000 +# define A_ITALIC (chtype)0x00080000 +# define A_UNDERLINE (chtype)0x00100000 +# define A_REVERSE (chtype)0x00200000 +# define A_BLINK (chtype)0x00400000 +# define A_BOLD (chtype)0x00800000 + +# define A_ATTRIBUTES (chtype)0xffff0000 +# define A_CHARTEXT (chtype)0x0000ffff +# define A_COLOR (chtype)0xff000000 + +# define PDC_COLOR_SHIFT 24 +#else +# define A_BOLD (chtype)0x0100 /* X/Open */ +# define A_REVERSE (chtype)0x0200 /* X/Open */ +# define A_BLINK (chtype)0x0400 /* X/Open */ + +# define A_ATTRIBUTES (chtype)0xff00 /* X/Open */ +# define A_CHARTEXT (chtype)0x00ff /* X/Open */ +# define A_COLOR (chtype)0xf800 /* System V */ + +# define A_ALTCHARSET A_NORMAL /* X/Open */ +# define A_UNDERLINE A_NORMAL /* X/Open */ + +# define A_LEFT A_NORMAL +# define A_RIGHT A_NORMAL +# define A_ITALIC A_NORMAL + +# define PDC_COLOR_SHIFT 11 +#endif + +#define A_LEFTLINE A_LEFT +#define A_RIGHTLINE A_RIGHT +#define A_STANDOUT (A_REVERSE | A_BOLD) /* X/Open */ + +#define A_DIM A_NORMAL +#define A_INVIS A_NORMAL +#define A_PROTECT A_NORMAL + +#define A_HORIZONTAL A_NORMAL +#define A_LOW A_NORMAL +#define A_TOP A_NORMAL +#define A_VERTICAL A_NORMAL + +#define CHR_MSK A_CHARTEXT /* Obsolete */ +#define ATR_MSK A_ATTRIBUTES /* Obsolete */ +#define ATR_NRM A_NORMAL /* Obsolete */ + +/* For use with attr_t -- X/Open says, "these shall be distinct", so + this is a non-conforming implementation. */ + +#define WA_NORMAL A_NORMAL + +#define WA_ALTCHARSET A_ALTCHARSET +#define WA_BLINK A_BLINK +#define WA_BOLD A_BOLD +#define WA_DIM A_DIM +#define WA_INVIS A_INVIS +#define WA_ITALIC A_ITALIC +#define WA_LEFT A_LEFT +#define WA_PROTECT A_PROTECT +#define WA_REVERSE A_REVERSE +#define WA_RIGHT A_RIGHT +#define WA_STANDOUT A_STANDOUT +#define WA_UNDERLINE A_UNDERLINE + +#define WA_HORIZONTAL A_HORIZONTAL +#define WA_LOW A_LOW +#define WA_TOP A_TOP +#define WA_VERTICAL A_VERTICAL + +#define WA_ATTRIBUTES A_ATTRIBUTES + +/*** Alternate character set macros ***/ + +/* 'w' = 32-bit chtype; acs_map[] index | A_ALTCHARSET + 'n' = 16-bit chtype; it gets the fallback set because no bit is + available for A_ALTCHARSET */ + +#ifdef CHTYPE_LONG +# define ACS_PICK(w, n) ((chtype)w | A_ALTCHARSET) +#else +# define ACS_PICK(w, n) ((chtype)n) +#endif + +/* VT100-compatible symbols -- box chars */ + +#define ACS_ULCORNER ACS_PICK('l', '+') +#define ACS_LLCORNER ACS_PICK('m', '+') +#define ACS_URCORNER ACS_PICK('k', '+') +#define ACS_LRCORNER ACS_PICK('j', '+') +#define ACS_RTEE ACS_PICK('u', '+') +#define ACS_LTEE ACS_PICK('t', '+') +#define ACS_BTEE ACS_PICK('v', '+') +#define ACS_TTEE ACS_PICK('w', '+') +#define ACS_HLINE ACS_PICK('q', '-') +#define ACS_VLINE ACS_PICK('x', '|') +#define ACS_PLUS ACS_PICK('n', '+') + +/* VT100-compatible symbols -- other */ + +#define ACS_S1 ACS_PICK('o', '-') +#define ACS_S9 ACS_PICK('s', '_') +#define ACS_DIAMOND ACS_PICK('`', '+') +#define ACS_CKBOARD ACS_PICK('a', ':') +#define ACS_DEGREE ACS_PICK('f', '\'') +#define ACS_PLMINUS ACS_PICK('g', '#') +#define ACS_BULLET ACS_PICK('~', 'o') + +/* Teletype 5410v1 symbols -- these are defined in SysV curses, but + are not well-supported by most terminals. Stick to VT100 characters + for optimum portability. */ + +#define ACS_LARROW ACS_PICK(',', '<') +#define ACS_RARROW ACS_PICK('+', '>') +#define ACS_DARROW ACS_PICK('.', 'v') +#define ACS_UARROW ACS_PICK('-', '^') +#define ACS_BOARD ACS_PICK('h', '#') +#define ACS_LANTERN ACS_PICK('i', '*') +#define ACS_BLOCK ACS_PICK('0', '#') + +/* That goes double for these -- undocumented SysV symbols. Don't use + them. */ + +#define ACS_S3 ACS_PICK('p', '-') +#define ACS_S7 ACS_PICK('r', '-') +#define ACS_LEQUAL ACS_PICK('y', '<') +#define ACS_GEQUAL ACS_PICK('z', '>') +#define ACS_PI ACS_PICK('{', 'n') +#define ACS_NEQUAL ACS_PICK('|', '+') +#define ACS_STERLING ACS_PICK('}', 'L') + +/* Box char aliases */ + +#define ACS_BSSB ACS_ULCORNER +#define ACS_SSBB ACS_LLCORNER +#define ACS_BBSS ACS_URCORNER +#define ACS_SBBS ACS_LRCORNER +#define ACS_SBSS ACS_RTEE +#define ACS_SSSB ACS_LTEE +#define ACS_SSBS ACS_BTEE +#define ACS_BSSS ACS_TTEE +#define ACS_BSBS ACS_HLINE +#define ACS_SBSB ACS_VLINE +#define ACS_SSSS ACS_PLUS + +/* cchar_t aliases */ + +#ifdef PDC_WIDE +# define WACS_ULCORNER (&(acs_map['l'])) +# define WACS_LLCORNER (&(acs_map['m'])) +# define WACS_URCORNER (&(acs_map['k'])) +# define WACS_LRCORNER (&(acs_map['j'])) +# define WACS_RTEE (&(acs_map['u'])) +# define WACS_LTEE (&(acs_map['t'])) +# define WACS_BTEE (&(acs_map['v'])) +# define WACS_TTEE (&(acs_map['w'])) +# define WACS_HLINE (&(acs_map['q'])) +# define WACS_VLINE (&(acs_map['x'])) +# define WACS_PLUS (&(acs_map['n'])) + +# define WACS_S1 (&(acs_map['o'])) +# define WACS_S9 (&(acs_map['s'])) +# define WACS_DIAMOND (&(acs_map['`'])) +# define WACS_CKBOARD (&(acs_map['a'])) +# define WACS_DEGREE (&(acs_map['f'])) +# define WACS_PLMINUS (&(acs_map['g'])) +# define WACS_BULLET (&(acs_map['~'])) + +# define WACS_LARROW (&(acs_map[','])) +# define WACS_RARROW (&(acs_map['+'])) +# define WACS_DARROW (&(acs_map['.'])) +# define WACS_UARROW (&(acs_map['-'])) +# define WACS_BOARD (&(acs_map['h'])) +# define WACS_LANTERN (&(acs_map['i'])) +# define WACS_BLOCK (&(acs_map['0'])) + +# define WACS_S3 (&(acs_map['p'])) +# define WACS_S7 (&(acs_map['r'])) +# define WACS_LEQUAL (&(acs_map['y'])) +# define WACS_GEQUAL (&(acs_map['z'])) +# define WACS_PI (&(acs_map['{'])) +# define WACS_NEQUAL (&(acs_map['|'])) +# define WACS_STERLING (&(acs_map['}'])) + +# define WACS_BSSB WACS_ULCORNER +# define WACS_SSBB WACS_LLCORNER +# define WACS_BBSS WACS_URCORNER +# define WACS_SBBS WACS_LRCORNER +# define WACS_SBSS WACS_RTEE +# define WACS_SSSB WACS_LTEE +# define WACS_SSBS WACS_BTEE +# define WACS_BSSS WACS_TTEE +# define WACS_BSBS WACS_HLINE +# define WACS_SBSB WACS_VLINE +# define WACS_SSSS WACS_PLUS +#endif + +/*** Color macros ***/ + +#define COLOR_BLACK 0 + +#ifdef PDC_RGB /* RGB */ +# define COLOR_RED 1 +# define COLOR_GREEN 2 +# define COLOR_BLUE 4 +#else /* BGR */ +# define COLOR_BLUE 1 +# define COLOR_GREEN 2 +# define COLOR_RED 4 +#endif + +#define COLOR_CYAN (COLOR_BLUE | COLOR_GREEN) +#define COLOR_MAGENTA (COLOR_RED | COLOR_BLUE) +#define COLOR_YELLOW (COLOR_RED | COLOR_GREEN) + +#define COLOR_WHITE 7 + +/*---------------------------------------------------------------------- + * + * Function and Keypad Key Definitions. + * Many are just for compatibility. + * + */ + +#define KEY_CODE_YES 0x100 /* If get_wch() gives a key code */ + +#define KEY_BREAK 0x101 /* Not on PC KBD */ +#define KEY_DOWN 0x102 /* Down arrow key */ +#define KEY_UP 0x103 /* Up arrow key */ +#define KEY_LEFT 0x104 /* Left arrow key */ +#define KEY_RIGHT 0x105 /* Right arrow key */ +#define KEY_HOME 0x106 /* home key */ +#define KEY_BACKSPACE 0x107 /* not on pc */ +#define KEY_F0 0x108 /* function keys; 64 reserved */ + +#define KEY_DL 0x148 /* delete line */ +#define KEY_IL 0x149 /* insert line */ +#define KEY_DC 0x14a /* delete character */ +#define KEY_IC 0x14b /* insert char or enter ins mode */ +#define KEY_EIC 0x14c /* exit insert char mode */ +#define KEY_CLEAR 0x14d /* clear screen */ +#define KEY_EOS 0x14e /* clear to end of screen */ +#define KEY_EOL 0x14f /* clear to end of line */ +#define KEY_SF 0x150 /* scroll 1 line forward */ +#define KEY_SR 0x151 /* scroll 1 line back (reverse) */ +#define KEY_NPAGE 0x152 /* next page */ +#define KEY_PPAGE 0x153 /* previous page */ +#define KEY_STAB 0x154 /* set tab */ +#define KEY_CTAB 0x155 /* clear tab */ +#define KEY_CATAB 0x156 /* clear all tabs */ +#define KEY_ENTER 0x157 /* enter or send (unreliable) */ +#define KEY_SRESET 0x158 /* soft/reset (partial/unreliable) */ +#define KEY_RESET 0x159 /* reset/hard reset (unreliable) */ +#define KEY_PRINT 0x15a /* print/copy */ +#define KEY_LL 0x15b /* home down/bottom (lower left) */ +#define KEY_ABORT 0x15c /* abort/terminate key (any) */ +#define KEY_SHELP 0x15d /* short help */ +#define KEY_LHELP 0x15e /* long help */ +#define KEY_BTAB 0x15f /* Back tab key */ +#define KEY_BEG 0x160 /* beg(inning) key */ +#define KEY_CANCEL 0x161 /* cancel key */ +#define KEY_CLOSE 0x162 /* close key */ +#define KEY_COMMAND 0x163 /* cmd (command) key */ +#define KEY_COPY 0x164 /* copy key */ +#define KEY_CREATE 0x165 /* create key */ +#define KEY_END 0x166 /* end key */ +#define KEY_EXIT 0x167 /* exit key */ +#define KEY_FIND 0x168 /* find key */ +#define KEY_HELP 0x169 /* help key */ +#define KEY_MARK 0x16a /* mark key */ +#define KEY_MESSAGE 0x16b /* message key */ +#define KEY_MOVE 0x16c /* move key */ +#define KEY_NEXT 0x16d /* next object key */ +#define KEY_OPEN 0x16e /* open key */ +#define KEY_OPTIONS 0x16f /* options key */ +#define KEY_PREVIOUS 0x170 /* previous object key */ +#define KEY_REDO 0x171 /* redo key */ +#define KEY_REFERENCE 0x172 /* ref(erence) key */ +#define KEY_REFRESH 0x173 /* refresh key */ +#define KEY_REPLACE 0x174 /* replace key */ +#define KEY_RESTART 0x175 /* restart key */ +#define KEY_RESUME 0x176 /* resume key */ +#define KEY_SAVE 0x177 /* save key */ +#define KEY_SBEG 0x178 /* shifted beginning key */ +#define KEY_SCANCEL 0x179 /* shifted cancel key */ +#define KEY_SCOMMAND 0x17a /* shifted command key */ +#define KEY_SCOPY 0x17b /* shifted copy key */ +#define KEY_SCREATE 0x17c /* shifted create key */ +#define KEY_SDC 0x17d /* shifted delete char key */ +#define KEY_SDL 0x17e /* shifted delete line key */ +#define KEY_SELECT 0x17f /* select key */ +#define KEY_SEND 0x180 /* shifted end key */ +#define KEY_SEOL 0x181 /* shifted clear line key */ +#define KEY_SEXIT 0x182 /* shifted exit key */ +#define KEY_SFIND 0x183 /* shifted find key */ +#define KEY_SHOME 0x184 /* shifted home key */ +#define KEY_SIC 0x185 /* shifted input key */ + +#define KEY_SLEFT 0x187 /* shifted left arrow key */ +#define KEY_SMESSAGE 0x188 /* shifted message key */ +#define KEY_SMOVE 0x189 /* shifted move key */ +#define KEY_SNEXT 0x18a /* shifted next key */ +#define KEY_SOPTIONS 0x18b /* shifted options key */ +#define KEY_SPREVIOUS 0x18c /* shifted prev key */ +#define KEY_SPRINT 0x18d /* shifted print key */ +#define KEY_SREDO 0x18e /* shifted redo key */ +#define KEY_SREPLACE 0x18f /* shifted replace key */ +#define KEY_SRIGHT 0x190 /* shifted right arrow */ +#define KEY_SRSUME 0x191 /* shifted resume key */ +#define KEY_SSAVE 0x192 /* shifted save key */ +#define KEY_SSUSPEND 0x193 /* shifted suspend key */ +#define KEY_SUNDO 0x194 /* shifted undo key */ +#define KEY_SUSPEND 0x195 /* suspend key */ +#define KEY_UNDO 0x196 /* undo key */ + +/* PDCurses-specific key definitions -- PC only */ + +#define ALT_0 0x197 +#define ALT_1 0x198 +#define ALT_2 0x199 +#define ALT_3 0x19a +#define ALT_4 0x19b +#define ALT_5 0x19c +#define ALT_6 0x19d +#define ALT_7 0x19e +#define ALT_8 0x19f +#define ALT_9 0x1a0 +#define ALT_A 0x1a1 +#define ALT_B 0x1a2 +#define ALT_C 0x1a3 +#define ALT_D 0x1a4 +#define ALT_E 0x1a5 +#define ALT_F 0x1a6 +#define ALT_G 0x1a7 +#define ALT_H 0x1a8 +#define ALT_I 0x1a9 +#define ALT_J 0x1aa +#define ALT_K 0x1ab +#define ALT_L 0x1ac +#define ALT_M 0x1ad +#define ALT_N 0x1ae +#define ALT_O 0x1af +#define ALT_P 0x1b0 +#define ALT_Q 0x1b1 +#define ALT_R 0x1b2 +#define ALT_S 0x1b3 +#define ALT_T 0x1b4 +#define ALT_U 0x1b5 +#define ALT_V 0x1b6 +#define ALT_W 0x1b7 +#define ALT_X 0x1b8 +#define ALT_Y 0x1b9 +#define ALT_Z 0x1ba + +#define CTL_LEFT 0x1bb /* Control-Left-Arrow */ +#define CTL_RIGHT 0x1bc +#define CTL_PGUP 0x1bd +#define CTL_PGDN 0x1be +#define CTL_HOME 0x1bf +#define CTL_END 0x1c0 + +#define KEY_A1 0x1c1 /* upper left on Virtual keypad */ +#define KEY_A2 0x1c2 /* upper middle on Virt. keypad */ +#define KEY_A3 0x1c3 /* upper right on Vir. keypad */ +#define KEY_B1 0x1c4 /* middle left on Virt. keypad */ +#define KEY_B2 0x1c5 /* center on Virt. keypad */ +#define KEY_B3 0x1c6 /* middle right on Vir. keypad */ +#define KEY_C1 0x1c7 /* lower left on Virt. keypad */ +#define KEY_C2 0x1c8 /* lower middle on Virt. keypad */ +#define KEY_C3 0x1c9 /* lower right on Vir. keypad */ + +#define PADSLASH 0x1ca /* slash on keypad */ +#define PADENTER 0x1cb /* enter on keypad */ +#define CTL_PADENTER 0x1cc /* ctl-enter on keypad */ +#define ALT_PADENTER 0x1cd /* alt-enter on keypad */ +#define PADSTOP 0x1ce /* stop on keypad */ +#define PADSTAR 0x1cf /* star on keypad */ +#define PADMINUS 0x1d0 /* minus on keypad */ +#define PADPLUS 0x1d1 /* plus on keypad */ +#define CTL_PADSTOP 0x1d2 /* ctl-stop on keypad */ +#define CTL_PADCENTER 0x1d3 /* ctl-enter on keypad */ +#define CTL_PADPLUS 0x1d4 /* ctl-plus on keypad */ +#define CTL_PADMINUS 0x1d5 /* ctl-minus on keypad */ +#define CTL_PADSLASH 0x1d6 /* ctl-slash on keypad */ +#define CTL_PADSTAR 0x1d7 /* ctl-star on keypad */ +#define ALT_PADPLUS 0x1d8 /* alt-plus on keypad */ +#define ALT_PADMINUS 0x1d9 /* alt-minus on keypad */ +#define ALT_PADSLASH 0x1da /* alt-slash on keypad */ +#define ALT_PADSTAR 0x1db /* alt-star on keypad */ +#define ALT_PADSTOP 0x1dc /* alt-stop on keypad */ +#define CTL_INS 0x1dd /* ctl-insert */ +#define ALT_DEL 0x1de /* alt-delete */ +#define ALT_INS 0x1df /* alt-insert */ +#define CTL_UP 0x1e0 /* ctl-up arrow */ +#define CTL_DOWN 0x1e1 /* ctl-down arrow */ +#define CTL_TAB 0x1e2 /* ctl-tab */ +#define ALT_TAB 0x1e3 +#define ALT_MINUS 0x1e4 +#define ALT_EQUAL 0x1e5 +#define ALT_HOME 0x1e6 +#define ALT_PGUP 0x1e7 +#define ALT_PGDN 0x1e8 +#define ALT_END 0x1e9 +#define ALT_UP 0x1ea /* alt-up arrow */ +#define ALT_DOWN 0x1eb /* alt-down arrow */ +#define ALT_RIGHT 0x1ec /* alt-right arrow */ +#define ALT_LEFT 0x1ed /* alt-left arrow */ +#define ALT_ENTER 0x1ee /* alt-enter */ +#define ALT_ESC 0x1ef /* alt-escape */ +#define ALT_BQUOTE 0x1f0 /* alt-back quote */ +#define ALT_LBRACKET 0x1f1 /* alt-left bracket */ +#define ALT_RBRACKET 0x1f2 /* alt-right bracket */ +#define ALT_SEMICOLON 0x1f3 /* alt-semi-colon */ +#define ALT_FQUOTE 0x1f4 /* alt-forward quote */ +#define ALT_COMMA 0x1f5 /* alt-comma */ +#define ALT_STOP 0x1f6 /* alt-stop */ +#define ALT_FSLASH 0x1f7 /* alt-forward slash */ +#define ALT_BKSP 0x1f8 /* alt-backspace */ +#define CTL_BKSP 0x1f9 /* ctl-backspace */ +#define PAD0 0x1fa /* keypad 0 */ + +#define CTL_PAD0 0x1fb /* ctl-keypad 0 */ +#define CTL_PAD1 0x1fc +#define CTL_PAD2 0x1fd +#define CTL_PAD3 0x1fe +#define CTL_PAD4 0x1ff +#define CTL_PAD5 0x200 +#define CTL_PAD6 0x201 +#define CTL_PAD7 0x202 +#define CTL_PAD8 0x203 +#define CTL_PAD9 0x204 + +#define ALT_PAD0 0x205 /* alt-keypad 0 */ +#define ALT_PAD1 0x206 +#define ALT_PAD2 0x207 +#define ALT_PAD3 0x208 +#define ALT_PAD4 0x209 +#define ALT_PAD5 0x20a +#define ALT_PAD6 0x20b +#define ALT_PAD7 0x20c +#define ALT_PAD8 0x20d +#define ALT_PAD9 0x20e + +#define CTL_DEL 0x20f /* clt-delete */ +#define ALT_BSLASH 0x210 /* alt-back slash */ +#define CTL_ENTER 0x211 /* ctl-enter */ + +#define SHF_PADENTER 0x212 /* shift-enter on keypad */ +#define SHF_PADSLASH 0x213 /* shift-slash on keypad */ +#define SHF_PADSTAR 0x214 /* shift-star on keypad */ +#define SHF_PADPLUS 0x215 /* shift-plus on keypad */ +#define SHF_PADMINUS 0x216 /* shift-minus on keypad */ +#define SHF_UP 0x217 /* shift-up on keypad */ +#define SHF_DOWN 0x218 /* shift-down on keypad */ +#define SHF_IC 0x219 /* shift-insert on keypad */ +#define SHF_DC 0x21a /* shift-delete on keypad */ + +#define KEY_MOUSE 0x21b /* "mouse" key */ +#define KEY_SHIFT_L 0x21c /* Left-shift */ +#define KEY_SHIFT_R 0x21d /* Right-shift */ +#define KEY_CONTROL_L 0x21e /* Left-control */ +#define KEY_CONTROL_R 0x21f /* Right-control */ +#define KEY_ALT_L 0x220 /* Left-alt */ +#define KEY_ALT_R 0x221 /* Right-alt */ +#define KEY_RESIZE 0x222 /* Window resize */ +#define KEY_SUP 0x223 /* Shifted up arrow */ +#define KEY_SDOWN 0x224 /* Shifted down arrow */ + +#define KEY_MIN KEY_BREAK /* Minimum curses key value */ +#define KEY_MAX KEY_SDOWN /* Maximum curses key */ + +#define KEY_F(n) (KEY_F0 + (n)) + +/*---------------------------------------------------------------------- + * + * PDCurses Function Declarations + * + */ + +/* Standard */ + +PDCEX int addch(const chtype); +PDCEX int addchnstr(const chtype *, int); +PDCEX int addchstr(const chtype *); +PDCEX int addnstr(const char *, int); +PDCEX int addstr(const char *); +PDCEX int attroff(chtype); +PDCEX int attron(chtype); +PDCEX int attrset(chtype); +PDCEX int attr_get(attr_t *, short *, void *); +PDCEX int attr_off(attr_t, void *); +PDCEX int attr_on(attr_t, void *); +PDCEX int attr_set(attr_t, short, void *); +PDCEX int baudrate(void); +PDCEX int beep(void); +PDCEX int bkgd(chtype); +PDCEX void bkgdset(chtype); +PDCEX int border(chtype, chtype, chtype, chtype, + chtype, chtype, chtype, chtype); +PDCEX int box(WINDOW *, chtype, chtype); +PDCEX bool can_change_color(void); +PDCEX int cbreak(void); +PDCEX int chgat(int, attr_t, short, const void *); +PDCEX int clearok(WINDOW *, bool); +PDCEX int clear(void); +PDCEX int clrtobot(void); +PDCEX int clrtoeol(void); +PDCEX int color_content(short, short *, short *, short *); +PDCEX int color_set(short, void *); +PDCEX int copywin(const WINDOW *, WINDOW *, int, int, int, + int, int, int, int); +PDCEX int curs_set(int); +PDCEX int def_prog_mode(void); +PDCEX int def_shell_mode(void); +PDCEX int delay_output(int); +PDCEX int delch(void); +PDCEX int deleteln(void); +PDCEX void delscreen(SCREEN *); +PDCEX int delwin(WINDOW *); +PDCEX WINDOW *derwin(WINDOW *, int, int, int, int); +PDCEX int doupdate(void); +PDCEX WINDOW *dupwin(WINDOW *); +PDCEX int echochar(const chtype); +PDCEX int echo(void); +PDCEX int endwin(void); +PDCEX char erasechar(void); +PDCEX int erase(void); +PDCEX void filter(void); +PDCEX int flash(void); +PDCEX int flushinp(void); +PDCEX chtype getbkgd(WINDOW *); +PDCEX int getnstr(char *, int); +PDCEX int getstr(char *); +PDCEX WINDOW *getwin(FILE *); +PDCEX int halfdelay(int); +PDCEX bool has_colors(void); +PDCEX bool has_ic(void); +PDCEX bool has_il(void); +PDCEX int hline(chtype, int); +PDCEX void idcok(WINDOW *, bool); +PDCEX int idlok(WINDOW *, bool); +PDCEX void immedok(WINDOW *, bool); +PDCEX int inchnstr(chtype *, int); +PDCEX int inchstr(chtype *); +PDCEX chtype inch(void); +PDCEX int init_color(short, short, short, short); +PDCEX int init_pair(short, short, short); +PDCEX WINDOW *initscr(void); +PDCEX int innstr(char *, int); +PDCEX int insch(chtype); +PDCEX int insdelln(int); +PDCEX int insertln(void); +PDCEX int insnstr(const char *, int); +PDCEX int insstr(const char *); +PDCEX int instr(char *); +PDCEX int intrflush(WINDOW *, bool); +PDCEX bool isendwin(void); +PDCEX bool is_linetouched(WINDOW *, int); +PDCEX bool is_wintouched(WINDOW *); +PDCEX char *keyname(int); +PDCEX int keypad(WINDOW *, bool); +PDCEX char killchar(void); +PDCEX int leaveok(WINDOW *, bool); +PDCEX char *longname(void); +PDCEX int meta(WINDOW *, bool); +PDCEX int move(int, int); +PDCEX int mvaddch(int, int, const chtype); +PDCEX int mvaddchnstr(int, int, const chtype *, int); +PDCEX int mvaddchstr(int, int, const chtype *); +PDCEX int mvaddnstr(int, int, const char *, int); +PDCEX int mvaddstr(int, int, const char *); +PDCEX int mvchgat(int, int, int, attr_t, short, const void *); +PDCEX int mvcur(int, int, int, int); +PDCEX int mvdelch(int, int); +PDCEX int mvderwin(WINDOW *, int, int); +PDCEX int mvgetch(int, int); +PDCEX int mvgetnstr(int, int, char *, int); +PDCEX int mvgetstr(int, int, char *); +PDCEX int mvhline(int, int, chtype, int); +PDCEX chtype mvinch(int, int); +PDCEX int mvinchnstr(int, int, chtype *, int); +PDCEX int mvinchstr(int, int, chtype *); +PDCEX int mvinnstr(int, int, char *, int); +PDCEX int mvinsch(int, int, chtype); +PDCEX int mvinsnstr(int, int, const char *, int); +PDCEX int mvinsstr(int, int, const char *); +PDCEX int mvinstr(int, int, char *); +PDCEX int mvprintw(int, int, const char *, ...); +PDCEX int mvscanw(int, int, const char *, ...); +PDCEX int mvvline(int, int, chtype, int); +PDCEX int mvwaddchnstr(WINDOW *, int, int, const chtype *, int); +PDCEX int mvwaddchstr(WINDOW *, int, int, const chtype *); +PDCEX int mvwaddch(WINDOW *, int, int, const chtype); +PDCEX int mvwaddnstr(WINDOW *, int, int, const char *, int); +PDCEX int mvwaddstr(WINDOW *, int, int, const char *); +PDCEX int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *); +PDCEX int mvwdelch(WINDOW *, int, int); +PDCEX int mvwgetch(WINDOW *, int, int); +PDCEX int mvwgetnstr(WINDOW *, int, int, char *, int); +PDCEX int mvwgetstr(WINDOW *, int, int, char *); +PDCEX int mvwhline(WINDOW *, int, int, chtype, int); +PDCEX int mvwinchnstr(WINDOW *, int, int, chtype *, int); +PDCEX int mvwinchstr(WINDOW *, int, int, chtype *); +PDCEX chtype mvwinch(WINDOW *, int, int); +PDCEX int mvwinnstr(WINDOW *, int, int, char *, int); +PDCEX int mvwinsch(WINDOW *, int, int, chtype); +PDCEX int mvwinsnstr(WINDOW *, int, int, const char *, int); +PDCEX int mvwinsstr(WINDOW *, int, int, const char *); +PDCEX int mvwinstr(WINDOW *, int, int, char *); +PDCEX int mvwin(WINDOW *, int, int); +PDCEX int mvwprintw(WINDOW *, int, int, const char *, ...); +PDCEX int mvwscanw(WINDOW *, int, int, const char *, ...); +PDCEX int mvwvline(WINDOW *, int, int, chtype, int); +PDCEX int napms(int); +PDCEX WINDOW *newpad(int, int); +PDCEX SCREEN *newterm(const char *, FILE *, FILE *); +PDCEX WINDOW *newwin(int, int, int, int); +PDCEX int nl(void); +PDCEX int nocbreak(void); +PDCEX int nodelay(WINDOW *, bool); +PDCEX int noecho(void); +PDCEX int nonl(void); +PDCEX void noqiflush(void); +PDCEX int noraw(void); +PDCEX int notimeout(WINDOW *, bool); +PDCEX int overlay(const WINDOW *, WINDOW *); +PDCEX int overwrite(const WINDOW *, WINDOW *); +PDCEX int pair_content(short, short *, short *); +PDCEX int pechochar(WINDOW *, chtype); +PDCEX int pnoutrefresh(WINDOW *, int, int, int, int, int, int); +PDCEX int prefresh(WINDOW *, int, int, int, int, int, int); +PDCEX int printw(const char *, ...); +PDCEX int putwin(WINDOW *, FILE *); +PDCEX void qiflush(void); +PDCEX int raw(void); +PDCEX int redrawwin(WINDOW *); +PDCEX int refresh(void); +PDCEX int reset_prog_mode(void); +PDCEX int reset_shell_mode(void); +PDCEX int resetty(void); +PDCEX int ripoffline(int, int (*)(WINDOW *, int)); +PDCEX int savetty(void); +PDCEX int scanw(const char *, ...); +PDCEX int scr_dump(const char *); +PDCEX int scr_init(const char *); +PDCEX int scr_restore(const char *); +PDCEX int scr_set(const char *); +PDCEX int scrl(int); +PDCEX int scroll(WINDOW *); +PDCEX int scrollok(WINDOW *, bool); +PDCEX SCREEN *set_term(SCREEN *); +PDCEX int setscrreg(int, int); +PDCEX int slk_attroff(const chtype); +PDCEX int slk_attr_off(const attr_t, void *); +PDCEX int slk_attron(const chtype); +PDCEX int slk_attr_on(const attr_t, void *); +PDCEX int slk_attrset(const chtype); +PDCEX int slk_attr_set(const attr_t, short, void *); +PDCEX int slk_clear(void); +PDCEX int slk_color(short); +PDCEX int slk_init(int); +PDCEX char *slk_label(int); +PDCEX int slk_noutrefresh(void); +PDCEX int slk_refresh(void); +PDCEX int slk_restore(void); +PDCEX int slk_set(int, const char *, int); +PDCEX int slk_touch(void); +PDCEX int standend(void); +PDCEX int standout(void); +PDCEX int start_color(void); +PDCEX WINDOW *subpad(WINDOW *, int, int, int, int); +PDCEX WINDOW *subwin(WINDOW *, int, int, int, int); +PDCEX int syncok(WINDOW *, bool); +PDCEX chtype termattrs(void); +PDCEX attr_t term_attrs(void); +PDCEX char *termname(void); +PDCEX void timeout(int); +PDCEX int touchline(WINDOW *, int, int); +PDCEX int touchwin(WINDOW *); +PDCEX int typeahead(int); +PDCEX int untouchwin(WINDOW *); +PDCEX void use_env(bool); +PDCEX int vidattr(chtype); +PDCEX int vid_attr(attr_t, short, void *); +PDCEX int vidputs(chtype, int (*)(int)); +PDCEX int vid_puts(attr_t, short, void *, int (*)(int)); +PDCEX int vline(chtype, int); +PDCEX int vw_printw(WINDOW *, const char *, va_list); +PDCEX int vwprintw(WINDOW *, const char *, va_list); +PDCEX int vw_scanw(WINDOW *, const char *, va_list); +PDCEX int vwscanw(WINDOW *, const char *, va_list); +PDCEX int waddchnstr(WINDOW *, const chtype *, int); +PDCEX int waddchstr(WINDOW *, const chtype *); +PDCEX int waddch(WINDOW *, const chtype); +PDCEX int waddnstr(WINDOW *, const char *, int); +PDCEX int waddstr(WINDOW *, const char *); +PDCEX int wattroff(WINDOW *, chtype); +PDCEX int wattron(WINDOW *, chtype); +PDCEX int wattrset(WINDOW *, chtype); +PDCEX int wattr_get(WINDOW *, attr_t *, short *, void *); +PDCEX int wattr_off(WINDOW *, attr_t, void *); +PDCEX int wattr_on(WINDOW *, attr_t, void *); +PDCEX int wattr_set(WINDOW *, attr_t, short, void *); +PDCEX void wbkgdset(WINDOW *, chtype); +PDCEX int wbkgd(WINDOW *, chtype); +PDCEX int wborder(WINDOW *, chtype, chtype, chtype, chtype, + chtype, chtype, chtype, chtype); +PDCEX int wchgat(WINDOW *, int, attr_t, short, const void *); +PDCEX int wclear(WINDOW *); +PDCEX int wclrtobot(WINDOW *); +PDCEX int wclrtoeol(WINDOW *); +PDCEX int wcolor_set(WINDOW *, short, void *); +PDCEX void wcursyncup(WINDOW *); +PDCEX int wdelch(WINDOW *); +PDCEX int wdeleteln(WINDOW *); +PDCEX int wechochar(WINDOW *, const chtype); +PDCEX int werase(WINDOW *); +PDCEX int wgetch(WINDOW *); +PDCEX int wgetnstr(WINDOW *, char *, int); +PDCEX int wgetstr(WINDOW *, char *); +PDCEX int whline(WINDOW *, chtype, int); +PDCEX int winchnstr(WINDOW *, chtype *, int); +PDCEX int winchstr(WINDOW *, chtype *); +PDCEX chtype winch(WINDOW *); +PDCEX int winnstr(WINDOW *, char *, int); +PDCEX int winsch(WINDOW *, chtype); +PDCEX int winsdelln(WINDOW *, int); +PDCEX int winsertln(WINDOW *); +PDCEX int winsnstr(WINDOW *, const char *, int); +PDCEX int winsstr(WINDOW *, const char *); +PDCEX int winstr(WINDOW *, char *); +PDCEX int wmove(WINDOW *, int, int); +PDCEX int wnoutrefresh(WINDOW *); +PDCEX int wprintw(WINDOW *, const char *, ...); +PDCEX int wredrawln(WINDOW *, int, int); +PDCEX int wrefresh(WINDOW *); +PDCEX int wscanw(WINDOW *, const char *, ...); +PDCEX int wscrl(WINDOW *, int); +PDCEX int wsetscrreg(WINDOW *, int, int); +PDCEX int wstandend(WINDOW *); +PDCEX int wstandout(WINDOW *); +PDCEX void wsyncdown(WINDOW *); +PDCEX void wsyncup(WINDOW *); +PDCEX void wtimeout(WINDOW *, int); +PDCEX int wtouchln(WINDOW *, int, int, int); +PDCEX int wvline(WINDOW *, chtype, int); + +/* Wide-character functions */ + +#ifdef PDC_WIDE +PDCEX int addnwstr(const wchar_t *, int); +PDCEX int addwstr(const wchar_t *); +PDCEX int add_wch(const cchar_t *); +PDCEX int add_wchnstr(const cchar_t *, int); +PDCEX int add_wchstr(const cchar_t *); +PDCEX int bkgrnd(const cchar_t *); +PDCEX void bkgrndset(const cchar_t *); +PDCEX int border_set(const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *); +PDCEX int box_set(WINDOW *, const cchar_t *, const cchar_t *); +PDCEX int echo_wchar(const cchar_t *); +PDCEX int erasewchar(wchar_t *); +PDCEX int getbkgrnd(cchar_t *); +PDCEX int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *); +PDCEX int getn_wstr(wint_t *, int); +PDCEX int get_wch(wint_t *); +PDCEX int get_wstr(wint_t *); +PDCEX int hline_set(const cchar_t *, int); +PDCEX int innwstr(wchar_t *, int); +PDCEX int ins_nwstr(const wchar_t *, int); +PDCEX int ins_wch(const cchar_t *); +PDCEX int ins_wstr(const wchar_t *); +PDCEX int inwstr(wchar_t *); +PDCEX int in_wch(cchar_t *); +PDCEX int in_wchnstr(cchar_t *, int); +PDCEX int in_wchstr(cchar_t *); +PDCEX char *key_name(wchar_t); +PDCEX int killwchar(wchar_t *); +PDCEX int mvaddnwstr(int, int, const wchar_t *, int); +PDCEX int mvaddwstr(int, int, const wchar_t *); +PDCEX int mvadd_wch(int, int, const cchar_t *); +PDCEX int mvadd_wchnstr(int, int, const cchar_t *, int); +PDCEX int mvadd_wchstr(int, int, const cchar_t *); +PDCEX int mvgetn_wstr(int, int, wint_t *, int); +PDCEX int mvget_wch(int, int, wint_t *); +PDCEX int mvget_wstr(int, int, wint_t *); +PDCEX int mvhline_set(int, int, const cchar_t *, int); +PDCEX int mvinnwstr(int, int, wchar_t *, int); +PDCEX int mvins_nwstr(int, int, const wchar_t *, int); +PDCEX int mvins_wch(int, int, const cchar_t *); +PDCEX int mvins_wstr(int, int, const wchar_t *); +PDCEX int mvinwstr(int, int, wchar_t *); +PDCEX int mvin_wch(int, int, cchar_t *); +PDCEX int mvin_wchnstr(int, int, cchar_t *, int); +PDCEX int mvin_wchstr(int, int, cchar_t *); +PDCEX int mvvline_set(int, int, const cchar_t *, int); +PDCEX int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int); +PDCEX int mvwaddwstr(WINDOW *, int, int, const wchar_t *); +PDCEX int mvwadd_wch(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int); +PDCEX int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int); +PDCEX int mvwget_wch(WINDOW *, int, int, wint_t *); +PDCEX int mvwget_wstr(WINDOW *, int, int, wint_t *); +PDCEX int mvwhline_set(WINDOW *, int, int, const cchar_t *, int); +PDCEX int mvwinnwstr(WINDOW *, int, int, wchar_t *, int); +PDCEX int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int); +PDCEX int mvwins_wch(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwins_wstr(WINDOW *, int, int, const wchar_t *); +PDCEX int mvwin_wch(WINDOW *, int, int, cchar_t *); +PDCEX int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int); +PDCEX int mvwin_wchstr(WINDOW *, int, int, cchar_t *); +PDCEX int mvwinwstr(WINDOW *, int, int, wchar_t *); +PDCEX int mvwvline_set(WINDOW *, int, int, const cchar_t *, int); +PDCEX int pecho_wchar(WINDOW *, const cchar_t*); +PDCEX int setcchar(cchar_t*, const wchar_t*, const attr_t, + short, const void*); +PDCEX int slk_wset(int, const wchar_t *, int); +PDCEX int unget_wch(const wchar_t); +PDCEX int vline_set(const cchar_t *, int); +PDCEX int waddnwstr(WINDOW *, const wchar_t *, int); +PDCEX int waddwstr(WINDOW *, const wchar_t *); +PDCEX int wadd_wch(WINDOW *, const cchar_t *); +PDCEX int wadd_wchnstr(WINDOW *, const cchar_t *, int); +PDCEX int wadd_wchstr(WINDOW *, const cchar_t *); +PDCEX int wbkgrnd(WINDOW *, const cchar_t *); +PDCEX void wbkgrndset(WINDOW *, const cchar_t *); +PDCEX int wborder_set(WINDOW *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *); +PDCEX int wecho_wchar(WINDOW *, const cchar_t *); +PDCEX int wgetbkgrnd(WINDOW *, cchar_t *); +PDCEX int wgetn_wstr(WINDOW *, wint_t *, int); +PDCEX int wget_wch(WINDOW *, wint_t *); +PDCEX int wget_wstr(WINDOW *, wint_t *); +PDCEX int whline_set(WINDOW *, const cchar_t *, int); +PDCEX int winnwstr(WINDOW *, wchar_t *, int); +PDCEX int wins_nwstr(WINDOW *, const wchar_t *, int); +PDCEX int wins_wch(WINDOW *, const cchar_t *); +PDCEX int wins_wstr(WINDOW *, const wchar_t *); +PDCEX int winwstr(WINDOW *, wchar_t *); +PDCEX int win_wch(WINDOW *, cchar_t *); +PDCEX int win_wchnstr(WINDOW *, cchar_t *, int); +PDCEX int win_wchstr(WINDOW *, cchar_t *); +PDCEX wchar_t *wunctrl(cchar_t *); +PDCEX int wvline_set(WINDOW *, const cchar_t *, int); +#endif + +/* Quasi-standard */ + +PDCEX chtype getattrs(WINDOW *); +PDCEX int getbegx(WINDOW *); +PDCEX int getbegy(WINDOW *); +PDCEX int getmaxx(WINDOW *); +PDCEX int getmaxy(WINDOW *); +PDCEX int getparx(WINDOW *); +PDCEX int getpary(WINDOW *); +PDCEX int getcurx(WINDOW *); +PDCEX int getcury(WINDOW *); +PDCEX void traceoff(void); +PDCEX void traceon(void); +PDCEX char *unctrl(chtype); + +PDCEX int crmode(void); +PDCEX int nocrmode(void); +PDCEX int draino(int); +PDCEX int resetterm(void); +PDCEX int fixterm(void); +PDCEX int saveterm(void); +PDCEX int setsyx(int, int); + +PDCEX int mouse_set(unsigned long); +PDCEX int mouse_on(unsigned long); +PDCEX int mouse_off(unsigned long); +PDCEX int request_mouse_pos(void); +PDCEX int map_button(unsigned long); +PDCEX void wmouse_position(WINDOW *, int *, int *); +PDCEX unsigned long getmouse(void); +PDCEX unsigned long getbmap(void); + +/* ncurses */ + +PDCEX int assume_default_colors(int, int); +PDCEX const char *curses_version(void); +PDCEX bool has_key(int); +PDCEX int use_default_colors(void); +PDCEX int wresize(WINDOW *, int, int); + +PDCEX int mouseinterval(int); +PDCEX mmask_t mousemask(mmask_t, mmask_t *); +PDCEX bool mouse_trafo(int *, int *, bool); +PDCEX int nc_getmouse(MEVENT *); +PDCEX int ungetmouse(MEVENT *); +PDCEX bool wenclose(const WINDOW *, int, int); +PDCEX bool wmouse_trafo(const WINDOW *, int *, int *, bool); + +/* PDCurses */ + +PDCEX int addrawch(chtype); +PDCEX int insrawch(chtype); +PDCEX bool is_termresized(void); +PDCEX int mvaddrawch(int, int, chtype); +PDCEX int mvdeleteln(int, int); +PDCEX int mvinsertln(int, int); +PDCEX int mvinsrawch(int, int, chtype); +PDCEX int mvwaddrawch(WINDOW *, int, int, chtype); +PDCEX int mvwdeleteln(WINDOW *, int, int); +PDCEX int mvwinsertln(WINDOW *, int, int); +PDCEX int mvwinsrawch(WINDOW *, int, int, chtype); +PDCEX int raw_output(bool); +PDCEX int resize_term(int, int); +PDCEX WINDOW *resize_window(WINDOW *, int, int); +PDCEX int waddrawch(WINDOW *, chtype); +PDCEX int winsrawch(WINDOW *, chtype); +PDCEX char wordchar(void); + +#ifdef PDC_WIDE +PDCEX wchar_t *slk_wlabel(int); +#endif + +PDCEX void PDC_debug(const char *, ...); +PDCEX int PDC_ungetch(int); +PDCEX int PDC_set_blink(bool); +PDCEX int PDC_set_bold(bool); +PDCEX int PDC_set_line_color(short); +PDCEX void PDC_set_title(const char *); + +PDCEX int PDC_clearclipboard(void); +PDCEX int PDC_freeclipboard(char *); +PDCEX int PDC_getclipboard(char **, long *); +PDCEX int PDC_setclipboard(const char *, long); + +PDCEX unsigned long PDC_get_input_fd(void); +PDCEX unsigned long PDC_get_key_modifiers(void); +PDCEX int PDC_return_key_modifiers(bool); +PDCEX int PDC_save_key_modifiers(bool); + +#ifdef XCURSES +PDCEX WINDOW *Xinitscr(int, char **); +PDCEX void XCursesExit(void); +PDCEX int sb_init(void); +PDCEX int sb_set_horz(int, int, int); +PDCEX int sb_set_vert(int, int, int); +PDCEX int sb_get_horz(int *, int *, int *); +PDCEX int sb_get_vert(int *, int *, int *); +PDCEX int sb_refresh(void); +#endif + +/*** Functions defined as macros ***/ + +/* getch() and ungetch() conflict with some DOS libraries */ + +#define getch() wgetch(stdscr) +#define ungetch(ch) PDC_ungetch(ch) + +#define COLOR_PAIR(n) (((chtype)(n) << PDC_COLOR_SHIFT) & A_COLOR) +#define PAIR_NUMBER(n) (((n) & A_COLOR) >> PDC_COLOR_SHIFT) + +/* These will _only_ work as macros */ + +#define getbegyx(w, y, x) (y = getbegy(w), x = getbegx(w)) +#define getmaxyx(w, y, x) (y = getmaxy(w), x = getmaxx(w)) +#define getparyx(w, y, x) (y = getpary(w), x = getparx(w)) +#define getyx(w, y, x) (y = getcury(w), x = getcurx(w)) + +#define getsyx(y, x) { if (curscr->_leaveit) (y)=(x)=-1; \ + else getyx(curscr,(y),(x)); } + +#ifdef NCURSES_MOUSE_VERSION +# define getmouse(x) nc_getmouse(x) +#endif + +/* return codes from PDC_getclipboard() and PDC_setclipboard() calls */ + +#define PDC_CLIP_SUCCESS 0 +#define PDC_CLIP_ACCESS_ERROR 1 +#define PDC_CLIP_EMPTY 2 +#define PDC_CLIP_MEMORY_ERROR 3 + +/* PDCurses key modifier masks */ + +#define PDC_KEY_MODIFIER_SHIFT 1 +#define PDC_KEY_MODIFIER_CONTROL 2 +#define PDC_KEY_MODIFIER_ALT 4 +#define PDC_KEY_MODIFIER_NUMLOCK 8 + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +# undef bool +} +#endif + +#endif /* __PDCURSES__ */ diff --git a/plan9/pdcclip.c b/plan9/pdcclip.c new file mode 100644 index 000000000..a8c39feae --- /dev/null +++ b/plan9/pdcclip.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include "pdcplan9.h" + + +static char *clip = NULL; + +int PDC_getclipboard(char **sp, long *np) +{ + long n; + + PDC_LOG(("PDC_getclipboard() - called\n")); + if (!clip) + return PDC_CLIP_EMPTY; + + n = strlen(clip); + if ((*sp = malloc(n + 1)) == NULL) + return PDC_CLIP_MEMORY_ERROR; + + memmove(*sp, clip, n); + *np = n; + + return PDC_CLIP_SUCCESS; +} + + +int PDC_setclipboard(const char *s, long n) +{ + PDC_LOG(("PDC_setclipboard() - called\n")); + if (clip) + { + free(clip); + clip = NULL; + } + if (s) + { + if ((clip = malloc(n + 1)) == NULL) + return PDC_CLIP_MEMORY_ERROR; + memmove(clip, s, n); + clip[n] = 0; + } + + return PDC_CLIP_SUCCESS; +} + + +int PDC_freeclipboard(char *s) +{ + PDC_LOG(("PDC_freeclipboard() - called\n")); + free(s); + + return PDC_CLIP_SUCCESS; +} + + +int PDC_clearclipboard(void) +{ + PDC_LOG(("PDC_clearclipboard() - called\n")); + if (clip) + { + free(clip); + clip = NULL; + } + + return PDC_CLIP_SUCCESS; +} diff --git a/plan9/pdcdisp.c b/plan9/pdcdisp.c new file mode 100644 index 000000000..79cdb4027 --- /dev/null +++ b/plan9/pdcdisp.c @@ -0,0 +1,58 @@ +#include +#include "pdcplan9.h" + +#ifdef CHTYPE_LONG +# define A(x) ((chtype)x | A_ALTCHARSET) +chtype acs_map[128] = { + A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), + A(10), A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18), + A(19), A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27), + A(28), A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&', + '\'', '(', ')', '*', + + 0x2192, 0x2190, 0x2191, 0x2193, + + '/', + + 0x2588, + + '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', + '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', + 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', + + 0x25c6, 0x2592, + + 'b', 'c', 'd', 'e', + + 0x00ba, 0x00b1, 0x0023, 0x0023, 0x2518, 0x2510, 0x250c, 0x2514, + 0x253c, 'o', + 'p', 0x2500, 'r', 's', 0x2524, 0x251c, 0x2534, 0x252c, 0x2502, + 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x2022, + + A(127) +}; + +# undef A +#endif + + +void PDC_gotoyx(int y, int x) +{ + chtype *ch; + + PDC_LOG(("PDC_gotoyx() - called: y %d x %d\n", y, x)); + p9setcur(SP->cursrow, SP->curscol, y, x, SP->visibility); +} + + +void PDC_transform_line(int y, int x, int len, const chtype * srcp) +{ + int i; + + PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno)); + for (i = 0; i < len; i++) + { + p9putc(y, x + i, srcp[i]); + } +} diff --git a/plan9/pdcgetsc.c b/plan9/pdcgetsc.c new file mode 100644 index 000000000..e5d272fe1 --- /dev/null +++ b/plan9/pdcgetsc.c @@ -0,0 +1,28 @@ +#include +#include "pdcplan9.h" + +int PDC_get_columns(void) +{ + int i; + + i = p9getcols(); + PDC_LOG(("PDC_get_columns() returns: %d\n", i)); + return i; +} + + +int PDC_get_cursor_mode(void) +{ + PDC_LOG(("PDC_get_cursor_mode() - called\n")); + return 0; +} + + +int PDC_get_rows(void) +{ + int i; + + i = p9getrows(); + PDC_LOG(("PDC_get_rows() - returns: %d\n", i)); + return i; +} diff --git a/plan9/pdckbd.c b/plan9/pdckbd.c new file mode 100644 index 000000000..78864e854 --- /dev/null +++ b/plan9/pdckbd.c @@ -0,0 +1,52 @@ +#include +#include "pdcplan9.h" + + +unsigned long pdc_key_modifiers = 0L; + + +bool PDC_check_key(void) +{ + PDC_LOG(("PDC_check_key() - called\n")); + return p9ecan(); +} + + +int PDC_get_key(void) +{ + PDC_LOG(("PDC_check_key() - called\n")); + return p9eget(); +} + + +void PDC_flushinp(void) +{ + PDC_LOG(("PDC_flushinp() - called\n")); +} + + +int PDC_modifiers_set(void) +{ + PDC_LOG(("PDC_modifiers_set() - called\n")); + return OK; +} + + +int PDC_mouse_set(void) +{ + PDC_LOG(("PDC_mouse_set() - called\n")); + return OK; +} + + +void PDC_set_keyboard_binary(bool) +{ + PDC_LOG(("PDC_mouse_set() - called\n")); +} + + +unsigned long PDC_get_input_fd(void) +{ + PDC_LOG(("PDC_get_input_fd() - called\n")); + return -1; +} diff --git a/plan9/pdcplan9.c b/plan9/pdcplan9.c new file mode 100644 index 000000000..abdcdc989 --- /dev/null +++ b/plan9/pdcplan9.c @@ -0,0 +1,348 @@ +#define _LOCK_EXTENSION +#define _QLOCK_EXTENSION +#define _PLAN9_SOURCE +#define _RESEARCH_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define border curborder +#include +#undef border +#include +#include +#include +#include "pdcplan9.h" + +enum { + Ncolors = 18, + Eresized = 3, +}; + +uint rgbacolors[Ncolors] = { + 0x000000FF, /* black */ + 0x0000FFFF, /* blue */ + 0x00AA00FF, /* green */ + 0x00AAAAFF, /* cyan */ + 0xAA0000FF, /* red */ + 0xAA00AAFF, /* purple */ + 0xFF5500FF, /* brown */ + 0x7F7F7FFF, /* white */ + 0x555555FF, /* light black aka grey */ + 0x5555FFFF, /* light blue */ + 0x55FF55FF, /* light green */ + 0x55FFFFFF, /* light cyan */ + 0xFF5555FF, /* light red */ + 0xFF55FFFF, /* light purple */ + 0xFFFF55FF, /* light brown aka yellow */ + 0xFFFFFFFF, /* light grey aka white */ + 0x9EEEEFF, + 0x9EE9EFF, +}; + +static Image *colors[Ncolors]; + +static void fatal(char *s) +{ + fprint(2, "curses: %s: %r\n", s); + abort(); +} + + +void p9napms(int ms) +{ + sleep(ms); +} + + +void p9setlabel(char *s) +{ + int fd; + + fd = open("/dev/label", 1); + if (fd >= 0) + { + fprint(fd, "%s", s); + close(fd); + } +} + + +void p9resize(int nl, int nc) +{ + int fd; + + fd = open("/dev/wctl", 1); + if (fd >= 0) + { + fprint(fd, "resize -dx %d -dy %d", + nc * stringwidth(font, "0") + 8, nl * font->height + 8); + close(fd); + } +} + + +int p9getrows(void) +{ + return Dy(screen->r) / font->height; +} + + +int p9getcols(void) +{ + return Dx(screen->r) / stringwidth(font, "0"); +} + + +#define ms pdc_mouse_status /* I don't like this var name */ +static void setms(Mouse m) +{ + static uint clickmsec; + MOUSE_STATUS oldms; + int but, b, x, y; + + oldms = ms; + memset(&ms, 0, sizeof(ms)); + ms.x = (m.xy.x - screen->r.min.x) / stringwidth(font, "0"); + ms.y = (m.xy.y - screen->r.min.y) / font->height; + if (ms.x != oldms.x || ms.y != oldms.y) + ms.changes |= PDC_MOUSE_MOVED; + + /*scroll wheel */ + if (m.buttons & (8 | 16)) + { + if (m.buttons & 8) + ms.changes |= PDC_MOUSE_WHEEL_UP; + else + ms.changes |= PDC_MOUSE_WHEEL_DOWN; + SP->key_code = TRUE; + return; + } + but = 0; + if (m.buttons & 1) + but = 1; + else if (m.buttons & 2) + but = 2; + else if (m.buttons & 4) + but = 3; + + if (but == 0) + return; + + b = m.buttons; + if (m.msec - clickmsec < 500) + { + ms.button[but - 1] = BUTTON_DOUBLE_CLICKED; + x = m.xy.x; + y = m.xy.y; + /* stay here until something interesting happens */ + do + m = emouse(); + while (m.buttons == b && abs(m.xy.x - x) < 3 + && abs(m.xy.y - y) < 3); + } + if (m.buttons == b) + { + uint msec = m.msec; + do + m = emouse(); + while (m.buttons == b); + if (m.msec - msec < 250) + ms.button[but - 1] = BUTTON_CLICKED; + else + ms.button[but - 1] = BUTTON_PRESSED; + } + if (oldms.x == ms.x && oldms.y == ms.y) + { + if (m.msec - clickmsec < 500) + ms.button[but - 1] = BUTTON_DOUBLE_CLICKED; + else + clickmsec = m.msec; + } + /* choording should be here */ + while (m.buttons == b) + m = emouse(); + + ms.changes |= 1 << (but - 1); + SP->key_code = FALSE; +} +#undef ms + + +static int transk(Rune k) +{ + switch (k) + { + case Khome: + return KEY_HOME; + case Kup: + return KEY_UP; + case Kpgup: + return KEY_PPAGE; + case Kprint: + return KEY_PRINT; + case Kleft: + return KEY_LEFT; + case Kright: + return KEY_RIGHT; + case Kdown: + return KEY_DOWN; + case Kpgdown: + return KEY_NPAGE; + case Kins: + return KEY_IC; + case Kend: + return KEY_END; + default: + return k; + } +} + +static int resized; + +void eresized(int) +{ + if (getwindow(display, Refnone) < 0) + fatal("can't reattach to window"); + + draw(screen, screen->r, display->black, nil, ZP); + resized = TRUE; +} + + +int p9ecan(void) +{ + return ecanread(Ekeyboard | Emouse); +} + + +int p9eget(void) +{ + char c; + Event e; + int x = 0; + + if (resized) + { + resized = FALSE; + SP->resized = TRUE; + x = KEY_RESIZE; + } + switch (event(&e)) + { + case Emouse: + setms(e.mouse); + x = KEY_MOUSE; + case Ekeyboard: + if (e.kbdc == Kdel) + raise(SIGINT); + x = transk(e.kbdc); + }; + return x; +} + +void p9init(void) +{ + int i; + + if (initdraw(0, "/lib/font/bit/fixed/unicode.9x15.font", "curses") < 0) + fatal("can't open display"); + + draw(screen, screen->r, display->black, nil, ZP); + einit(Ekeyboard | Emouse); + for (i = 0; i < Ncolors; i++) + { + colors[i] = + allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, + rgbacolors[i]); + if (colors[i] == nil) + fatal("can't allocate image"); + } +} + +static Point getcur(int y, int x) +{ + Point p; + + p.x = screen->r.min.x + stringwidth(font, "0") * x; + p.y = screen->r.min.y + font->height * y; + + return p; +} + + +void p9putc(int y, int x, chtype ch) +{ + chtype attr; + int c, t; + short fg, bg; + Point p0, p1; + Rune buf[1]; + + attr = ch & A_ATTRIBUTES; + if (pair_content(PAIR_NUMBER(attr), &fg, &bg) == ERR) + { + fg = COLOR_WHITE; + bg = COLOR_BLACK; + } + + fg |= attr & A_BOLD ? 8 : 0; + bg |= attr & A_BLINK ? 8 : 0; + if (attr & A_REVERSE) + { + t = fg; + fg = bg; + bg = t; + } + if (attr & A_ALTCHARSET && !(ch & 0xff80)) + ch = acs_map[ch & 0x7f]; + + c = ch & A_CHARTEXT; + + buf[0] = c; + p0 = getcur(y, x); + runestringnbg(screen, p0, colors[fg], ZP, font, buf, 1, colors[bg], ZP); + if (attr & A_UNDERLINE) + { + p1 = p0; + p1.x += runestringnwidth(font, buf, 1); + line(screen, p0, p1, Enddisc, Enddisc, 0, colors[fg], ZP); + } +} + + +void p9setcur(int oy, int ox, int y, int x, int vis) +{ + Image *c; + chtype *ch; + Point p; + + ch = curscr->_y[oy] + ox; + p9putc(oy, ox, *ch); + if (vis == 0) + return; + + if (vis == 1) + c = colors[Ncolors - 2]; + else + c = colors[Ncolors - 1]; + + p = getcur(y, x); + draw(screen, + Rect(p.x, p.y + font->height - 2, p.x + stringwidth(font, "0"), + p.y + font->height), c, nil, ZP); + + flushimage(display, 1); +} diff --git a/plan9/pdcplan9.h b/plan9/pdcplan9.h new file mode 100644 index 000000000..7791289d4 --- /dev/null +++ b/plan9/pdcplan9.h @@ -0,0 +1,10 @@ +void p9init(void); +int p9ecan(void); +int p9eget(void); +int p9getcols(void); +int p9getrows(void); +void p9napms(int); +void p9putc(int, int, chtype); +void p9resize(int, int); +void p9setlabel(char *); +void p9setcur(int, int, int, int, int); diff --git a/plan9/pdcscrn.c b/plan9/pdcscrn.c new file mode 100644 index 000000000..641c53ff1 --- /dev/null +++ b/plan9/pdcscrn.c @@ -0,0 +1,114 @@ +#include +#include +#include "pdcplan9.h" + +bool PDC_can_change_color(void) +{ + PDC_LOG(("PDC_can_change_color() - called.\n")); + + return FALSE; +} + + +int PDC_color_content(short color, short *red, short *green, short *blue) +{ + PDC_LOG(("PDC_color_content() - called.\n")); + + return ERR; +} + + +int PDC_init_color(short color, short red, short green, short blue) +{ + PDC_LOG(("PDC_init_color() - called. Lines: %d Cols: %d\n", color, + red, green, blue)); + + return OK; +} + + +int PDC_scr_open(int, char **) +{ + PDC_LOG(("PDC_scr_open() - called\n")); + + SP = calloc(1, sizeof(SCREEN)); + if (!SP) + return ERR; + + p9init(); + SP->cols = PDC_get_columns(); + SP->lines = PDC_get_rows(); + SP->cursrow = SP->curscol = 0; + SP->orig_attr = FALSE; + SP->orig_cursor = 0; + + return OK; +} + + +void PDC_scr_close(void) +{ + PDC_LOG(("PDC_scr_close() - called\n")); +} + + +void PDC_reset_shell_mode(void) +{ + PDC_LOG(("PDC_reset_shell_mode() - called\n")); +} + + +int PDC_resize_screen(int nlines, int ncols) +{ + PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n", + nlines, ncols)); + + if (nlines == 0 && ncols == 0) + return OK; + + p9resize(nlines, ncols); + SP->resized = FALSE; + SP->cursrow = SP->curscol = 0; + + return OK; +} + + +void PDC_reset_prog_mode(void) +{ + PDC_LOG(("PDC_reset_prog_mode() - called.\n")); +} + + +void PDC_restore_screen_mode(int) +{ + PDC_LOG(("PDC_restore_screen_mode() - called.\n")); +} + + +void PDC_save_screen_mode(int) +{ + PDC_LOG(("PDC_save_screen_mode() - called.\n")); +} + + +void PDC_scr_free(void) +{ + free(SP); +} + +static struct {short f, b;} atrtab[PDC_COLOR_PAIRS]; + +void PDC_init_pair(short pair, short fg, short bg) +{ + atrtab[pair].f = fg; + atrtab[pair].b = bg; +} + +int PDC_pair_content(short pair, short *fg, short *bg) +{ + *fg = atrtab[pair].f; + *bg = atrtab[pair].b; + + return OK; +} diff --git a/plan9/pdcsetsc.c b/plan9/pdcsetsc.c new file mode 100644 index 000000000..c97c8eae6 --- /dev/null +++ b/plan9/pdcsetsc.c @@ -0,0 +1,33 @@ +#include +#include "pdcplan9.h" + + +int PDC_curs_set(int vis) +{ + int rvis; + chtype *ch; + + PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", vis)); + rvis = SP->visibility; + p9setcur(SP->cursrow, SP->curscol, SP->cursrow, SP->curscol, vis); + SP->visibility = vis; + + return rvis; +} + + +void PDC_set_title(const char *title) +{ + PDC_LOG(("PDC_set_title() - called:<%s>\n", title)); + p9setlabel(title); +} + + +int PDC_set_blink(bool blinkon) +{ + PDC_LOG(("PDC_set_title() - called:<%d>\n", blinkon)); + if (pdc_color_started) + COLORS = 16; + + return blinkon ? ERR : OK; +} diff --git a/plan9/pdcutil.c b/plan9/pdcutil.c new file mode 100644 index 000000000..7a8641944 --- /dev/null +++ b/plan9/pdcutil.c @@ -0,0 +1,24 @@ +#include +#include +#include "pdcplan9.h" + + +void PDC_beep(void) +{ + PDC_LOG(("PDC_beep() - called\n")); +} + + +void PDC_napms(int ms) +{ + PDC_LOG(("PDC_napms() - called\n")); + p9napms(ms); +} + + +const char *PDC_sysname(void) +{ + PDC_LOG(("PDC_sysname() - called\n")); + + return "PLAN9"; +} From 5587c5235f03f1cfd35ef68c85566fbe3d53df16 Mon Sep 17 00:00:00 2001 From: Jens Staal Date: Thu, 4 Jun 2020 13:34:51 +0200 Subject: [PATCH 2/9] removed old plan9/curses.h - we have to make do without #pragma lib. Updated mkfiles --- demos/mkfile | 4 +- mkfile | 6 +- plan9/curses.h | 1399 ------------------------------------------------ 3 files changed, 3 insertions(+), 1406 deletions(-) delete mode 100644 plan9/curses.h diff --git a/demos/mkfile b/demos/mkfile index 076481ed2..8377db11a 100644 --- a/demos/mkfile +++ b/demos/mkfile @@ -3,7 +3,7 @@ APE=/sys/src/ape TARG=\ firework\ - newdemo\ + ozdemo\ ptest\ rain\ testcurs\ @@ -28,4 +28,4 @@ CFLAGS= -c -D_POSIX_SOURCE -D_BSD_EXTENSION #-DPDCDEBUG $O.tuidemo:V: tui.$O tuidemo.$O $LD -o $target $prereq -$O.out: /$objtype/lib/ape/libcurses.a /$objtype/lib/ape/libpanel.a +$O.out: /$objtype/lib/ape/libcurses.a diff --git a/mkfile b/mkfile index 41180bc32..44e18d889 100644 --- a/mkfile +++ b/mkfile @@ -16,7 +16,6 @@ OFILES=\ debug.$O\ delch.$O\ deleteln.$O\ - deprec.$O\ getch.$O\ getstr.$O\ getyx.$O\ @@ -42,7 +41,6 @@ OFILES=\ scroll.$O\ slk.$O\ termattr.$O\ - terminfo.$O\ touch.$O\ util.$O\ window.$O\ @@ -59,7 +57,6 @@ OFILES=\ HFILES=\ /sys/include/ape/curses.h\ /sys/include/ape/panel.h\ - /sys/include/ape/term.h UPDATE=\ mkfile\ @@ -83,9 +80,8 @@ CFLAGS= -c -I. -D_POSIX_SOURCE -D_BSD_EXTENSION -D_C99_SNPRINTF_EXTENSION \ install:V: cp libcurses.a /$objtype/lib/ape/libcurses.a - cp plan9/curses.h /sys/include/ape/curses.h + cp curses.h /sys/include/ape/curses.h cp panel.h /sys/include/ape/ - cp term.h /sys/include/ape/ demos:V: @{ diff --git a/plan9/curses.h b/plan9/curses.h deleted file mode 100644 index b607ce5db..000000000 --- a/plan9/curses.h +++ /dev/null @@ -1,1399 +0,0 @@ -/* Public Domain Curses */ - -/*----------------------------------------------------------------------* - * PDCurses * - *----------------------------------------------------------------------*/ - -#ifndef __PDCURSES__ -#define __PDCURSES__ 1 - -#pragma lib "/$M/lib/ape/libcurses.a" - -/*man-start************************************************************** - -PDCurses definitions list: (Only define those needed) - - XCURSES True if compiling for X11. - PDC_RGB True if you want to use RGB color definitions - (Red = 1, Green = 2, Blue = 4) instead of BGR. - PDC_WIDE True if building wide-character support. - PDC_DLL_BUILD True if building a Windows DLL. - NCURSES_MOUSE_VERSION Use the ncurses mouse API instead - of PDCurses' traditional mouse API. - -PDCurses portable platform definitions list: - - PDC_BUILD Defines API build version. - PDCURSES Enables access to PDCurses-only routines. - XOPEN Always true. - SYSVcurses True if you are compiling for SYSV portability. - BSDcurses True if you are compiling for BSD portability. - -**man-end****************************************************************/ - -#define PDC_BUILD 3601 -#define PDCURSES 1 /* PDCurses-only routines */ -#define XOPEN 1 /* X/Open Curses routines */ -#define SYSVcurses 1 /* System V Curses routines */ -#define BSDcurses 1 /* BSD Curses routines */ -#define CHTYPE_LONG 1 /* size of chtype; long */ - -/*----------------------------------------------------------------------*/ - -#include -#include -#include /* Required by X/Open usage below */ - -#ifdef PDC_WIDE -# include -#endif - -#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) -extern "C" -{ -# define bool _bool -#endif - -/*---------------------------------------------------------------------- - * - * PDCurses Manifest Constants - * - */ - -#ifndef FALSE -# define FALSE 0 -#endif -#ifndef TRUE -# define TRUE 1 -#endif -#ifndef NULL -# define NULL (void *)0 -#endif -#ifndef ERR -# define ERR (-1) -#endif -#ifndef OK -# define OK 0 -#endif - -/*---------------------------------------------------------------------- - * - * PDCurses Type Declarations - * - */ - -typedef unsigned char bool; /* PDCurses Boolean type */ - -#ifdef CHTYPE_LONG -# if _LP64 -typedef unsigned int chtype; -# else -typedef unsigned long chtype; /* 16-bit attr + 16-bit char */ -# endif -#else -typedef unsigned short chtype; /* 8-bit attr + 8-bit char */ -#endif - -#ifdef PDC_WIDE -typedef chtype cchar_t; -#endif - -typedef chtype attr_t; - -/*---------------------------------------------------------------------- - * - * PDCurses Mouse Interface -- SYSVR4, with extensions - * - */ - -typedef struct -{ - int x; /* absolute column, 0 based, measured in characters */ - int y; /* absolute row, 0 based, measured in characters */ - short button[3]; /* state of each button */ - int changes; /* flags indicating what has changed with the mouse */ -} MOUSE_STATUS; - -#define BUTTON_RELEASED 0x0000 -#define BUTTON_PRESSED 0x0001 -#define BUTTON_CLICKED 0x0002 -#define BUTTON_DOUBLE_CLICKED 0x0003 -#define BUTTON_TRIPLE_CLICKED 0x0004 -#define BUTTON_MOVED 0x0005 /* PDCurses */ -#define WHEEL_SCROLLED 0x0006 /* PDCurses */ -#define BUTTON_ACTION_MASK 0x0007 /* PDCurses */ - -#define PDC_BUTTON_SHIFT 0x0008 /* PDCurses */ -#define PDC_BUTTON_CONTROL 0x0010 /* PDCurses */ -#define PDC_BUTTON_ALT 0x0020 /* PDCurses */ -#define BUTTON_MODIFIER_MASK 0x0038 /* PDCurses */ - -#define MOUSE_X_POS (Mouse_status.x) -#define MOUSE_Y_POS (Mouse_status.y) - -/* - * Bits associated with the .changes field: - * 3 2 1 0 - * 210987654321098765432109876543210 - * 1 <- button 1 has changed - * 10 <- button 2 has changed - * 100 <- button 3 has changed - * 1000 <- mouse has moved - * 10000 <- mouse position report - * 100000 <- mouse wheel up - * 1000000 <- mouse wheel down - * 10000000 <- mouse wheel left - * 100000000 <- mouse wheel right - */ - -#define PDC_MOUSE_MOVED 0x0008 -#define PDC_MOUSE_POSITION 0x0010 -#define PDC_MOUSE_WHEEL_UP 0x0020 -#define PDC_MOUSE_WHEEL_DOWN 0x0040 -#define PDC_MOUSE_WHEEL_LEFT 0x0080 -#define PDC_MOUSE_WHEEL_RIGHT 0x0100 - -#define A_BUTTON_CHANGED (Mouse_status.changes & 7) -#define MOUSE_MOVED (Mouse_status.changes & PDC_MOUSE_MOVED) -#define MOUSE_POS_REPORT (Mouse_status.changes & PDC_MOUSE_POSITION) -#define BUTTON_CHANGED(x) (Mouse_status.changes & (1 << ((x) - 1))) -#define BUTTON_STATUS(x) (Mouse_status.button[(x) - 1]) -#define MOUSE_WHEEL_UP (Mouse_status.changes & PDC_MOUSE_WHEEL_UP) -#define MOUSE_WHEEL_DOWN (Mouse_status.changes & PDC_MOUSE_WHEEL_DOWN) -#define MOUSE_WHEEL_LEFT (Mouse_status.changes & PDC_MOUSE_WHEEL_LEFT) -#define MOUSE_WHEEL_RIGHT (Mouse_status.changes & PDC_MOUSE_WHEEL_RIGHT) - -/* mouse bit-masks */ - -#define BUTTON1_RELEASED 0x00000001L -#define BUTTON1_PRESSED 0x00000002L -#define BUTTON1_CLICKED 0x00000004L -#define BUTTON1_DOUBLE_CLICKED 0x00000008L -#define BUTTON1_TRIPLE_CLICKED 0x00000010L -#define BUTTON1_MOVED 0x00000010L /* PDCurses */ - -#define BUTTON2_RELEASED 0x00000020L -#define BUTTON2_PRESSED 0x00000040L -#define BUTTON2_CLICKED 0x00000080L -#define BUTTON2_DOUBLE_CLICKED 0x00000100L -#define BUTTON2_TRIPLE_CLICKED 0x00000200L -#define BUTTON2_MOVED 0x00000200L /* PDCurses */ - -#define BUTTON3_RELEASED 0x00000400L -#define BUTTON3_PRESSED 0x00000800L -#define BUTTON3_CLICKED 0x00001000L -#define BUTTON3_DOUBLE_CLICKED 0x00002000L -#define BUTTON3_TRIPLE_CLICKED 0x00004000L -#define BUTTON3_MOVED 0x00004000L /* PDCurses */ - -/* For the ncurses-compatible functions only, BUTTON4_PRESSED and - BUTTON5_PRESSED are returned for mouse scroll wheel up and down; - otherwise PDCurses doesn't support buttons 4 and 5 */ - -#define BUTTON4_RELEASED 0x00008000L -#define BUTTON4_PRESSED 0x00010000L -#define BUTTON4_CLICKED 0x00020000L -#define BUTTON4_DOUBLE_CLICKED 0x00040000L -#define BUTTON4_TRIPLE_CLICKED 0x00080000L - -#define BUTTON5_RELEASED 0x00100000L -#define BUTTON5_PRESSED 0x00200000L -#define BUTTON5_CLICKED 0x00400000L -#define BUTTON5_DOUBLE_CLICKED 0x00800000L -#define BUTTON5_TRIPLE_CLICKED 0x01000000L - -#define MOUSE_WHEEL_SCROLL 0x02000000L /* PDCurses */ -#define BUTTON_MODIFIER_SHIFT 0x04000000L /* PDCurses */ -#define BUTTON_MODIFIER_CONTROL 0x08000000L /* PDCurses */ -#define BUTTON_MODIFIER_ALT 0x10000000L /* PDCurses */ - -#define ALL_MOUSE_EVENTS 0x1fffffffL -#define REPORT_MOUSE_POSITION 0x20000000L - -/* ncurses mouse interface */ - -typedef unsigned long mmask_t; - -typedef struct -{ - short id; /* unused, always 0 */ - int x, y, z; /* x, y same as MOUSE_STATUS; z unused */ - mmask_t bstate; /* equivalent to changes + button[], but - in the same format as used for mousemask() */ -} MEVENT; - -#ifdef NCURSES_MOUSE_VERSION -# define BUTTON_SHIFT BUTTON_MODIFIER_SHIFT -# define BUTTON_CONTROL BUTTON_MODIFIER_CONTROL -# define BUTTON_CTRL BUTTON_MODIFIER_CONTROL -# define BUTTON_ALT BUTTON_MODIFIER_ALT -#else -# define BUTTON_SHIFT PDC_BUTTON_SHIFT -# define BUTTON_CONTROL PDC_BUTTON_CONTROL -# define BUTTON_ALT PDC_BUTTON_ALT -#endif - -/*---------------------------------------------------------------------- - * - * PDCurses Structure Definitions - * - */ - -typedef struct _win /* definition of a window */ -{ - int _cury; /* current pseudo-cursor */ - int _curx; - int _maxy; /* max window coordinates */ - int _maxx; - int _begy; /* origin on screen */ - int _begx; - int _flags; /* window properties */ - chtype _attrs; /* standard attributes and colors */ - chtype _bkgd; /* background, normally blank */ - bool _clear; /* causes clear at next refresh */ - bool _leaveit; /* leaves cursor where it is */ - bool _scroll; /* allows window scrolling */ - bool _nodelay; /* input character wait flag */ - bool _immed; /* immediate update flag */ - bool _sync; /* synchronise window ancestors */ - bool _use_keypad; /* flags keypad key mode active */ - chtype **_y; /* pointer to line pointer array */ - int *_firstch; /* first changed character in line */ - int *_lastch; /* last changed character in line */ - int _tmarg; /* top of scrolling region */ - int _bmarg; /* bottom of scrolling region */ - int _delayms; /* milliseconds of delay for getch() */ - int _parx, _pary; /* coords relative to parent (0,0) */ - struct _win *_parent; /* subwin's pointer to parent win */ -} WINDOW; - -/* Avoid using the SCREEN struct directly -- use the corresponding - functions if possible. This struct may eventually be made private. */ - -typedef struct -{ - bool alive; /* if initscr() called, and not endwin() */ - bool autocr; /* if cr -> lf */ - bool cbreak; /* if terminal unbuffered */ - bool echo; /* if terminal echo */ - bool raw_inp; /* raw input mode (v. cooked input) */ - bool raw_out; /* raw output mode (7 v. 8 bits) */ - bool audible; /* FALSE if the bell is visual */ - bool mono; /* TRUE if current screen is mono */ - bool resized; /* TRUE if TERM has been resized */ - bool orig_attr; /* TRUE if we have the original colors */ - short orig_fore; /* original screen foreground color */ - short orig_back; /* original screen foreground color */ - int cursrow; /* position of physical cursor */ - int curscol; /* position of physical cursor */ - int visibility; /* visibility of cursor */ - int orig_cursor; /* original cursor size */ - int lines; /* new value for LINES */ - int cols; /* new value for COLS */ - unsigned long _trap_mbe; /* trap these mouse button events */ - unsigned long _map_mbe_to_key; /* map mouse buttons to slk */ - int mouse_wait; /* time to wait (in ms) for a - button release after a press, in - order to count it as a click */ - int slklines; /* lines in use by slk_init() */ - WINDOW *slk_winptr; /* window for slk */ - int linesrippedoff; /* lines ripped off via ripoffline() */ - int linesrippedoffontop; /* lines ripped off on - top via ripoffline() */ - int delaytenths; /* 1/10ths second to wait block - getch() for */ - bool _preserve; /* TRUE if screen background - to be preserved */ - int _restore; /* specifies if screen background - to be restored, and how */ - bool save_key_modifiers; /* TRUE if each key modifiers saved - with each key press */ - bool return_key_modifiers; /* TRUE if modifier keys are - returned as "real" keys */ - bool key_code; /* TRUE if last key is a special key; - used internally by get_wch() */ -#ifdef XCURSES - int XcurscrSize; /* size of Xcurscr shared memory block */ - bool sb_on; - int sb_viewport_y; - int sb_viewport_x; - int sb_total_y; - int sb_total_x; - int sb_cur_y; - int sb_cur_x; -#endif - short line_color; /* color of line attributes - default -1 */ - attr_t termattrs; /* attribute capabilities */ -} SCREEN; - -/*---------------------------------------------------------------------- - * - * PDCurses External Variables - * - */ - -#ifdef PDC_DLL_BUILD -# ifdef CURSES_LIBRARY -# define PDCEX __declspec(dllexport) extern -# else -# define PDCEX __declspec(dllimport) -# endif -#else -# define PDCEX extern -#endif - -PDCEX int LINES; /* terminal height */ -PDCEX int COLS; /* terminal width */ -PDCEX WINDOW *stdscr; /* the default screen window */ -PDCEX WINDOW *curscr; /* the current screen image */ -PDCEX SCREEN *SP; /* curses variables */ -PDCEX MOUSE_STATUS Mouse_status; -PDCEX int COLORS; -PDCEX int COLOR_PAIRS; -PDCEX int TABSIZE; -PDCEX chtype acs_map[]; /* alternate character set map */ -PDCEX char ttytype[]; /* terminal name/description */ - -/*man-start************************************************************** - -PDCurses Text Attributes -======================== - -Originally, PDCurses used a short (16 bits) for its chtype. To include -color, a number of things had to be sacrificed from the strict Unix and -System V support. The main problem was fitting all character attributes -and color into an unsigned char (all 8 bits!). - -Today, PDCurses by default uses a long (32 bits) for its chtype, as in -System V. The short chtype is still available, by undefining CHTYPE_LONG -and rebuilding the library. - -The following is the structure of a win->_attrs chtype: - -short form: - - +-----------------------------------------------+ - |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0| - +-----------------------------------------------+ - color number | attrs | character eg 'a' - -The available non-color attributes are bold, reverse and blink. Others -have no effect. The high order char is an index into an array of -physical colors (defined in color.c) -- 32 foreground/background color -pairs (5 bits) plus 3 bits for other attributes. - -long form: - - +--------------------------------------------------------------------+ - |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|..| 2| 1| 0| - +--------------------------------------------------------------------+ - color number | modifiers | character eg 'a' - -The available non-color attributes are bold, underline, right-line, -left-line, italic, reverse and blink, plus the alternate character set -indicator. 256 color pairs (8 bits), 8 bits for other attributes, and 16 -bits for character data. - -**man-end****************************************************************/ - -/*** Video attribute macros ***/ - -#define A_NORMAL (chtype)0 - -#ifdef CHTYPE_LONG -# define A_ALTCHARSET (chtype)0x00010000 -# define A_RIGHT (chtype)0x00020000 -# define A_LEFT (chtype)0x00040000 -# define A_ITALIC (chtype)0x00080000 -# define A_UNDERLINE (chtype)0x00100000 -# define A_REVERSE (chtype)0x00200000 -# define A_BLINK (chtype)0x00400000 -# define A_BOLD (chtype)0x00800000 - -# define A_ATTRIBUTES (chtype)0xffff0000 -# define A_CHARTEXT (chtype)0x0000ffff -# define A_COLOR (chtype)0xff000000 - -# define PDC_COLOR_SHIFT 24 -#else -# define A_BOLD (chtype)0x0100 /* X/Open */ -# define A_REVERSE (chtype)0x0200 /* X/Open */ -# define A_BLINK (chtype)0x0400 /* X/Open */ - -# define A_ATTRIBUTES (chtype)0xff00 /* X/Open */ -# define A_CHARTEXT (chtype)0x00ff /* X/Open */ -# define A_COLOR (chtype)0xf800 /* System V */ - -# define A_ALTCHARSET A_NORMAL /* X/Open */ -# define A_UNDERLINE A_NORMAL /* X/Open */ - -# define A_LEFT A_NORMAL -# define A_RIGHT A_NORMAL -# define A_ITALIC A_NORMAL - -# define PDC_COLOR_SHIFT 11 -#endif - -#define A_LEFTLINE A_LEFT -#define A_RIGHTLINE A_RIGHT -#define A_STANDOUT (A_REVERSE | A_BOLD) /* X/Open */ - -#define A_DIM A_NORMAL -#define A_INVIS A_NORMAL -#define A_PROTECT A_NORMAL - -#define A_HORIZONTAL A_NORMAL -#define A_LOW A_NORMAL -#define A_TOP A_NORMAL -#define A_VERTICAL A_NORMAL - -#define CHR_MSK A_CHARTEXT /* Obsolete */ -#define ATR_MSK A_ATTRIBUTES /* Obsolete */ -#define ATR_NRM A_NORMAL /* Obsolete */ - -/* For use with attr_t -- X/Open says, "these shall be distinct", so - this is a non-conforming implementation. */ - -#define WA_NORMAL A_NORMAL - -#define WA_ALTCHARSET A_ALTCHARSET -#define WA_BLINK A_BLINK -#define WA_BOLD A_BOLD -#define WA_DIM A_DIM -#define WA_INVIS A_INVIS -#define WA_ITALIC A_ITALIC -#define WA_LEFT A_LEFT -#define WA_PROTECT A_PROTECT -#define WA_REVERSE A_REVERSE -#define WA_RIGHT A_RIGHT -#define WA_STANDOUT A_STANDOUT -#define WA_UNDERLINE A_UNDERLINE - -#define WA_HORIZONTAL A_HORIZONTAL -#define WA_LOW A_LOW -#define WA_TOP A_TOP -#define WA_VERTICAL A_VERTICAL - -#define WA_ATTRIBUTES A_ATTRIBUTES - -/*** Alternate character set macros ***/ - -/* 'w' = 32-bit chtype; acs_map[] index | A_ALTCHARSET - 'n' = 16-bit chtype; it gets the fallback set because no bit is - available for A_ALTCHARSET */ - -#ifdef CHTYPE_LONG -# define ACS_PICK(w, n) ((chtype)w | A_ALTCHARSET) -#else -# define ACS_PICK(w, n) ((chtype)n) -#endif - -/* VT100-compatible symbols -- box chars */ - -#define ACS_ULCORNER ACS_PICK('l', '+') -#define ACS_LLCORNER ACS_PICK('m', '+') -#define ACS_URCORNER ACS_PICK('k', '+') -#define ACS_LRCORNER ACS_PICK('j', '+') -#define ACS_RTEE ACS_PICK('u', '+') -#define ACS_LTEE ACS_PICK('t', '+') -#define ACS_BTEE ACS_PICK('v', '+') -#define ACS_TTEE ACS_PICK('w', '+') -#define ACS_HLINE ACS_PICK('q', '-') -#define ACS_VLINE ACS_PICK('x', '|') -#define ACS_PLUS ACS_PICK('n', '+') - -/* VT100-compatible symbols -- other */ - -#define ACS_S1 ACS_PICK('o', '-') -#define ACS_S9 ACS_PICK('s', '_') -#define ACS_DIAMOND ACS_PICK('`', '+') -#define ACS_CKBOARD ACS_PICK('a', ':') -#define ACS_DEGREE ACS_PICK('f', '\'') -#define ACS_PLMINUS ACS_PICK('g', '#') -#define ACS_BULLET ACS_PICK('~', 'o') - -/* Teletype 5410v1 symbols -- these are defined in SysV curses, but - are not well-supported by most terminals. Stick to VT100 characters - for optimum portability. */ - -#define ACS_LARROW ACS_PICK(',', '<') -#define ACS_RARROW ACS_PICK('+', '>') -#define ACS_DARROW ACS_PICK('.', 'v') -#define ACS_UARROW ACS_PICK('-', '^') -#define ACS_BOARD ACS_PICK('h', '#') -#define ACS_LANTERN ACS_PICK('i', '*') -#define ACS_BLOCK ACS_PICK('0', '#') - -/* That goes double for these -- undocumented SysV symbols. Don't use - them. */ - -#define ACS_S3 ACS_PICK('p', '-') -#define ACS_S7 ACS_PICK('r', '-') -#define ACS_LEQUAL ACS_PICK('y', '<') -#define ACS_GEQUAL ACS_PICK('z', '>') -#define ACS_PI ACS_PICK('{', 'n') -#define ACS_NEQUAL ACS_PICK('|', '+') -#define ACS_STERLING ACS_PICK('}', 'L') - -/* Box char aliases */ - -#define ACS_BSSB ACS_ULCORNER -#define ACS_SSBB ACS_LLCORNER -#define ACS_BBSS ACS_URCORNER -#define ACS_SBBS ACS_LRCORNER -#define ACS_SBSS ACS_RTEE -#define ACS_SSSB ACS_LTEE -#define ACS_SSBS ACS_BTEE -#define ACS_BSSS ACS_TTEE -#define ACS_BSBS ACS_HLINE -#define ACS_SBSB ACS_VLINE -#define ACS_SSSS ACS_PLUS - -/* cchar_t aliases */ - -#ifdef PDC_WIDE -# define WACS_ULCORNER (&(acs_map['l'])) -# define WACS_LLCORNER (&(acs_map['m'])) -# define WACS_URCORNER (&(acs_map['k'])) -# define WACS_LRCORNER (&(acs_map['j'])) -# define WACS_RTEE (&(acs_map['u'])) -# define WACS_LTEE (&(acs_map['t'])) -# define WACS_BTEE (&(acs_map['v'])) -# define WACS_TTEE (&(acs_map['w'])) -# define WACS_HLINE (&(acs_map['q'])) -# define WACS_VLINE (&(acs_map['x'])) -# define WACS_PLUS (&(acs_map['n'])) - -# define WACS_S1 (&(acs_map['o'])) -# define WACS_S9 (&(acs_map['s'])) -# define WACS_DIAMOND (&(acs_map['`'])) -# define WACS_CKBOARD (&(acs_map['a'])) -# define WACS_DEGREE (&(acs_map['f'])) -# define WACS_PLMINUS (&(acs_map['g'])) -# define WACS_BULLET (&(acs_map['~'])) - -# define WACS_LARROW (&(acs_map[','])) -# define WACS_RARROW (&(acs_map['+'])) -# define WACS_DARROW (&(acs_map['.'])) -# define WACS_UARROW (&(acs_map['-'])) -# define WACS_BOARD (&(acs_map['h'])) -# define WACS_LANTERN (&(acs_map['i'])) -# define WACS_BLOCK (&(acs_map['0'])) - -# define WACS_S3 (&(acs_map['p'])) -# define WACS_S7 (&(acs_map['r'])) -# define WACS_LEQUAL (&(acs_map['y'])) -# define WACS_GEQUAL (&(acs_map['z'])) -# define WACS_PI (&(acs_map['{'])) -# define WACS_NEQUAL (&(acs_map['|'])) -# define WACS_STERLING (&(acs_map['}'])) - -# define WACS_BSSB WACS_ULCORNER -# define WACS_SSBB WACS_LLCORNER -# define WACS_BBSS WACS_URCORNER -# define WACS_SBBS WACS_LRCORNER -# define WACS_SBSS WACS_RTEE -# define WACS_SSSB WACS_LTEE -# define WACS_SSBS WACS_BTEE -# define WACS_BSSS WACS_TTEE -# define WACS_BSBS WACS_HLINE -# define WACS_SBSB WACS_VLINE -# define WACS_SSSS WACS_PLUS -#endif - -/*** Color macros ***/ - -#define COLOR_BLACK 0 - -#ifdef PDC_RGB /* RGB */ -# define COLOR_RED 1 -# define COLOR_GREEN 2 -# define COLOR_BLUE 4 -#else /* BGR */ -# define COLOR_BLUE 1 -# define COLOR_GREEN 2 -# define COLOR_RED 4 -#endif - -#define COLOR_CYAN (COLOR_BLUE | COLOR_GREEN) -#define COLOR_MAGENTA (COLOR_RED | COLOR_BLUE) -#define COLOR_YELLOW (COLOR_RED | COLOR_GREEN) - -#define COLOR_WHITE 7 - -/*---------------------------------------------------------------------- - * - * Function and Keypad Key Definitions. - * Many are just for compatibility. - * - */ - -#define KEY_CODE_YES 0x100 /* If get_wch() gives a key code */ - -#define KEY_BREAK 0x101 /* Not on PC KBD */ -#define KEY_DOWN 0x102 /* Down arrow key */ -#define KEY_UP 0x103 /* Up arrow key */ -#define KEY_LEFT 0x104 /* Left arrow key */ -#define KEY_RIGHT 0x105 /* Right arrow key */ -#define KEY_HOME 0x106 /* home key */ -#define KEY_BACKSPACE 0x107 /* not on pc */ -#define KEY_F0 0x108 /* function keys; 64 reserved */ - -#define KEY_DL 0x148 /* delete line */ -#define KEY_IL 0x149 /* insert line */ -#define KEY_DC 0x14a /* delete character */ -#define KEY_IC 0x14b /* insert char or enter ins mode */ -#define KEY_EIC 0x14c /* exit insert char mode */ -#define KEY_CLEAR 0x14d /* clear screen */ -#define KEY_EOS 0x14e /* clear to end of screen */ -#define KEY_EOL 0x14f /* clear to end of line */ -#define KEY_SF 0x150 /* scroll 1 line forward */ -#define KEY_SR 0x151 /* scroll 1 line back (reverse) */ -#define KEY_NPAGE 0x152 /* next page */ -#define KEY_PPAGE 0x153 /* previous page */ -#define KEY_STAB 0x154 /* set tab */ -#define KEY_CTAB 0x155 /* clear tab */ -#define KEY_CATAB 0x156 /* clear all tabs */ -#define KEY_ENTER 0x157 /* enter or send (unreliable) */ -#define KEY_SRESET 0x158 /* soft/reset (partial/unreliable) */ -#define KEY_RESET 0x159 /* reset/hard reset (unreliable) */ -#define KEY_PRINT 0x15a /* print/copy */ -#define KEY_LL 0x15b /* home down/bottom (lower left) */ -#define KEY_ABORT 0x15c /* abort/terminate key (any) */ -#define KEY_SHELP 0x15d /* short help */ -#define KEY_LHELP 0x15e /* long help */ -#define KEY_BTAB 0x15f /* Back tab key */ -#define KEY_BEG 0x160 /* beg(inning) key */ -#define KEY_CANCEL 0x161 /* cancel key */ -#define KEY_CLOSE 0x162 /* close key */ -#define KEY_COMMAND 0x163 /* cmd (command) key */ -#define KEY_COPY 0x164 /* copy key */ -#define KEY_CREATE 0x165 /* create key */ -#define KEY_END 0x166 /* end key */ -#define KEY_EXIT 0x167 /* exit key */ -#define KEY_FIND 0x168 /* find key */ -#define KEY_HELP 0x169 /* help key */ -#define KEY_MARK 0x16a /* mark key */ -#define KEY_MESSAGE 0x16b /* message key */ -#define KEY_MOVE 0x16c /* move key */ -#define KEY_NEXT 0x16d /* next object key */ -#define KEY_OPEN 0x16e /* open key */ -#define KEY_OPTIONS 0x16f /* options key */ -#define KEY_PREVIOUS 0x170 /* previous object key */ -#define KEY_REDO 0x171 /* redo key */ -#define KEY_REFERENCE 0x172 /* ref(erence) key */ -#define KEY_REFRESH 0x173 /* refresh key */ -#define KEY_REPLACE 0x174 /* replace key */ -#define KEY_RESTART 0x175 /* restart key */ -#define KEY_RESUME 0x176 /* resume key */ -#define KEY_SAVE 0x177 /* save key */ -#define KEY_SBEG 0x178 /* shifted beginning key */ -#define KEY_SCANCEL 0x179 /* shifted cancel key */ -#define KEY_SCOMMAND 0x17a /* shifted command key */ -#define KEY_SCOPY 0x17b /* shifted copy key */ -#define KEY_SCREATE 0x17c /* shifted create key */ -#define KEY_SDC 0x17d /* shifted delete char key */ -#define KEY_SDL 0x17e /* shifted delete line key */ -#define KEY_SELECT 0x17f /* select key */ -#define KEY_SEND 0x180 /* shifted end key */ -#define KEY_SEOL 0x181 /* shifted clear line key */ -#define KEY_SEXIT 0x182 /* shifted exit key */ -#define KEY_SFIND 0x183 /* shifted find key */ -#define KEY_SHOME 0x184 /* shifted home key */ -#define KEY_SIC 0x185 /* shifted input key */ - -#define KEY_SLEFT 0x187 /* shifted left arrow key */ -#define KEY_SMESSAGE 0x188 /* shifted message key */ -#define KEY_SMOVE 0x189 /* shifted move key */ -#define KEY_SNEXT 0x18a /* shifted next key */ -#define KEY_SOPTIONS 0x18b /* shifted options key */ -#define KEY_SPREVIOUS 0x18c /* shifted prev key */ -#define KEY_SPRINT 0x18d /* shifted print key */ -#define KEY_SREDO 0x18e /* shifted redo key */ -#define KEY_SREPLACE 0x18f /* shifted replace key */ -#define KEY_SRIGHT 0x190 /* shifted right arrow */ -#define KEY_SRSUME 0x191 /* shifted resume key */ -#define KEY_SSAVE 0x192 /* shifted save key */ -#define KEY_SSUSPEND 0x193 /* shifted suspend key */ -#define KEY_SUNDO 0x194 /* shifted undo key */ -#define KEY_SUSPEND 0x195 /* suspend key */ -#define KEY_UNDO 0x196 /* undo key */ - -/* PDCurses-specific key definitions -- PC only */ - -#define ALT_0 0x197 -#define ALT_1 0x198 -#define ALT_2 0x199 -#define ALT_3 0x19a -#define ALT_4 0x19b -#define ALT_5 0x19c -#define ALT_6 0x19d -#define ALT_7 0x19e -#define ALT_8 0x19f -#define ALT_9 0x1a0 -#define ALT_A 0x1a1 -#define ALT_B 0x1a2 -#define ALT_C 0x1a3 -#define ALT_D 0x1a4 -#define ALT_E 0x1a5 -#define ALT_F 0x1a6 -#define ALT_G 0x1a7 -#define ALT_H 0x1a8 -#define ALT_I 0x1a9 -#define ALT_J 0x1aa -#define ALT_K 0x1ab -#define ALT_L 0x1ac -#define ALT_M 0x1ad -#define ALT_N 0x1ae -#define ALT_O 0x1af -#define ALT_P 0x1b0 -#define ALT_Q 0x1b1 -#define ALT_R 0x1b2 -#define ALT_S 0x1b3 -#define ALT_T 0x1b4 -#define ALT_U 0x1b5 -#define ALT_V 0x1b6 -#define ALT_W 0x1b7 -#define ALT_X 0x1b8 -#define ALT_Y 0x1b9 -#define ALT_Z 0x1ba - -#define CTL_LEFT 0x1bb /* Control-Left-Arrow */ -#define CTL_RIGHT 0x1bc -#define CTL_PGUP 0x1bd -#define CTL_PGDN 0x1be -#define CTL_HOME 0x1bf -#define CTL_END 0x1c0 - -#define KEY_A1 0x1c1 /* upper left on Virtual keypad */ -#define KEY_A2 0x1c2 /* upper middle on Virt. keypad */ -#define KEY_A3 0x1c3 /* upper right on Vir. keypad */ -#define KEY_B1 0x1c4 /* middle left on Virt. keypad */ -#define KEY_B2 0x1c5 /* center on Virt. keypad */ -#define KEY_B3 0x1c6 /* middle right on Vir. keypad */ -#define KEY_C1 0x1c7 /* lower left on Virt. keypad */ -#define KEY_C2 0x1c8 /* lower middle on Virt. keypad */ -#define KEY_C3 0x1c9 /* lower right on Vir. keypad */ - -#define PADSLASH 0x1ca /* slash on keypad */ -#define PADENTER 0x1cb /* enter on keypad */ -#define CTL_PADENTER 0x1cc /* ctl-enter on keypad */ -#define ALT_PADENTER 0x1cd /* alt-enter on keypad */ -#define PADSTOP 0x1ce /* stop on keypad */ -#define PADSTAR 0x1cf /* star on keypad */ -#define PADMINUS 0x1d0 /* minus on keypad */ -#define PADPLUS 0x1d1 /* plus on keypad */ -#define CTL_PADSTOP 0x1d2 /* ctl-stop on keypad */ -#define CTL_PADCENTER 0x1d3 /* ctl-enter on keypad */ -#define CTL_PADPLUS 0x1d4 /* ctl-plus on keypad */ -#define CTL_PADMINUS 0x1d5 /* ctl-minus on keypad */ -#define CTL_PADSLASH 0x1d6 /* ctl-slash on keypad */ -#define CTL_PADSTAR 0x1d7 /* ctl-star on keypad */ -#define ALT_PADPLUS 0x1d8 /* alt-plus on keypad */ -#define ALT_PADMINUS 0x1d9 /* alt-minus on keypad */ -#define ALT_PADSLASH 0x1da /* alt-slash on keypad */ -#define ALT_PADSTAR 0x1db /* alt-star on keypad */ -#define ALT_PADSTOP 0x1dc /* alt-stop on keypad */ -#define CTL_INS 0x1dd /* ctl-insert */ -#define ALT_DEL 0x1de /* alt-delete */ -#define ALT_INS 0x1df /* alt-insert */ -#define CTL_UP 0x1e0 /* ctl-up arrow */ -#define CTL_DOWN 0x1e1 /* ctl-down arrow */ -#define CTL_TAB 0x1e2 /* ctl-tab */ -#define ALT_TAB 0x1e3 -#define ALT_MINUS 0x1e4 -#define ALT_EQUAL 0x1e5 -#define ALT_HOME 0x1e6 -#define ALT_PGUP 0x1e7 -#define ALT_PGDN 0x1e8 -#define ALT_END 0x1e9 -#define ALT_UP 0x1ea /* alt-up arrow */ -#define ALT_DOWN 0x1eb /* alt-down arrow */ -#define ALT_RIGHT 0x1ec /* alt-right arrow */ -#define ALT_LEFT 0x1ed /* alt-left arrow */ -#define ALT_ENTER 0x1ee /* alt-enter */ -#define ALT_ESC 0x1ef /* alt-escape */ -#define ALT_BQUOTE 0x1f0 /* alt-back quote */ -#define ALT_LBRACKET 0x1f1 /* alt-left bracket */ -#define ALT_RBRACKET 0x1f2 /* alt-right bracket */ -#define ALT_SEMICOLON 0x1f3 /* alt-semi-colon */ -#define ALT_FQUOTE 0x1f4 /* alt-forward quote */ -#define ALT_COMMA 0x1f5 /* alt-comma */ -#define ALT_STOP 0x1f6 /* alt-stop */ -#define ALT_FSLASH 0x1f7 /* alt-forward slash */ -#define ALT_BKSP 0x1f8 /* alt-backspace */ -#define CTL_BKSP 0x1f9 /* ctl-backspace */ -#define PAD0 0x1fa /* keypad 0 */ - -#define CTL_PAD0 0x1fb /* ctl-keypad 0 */ -#define CTL_PAD1 0x1fc -#define CTL_PAD2 0x1fd -#define CTL_PAD3 0x1fe -#define CTL_PAD4 0x1ff -#define CTL_PAD5 0x200 -#define CTL_PAD6 0x201 -#define CTL_PAD7 0x202 -#define CTL_PAD8 0x203 -#define CTL_PAD9 0x204 - -#define ALT_PAD0 0x205 /* alt-keypad 0 */ -#define ALT_PAD1 0x206 -#define ALT_PAD2 0x207 -#define ALT_PAD3 0x208 -#define ALT_PAD4 0x209 -#define ALT_PAD5 0x20a -#define ALT_PAD6 0x20b -#define ALT_PAD7 0x20c -#define ALT_PAD8 0x20d -#define ALT_PAD9 0x20e - -#define CTL_DEL 0x20f /* clt-delete */ -#define ALT_BSLASH 0x210 /* alt-back slash */ -#define CTL_ENTER 0x211 /* ctl-enter */ - -#define SHF_PADENTER 0x212 /* shift-enter on keypad */ -#define SHF_PADSLASH 0x213 /* shift-slash on keypad */ -#define SHF_PADSTAR 0x214 /* shift-star on keypad */ -#define SHF_PADPLUS 0x215 /* shift-plus on keypad */ -#define SHF_PADMINUS 0x216 /* shift-minus on keypad */ -#define SHF_UP 0x217 /* shift-up on keypad */ -#define SHF_DOWN 0x218 /* shift-down on keypad */ -#define SHF_IC 0x219 /* shift-insert on keypad */ -#define SHF_DC 0x21a /* shift-delete on keypad */ - -#define KEY_MOUSE 0x21b /* "mouse" key */ -#define KEY_SHIFT_L 0x21c /* Left-shift */ -#define KEY_SHIFT_R 0x21d /* Right-shift */ -#define KEY_CONTROL_L 0x21e /* Left-control */ -#define KEY_CONTROL_R 0x21f /* Right-control */ -#define KEY_ALT_L 0x220 /* Left-alt */ -#define KEY_ALT_R 0x221 /* Right-alt */ -#define KEY_RESIZE 0x222 /* Window resize */ -#define KEY_SUP 0x223 /* Shifted up arrow */ -#define KEY_SDOWN 0x224 /* Shifted down arrow */ - -#define KEY_MIN KEY_BREAK /* Minimum curses key value */ -#define KEY_MAX KEY_SDOWN /* Maximum curses key */ - -#define KEY_F(n) (KEY_F0 + (n)) - -/*---------------------------------------------------------------------- - * - * PDCurses Function Declarations - * - */ - -/* Standard */ - -PDCEX int addch(const chtype); -PDCEX int addchnstr(const chtype *, int); -PDCEX int addchstr(const chtype *); -PDCEX int addnstr(const char *, int); -PDCEX int addstr(const char *); -PDCEX int attroff(chtype); -PDCEX int attron(chtype); -PDCEX int attrset(chtype); -PDCEX int attr_get(attr_t *, short *, void *); -PDCEX int attr_off(attr_t, void *); -PDCEX int attr_on(attr_t, void *); -PDCEX int attr_set(attr_t, short, void *); -PDCEX int baudrate(void); -PDCEX int beep(void); -PDCEX int bkgd(chtype); -PDCEX void bkgdset(chtype); -PDCEX int border(chtype, chtype, chtype, chtype, - chtype, chtype, chtype, chtype); -PDCEX int box(WINDOW *, chtype, chtype); -PDCEX bool can_change_color(void); -PDCEX int cbreak(void); -PDCEX int chgat(int, attr_t, short, const void *); -PDCEX int clearok(WINDOW *, bool); -PDCEX int clear(void); -PDCEX int clrtobot(void); -PDCEX int clrtoeol(void); -PDCEX int color_content(short, short *, short *, short *); -PDCEX int color_set(short, void *); -PDCEX int copywin(const WINDOW *, WINDOW *, int, int, int, - int, int, int, int); -PDCEX int curs_set(int); -PDCEX int def_prog_mode(void); -PDCEX int def_shell_mode(void); -PDCEX int delay_output(int); -PDCEX int delch(void); -PDCEX int deleteln(void); -PDCEX void delscreen(SCREEN *); -PDCEX int delwin(WINDOW *); -PDCEX WINDOW *derwin(WINDOW *, int, int, int, int); -PDCEX int doupdate(void); -PDCEX WINDOW *dupwin(WINDOW *); -PDCEX int echochar(const chtype); -PDCEX int echo(void); -PDCEX int endwin(void); -PDCEX char erasechar(void); -PDCEX int erase(void); -PDCEX void filter(void); -PDCEX int flash(void); -PDCEX int flushinp(void); -PDCEX chtype getbkgd(WINDOW *); -PDCEX int getnstr(char *, int); -PDCEX int getstr(char *); -PDCEX WINDOW *getwin(FILE *); -PDCEX int halfdelay(int); -PDCEX bool has_colors(void); -PDCEX bool has_ic(void); -PDCEX bool has_il(void); -PDCEX int hline(chtype, int); -PDCEX void idcok(WINDOW *, bool); -PDCEX int idlok(WINDOW *, bool); -PDCEX void immedok(WINDOW *, bool); -PDCEX int inchnstr(chtype *, int); -PDCEX int inchstr(chtype *); -PDCEX chtype inch(void); -PDCEX int init_color(short, short, short, short); -PDCEX int init_pair(short, short, short); -PDCEX WINDOW *initscr(void); -PDCEX int innstr(char *, int); -PDCEX int insch(chtype); -PDCEX int insdelln(int); -PDCEX int insertln(void); -PDCEX int insnstr(const char *, int); -PDCEX int insstr(const char *); -PDCEX int instr(char *); -PDCEX int intrflush(WINDOW *, bool); -PDCEX bool isendwin(void); -PDCEX bool is_linetouched(WINDOW *, int); -PDCEX bool is_wintouched(WINDOW *); -PDCEX char *keyname(int); -PDCEX int keypad(WINDOW *, bool); -PDCEX char killchar(void); -PDCEX int leaveok(WINDOW *, bool); -PDCEX char *longname(void); -PDCEX int meta(WINDOW *, bool); -PDCEX int move(int, int); -PDCEX int mvaddch(int, int, const chtype); -PDCEX int mvaddchnstr(int, int, const chtype *, int); -PDCEX int mvaddchstr(int, int, const chtype *); -PDCEX int mvaddnstr(int, int, const char *, int); -PDCEX int mvaddstr(int, int, const char *); -PDCEX int mvchgat(int, int, int, attr_t, short, const void *); -PDCEX int mvcur(int, int, int, int); -PDCEX int mvdelch(int, int); -PDCEX int mvderwin(WINDOW *, int, int); -PDCEX int mvgetch(int, int); -PDCEX int mvgetnstr(int, int, char *, int); -PDCEX int mvgetstr(int, int, char *); -PDCEX int mvhline(int, int, chtype, int); -PDCEX chtype mvinch(int, int); -PDCEX int mvinchnstr(int, int, chtype *, int); -PDCEX int mvinchstr(int, int, chtype *); -PDCEX int mvinnstr(int, int, char *, int); -PDCEX int mvinsch(int, int, chtype); -PDCEX int mvinsnstr(int, int, const char *, int); -PDCEX int mvinsstr(int, int, const char *); -PDCEX int mvinstr(int, int, char *); -PDCEX int mvprintw(int, int, const char *, ...); -PDCEX int mvscanw(int, int, const char *, ...); -PDCEX int mvvline(int, int, chtype, int); -PDCEX int mvwaddchnstr(WINDOW *, int, int, const chtype *, int); -PDCEX int mvwaddchstr(WINDOW *, int, int, const chtype *); -PDCEX int mvwaddch(WINDOW *, int, int, const chtype); -PDCEX int mvwaddnstr(WINDOW *, int, int, const char *, int); -PDCEX int mvwaddstr(WINDOW *, int, int, const char *); -PDCEX int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *); -PDCEX int mvwdelch(WINDOW *, int, int); -PDCEX int mvwgetch(WINDOW *, int, int); -PDCEX int mvwgetnstr(WINDOW *, int, int, char *, int); -PDCEX int mvwgetstr(WINDOW *, int, int, char *); -PDCEX int mvwhline(WINDOW *, int, int, chtype, int); -PDCEX int mvwinchnstr(WINDOW *, int, int, chtype *, int); -PDCEX int mvwinchstr(WINDOW *, int, int, chtype *); -PDCEX chtype mvwinch(WINDOW *, int, int); -PDCEX int mvwinnstr(WINDOW *, int, int, char *, int); -PDCEX int mvwinsch(WINDOW *, int, int, chtype); -PDCEX int mvwinsnstr(WINDOW *, int, int, const char *, int); -PDCEX int mvwinsstr(WINDOW *, int, int, const char *); -PDCEX int mvwinstr(WINDOW *, int, int, char *); -PDCEX int mvwin(WINDOW *, int, int); -PDCEX int mvwprintw(WINDOW *, int, int, const char *, ...); -PDCEX int mvwscanw(WINDOW *, int, int, const char *, ...); -PDCEX int mvwvline(WINDOW *, int, int, chtype, int); -PDCEX int napms(int); -PDCEX WINDOW *newpad(int, int); -PDCEX SCREEN *newterm(const char *, FILE *, FILE *); -PDCEX WINDOW *newwin(int, int, int, int); -PDCEX int nl(void); -PDCEX int nocbreak(void); -PDCEX int nodelay(WINDOW *, bool); -PDCEX int noecho(void); -PDCEX int nonl(void); -PDCEX void noqiflush(void); -PDCEX int noraw(void); -PDCEX int notimeout(WINDOW *, bool); -PDCEX int overlay(const WINDOW *, WINDOW *); -PDCEX int overwrite(const WINDOW *, WINDOW *); -PDCEX int pair_content(short, short *, short *); -PDCEX int pechochar(WINDOW *, chtype); -PDCEX int pnoutrefresh(WINDOW *, int, int, int, int, int, int); -PDCEX int prefresh(WINDOW *, int, int, int, int, int, int); -PDCEX int printw(const char *, ...); -PDCEX int putwin(WINDOW *, FILE *); -PDCEX void qiflush(void); -PDCEX int raw(void); -PDCEX int redrawwin(WINDOW *); -PDCEX int refresh(void); -PDCEX int reset_prog_mode(void); -PDCEX int reset_shell_mode(void); -PDCEX int resetty(void); -PDCEX int ripoffline(int, int (*)(WINDOW *, int)); -PDCEX int savetty(void); -PDCEX int scanw(const char *, ...); -PDCEX int scr_dump(const char *); -PDCEX int scr_init(const char *); -PDCEX int scr_restore(const char *); -PDCEX int scr_set(const char *); -PDCEX int scrl(int); -PDCEX int scroll(WINDOW *); -PDCEX int scrollok(WINDOW *, bool); -PDCEX SCREEN *set_term(SCREEN *); -PDCEX int setscrreg(int, int); -PDCEX int slk_attroff(const chtype); -PDCEX int slk_attr_off(const attr_t, void *); -PDCEX int slk_attron(const chtype); -PDCEX int slk_attr_on(const attr_t, void *); -PDCEX int slk_attrset(const chtype); -PDCEX int slk_attr_set(const attr_t, short, void *); -PDCEX int slk_clear(void); -PDCEX int slk_color(short); -PDCEX int slk_init(int); -PDCEX char *slk_label(int); -PDCEX int slk_noutrefresh(void); -PDCEX int slk_refresh(void); -PDCEX int slk_restore(void); -PDCEX int slk_set(int, const char *, int); -PDCEX int slk_touch(void); -PDCEX int standend(void); -PDCEX int standout(void); -PDCEX int start_color(void); -PDCEX WINDOW *subpad(WINDOW *, int, int, int, int); -PDCEX WINDOW *subwin(WINDOW *, int, int, int, int); -PDCEX int syncok(WINDOW *, bool); -PDCEX chtype termattrs(void); -PDCEX attr_t term_attrs(void); -PDCEX char *termname(void); -PDCEX void timeout(int); -PDCEX int touchline(WINDOW *, int, int); -PDCEX int touchwin(WINDOW *); -PDCEX int typeahead(int); -PDCEX int untouchwin(WINDOW *); -PDCEX void use_env(bool); -PDCEX int vidattr(chtype); -PDCEX int vid_attr(attr_t, short, void *); -PDCEX int vidputs(chtype, int (*)(int)); -PDCEX int vid_puts(attr_t, short, void *, int (*)(int)); -PDCEX int vline(chtype, int); -PDCEX int vw_printw(WINDOW *, const char *, va_list); -PDCEX int vwprintw(WINDOW *, const char *, va_list); -PDCEX int vw_scanw(WINDOW *, const char *, va_list); -PDCEX int vwscanw(WINDOW *, const char *, va_list); -PDCEX int waddchnstr(WINDOW *, const chtype *, int); -PDCEX int waddchstr(WINDOW *, const chtype *); -PDCEX int waddch(WINDOW *, const chtype); -PDCEX int waddnstr(WINDOW *, const char *, int); -PDCEX int waddstr(WINDOW *, const char *); -PDCEX int wattroff(WINDOW *, chtype); -PDCEX int wattron(WINDOW *, chtype); -PDCEX int wattrset(WINDOW *, chtype); -PDCEX int wattr_get(WINDOW *, attr_t *, short *, void *); -PDCEX int wattr_off(WINDOW *, attr_t, void *); -PDCEX int wattr_on(WINDOW *, attr_t, void *); -PDCEX int wattr_set(WINDOW *, attr_t, short, void *); -PDCEX void wbkgdset(WINDOW *, chtype); -PDCEX int wbkgd(WINDOW *, chtype); -PDCEX int wborder(WINDOW *, chtype, chtype, chtype, chtype, - chtype, chtype, chtype, chtype); -PDCEX int wchgat(WINDOW *, int, attr_t, short, const void *); -PDCEX int wclear(WINDOW *); -PDCEX int wclrtobot(WINDOW *); -PDCEX int wclrtoeol(WINDOW *); -PDCEX int wcolor_set(WINDOW *, short, void *); -PDCEX void wcursyncup(WINDOW *); -PDCEX int wdelch(WINDOW *); -PDCEX int wdeleteln(WINDOW *); -PDCEX int wechochar(WINDOW *, const chtype); -PDCEX int werase(WINDOW *); -PDCEX int wgetch(WINDOW *); -PDCEX int wgetnstr(WINDOW *, char *, int); -PDCEX int wgetstr(WINDOW *, char *); -PDCEX int whline(WINDOW *, chtype, int); -PDCEX int winchnstr(WINDOW *, chtype *, int); -PDCEX int winchstr(WINDOW *, chtype *); -PDCEX chtype winch(WINDOW *); -PDCEX int winnstr(WINDOW *, char *, int); -PDCEX int winsch(WINDOW *, chtype); -PDCEX int winsdelln(WINDOW *, int); -PDCEX int winsertln(WINDOW *); -PDCEX int winsnstr(WINDOW *, const char *, int); -PDCEX int winsstr(WINDOW *, const char *); -PDCEX int winstr(WINDOW *, char *); -PDCEX int wmove(WINDOW *, int, int); -PDCEX int wnoutrefresh(WINDOW *); -PDCEX int wprintw(WINDOW *, const char *, ...); -PDCEX int wredrawln(WINDOW *, int, int); -PDCEX int wrefresh(WINDOW *); -PDCEX int wscanw(WINDOW *, const char *, ...); -PDCEX int wscrl(WINDOW *, int); -PDCEX int wsetscrreg(WINDOW *, int, int); -PDCEX int wstandend(WINDOW *); -PDCEX int wstandout(WINDOW *); -PDCEX void wsyncdown(WINDOW *); -PDCEX void wsyncup(WINDOW *); -PDCEX void wtimeout(WINDOW *, int); -PDCEX int wtouchln(WINDOW *, int, int, int); -PDCEX int wvline(WINDOW *, chtype, int); - -/* Wide-character functions */ - -#ifdef PDC_WIDE -PDCEX int addnwstr(const wchar_t *, int); -PDCEX int addwstr(const wchar_t *); -PDCEX int add_wch(const cchar_t *); -PDCEX int add_wchnstr(const cchar_t *, int); -PDCEX int add_wchstr(const cchar_t *); -PDCEX int bkgrnd(const cchar_t *); -PDCEX void bkgrndset(const cchar_t *); -PDCEX int border_set(const cchar_t *, const cchar_t *, const cchar_t *, - const cchar_t *, const cchar_t *, const cchar_t *, - const cchar_t *, const cchar_t *); -PDCEX int box_set(WINDOW *, const cchar_t *, const cchar_t *); -PDCEX int echo_wchar(const cchar_t *); -PDCEX int erasewchar(wchar_t *); -PDCEX int getbkgrnd(cchar_t *); -PDCEX int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *); -PDCEX int getn_wstr(wint_t *, int); -PDCEX int get_wch(wint_t *); -PDCEX int get_wstr(wint_t *); -PDCEX int hline_set(const cchar_t *, int); -PDCEX int innwstr(wchar_t *, int); -PDCEX int ins_nwstr(const wchar_t *, int); -PDCEX int ins_wch(const cchar_t *); -PDCEX int ins_wstr(const wchar_t *); -PDCEX int inwstr(wchar_t *); -PDCEX int in_wch(cchar_t *); -PDCEX int in_wchnstr(cchar_t *, int); -PDCEX int in_wchstr(cchar_t *); -PDCEX char *key_name(wchar_t); -PDCEX int killwchar(wchar_t *); -PDCEX int mvaddnwstr(int, int, const wchar_t *, int); -PDCEX int mvaddwstr(int, int, const wchar_t *); -PDCEX int mvadd_wch(int, int, const cchar_t *); -PDCEX int mvadd_wchnstr(int, int, const cchar_t *, int); -PDCEX int mvadd_wchstr(int, int, const cchar_t *); -PDCEX int mvgetn_wstr(int, int, wint_t *, int); -PDCEX int mvget_wch(int, int, wint_t *); -PDCEX int mvget_wstr(int, int, wint_t *); -PDCEX int mvhline_set(int, int, const cchar_t *, int); -PDCEX int mvinnwstr(int, int, wchar_t *, int); -PDCEX int mvins_nwstr(int, int, const wchar_t *, int); -PDCEX int mvins_wch(int, int, const cchar_t *); -PDCEX int mvins_wstr(int, int, const wchar_t *); -PDCEX int mvinwstr(int, int, wchar_t *); -PDCEX int mvin_wch(int, int, cchar_t *); -PDCEX int mvin_wchnstr(int, int, cchar_t *, int); -PDCEX int mvin_wchstr(int, int, cchar_t *); -PDCEX int mvvline_set(int, int, const cchar_t *, int); -PDCEX int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int); -PDCEX int mvwaddwstr(WINDOW *, int, int, const wchar_t *); -PDCEX int mvwadd_wch(WINDOW *, int, int, const cchar_t *); -PDCEX int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int); -PDCEX int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *); -PDCEX int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int); -PDCEX int mvwget_wch(WINDOW *, int, int, wint_t *); -PDCEX int mvwget_wstr(WINDOW *, int, int, wint_t *); -PDCEX int mvwhline_set(WINDOW *, int, int, const cchar_t *, int); -PDCEX int mvwinnwstr(WINDOW *, int, int, wchar_t *, int); -PDCEX int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int); -PDCEX int mvwins_wch(WINDOW *, int, int, const cchar_t *); -PDCEX int mvwins_wstr(WINDOW *, int, int, const wchar_t *); -PDCEX int mvwin_wch(WINDOW *, int, int, cchar_t *); -PDCEX int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int); -PDCEX int mvwin_wchstr(WINDOW *, int, int, cchar_t *); -PDCEX int mvwinwstr(WINDOW *, int, int, wchar_t *); -PDCEX int mvwvline_set(WINDOW *, int, int, const cchar_t *, int); -PDCEX int pecho_wchar(WINDOW *, const cchar_t*); -PDCEX int setcchar(cchar_t*, const wchar_t*, const attr_t, - short, const void*); -PDCEX int slk_wset(int, const wchar_t *, int); -PDCEX int unget_wch(const wchar_t); -PDCEX int vline_set(const cchar_t *, int); -PDCEX int waddnwstr(WINDOW *, const wchar_t *, int); -PDCEX int waddwstr(WINDOW *, const wchar_t *); -PDCEX int wadd_wch(WINDOW *, const cchar_t *); -PDCEX int wadd_wchnstr(WINDOW *, const cchar_t *, int); -PDCEX int wadd_wchstr(WINDOW *, const cchar_t *); -PDCEX int wbkgrnd(WINDOW *, const cchar_t *); -PDCEX void wbkgrndset(WINDOW *, const cchar_t *); -PDCEX int wborder_set(WINDOW *, const cchar_t *, const cchar_t *, - const cchar_t *, const cchar_t *, const cchar_t *, - const cchar_t *, const cchar_t *, const cchar_t *); -PDCEX int wecho_wchar(WINDOW *, const cchar_t *); -PDCEX int wgetbkgrnd(WINDOW *, cchar_t *); -PDCEX int wgetn_wstr(WINDOW *, wint_t *, int); -PDCEX int wget_wch(WINDOW *, wint_t *); -PDCEX int wget_wstr(WINDOW *, wint_t *); -PDCEX int whline_set(WINDOW *, const cchar_t *, int); -PDCEX int winnwstr(WINDOW *, wchar_t *, int); -PDCEX int wins_nwstr(WINDOW *, const wchar_t *, int); -PDCEX int wins_wch(WINDOW *, const cchar_t *); -PDCEX int wins_wstr(WINDOW *, const wchar_t *); -PDCEX int winwstr(WINDOW *, wchar_t *); -PDCEX int win_wch(WINDOW *, cchar_t *); -PDCEX int win_wchnstr(WINDOW *, cchar_t *, int); -PDCEX int win_wchstr(WINDOW *, cchar_t *); -PDCEX wchar_t *wunctrl(cchar_t *); -PDCEX int wvline_set(WINDOW *, const cchar_t *, int); -#endif - -/* Quasi-standard */ - -PDCEX chtype getattrs(WINDOW *); -PDCEX int getbegx(WINDOW *); -PDCEX int getbegy(WINDOW *); -PDCEX int getmaxx(WINDOW *); -PDCEX int getmaxy(WINDOW *); -PDCEX int getparx(WINDOW *); -PDCEX int getpary(WINDOW *); -PDCEX int getcurx(WINDOW *); -PDCEX int getcury(WINDOW *); -PDCEX void traceoff(void); -PDCEX void traceon(void); -PDCEX char *unctrl(chtype); - -PDCEX int crmode(void); -PDCEX int nocrmode(void); -PDCEX int draino(int); -PDCEX int resetterm(void); -PDCEX int fixterm(void); -PDCEX int saveterm(void); -PDCEX int setsyx(int, int); - -PDCEX int mouse_set(unsigned long); -PDCEX int mouse_on(unsigned long); -PDCEX int mouse_off(unsigned long); -PDCEX int request_mouse_pos(void); -PDCEX int map_button(unsigned long); -PDCEX void wmouse_position(WINDOW *, int *, int *); -PDCEX unsigned long getmouse(void); -PDCEX unsigned long getbmap(void); - -/* ncurses */ - -PDCEX int assume_default_colors(int, int); -PDCEX const char *curses_version(void); -PDCEX bool has_key(int); -PDCEX int use_default_colors(void); -PDCEX int wresize(WINDOW *, int, int); - -PDCEX int mouseinterval(int); -PDCEX mmask_t mousemask(mmask_t, mmask_t *); -PDCEX bool mouse_trafo(int *, int *, bool); -PDCEX int nc_getmouse(MEVENT *); -PDCEX int ungetmouse(MEVENT *); -PDCEX bool wenclose(const WINDOW *, int, int); -PDCEX bool wmouse_trafo(const WINDOW *, int *, int *, bool); - -/* PDCurses */ - -PDCEX int addrawch(chtype); -PDCEX int insrawch(chtype); -PDCEX bool is_termresized(void); -PDCEX int mvaddrawch(int, int, chtype); -PDCEX int mvdeleteln(int, int); -PDCEX int mvinsertln(int, int); -PDCEX int mvinsrawch(int, int, chtype); -PDCEX int mvwaddrawch(WINDOW *, int, int, chtype); -PDCEX int mvwdeleteln(WINDOW *, int, int); -PDCEX int mvwinsertln(WINDOW *, int, int); -PDCEX int mvwinsrawch(WINDOW *, int, int, chtype); -PDCEX int raw_output(bool); -PDCEX int resize_term(int, int); -PDCEX WINDOW *resize_window(WINDOW *, int, int); -PDCEX int waddrawch(WINDOW *, chtype); -PDCEX int winsrawch(WINDOW *, chtype); -PDCEX char wordchar(void); - -#ifdef PDC_WIDE -PDCEX wchar_t *slk_wlabel(int); -#endif - -PDCEX void PDC_debug(const char *, ...); -PDCEX int PDC_ungetch(int); -PDCEX int PDC_set_blink(bool); -PDCEX int PDC_set_bold(bool); -PDCEX int PDC_set_line_color(short); -PDCEX void PDC_set_title(const char *); - -PDCEX int PDC_clearclipboard(void); -PDCEX int PDC_freeclipboard(char *); -PDCEX int PDC_getclipboard(char **, long *); -PDCEX int PDC_setclipboard(const char *, long); - -PDCEX unsigned long PDC_get_input_fd(void); -PDCEX unsigned long PDC_get_key_modifiers(void); -PDCEX int PDC_return_key_modifiers(bool); -PDCEX int PDC_save_key_modifiers(bool); - -#ifdef XCURSES -PDCEX WINDOW *Xinitscr(int, char **); -PDCEX void XCursesExit(void); -PDCEX int sb_init(void); -PDCEX int sb_set_horz(int, int, int); -PDCEX int sb_set_vert(int, int, int); -PDCEX int sb_get_horz(int *, int *, int *); -PDCEX int sb_get_vert(int *, int *, int *); -PDCEX int sb_refresh(void); -#endif - -/*** Functions defined as macros ***/ - -/* getch() and ungetch() conflict with some DOS libraries */ - -#define getch() wgetch(stdscr) -#define ungetch(ch) PDC_ungetch(ch) - -#define COLOR_PAIR(n) (((chtype)(n) << PDC_COLOR_SHIFT) & A_COLOR) -#define PAIR_NUMBER(n) (((n) & A_COLOR) >> PDC_COLOR_SHIFT) - -/* These will _only_ work as macros */ - -#define getbegyx(w, y, x) (y = getbegy(w), x = getbegx(w)) -#define getmaxyx(w, y, x) (y = getmaxy(w), x = getmaxx(w)) -#define getparyx(w, y, x) (y = getpary(w), x = getparx(w)) -#define getyx(w, y, x) (y = getcury(w), x = getcurx(w)) - -#define getsyx(y, x) { if (curscr->_leaveit) (y)=(x)=-1; \ - else getyx(curscr,(y),(x)); } - -#ifdef NCURSES_MOUSE_VERSION -# define getmouse(x) nc_getmouse(x) -#endif - -/* return codes from PDC_getclipboard() and PDC_setclipboard() calls */ - -#define PDC_CLIP_SUCCESS 0 -#define PDC_CLIP_ACCESS_ERROR 1 -#define PDC_CLIP_EMPTY 2 -#define PDC_CLIP_MEMORY_ERROR 3 - -/* PDCurses key modifier masks */ - -#define PDC_KEY_MODIFIER_SHIFT 1 -#define PDC_KEY_MODIFIER_CONTROL 2 -#define PDC_KEY_MODIFIER_ALT 4 -#define PDC_KEY_MODIFIER_NUMLOCK 8 - -#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) -# undef bool -} -#endif - -#endif /* __PDCURSES__ */ From f3544fcb1f314a3da808f4bba6e49fc0e017b76f Mon Sep 17 00:00:00 2001 From: Jens Staal Date: Fri, 5 Jun 2020 06:01:22 +0200 Subject: [PATCH 3/9] moved Plan9 stuff to the plan9 directory --- README.Plan9 | 10 ---------- README.md | 1 + plan9/{README => README.Plan9} | 11 +++++++++++ plan9/README.md | 35 ++++++++++++++++++++++++++++++++++ mkfile => plan9/mkfile | 12 ++++++------ 5 files changed, 53 insertions(+), 16 deletions(-) delete mode 100644 README.Plan9 rename plan9/{README => README.Plan9} (87%) create mode 100644 plan9/README.md rename mkfile => plan9/mkfile (87%) diff --git a/README.Plan9 b/README.Plan9 deleted file mode 100644 index 59cb35b8d..000000000 --- a/README.Plan9 +++ /dev/null @@ -1,10 +0,0 @@ -This is William McBrine PDCurses 3.4 -ported and repackaged for Plan 9. -See README & maintain.er. - -Federico G. Benavento -January 2008 -benavento@gmail.com - -Jens Staal -July 2015 diff --git a/README.md b/README.md index 35d3f63bb..00981bddf 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ Build instructions are in the README.md file for each platform: - [DOS] - [OS/2] +- [Plan9] - [SDL 1.x] - [SDL 2.x] - [Windows] diff --git a/plan9/README b/plan9/README.Plan9 similarity index 87% rename from plan9/README rename to plan9/README.Plan9 index b6b420663..e9aa5fd57 100644 --- a/plan9/README +++ b/plan9/README.Plan9 @@ -1,3 +1,14 @@ +This is William McBrine PDCurses 3.4 +ported and repackaged for Plan 9. + +Federico G. Benavento +January 2008 +benavento@gmail.com + +Jens Staal +July 2015 + + Copyright (c) 2007 Federico G. Benavento Permission is hereby granted, free of charge, to any person obtaining diff --git a/plan9/README.md b/plan9/README.md new file mode 100644 index 000000000..6363264a1 --- /dev/null +++ b/plan9/README.md @@ -0,0 +1,35 @@ +PDCurses for Plan9 +================== + +This directory contains PDCurses source code files specific to Plan9. + + +Building +-------- + +- cd to the plan9 sub directory + +- Build it: + + mk + mk install + +- Optionally, you can cross compile by setting the variable $objtype, + for example: + + objtype=amd64 mk + +Distribution Status +------------------- + +See README.Plan9 for the copyright notice of Federico G. Benavento with +a permissive license. + + +Acknowledgements +---------------- + +Federico G. Benavento made the original port to PDCurses 3.0 + + +Jens Staal updated it diff --git a/mkfile b/plan9/mkfile similarity index 87% rename from mkfile rename to plan9/mkfile index 44e18d889..ca53d54ae 100644 --- a/mkfile +++ b/plan9/mkfile @@ -71,17 +71,17 @@ LD=pcc CFLAGS= -c -I. -D_POSIX_SOURCE -D_BSD_EXTENSION -D_C99_SNPRINTF_EXTENSION \ -DHAVE_VSNPRINTF -%.$O: pdcurses/%.c - $CC $CFLAGS pdcurses/$stem.c +%.$O: ../pdcurses/%.c + $CC $CFLAGS ../pdcurses/$stem.c -%.$O: plan9/%.c - $CC $CFLAGS plan9/$stem.c +%.$O: %.c + $CC $CFLAGS $stem.c install:V: cp libcurses.a /$objtype/lib/ape/libcurses.a - cp curses.h /sys/include/ape/curses.h - cp panel.h /sys/include/ape/ + cp ../curses.h /sys/include/ape/curses.h + cp ../panel.h /sys/include/ape/ demos:V: @{ From f73004da87920275d1f30f42b13a467dbbf55c1d Mon Sep 17 00:00:00 2001 From: Jens Staal Date: Fri, 5 Jun 2020 11:24:15 +0200 Subject: [PATCH 4/9] modifications made to successfully build all demos. demos execute but seem un-responsive --- plan9/header.patch | 11 +++++++++++ plan9/mkfile | 11 ++++++----- plan9/pdcdisp.c | 7 +++++++ plan9/pdckbd.c | 9 +++++---- plan9/pdcplan9.c | 2 +- plan9/pdcscrn.c | 2 +- plan9/pdcsetsc.c | 20 +++++++++++++++++++- 7 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 plan9/header.patch diff --git a/plan9/header.patch b/plan9/header.patch new file mode 100644 index 000000000..3ebb1f859 --- /dev/null +++ b/plan9/header.patch @@ -0,0 +1,11 @@ +--- curses.h 2020-06-04 13:06:57.089157964 +0200 ++++ curses.ape 2020-06-05 11:17:57.562007451 +0200 +@@ -27,6 +27,8 @@ + + **man-end****************************************************************/ + ++#pragma lib "/$M/lib/ape/libcurses.a" ++ + #define PDCURSES 1 + #define PDC_BUILD 3905 + #define PDC_VER_MAJOR 3 diff --git a/plan9/mkfile b/plan9/mkfile index ca53d54ae..c22545c30 100644 --- a/plan9/mkfile +++ b/plan9/mkfile @@ -68,8 +68,8 @@ UPDATE=\ CC=pcc LD=pcc -CFLAGS= -c -I. -D_POSIX_SOURCE -D_BSD_EXTENSION -D_C99_SNPRINTF_EXTENSION \ --DHAVE_VSNPRINTF +CFLAGS= -c -I. -I.. -D_POSIX_SOURCE -D_BSD_EXTENSION -D_C99_SNPRINTF_EXTENSION \ +-DHAVE_VSNPRINTF %.$O: ../pdcurses/%.c $CC $CFLAGS ../pdcurses/$stem.c @@ -81,17 +81,18 @@ CFLAGS= -c -I. -D_POSIX_SOURCE -D_BSD_EXTENSION -D_C99_SNPRINTF_EXTENSION \ install:V: cp libcurses.a /$objtype/lib/ape/libcurses.a cp ../curses.h /sys/include/ape/curses.h - cp ../panel.h /sys/include/ape/ + ape/patch /sys/include/ape/curses.h mouse_status /* I don't like this var name */ static void setms(Mouse m) { static uint clickmsec; diff --git a/plan9/pdcscrn.c b/plan9/pdcscrn.c index 641c53ff1..57ff69286 100644 --- a/plan9/pdcscrn.c +++ b/plan9/pdcscrn.c @@ -27,7 +27,7 @@ int PDC_init_color(short color, short red, short green, short blue) } -int PDC_scr_open(int, char **) +int PDC_scr_open(void) { PDC_LOG(("PDC_scr_open() - called\n")); diff --git a/plan9/pdcsetsc.c b/plan9/pdcsetsc.c index c97c8eae6..3a0747724 100644 --- a/plan9/pdcsetsc.c +++ b/plan9/pdcsetsc.c @@ -26,8 +26,26 @@ void PDC_set_title(const char *title) int PDC_set_blink(bool blinkon) { PDC_LOG(("PDC_set_title() - called:<%d>\n", blinkon)); - if (pdc_color_started) + if (SP->color_started) COLORS = 16; return blinkon ? ERR : OK; } + +int PDC_set_bold(bool boldon) +{ + if (!SP) + return ERR; + +#ifdef PDC_WIDE + if (boldon) + SP->termattrs |= A_BOLD; + else + SP->termattrs &= ~A_BOLD; + + return OK; +#else + return boldon ? ERR : OK; +#endif +} + From be9af19d60f32c5ab4d1b87aa4b02cf9d39f5055 Mon Sep 17 00:00:00 2001 From: Jens Staal Date: Fri, 12 Jun 2020 22:15:49 +0200 Subject: [PATCH 5/9] solved the slowness of pdcurses: we use posix sleep() how do we do ms sleep?. Thanks @Bill-Gray --- plan9/pdcplan9.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plan9/pdcplan9.c b/plan9/pdcplan9.c index 79651b689..a84afb270 100644 --- a/plan9/pdcplan9.c +++ b/plan9/pdcplan9.c @@ -63,7 +63,10 @@ static void fatal(char *s) void p9napms(int ms) { - sleep(ms); + /* posix sleep is in seconds... nanosleep did not work + alternatives? */ + + sleep(ms/1000); } From 47ab90d0365720c53611028c97ba4abdef57a454 Mon Sep 17 00:00:00 2001 From: Jens Staal Date: Sat, 13 Jun 2020 21:40:52 +0200 Subject: [PATCH 6/9] implement p9napms using nanosleep(). Demos now run at proper speed --- plan9/pdcplan9.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plan9/pdcplan9.c b/plan9/pdcplan9.c index a84afb270..90746f0c8 100644 --- a/plan9/pdcplan9.c +++ b/plan9/pdcplan9.c @@ -17,6 +17,7 @@ #include #include #include +#include #define border curborder #include @@ -63,10 +64,12 @@ static void fatal(char *s) void p9napms(int ms) { - /* posix sleep is in seconds... nanosleep did not work - alternatives? */ - - sleep(ms/1000); + int second = ms/1000; + long nano = ms*1000000 - second*1000000000; + struct timespec sleepy = {0}; + sleepy.ts_sec = second; + sleepy.ts_nsec = nano; + nanosleep(&sleepy, (struct timespec *) NULL); } From 722c9446cd049e9aa39d59d65f2e4d37247aaec3 Mon Sep 17 00:00:00 2001 From: Jens Staal Date: Sat, 13 Jun 2020 21:52:41 +0200 Subject: [PATCH 7/9] just learned about _SLEEP. Thanks @benavento --- plan9/pdcplan9.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/plan9/pdcplan9.c b/plan9/pdcplan9.c index 90746f0c8..129084211 100644 --- a/plan9/pdcplan9.c +++ b/plan9/pdcplan9.c @@ -17,7 +17,6 @@ #include #include #include -#include #define border curborder #include @@ -64,12 +63,7 @@ static void fatal(char *s) void p9napms(int ms) { - int second = ms/1000; - long nano = ms*1000000 - second*1000000000; - struct timespec sleepy = {0}; - sleepy.ts_sec = second; - sleepy.ts_nsec = nano; - nanosleep(&sleepy, (struct timespec *) NULL); + _SLEEP(ms); } From d769c3659c8f01f28a02d26e2189f98d01f3a445 Mon Sep 17 00:00:00 2001 From: Jens Staal Date: Tue, 23 Jun 2020 10:57:19 +0200 Subject: [PATCH 8/9] Update README.md Fixed link to plan9/README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 00981bddf..9343baa21 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ William McBrine [docs]: docs/README.md [DOS]: dos/README.md [OS/2]: os2/README.md +[Plan9]: plan9/README.md [SDL 1.x]: sdl1/README.md [SDL 2.x]: sdl2/README.md [Windows]: wincon/README.md From dc31c23ef0ba2b0a33947957d7965fa293aa7fa1 Mon Sep 17 00:00:00 2001 From: Jens Staal Date: Tue, 30 Jun 2020 05:40:47 +0200 Subject: [PATCH 9/9] cleaning up based on feedback from Plan9-bg pull request to Bill-Gray fork --- plan9/README.Plan9 | 32 ------------------------------- plan9/README.md | 28 ++++++++++++++++++++++++--- plan9/header.patch | 16 ++++++++-------- plan9/mkfile | 6 ++---- demos/mkfile => plan9/mkfile_demo | 5 ++++- 5 files changed, 39 insertions(+), 48 deletions(-) delete mode 100644 plan9/README.Plan9 rename demos/mkfile => plan9/mkfile_demo (75%) diff --git a/plan9/README.Plan9 b/plan9/README.Plan9 deleted file mode 100644 index e9aa5fd57..000000000 --- a/plan9/README.Plan9 +++ /dev/null @@ -1,32 +0,0 @@ -This is William McBrine PDCurses 3.4 -ported and repackaged for Plan 9. - -Federico G. Benavento -January 2008 -benavento@gmail.com - -Jens Staal -July 2015 - - -Copyright (c) 2007 Federico G. Benavento - -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, 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 AUTHORS OR 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. - diff --git a/plan9/README.md b/plan9/README.md index 6363264a1..49648ce9e 100644 --- a/plan9/README.md +++ b/plan9/README.md @@ -22,14 +22,36 @@ Building Distribution Status ------------------- -See README.Plan9 for the copyright notice of Federico G. Benavento with -a permissive license. +Copyright (c) 2007 Federico G. Benavento + +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, 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 AUTHORS OR 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. + +Federico G. Benavento +January 2008 +benavento@gmail.com Acknowledgements ---------------- Federico G. Benavento made the original port to PDCurses 3.0 - Jens Staal updated it + diff --git a/plan9/header.patch b/plan9/header.patch index 3ebb1f859..027e074fd 100644 --- a/plan9/header.patch +++ b/plan9/header.patch @@ -1,11 +1,11 @@ ---- curses.h 2020-06-04 13:06:57.089157964 +0200 -+++ curses.ape 2020-06-05 11:17:57.562007451 +0200 -@@ -27,6 +27,8 @@ - - **man-end****************************************************************/ +--- curses.h 2020-06-29 15:03:16.675718137 +0200 ++++ curses.h.ape 2020-06-29 19:09:31.624238344 +0200 +@@ -5,6 +5,8 @@ + #ifndef __PDCURSES__ + #define __PDCURSES__ 1 +#pragma lib "/$M/lib/ape/libcurses.a" + - #define PDCURSES 1 - #define PDC_BUILD 3905 - #define PDC_VER_MAJOR 3 + /*man-start************************************************************** + + Define before inclusion (only those needed): diff --git a/plan9/mkfile b/plan9/mkfile index c22545c30..41f2af413 100644 --- a/plan9/mkfile +++ b/plan9/mkfile @@ -86,14 +86,12 @@ install:V: demos:V: @{ - cd ../demos - mk all + mk -f mkfile_demo all } clean:V: @{ - cd ../demos - mk clean + mk -f mkfile_demo clean } rm -f *.[$OS] diff --git a/demos/mkfile b/plan9/mkfile_demo similarity index 75% rename from demos/mkfile rename to plan9/mkfile_demo index 8377db11a..f90763fa0 100644 --- a/demos/mkfile +++ b/plan9/mkfile_demo @@ -23,7 +23,10 @@ UPDATE=\