122686Sdist /* 234677Sbostic * Copyright (c) 1981 Regents of the University of California. 334677Sbostic * All rights reserved. 422686Sdist * 542653Sbostic * %sccs.include.redist.c% 634677Sbostic * 7*56650Selan * @(#)curses.h 5.18 (Berkeley) 10/27/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 3256116Selan #define _puts(s) tputs(s, 0, __cputchar) 3355990Sbostic #define _putchar(c) __cputchar(c) 342244Sarnold 3555990Sbostic /* Old-style terminal modes access. */ 3656116Selan #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() 4156116Selan #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 5356238Selan /* 5456647Selan * A window an array of __LINE structures pointed to by the 'lines' pointer. 5556647Selan * A line is an array of __LDATA structures pointed to by the 'line' pointer. 5656647Selan * 5756647Selan * IMPORTANT: the __LDATA structure must NOT induce any padding, so if new 5856647Selan * fields are added -- padding fields with *constant values* should ensure 5956647Selan * that the compiler will not generate any padding when storing an array of 6056647Selan * __LDATA structures. This is to enable consistent use of bcmp, and bcopy 6156647Selan * for comparing and copying arrays. 6256238Selan */ 6355990Sbostic 6456647Selan typedef struct { 6556647Selan char ch; /* the actual character */ 6656647Selan 6756647Selan #define __STANDOUT 0x01 /* Added characters are standout. */ 6856647Selan char attr; /* attributes of character */ 6956647Selan } __LDATA; 7056647Selan 7156647Selan #define __LDATASIZE (sizeof(__LDATA)) 7256647Selan 7356647Selan typedef struct { 7456238Selan #define __ISDIRTY 0x01 /* Line is dirty. */ 7556300Selan #define __ISPASTEOL 0x02 /* Cursor is past end of line */ 76*56650Selan #define __FORCEPAINT 0x04 /* Force a repaint of the line */ 7756238Selan u_int flags; 7856238Selan u_int hash; /* Hash value for the line. */ 7956238Selan size_t firstch, lastch; /* First and last changed columns. */ 8056647Selan __LDATA *line; /* Pointer to the line text. */ 8156647Selan } __LINE; 8256596Selan 8356238Selan typedef struct __window { /* Window structure. */ 8456238Selan struct __window *nextp, *orig; /* Subwindows list and parent. */ 8556238Selan size_t begy, begx; /* Window home. */ 8656238Selan size_t cury, curx; /* Current x, y coordinates. */ 8756238Selan size_t maxy, maxx; /* Maximum values for curx, cury. */ 8856238Selan short ch_off; /* x offset for firstch/lastch. */ 8956647Selan __LINE **lines; /* Array of pointers to the lines */ 9056647Selan __LINE *lspace; /* line space (for cleanup) */ 9156647Selan __LDATA *wspace; /* window space (for cleanup) */ 9255990Sbostic 9356238Selan #define __ENDLINE 0x001 /* End of screen. */ 9456238Selan #define __FLUSH 0x002 /* Fflush(stdout) after refresh. */ 9556238Selan #define __FULLLINE 0x004 /* Line width = terminal width. */ 9656238Selan #define __FULLWIN 0x008 /* Window is a screen. */ 9756238Selan #define __IDLINE 0x010 /* Insert/delete sequences. */ 9856238Selan #define __SCROLLWIN 0x020 /* Last char will scroll window. */ 9956238Selan #define __SCROLLOK 0x040 /* Scrolling ok. */ 10056238Selan #define __CLEAROK 0x080 /* Clear on next refresh. */ 10156238Selan #define __WSTANDOUT 0x100 /* Standout window */ 10256238Selan #define __LEAVEOK 0x200 /* If curser left */ 10356238Selan u_int flags; 10455990Sbostic } WINDOW; 10555990Sbostic 10655990Sbostic /* Termcap capabilities. */ 10755990Sbostic extern char AM, BS, CA, DA, EO, HC, HZ, IN, MI, MS, NC, NS, OS, 10855990Sbostic PC, UL, XB, XN, XT, XS, XX; 10919900Sbloom extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, 11019900Sbloom *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, 11119900Sbloom *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, 11219900Sbloom *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, 11319900Sbloom *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, 11456300Selan *VE, *al, *dl, *sf, *sr, 11555990Sbostic *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM, 11655990Sbostic *RIGHT_PARM; 1172244Sarnold 11855990Sbostic /* Curses external declarations. */ 11955990Sbostic extern WINDOW *curscr; /* Current screen. */ 12055990Sbostic extern WINDOW *stdscr; /* Standard screen. */ 1212244Sarnold 12255990Sbostic extern struct termios origtermio; /* Original terminal modes. */ 1232244Sarnold 12455990Sbostic extern int COLS; /* Columns on the screen. */ 12555990Sbostic extern int LINES; /* Lines on the screen. */ 1262244Sarnold 12755990Sbostic extern char GT; /* Gtty indicates tabs. */ 12855990Sbostic extern char NONL; /* Term can't hack LF doing a CR. */ 12955990Sbostic extern char UPPERCASE; /* Terminal is uppercase only. */ 13055990Sbostic extern char *ttytype; /* Full name of current terminal. */ 13155990Sbostic extern char *__unctrl[0x80]; /* Control strings. */ 13255990Sbostic extern char __unctrllen[0x80]; /* Control strings length. */ 1332244Sarnold 13455990Sbostic #define ERR (0) /* Error return. */ 13555990Sbostic #define OK (1) /* Success return. */ 1362244Sarnold 13755990Sbostic /* Standard screen pseudo functions. */ 13855990Sbostic #define addbytes(da, co) waddbytes(stdscr, da, co) 13955990Sbostic #define addch(ch) waddch(stdscr, ch) 14055990Sbostic #define addstr(str) waddbytes(stdscr, str, strlen(str)) 14155990Sbostic #define clear() wclear(stdscr) 14255990Sbostic #define clrtobot() wclrtobot(stdscr) 14355990Sbostic #define clrtoeol() wclrtoeol(stdscr) 14455990Sbostic #define delch() wdelch(stdscr) 14555990Sbostic #define deleteln() wdeleteln(stdscr) 14655990Sbostic #define erase() werase(stdscr) 14755990Sbostic #define getch() wgetch(stdscr) 14855990Sbostic #define getstr(str) wgetstr(stdscr, str) 14955990Sbostic #define inch() winch(stdscr) 15055990Sbostic #define insch(ch)) winsch(stdscr, ch) 15155990Sbostic #define insertln() winsertln(stdscr) 15255990Sbostic #define move(y, x) wmove(stdscr, y, x) 15355990Sbostic #define refresh() wrefresh(stdscr) 15455990Sbostic #define standend() wstandend(stdscr) 15555990Sbostic #define standout() wstandout(stdscr) 1562244Sarnold 15755990Sbostic /* Standard screen plus movement pseudo functions. */ 15855990Sbostic #define mvaddbytes(y, x, da, co) \ 15955990Sbostic mvwaddbytes(stdscr, y, x, da, co) 16055990Sbostic #define mvaddch(y, x, ch) mvwaddch(stdscr, y, x, ch) 16155990Sbostic #define mvaddstr(y, x, str) mvwaddstr(stdscr, y, x, str) 16255990Sbostic #define mvdelch(y, x) mvwdelch(stdscr, y, x) 16355990Sbostic #define mvgetch(y, x) mvwgetch(stdscr, y, x) 16455990Sbostic #define mvgetstr(y, x, str) mvwgetstr(stdscr, y, x, str) 16555990Sbostic #define mvinch(y, x) mvwinch(stdscr, y, x) 16655990Sbostic #define mvinsch(y, x, c) mvwinsch(stdscr, y, x, c) 16755990Sbostic #define mvwaddbytes(win, y, x, da, co) \ 16855990Sbostic (wmove(win, y, x) == ERR ? \ 16955990Sbostic ERR : waddbytes(win, da, co)) 17055990Sbostic #define mvwaddch(win, y, x, ch) (wmove(win, y, x) == ERR ? \ 17155990Sbostic ERR : waddch(win, ch)) 17255990Sbostic #define mvwaddstr(win, y, x, str) \ 17355990Sbostic (wmove(win, y, x) == ERR ? \ 17455990Sbostic ERR : waddbytes(win, str, strlen(str))) 17555990Sbostic #define mvwdelch(win, y, x) (wmove(win, y, x) == ERR ? ERR : wdelch(win)) 17655990Sbostic #define mvwgetch(win, y, x) (wmove(win, y, x) == ERR ? ERR : wgetch(win)) 17755990Sbostic #define mvwgetstr(win, y, x, str) \ 17855990Sbostic (wmove(win, y, x) == ERR ? \ 17955990Sbostic ERR : wgetstr(win, str)) 18055990Sbostic #define mvwinch(win, y, x) (wmove(win, y, x) == ERR ? ERR : winch(win)) 18155990Sbostic #define mvwinsch(win, y, x, c) (wmove(win, y, x) == ERR ? ERR : winsch(win, c)) 1822244Sarnold 18355990Sbostic /* Random psuedo functions. */ 18456238Selan #define clearok(win, bf) ((bf) ? (win->flags |= __CLEAROK) : \ 18556238Selan (win->flags &= ~__CLEAROK)) 18656238Selan #define flushok(win, bf) ((bf) ? (win->flags |= __FLUSH) : \ 18756238Selan (win->flags &= ~__FLUSH)) 18856238Selan #define scrollok(win, bf) ((bf) ? (win->flags |= __SCROLLOK) : \ 18956238Selan (win->flags &= ~__SCROLLOK)) 19056238Selan #define leaveok(win, bf) ((bf) ? (win->flags |= __LEAVEOK) : \ 19156238Selan (win->flags &= ~__LEAVEOK)) 19256238Selan #define getyx(win, y, x) (y) = win->cury, (x) = win->curx 19356238Selan #define winch(win) (win->lines[win->cury]->line[win->curx] & 0177) 1942244Sarnold 19555990Sbostic /* Public function prototypes. */ 19655990Sbostic void __cputchar __P((int)); 19755990Sbostic int _sprintw __P((WINDOW *, const char *, _BSD_VA_LIST_)); 19855990Sbostic int box __P((WINDOW *, int, int)); 19955990Sbostic int cbreak __P((void)); 20055990Sbostic int delwin __P((WINDOW *)); 20155990Sbostic int echo __P((void)); 20255990Sbostic int endwin __P((void)); 20355990Sbostic char *fullname __P((char *, char *)); 20455990Sbostic char *getcap __P((char *)); 20555990Sbostic int gettmode __P((void)); 20655990Sbostic void idlok __P((WINDOW *, int)); 20755990Sbostic WINDOW *initscr __P((void)); 20855990Sbostic char *longname __P((char *, char *)); 20955990Sbostic int mvcur __P((int, int, int, int)); 21055990Sbostic int mvprintw __P((int, int, const char *, ...)); 21155990Sbostic int mvscanw __P((int, int, const char *, ...)); 21255990Sbostic int mvwin __P((WINDOW *, int, int)); 21355990Sbostic int mvwprintw __P((WINDOW *, int, int, const char *, ...)); 21455990Sbostic int mvwscanw __P((WINDOW *, int, int, const char *, ...)); 21555990Sbostic WINDOW *newwin __P((int, int, int, int)); 21655990Sbostic int nl __P((void)); 21755990Sbostic int nocbreak __P((void)); 21855990Sbostic int noecho __P((void)); 21955990Sbostic int nonl __P((void)); 22055990Sbostic int noraw __P((void)); 22155990Sbostic int overlay __P((WINDOW *, WINDOW *)); 22255990Sbostic int overwrite __P((WINDOW *, WINDOW *)); 22355990Sbostic int printw __P((const char *, ...)); 22455990Sbostic int raw __P((void)); 22555990Sbostic int resetty __P((void)); 22655990Sbostic int savetty __P((void)); 22755990Sbostic int scanw __P((const char *, ...)); 22855990Sbostic int scroll __P((WINDOW *)); 22955990Sbostic int setterm __P((char *)); 23055990Sbostic int sscans __P((WINDOW *, const char *, _BSD_VA_LIST_)); 23155990Sbostic WINDOW *subwin __P((WINDOW *, int, int, int, int)); 23255990Sbostic int suspendwin __P((void)); 23355990Sbostic int touchline __P((WINDOW *, int, int, int)); 23455990Sbostic int touchoverlap __P((WINDOW *, WINDOW *)); 23555990Sbostic int touchwin __P((WINDOW *)); 23655990Sbostic void tstp __P((int)); 23755990Sbostic int waddch __P((WINDOW *, int)); 23855990Sbostic int waddstr __P((WINDOW *, char *)); 23955990Sbostic int wclear __P((WINDOW *)); 24055990Sbostic int wclrtobot __P((WINDOW *)); 24155990Sbostic int wclrtoeol __P((WINDOW *)); 24255990Sbostic int wdelch __P((WINDOW *)); 24355990Sbostic int wdeleteln __P((WINDOW *)); 24455990Sbostic int werase __P((WINDOW *)); 24555990Sbostic int wgetch __P((WINDOW *)); 24655990Sbostic int wgetstr __P((WINDOW *, char *)); 24755990Sbostic int winsch __P((WINDOW *, int)); 24855990Sbostic int winsertln __P((WINDOW *)); 24955990Sbostic int wmove __P((WINDOW *, int, int)); 25055990Sbostic int wprintw __P((WINDOW *, const char *, ...)); 25155990Sbostic int wrefresh __P((WINDOW *)); 25255990Sbostic int wscanw __P((WINDOW *, const char *, ...)); 25355990Sbostic char *wstandend __P((WINDOW *)); 25455990Sbostic char *wstandout __P((WINDOW *)); 2552244Sarnold 25655990Sbostic #ifdef _CURSES_PRIVATE 25755990Sbostic /* Private function prototypes. */ 258*56650Selan void __TRACE __P((const char *, ...)); 25955990Sbostic void __id_subwins __P((WINDOW *)); 26055990Sbostic void __set_subwin __P((WINDOW *, WINDOW *)); 26155990Sbostic void __swflags __P((WINDOW *)); 262*56650Selan int __touchline __P((WINDOW *, int, int, int, int)); 263*56650Selan int __touchwin __P((WINDOW *)); 264*56650Selan char *tscroll __P((const char *, int)); 26555990Sbostic int waddbytes __P((WINDOW *, char *, int)); 2662244Sarnold 26755990Sbostic /* Private #defines. */ 26855990Sbostic #define min(a,b) (a < b ? a : b) 26955990Sbostic #define max(a,b) (a > b ? a : b) 2702244Sarnold 27155990Sbostic /* Private externs. */ 27255990Sbostic extern int __echoit; 27355990Sbostic extern int __endwin; 27455990Sbostic extern int __pfast; 27555990Sbostic extern int __rawmode; 27656300Selan extern int __noqch; 27755990Sbostic #endif 2782244Sarnold 27955990Sbostic /* Termcap functions. */ 28055990Sbostic int tgetent __P((char *, char *)); 28155990Sbostic int tgetnum __P((char *)); 28255990Sbostic int tgetflag __P((char *)); 28355990Sbostic char *tgetstr __P((char *, char **)); 28455990Sbostic char *tgoto __P((char *, int, int)); 28555990Sbostic int tputs __P((char *, int, void (*)(int))); 2862244Sarnold 28755990Sbostic #endif /* !_CURSES_H_ */ 288