122686Sdist /* 234677Sbostic * Copyright (c) 1981 Regents of the University of California. 334677Sbostic * All rights reserved. 422686Sdist * 542653Sbostic * %sccs.include.redist.c% 634677Sbostic * 7*60058Sbostic * @(#)curses.h 5.34 (Berkeley) 05/16/93 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 3256116Selan #define _puts(s) tputs(s, 0, __cputchar) 3355990Sbostic #define _putchar(c) __cputchar(c) 342244Sarnold 3555990Sbostic /* Old-style terminal modes access. */ 3657712Sbostic #define baudrate() (cfgetospeed(&__orig_termios)) 3755990Sbostic #define crmode() cbreak() 3857712Sbostic #define erasechar() (__orig_termios.c_cc[VERASE]) 3957712Sbostic #define killchar() (__orig_termios.c_cc[VKILL]) 4055990Sbostic #define nocrmode() nocbreak() 4157712Sbostic #define ospeed (cfgetospeed(&__orig_termios)) 4255990Sbostic #endif /* _CURSES_PRIVATE */ 432244Sarnold 4457477Sbostic extern char GT; /* Gtty indicates tabs. */ 4557477Sbostic extern char NONL; /* Term can't hack LF doing a CR. */ 4657477Sbostic extern char UPPERCASE; /* Terminal is uppercase only. */ 4757477Sbostic 4855990Sbostic extern int My_term; /* Use Def_term regardless. */ 4955990Sbostic extern char *Def_term; /* Default terminal type. */ 5055990Sbostic 5157477Sbostic /* Termcap capabilities. */ 5257477Sbostic extern char AM, BS, CA, DA, EO, HC, HZ, IN, MI, MS, NC, NS, OS, 5357477Sbostic PC, UL, XB, XN, XT, XS, XX; 5457477Sbostic extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, 5557477Sbostic *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, 5657477Sbostic *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, 5757477Sbostic *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, 5857477Sbostic *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, 5957477Sbostic *VE, *al, *dl, *sf, *sr, 6057477Sbostic *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM, 6157477Sbostic *RIGHT_PARM; 6257477Sbostic 6355990Sbostic /* END BACKWARD COMPATIBILITY ONLY. */ 6455990Sbostic 6557830Selan /* 8-bit ASCII characters. */ 6657830Selan #define unctrl(c) __unctrl[(c) & 0xff] 6757830Selan #define unctrllen(ch) __unctrllen[(ch) & 0xff] 6855990Sbostic 6957479Selan extern char *__unctrl[256]; /* Control strings. */ 7057479Selan extern char __unctrllen[256]; /* Control strings length. */ 7157477Sbostic 7256238Selan /* 7356647Selan * A window an array of __LINE structures pointed to by the 'lines' pointer. 7456647Selan * A line is an array of __LDATA structures pointed to by the 'line' pointer. 7556647Selan * 7656647Selan * IMPORTANT: the __LDATA structure must NOT induce any padding, so if new 7756647Selan * fields are added -- padding fields with *constant values* should ensure 7856647Selan * that the compiler will not generate any padding when storing an array of 7958042Selan * __LDATA structures. This is to enable consistent use of memcmp, and memcpy 8056647Selan * for comparing and copying arrays. 8156238Selan */ 8256647Selan typedef struct { 8356647Selan char ch; /* the actual character */ 8456647Selan 8556647Selan #define __STANDOUT 0x01 /* Added characters are standout. */ 8656647Selan char attr; /* attributes of character */ 8756647Selan } __LDATA; 8856647Selan 8956647Selan #define __LDATASIZE (sizeof(__LDATA)) 9056647Selan 9156647Selan typedef struct { 9256238Selan #define __ISDIRTY 0x01 /* Line is dirty. */ 9356300Selan #define __ISPASTEOL 0x02 /* Cursor is past end of line */ 9456650Selan #define __FORCEPAINT 0x04 /* Force a repaint of the line */ 9556238Selan u_int flags; 9656238Selan u_int hash; /* Hash value for the line. */ 9756715Selan size_t *firstchp, *lastchp; /* First and last chngd columns ptrs */ 9856238Selan size_t firstch, lastch; /* First and last changed columns. */ 9956647Selan __LDATA *line; /* Pointer to the line text. */ 10056647Selan } __LINE; 10156596Selan 10256238Selan typedef struct __window { /* Window structure. */ 10356238Selan struct __window *nextp, *orig; /* Subwindows list and parent. */ 10456238Selan size_t begy, begx; /* Window home. */ 10556238Selan size_t cury, curx; /* Current x, y coordinates. */ 10656238Selan size_t maxy, maxx; /* Maximum values for curx, cury. */ 10756238Selan short ch_off; /* x offset for firstch/lastch. */ 10856647Selan __LINE **lines; /* Array of pointers to the lines */ 10956647Selan __LINE *lspace; /* line space (for cleanup) */ 11056647Selan __LDATA *wspace; /* window space (for cleanup) */ 11155990Sbostic 11256238Selan #define __ENDLINE 0x001 /* End of screen. */ 11356238Selan #define __FLUSH 0x002 /* Fflush(stdout) after refresh. */ 11456238Selan #define __FULLLINE 0x004 /* Line width = terminal width. */ 11556238Selan #define __FULLWIN 0x008 /* Window is a screen. */ 11656238Selan #define __IDLINE 0x010 /* Insert/delete sequences. */ 11756238Selan #define __SCROLLWIN 0x020 /* Last char will scroll window. */ 11856238Selan #define __SCROLLOK 0x040 /* Scrolling ok. */ 11956238Selan #define __CLEAROK 0x080 /* Clear on next refresh. */ 12056238Selan #define __WSTANDOUT 0x100 /* Standout window */ 12156238Selan #define __LEAVEOK 0x200 /* If curser left */ 12256238Selan u_int flags; 12355990Sbostic } WINDOW; 12455990Sbostic 12555990Sbostic /* Curses external declarations. */ 12655990Sbostic extern WINDOW *curscr; /* Current screen. */ 12755990Sbostic extern WINDOW *stdscr; /* Standard screen. */ 1282244Sarnold 12957712Sbostic extern struct termios __orig_termios; /* Original terminal modes. */ 1302244Sarnold 13155990Sbostic extern int COLS; /* Columns on the screen. */ 13255990Sbostic extern int LINES; /* Lines on the screen. */ 1332244Sarnold 13455990Sbostic extern char *ttytype; /* Full name of current terminal. */ 1352244Sarnold 13655990Sbostic #define ERR (0) /* Error return. */ 13755990Sbostic #define OK (1) /* Success return. */ 1382244Sarnold 13955990Sbostic /* Standard screen pseudo functions. */ 14057972Sbostic #define addbytes(s, n) __waddbytes(stdscr, s, n, 0) 14157477Sbostic #define addch(ch) waddch(stdscr, ch) 14257972Sbostic #define addnstr(s, n) waddnstr(stdscr, s, n) 14357972Sbostic #define addstr(s) __waddbytes(stdscr, s, strlen(s), 0) 14457477Sbostic #define clear() wclear(stdscr) 14557477Sbostic #define clrtobot() wclrtobot(stdscr) 14657477Sbostic #define clrtoeol() wclrtoeol(stdscr) 14757477Sbostic #define delch() wdelch(stdscr) 14857477Sbostic #define deleteln() wdeleteln(stdscr) 14957477Sbostic #define erase() werase(stdscr) 15057477Sbostic #define getch() wgetch(stdscr) 15157972Sbostic #define getstr(s) wgetstr(stdscr, s) 15257477Sbostic #define inch() winch(stdscr) 15358191Selan #define insch(ch) winsch(stdscr, ch) 15457477Sbostic #define insertln() winsertln(stdscr) 15557477Sbostic #define move(y, x) wmove(stdscr, y, x) 15659929Selan #define mvcur(fx, fy, tx, ty) __mvcur(fx, fy, tx, ty, 0) 15757477Sbostic #define refresh() wrefresh(stdscr) 15857477Sbostic #define standend() wstandend(stdscr) 15957477Sbostic #define standout() wstandout(stdscr) 16057972Sbostic #define waddbytes(w, s, n) __waddbytes(w, s, n, 0) 16157972Sbostic #define waddstr(w, s) __waddbytes(w, s, strlen(s), 0) 1622244Sarnold 16355990Sbostic /* Standard screen plus movement pseudo functions. */ 16457972Sbostic #define mvaddbytes(y, x, s, n) mvwaddbytes(stdscr, y, x, s, n) 16557477Sbostic #define mvaddch(y, x, ch) mvwaddch(stdscr, y, x, ch) 16657972Sbostic #define mvaddnstr(y, x, s, n) mvwaddnstr(stdscr, y, x, s, n) 16757972Sbostic #define mvaddstr(y, x, s) mvwaddstr(stdscr, y, x, s) 16857477Sbostic #define mvdelch(y, x) mvwdelch(stdscr, y, x) 16957477Sbostic #define mvgetch(y, x) mvwgetch(stdscr, y, x) 17057972Sbostic #define mvgetstr(y, x, s) mvwgetstr(stdscr, y, x, s) 17157477Sbostic #define mvinch(y, x) mvwinch(stdscr, y, x) 17257477Sbostic #define mvinsch(y, x, c) mvwinsch(stdscr, y, x, c) 17357972Sbostic #define mvwaddbytes(w, y, x, s, n) \ 17457972Sbostic (wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, n, 0)) 17557972Sbostic #define mvwaddch(w, y, x, ch) \ 17657972Sbostic (wmove(w, y, x) == ERR ? ERR : waddch(w, ch)) 17757972Sbostic #define mvwaddnstr(w, y, x, s, n) \ 17857972Sbostic (wmove(w, y, x) == ERR ? ERR : waddnstr(w, s, n)) 17957972Sbostic #define mvwaddstr(w, y, x, s) \ 18057972Sbostic (wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, strlen(s), 0)) 18157972Sbostic #define mvwdelch(w, y, x) \ 18257972Sbostic (wmove(w, y, x) == ERR ? ERR : wdelch(w)) 18357972Sbostic #define mvwgetch(w, y, x) \ 18457972Sbostic (wmove(w, y, x) == ERR ? ERR : wgetch(w)) 18557972Sbostic #define mvwgetstr(w, y, x, s) \ 18657972Sbostic (wmove(w, y, x) == ERR ? ERR : wgetstr(w, s)) 18757972Sbostic #define mvwinch(w, y, x) \ 18857972Sbostic (wmove(w, y, x) == ERR ? ERR : winch(w)) 18957972Sbostic #define mvwinsch(w, y, x, c) \ 19057972Sbostic (wmove(w, y, x) == ERR ? ERR : winsch(w, c)) 1912244Sarnold 19257477Sbostic /* Psuedo functions. */ 19357972Sbostic #define clearok(w, bf) \ 19457972Sbostic ((bf) ? ((w)->flags |= __CLEAROK) : ((w)->flags &= ~__CLEAROK)) 19557972Sbostic #define flushok(w, bf) \ 19657972Sbostic ((bf) ? ((w)->flags |= __FLUSH) : ((w)->flags &= ~__FLUSH)) 19757972Sbostic #define getyx(w, y, x) \ 19857972Sbostic (y) = (w)->cury, (x) = (w)->curx 19957972Sbostic #define leaveok(w, bf) \ 20057972Sbostic ((bf) ? ((w)->flags |= __LEAVEOK) : ((w)->flags &= ~__LEAVEOK)) 20157972Sbostic #define scrollok(w, bf) \ 20257972Sbostic ((bf) ? ((w)->flags |= __SCROLLOK) : ((w)->flags &= ~__SCROLLOK)) 20357972Sbostic #define winch(w) \ 20457972Sbostic ((w)->lines[(w)->cury]->line[(w)->curx].ch & 0177) 2052244Sarnold 20655990Sbostic /* Public function prototypes. */ 20755990Sbostic int box __P((WINDOW *, int, int)); 20855990Sbostic int cbreak __P((void)); 20955990Sbostic int delwin __P((WINDOW *)); 21055990Sbostic int echo __P((void)); 21155990Sbostic int endwin __P((void)); 21255990Sbostic char *fullname __P((char *, char *)); 21355990Sbostic char *getcap __P((char *)); 21455990Sbostic int gettmode __P((void)); 21555990Sbostic void idlok __P((WINDOW *, int)); 21655990Sbostic WINDOW *initscr __P((void)); 21755990Sbostic char *longname __P((char *, char *)); 21855990Sbostic int mvcur __P((int, int, int, int)); 21955990Sbostic int mvprintw __P((int, int, const char *, ...)); 22055990Sbostic int mvscanw __P((int, int, const char *, ...)); 22155990Sbostic int mvwin __P((WINDOW *, int, int)); 22255990Sbostic int mvwprintw __P((WINDOW *, int, int, const char *, ...)); 22355990Sbostic int mvwscanw __P((WINDOW *, int, int, const char *, ...)); 22455990Sbostic WINDOW *newwin __P((int, int, int, int)); 22555990Sbostic int nl __P((void)); 22655990Sbostic int nocbreak __P((void)); 22755990Sbostic int noecho __P((void)); 22855990Sbostic int nonl __P((void)); 22955990Sbostic int noraw __P((void)); 23055990Sbostic int overlay __P((WINDOW *, WINDOW *)); 23155990Sbostic int overwrite __P((WINDOW *, WINDOW *)); 23255990Sbostic int printw __P((const char *, ...)); 23355990Sbostic int raw __P((void)); 23455990Sbostic int resetty __P((void)); 23555990Sbostic int savetty __P((void)); 23655990Sbostic int scanw __P((const char *, ...)); 23755990Sbostic int scroll __P((WINDOW *)); 23855990Sbostic int setterm __P((char *)); 23957362Selan int sscans __P((WINDOW *, const char *, ...)); 24055990Sbostic WINDOW *subwin __P((WINDOW *, int, int, int, int)); 24155990Sbostic int suspendwin __P((void)); 24255990Sbostic int touchline __P((WINDOW *, int, int, int)); 24355990Sbostic int touchoverlap __P((WINDOW *, WINDOW *)); 24455990Sbostic int touchwin __P((WINDOW *)); 24557362Selan int vwprintw __P((WINDOW *, const char *, _BSD_VA_LIST_)); 24657362Selan int vwscanw __P((WINDOW *, const char *, _BSD_VA_LIST_)); 24755990Sbostic int waddch __P((WINDOW *, int)); 24857972Sbostic int waddnstr __P((WINDOW *, const char *, int)); 24955990Sbostic int wclear __P((WINDOW *)); 25055990Sbostic int wclrtobot __P((WINDOW *)); 25155990Sbostic int wclrtoeol __P((WINDOW *)); 25255990Sbostic int wdelch __P((WINDOW *)); 25355990Sbostic int wdeleteln __P((WINDOW *)); 25455990Sbostic int werase __P((WINDOW *)); 25555990Sbostic int wgetch __P((WINDOW *)); 25655990Sbostic int wgetstr __P((WINDOW *, char *)); 25755990Sbostic int winsch __P((WINDOW *, int)); 25855990Sbostic int winsertln __P((WINDOW *)); 25955990Sbostic int wmove __P((WINDOW *, int, int)); 26055990Sbostic int wprintw __P((WINDOW *, const char *, ...)); 26155990Sbostic int wrefresh __P((WINDOW *)); 26255990Sbostic int wscanw __P((WINDOW *, const char *, ...)); 26355990Sbostic char *wstandend __P((WINDOW *)); 26455990Sbostic char *wstandout __P((WINDOW *)); 26557477Sbostic int vwprintw __P((WINDOW *, const char *, _BSD_VA_LIST_)); 2662244Sarnold 26759789Sbostic void __cputchar __P((int)); /* Public: backward compatibility */ 26859789Sbostic 26955990Sbostic #ifdef _CURSES_PRIVATE 27055990Sbostic /* Private function prototypes. */ 271*60058Sbostic void __CTRACE __P((const char *, ...)); 27258048Selan u_int __hash __P((char *, int)); 27355990Sbostic void __id_subwins __P((WINDOW *)); 27459929Selan int __mvcur __P((int, int, int, int, int)); 27555990Sbostic void __set_subwin __P((WINDOW *, WINDOW *)); 27657712Sbostic void __startwin __P((void)); 27757712Sbostic void __stop_signal_handler __P((int)); 27855990Sbostic void __swflags __P((WINDOW *)); 27956650Selan int __touchline __P((WINDOW *, int, int, int, int)); 28056650Selan int __touchwin __P((WINDOW *)); 28157477Sbostic char *__tscroll __P((const char *, int)); 28257941Sbostic int __waddbytes __P((WINDOW *, const char *, int, int)); 28358048Selan int __waddch __P((WINDOW *, __LDATA *)); 2842244Sarnold 28555990Sbostic /* Private #defines. */ 28655990Sbostic #define min(a,b) (a < b ? a : b) 28755990Sbostic #define max(a,b) (a > b ? a : b) 2882244Sarnold 28955990Sbostic /* Private externs. */ 29055990Sbostic extern int __echoit; 29155990Sbostic extern int __endwin; 29255990Sbostic extern int __pfast; 29355990Sbostic extern int __rawmode; 29456300Selan extern int __noqch; 29555990Sbostic #endif 2962244Sarnold 29755990Sbostic /* Termcap functions. */ 29855990Sbostic int tgetent __P((char *, char *)); 29955990Sbostic int tgetnum __P((char *)); 30055990Sbostic int tgetflag __P((char *)); 30155990Sbostic char *tgetstr __P((char *, char **)); 30255990Sbostic char *tgoto __P((char *, int, int)); 30355990Sbostic int tputs __P((char *, int, void (*)(int))); 3042244Sarnold 30555990Sbostic #endif /* !_CURSES_H_ */ 306