122686Sdist /* 234677Sbostic * Copyright (c) 1981 Regents of the University of California. 334677Sbostic * All rights reserved. 422686Sdist * 542653Sbostic * %sccs.include.redist.c% 634677Sbostic * 7*56116Selan * @(#)curses.h 5.11 (Berkeley) 08/31/92 822686Sdist */ 922686Sdist 1055990Sbostic #ifndef _CURSES_H_ 1155990Sbostic #define _CURSES_H_ 122244Sarnold 1355990Sbostic #include <stdio.h> 142244Sarnold 1555990Sbostic /* 1655990Sbostic * The following #defines and #includes are present for backward 1755990Sbostic * compatibility only. They should not be used in future code. 1855990Sbostic * 1955990Sbostic * START BACKWARD COMPATIBILITY ONLY. 2055990Sbostic */ 2155990Sbostic #ifndef _CURSES_PRIVATE 2238839Skarels #define bool char 2338839Skarels #define reg register 242244Sarnold 2555990Sbostic #ifndef TRUE 2638839Skarels #define TRUE (1) 2755990Sbostic #endif 2855990Sbostic #ifndef FALSE 2938839Skarels #define FALSE (0) 3055990Sbostic #endif 312244Sarnold 32*56116Selan #define _puts(s) tputs(s, 0, __cputchar) 3355990Sbostic #define _putchar(c) __cputchar(c) 342244Sarnold 3555990Sbostic /* Old-style terminal modes access. */ 36*56116Selan #define baudrate() (cfgetospeed(&origtermio)) 3755990Sbostic #define crmode() cbreak() 3855990Sbostic #define erasechar() (origtermio.c_cc[VERASE]) 3955990Sbostic #define killchar() (origtermio.c_cc[VKILL]) 4055990Sbostic #define nocrmode() nocbreak() 41*56116Selan #define ospeed (cfgetospeed(&origtermio)) 4255990Sbostic #endif /* _CURSES_PRIVATE */ 432244Sarnold 4455990Sbostic extern int My_term; /* Use Def_term regardless. */ 4555990Sbostic extern char *Def_term; /* Default terminal type. */ 4655990Sbostic 4755990Sbostic /* END BACKWARD COMPATIBILITY ONLY. */ 4855990Sbostic 4955990Sbostic /* 7-bit ASCII characters. */ 5055990Sbostic #define unctrl(c) __unctrl[(c) & 0x7f] 5155990Sbostic #define unctrllen(ch) __unctrllen[(ch) & 0x7f] 5255990Sbostic 5355990Sbostic typedef struct _win_st { /* Window structure. */ 5455990Sbostic short _cury, _curx; /* Current x, y coordinates. */ 5555990Sbostic short _maxy, _maxx; /* Maximum values for curx, cury. */ 5655990Sbostic short _begy, _begx; /* Window home. */ 5755990Sbostic 5855990Sbostic #define _ENDLINE 0x001 /* End of screen. */ 5955990Sbostic #define _FLUSH 0x002 /* fflush(stdout) after refresh. */ 6055990Sbostic #define _FULLLINE 0x004 /* Line width = terminal width. */ 6155990Sbostic #define _FULLWIN 0x008 /* Window is a screen. */ 6255990Sbostic #define _IDLINE 0x010 /* Insert/delete sequences. */ 6355990Sbostic #define _SCROLLWIN 0x020 /* Last char will scroll window. */ 6455990Sbostic /* 6555990Sbostic * XXX 6655990Sbostic * _STANDOUT is the 8th bit, characters themselves are encoded. 672244Sarnold */ 6855990Sbostic #define _STANDOUT 0x080 /* Added characters are standout. */ 6955990Sbostic unsigned short _flags; 702244Sarnold 7155990Sbostic short scroll; /* Scrolling offset. */ 7255990Sbostic short _ch_off; /* x offset for firstch/lastch. */ 7355990Sbostic char _clear; /* If clear on next refresh. */ 7455990Sbostic char _leave; /* If cursor left. */ 7555990Sbostic char _scroll; /* If scrolling permitted. */ 7655990Sbostic char **_y; /* Line describing the window. */ 7755990Sbostic 7855990Sbostic #define _NOCHANGE -1 /* No change since last refresh. */ 7955990Sbostic short *_firstch; /* First and last changed in line. */ 8055990Sbostic short *_lastch; 8155990Sbostic struct _win_st *_nextp, *_orig;/* Subwindows list and parent. */ 8255990Sbostic } WINDOW; 8355990Sbostic 8455990Sbostic /* Termcap capabilities. */ 8555990Sbostic extern char AM, BS, CA, DA, EO, HC, HZ, IN, MI, MS, NC, NS, OS, 8655990Sbostic PC, UL, XB, XN, XT, XS, XX; 8719900Sbloom extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, 8819900Sbloom *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, 8919900Sbloom *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, 9019900Sbloom *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, 9119900Sbloom *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, 9255990Sbostic *VE, 9355990Sbostic *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM, 9455990Sbostic *RIGHT_PARM; 952244Sarnold 9655990Sbostic /* Curses external declarations. */ 9755990Sbostic extern WINDOW *curscr; /* Current screen. */ 9855990Sbostic extern WINDOW *stdscr; /* Standard screen. */ 992244Sarnold 10055990Sbostic extern struct termios origtermio; /* Original terminal modes. */ 1012244Sarnold 10255990Sbostic extern int COLS; /* Columns on the screen. */ 10355990Sbostic extern int LINES; /* Lines on the screen. */ 1042244Sarnold 10555990Sbostic extern char GT; /* Gtty indicates tabs. */ 10655990Sbostic extern char NONL; /* Term can't hack LF doing a CR. */ 10755990Sbostic extern char UPPERCASE; /* Terminal is uppercase only. */ 10855990Sbostic extern char *ttytype; /* Full name of current terminal. */ 10955990Sbostic extern char *__unctrl[0x80]; /* Control strings. */ 11055990Sbostic extern char __unctrllen[0x80]; /* Control strings length. */ 1112244Sarnold 11255990Sbostic #define ERR (0) /* Error return. */ 11355990Sbostic #define OK (1) /* Success return. */ 1142244Sarnold 11555990Sbostic /* Standard screen pseudo functions. */ 11655990Sbostic #define addbytes(da, co) waddbytes(stdscr, da, co) 11755990Sbostic #define addch(ch) waddch(stdscr, ch) 11855990Sbostic #define addstr(str) waddbytes(stdscr, str, strlen(str)) 11955990Sbostic #define clear() wclear(stdscr) 12055990Sbostic #define clrtobot() wclrtobot(stdscr) 12155990Sbostic #define clrtoeol() wclrtoeol(stdscr) 12255990Sbostic #define delch() wdelch(stdscr) 12355990Sbostic #define deleteln() wdeleteln(stdscr) 12455990Sbostic #define erase() werase(stdscr) 12555990Sbostic #define getch() wgetch(stdscr) 12655990Sbostic #define getstr(str) wgetstr(stdscr, str) 12755990Sbostic #define inch() winch(stdscr) 12855990Sbostic #define insch(ch)) winsch(stdscr, ch) 12955990Sbostic #define insertln() winsertln(stdscr) 13055990Sbostic #define move(y, x) wmove(stdscr, y, x) 13155990Sbostic #define refresh() wrefresh(stdscr) 13255990Sbostic #define standend() wstandend(stdscr) 13355990Sbostic #define standout() wstandout(stdscr) 1342244Sarnold 13555990Sbostic /* Standard screen plus movement pseudo functions. */ 13655990Sbostic #define mvaddbytes(y, x, da, co) \ 13755990Sbostic mvwaddbytes(stdscr, y, x, da, co) 13855990Sbostic #define mvaddch(y, x, ch) mvwaddch(stdscr, y, x, ch) 13955990Sbostic #define mvaddstr(y, x, str) mvwaddstr(stdscr, y, x, str) 14055990Sbostic #define mvdelch(y, x) mvwdelch(stdscr, y, x) 14155990Sbostic #define mvgetch(y, x) mvwgetch(stdscr, y, x) 14255990Sbostic #define mvgetstr(y, x, str) mvwgetstr(stdscr, y, x, str) 14355990Sbostic #define mvinch(y, x) mvwinch(stdscr, y, x) 14455990Sbostic #define mvinsch(y, x, c) mvwinsch(stdscr, y, x, c) 14555990Sbostic #define mvwaddbytes(win, y, x, da, co) \ 14655990Sbostic (wmove(win, y, x) == ERR ? \ 14755990Sbostic ERR : waddbytes(win, da, co)) 14855990Sbostic #define mvwaddch(win, y, x, ch) (wmove(win, y, x) == ERR ? \ 14955990Sbostic ERR : waddch(win, ch)) 15055990Sbostic #define mvwaddstr(win, y, x, str) \ 15155990Sbostic (wmove(win, y, x) == ERR ? \ 15255990Sbostic ERR : waddbytes(win, str, strlen(str))) 15355990Sbostic #define mvwdelch(win, y, x) (wmove(win, y, x) == ERR ? ERR : wdelch(win)) 15455990Sbostic #define mvwgetch(win, y, x) (wmove(win, y, x) == ERR ? ERR : wgetch(win)) 15555990Sbostic #define mvwgetstr(win, y, x, str) \ 15655990Sbostic (wmove(win, y, x) == ERR ? \ 15755990Sbostic ERR : wgetstr(win, str)) 15855990Sbostic #define mvwinch(win, y, x) (wmove(win, y, x) == ERR ? ERR : winch(win)) 15955990Sbostic #define mvwinsch(win, y, x, c) (wmove(win, y, x) == ERR ? ERR : winsch(win, c)) 1602244Sarnold 16155990Sbostic /* Random psuedo functions. */ 16255990Sbostic #define clearok(win, bf) (win->_clear = (bf)) 16355990Sbostic #define flushok(win, bf) ((bf) ? (win->_flags |= _FLUSH) : \ 16455990Sbostic (win->_flags &= ~_FLUSH)) 16555990Sbostic #define getyx(win, y, x) (y) = win->_cury, (x) = win->_curx 16655990Sbostic #define leaveok(win, bf) (win->_leave = (bf)) 16755990Sbostic #define scrollok(win, bf) (win->_scroll = (bf)) 16855990Sbostic #define winch(win) (win->_y[win->_cury][win->_curx] & 0177) 1692244Sarnold 17055990Sbostic /* Public function prototypes. */ 17155990Sbostic void __cputchar __P((int)); 17255990Sbostic int _sprintw __P((WINDOW *, const char *, _BSD_VA_LIST_)); 17355990Sbostic int box __P((WINDOW *, int, int)); 17455990Sbostic int cbreak __P((void)); 17555990Sbostic int delwin __P((WINDOW *)); 17655990Sbostic int echo __P((void)); 17755990Sbostic int endwin __P((void)); 17855990Sbostic char *fullname __P((char *, char *)); 17955990Sbostic char *getcap __P((char *)); 18055990Sbostic int gettmode __P((void)); 18155990Sbostic void idlok __P((WINDOW *, int)); 18255990Sbostic WINDOW *initscr __P((void)); 18355990Sbostic char *longname __P((char *, char *)); 18455990Sbostic int mvcur __P((int, int, int, int)); 18555990Sbostic int mvprintw __P((int, int, const char *, ...)); 18655990Sbostic int mvscanw __P((int, int, const char *, ...)); 18755990Sbostic int mvwin __P((WINDOW *, int, int)); 18855990Sbostic int mvwprintw __P((WINDOW *, int, int, const char *, ...)); 18955990Sbostic int mvwscanw __P((WINDOW *, int, int, const char *, ...)); 19055990Sbostic WINDOW *newwin __P((int, int, int, int)); 19155990Sbostic int nl __P((void)); 19255990Sbostic int nocbreak __P((void)); 19355990Sbostic int noecho __P((void)); 19455990Sbostic int nonl __P((void)); 19555990Sbostic int noraw __P((void)); 19655990Sbostic int overlay __P((WINDOW *, WINDOW *)); 19755990Sbostic int overwrite __P((WINDOW *, WINDOW *)); 19855990Sbostic int printw __P((const char *, ...)); 19955990Sbostic int raw __P((void)); 20055990Sbostic int resetty __P((void)); 20155990Sbostic int savetty __P((void)); 20255990Sbostic int scanw __P((const char *, ...)); 20355990Sbostic int scroll __P((WINDOW *)); 20455990Sbostic int setterm __P((char *)); 20555990Sbostic int sscans __P((WINDOW *, const char *, _BSD_VA_LIST_)); 20655990Sbostic WINDOW *subwin __P((WINDOW *, int, int, int, int)); 20755990Sbostic int suspendwin __P((void)); 20855990Sbostic int touchline __P((WINDOW *, int, int, int)); 20955990Sbostic int touchoverlap __P((WINDOW *, WINDOW *)); 21055990Sbostic int touchwin __P((WINDOW *)); 21155990Sbostic void tstp __P((int)); 21255990Sbostic int waddch __P((WINDOW *, int)); 21355990Sbostic int waddstr __P((WINDOW *, char *)); 21455990Sbostic int wclear __P((WINDOW *)); 21555990Sbostic int wclrtobot __P((WINDOW *)); 21655990Sbostic int wclrtoeol __P((WINDOW *)); 21755990Sbostic int wdelch __P((WINDOW *)); 21855990Sbostic int wdeleteln __P((WINDOW *)); 21955990Sbostic int werase __P((WINDOW *)); 22055990Sbostic int wgetch __P((WINDOW *)); 22155990Sbostic int wgetstr __P((WINDOW *, char *)); 22255990Sbostic int winsch __P((WINDOW *, int)); 22355990Sbostic int winsertln __P((WINDOW *)); 22455990Sbostic int wmove __P((WINDOW *, int, int)); 22555990Sbostic int wprintw __P((WINDOW *, const char *, ...)); 22655990Sbostic int wrefresh __P((WINDOW *)); 22755990Sbostic int wscanw __P((WINDOW *, const char *, ...)); 22855990Sbostic char *wstandend __P((WINDOW *)); 22955990Sbostic char *wstandout __P((WINDOW *)); 2302244Sarnold 23155990Sbostic #ifdef _CURSES_PRIVATE 23255990Sbostic /* Private function prototypes. */ 23355990Sbostic void __id_subwins __P((WINDOW *)); 23455990Sbostic void __set_subwin __P((WINDOW *, WINDOW *)); 23555990Sbostic void __swflags __P((WINDOW *)); 23655990Sbostic void __TRACE __P((const char *, ...)); 23755990Sbostic int waddbytes __P((WINDOW *, char *, int)); 2382244Sarnold 23955990Sbostic /* Private #defines. */ 24055990Sbostic #define min(a,b) (a < b ? a : b) 24155990Sbostic #define max(a,b) (a > b ? a : b) 2422244Sarnold 24355990Sbostic /* Private externs. */ 24455990Sbostic extern int __echoit; 24555990Sbostic extern int __endwin; 24655990Sbostic extern int __pfast; 24755990Sbostic extern int __rawmode; 24855990Sbostic #endif 2492244Sarnold 25055990Sbostic /* Termcap functions. */ 25155990Sbostic int tgetent __P((char *, char *)); 25255990Sbostic int tgetnum __P((char *)); 25355990Sbostic int tgetflag __P((char *)); 25455990Sbostic char *tgetstr __P((char *, char **)); 25555990Sbostic char *tgoto __P((char *, int, int)); 25655990Sbostic int tputs __P((char *, int, void (*)(int))); 2572244Sarnold 25855990Sbostic #endif /* !_CURSES_H_ */ 259