home *** CD-ROM | disk | FTP | other *** search
- /*
- * curses.h
- *
- * Stdscr Curses for PC Class Machines.
- *
- * Copyright 1990, 1993 by Anthony Howe. All rights reserved. No warranty.
- */
-
- #ifndef __curses_h__
- #define __curses_h__ 1
-
- #include <stdio.h>
- #include <stdarg.h>
- #include <fbios.h>
-
- #undef _
- #if __STDC__
- #define _(x) x
- #else
- #define _(x) ()
- #endif
-
- #undef CTRL
- #define CTRL(x) ((x) & 0x1f)
-
- #ifndef FALSE
- #define FALSE 0
- #define TRUE !FALSE
- #endif
-
- typedef struct {
- int page; /* DOS Bios display page */
- int mode; /* Video mode */
- unsigned short seg; /* Screen memory base segment */
- int height, width; /* Screen dimensions */
- int _cbreak : 1;
- int _crlf : 1; /* 1 = nl to crlf, 0 = nl to lf */
- int _echo : 1;
- int _raw : 1;
- } SCREEN;
-
- typedef struct {
- short row, col; /* Cursor logical location */
- short brow, bcol; /* Window location */
- short mrow, mcol; /* Max indexs */
- short flags;
- chtype attr;
- chtype back;
- chtype far **display;
- } WINDOW;
-
- /*
- * Flags
- */
- #define _CLEAROK 0x0001
- #define _IDLOK 0x0002
- #define _KEYPAD 0x0004
- #define _LEAVEOK 0x0008
- #define _SCROLLOK 0x0010
- #define _FULLWIN 0x0020
- #define _SUBWIN 0x0040
- #define _MEMMAP 0x8000
-
- #if 0
- #define A_NORMAL 0x0700
- #define A_REVERSE 0x7000
- #else
- /*
- * Read-only variables initialised by initscr().
- * It will correspond to the bottom-left hand corner attributes.
- */
- extern chtype A_NORMAL;
- extern chtype A_REVERSE;
- #endif
-
- #define A_ATTRIBUTES 0xff00
- #define A_CHARTEXT 0x00ff
- #define A_BLINK 0x8000
- #define A_BOLD 0x0800
- #define A_DIM 0
- #define A_PROTECT 0
- #define A_STANDOUT A_REVERSE
- #define A_UNDERLINE 0x0100
-
- #define OK 0
- #define ERR (-1)
-
- /* Single Line Box Characters */
- #define ACS_ULCORNER 0xda
- #define ACS_URCORNER 0xbf
- #define ACS_BLCORNER 0xc0
- #define ACS_BRCORNER 0xd9
- #define ACS_HLINE 0xc4
- #define ACS_VLINE 0xb3
- #define ACS_TTEE 0xc2
- #define ACS_BTEE 0xc1
- #define ACS_LTEE 0xc3
- #define ACS_RTEE 0xb4
-
- /* Double Line Box Characters */
- #define ACS_DULCORNER 0xc9
- #define ACS_DURCORNER 0xbb
- #define ACS_DBLCORNER 0xc8
- #define ACS_DBRCORNER 0xbc
- #define ACS_DHLINE 0xcd
- #define ACS_DVLINE 0xba
- #define ACS_DTTEE 0xcb
- #define ACS_DBTEE 0xca
- #define ACS_DLTEE 0xcc
- #define ACS_DRTEE 0xb9
-
- /* Some (not all) KEY_xxxx Macros */
- #define KEY_DOWN 0x0150 /* The four arrow keys */
- #define KEY_UP 0x0148
- #define KEY_LEFT 0x014B
- #define KEY_RIGHT 0x014D
- #define KEY_HOME 0x0147 /* Home key */
- #define KEY_BACKSPACE 0x010E /* Backspace key */
- #define KEY_DC 0x0153 /* Del key */
- #define KEY_IC 0x0152 /* Ins key */
- #define KEY_EIC 0x0152 /* Exit insert char mode */
- #define KEY_CLEAR 0x0177 /* Clear screen key */
- #define KEY_EOS 0x0176 /* Clear to end of screen */
- #define KEY_EOL 0x0175 /* Clear to end of line */
- #define KEY_NPAGE 0x0151 /* Next page PgDn */
- #define KEY_PPAGE 0x0149 /* Previous page PgUp */
- #define KEY_END 0x014F /* End key */
-
- #define KEY_F0 (-1) /* No real F0 */
- /* F1..F10 == 3B00..4400 */
- /* F11..F40 == 5400..7100 */
- #define KEY_F(n) (0x013A+(n)+((n)-11+30)/30*(0x54-0x45))
- #define KEY_SH_FN(n) KEY_F((n)+10)
- #define KEY_CTRL_FN(n) KEY_F((n)+20)
- #define KEY_ALT_FN(n) KEY_F((n)+30)
-
-
- /* Obscure Globals */
- extern SCREEN _tty;
- extern WINDOW _stdscr;
-
- /*
- * Globals
- */
- extern int clearok _((WINDOW *, int));
- extern int keypad _((WINDOW *, int));
- extern int leaveok _((WINDOW *, int));
- extern int idlok _((WINDOW *, int));
- extern int scrollok _((WINDOW *, int));
-
- extern int addch _((chtype));
- extern int addnstr _((char *, int));
- extern int beep _((void));
- extern int clrtobot _((void));
- extern int clrtoeol _((void));
- extern int endwin _((void));
- extern int getch _((void));
- extern int getnstr _((char *, int));
- /*extern int mvcur _((int, int, int, int));*/
- extern int printw _((char *, ...));
- extern int mvprintw _((int, int, char *, ...));
- extern int vwprintw _((WINDOW *, char *, va_list));
- extern int refresh _((void));
- extern WINDOW *initscr _((void));
-
- #define curscr stdscr
- #define stdscr (&_stdscr)
- #define LINES _tty.height
- #define COLS _tty.width
-
- #define erasechar() '\b'
- #define killchar() '\030'
- #define mvcur(a,b,r,c) SetCursorPos(_tty.page,r,c)
-
- #define cbreak() (_tty._cbreak = 1)
- #define echo() (_tty._echo = 1)
- #define nl() (_tty._crlf = 1)
- #define raw() (_tty._raw = 1)
- #define nocbreak() (_tty._cbreak = 0)
- #define noecho() (_tty._echo = 0)
- #define nonl() (_tty._crlf = 0)
- #define noraw() (_tty._raw = 0)
-
- #define getyx(w,y,x) ((y) = _stdscr.row, (x) = _stdscr.col)
- #define getbegyx(w,y,x) ((y) = _stdscr.brow, (x) = _stdscr.bcol)
- #define getmaxyx(w,y,x) ((y) = _stdscr.mrow, (x) = _stdscr.mcol)
-
- #define addstr(s) addnstr(s,-1)
- #define clear() (clearok(stdscr, TRUE), erase())
- #define doupdate() OK
- #define erase() (move(0,0),clrtobot())
- #define getstr(b) getnstr(b,-1)
- #define move(r,c) (_stdscr.row=r,_stdscr.col=c,OK)
- #define mvaddch(r,c,ch) (move(r,c),addch(ch))
- #define mvaddnstr(r,c,n,s) (move(r,c),addnstr(n,s))
- #define mvaddstr(r,c,s) (move(r,c),addstr(s))
- #define mvgetch(r,c) (move(r,c),getch())
- #define standend() (_stdscr.attr = A_NORMAL)
- #define standout() (_stdscr.attr = A_STANDOUT)
-
- #endif /* __curses_h__ */
-