122686Sdist /* 234677Sbostic * Copyright (c) 1981 Regents of the University of California. 334677Sbostic * All rights reserved. 422686Sdist * 542653Sbostic * %sccs.include.redist.c% 634677Sbostic * 7*56596Selan * @(#)curses.h 5.16 (Berkeley) 10/20/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 /* 5456238Selan * A window is a circular doubly linked list of LINEs who's first line is 5556238Selan * given by the topline pointer in the WINDOW structure. 5656238Selan */ 5755990Sbostic 5856238Selan typedef struct __line { 5956238Selan struct __line *next, *prev; /* Next line, previous line. */ 6056238Selan #define __ISDIRTY 0x01 /* Line is dirty. */ 6156300Selan #define __ISPASTEOL 0x02 /* Cursor is past end of line */ 6256238Selan u_int flags; 6356238Selan u_int hash; /* Hash value for the line. */ 6456238Selan size_t firstch, lastch; /* First and last changed columns. */ 65*56596Selan 66*56596Selan #define __STANDOUT 0x01 /* Added characters are standout. */ 67*56596Selan char *standout; /* Standout character markers. 68*56596Selan * This field is stored as an 69*56596Selan * extension to the line, i.e., 70*56596Selan * lp->standout = lp->line + win->maxx 71*56596Selan * is an invariant. 72*56596Selan */ 73*56596Selan 74*56596Selan char *line; /* Pointer to the line text. */ 7556238Selan } LINE; 762244Sarnold 7756238Selan typedef struct __window { /* Window structure. */ 7856238Selan struct __window *nextp, *orig; /* Subwindows list and parent. */ 7956238Selan size_t begy, begx; /* Window home. */ 8056238Selan size_t cury, curx; /* Current x, y coordinates. */ 8156238Selan size_t maxy, maxx; /* Maximum values for curx, cury. */ 8256238Selan short ch_off; /* x offset for firstch/lastch. */ 8356238Selan LINE **lines; /* Array of pointers to the lines */ 8456238Selan LINE *topline; /* Pointer to first line in window */ 8556238Selan char *wspace; /* window space (for cleanup) */ 8655990Sbostic 8756238Selan #define __ENDLINE 0x001 /* End of screen. */ 8856238Selan #define __FLUSH 0x002 /* Fflush(stdout) after refresh. */ 8956238Selan #define __FULLLINE 0x004 /* Line width = terminal width. */ 9056238Selan #define __FULLWIN 0x008 /* Window is a screen. */ 9156238Selan #define __IDLINE 0x010 /* Insert/delete sequences. */ 9256238Selan #define __SCROLLWIN 0x020 /* Last char will scroll window. */ 9356238Selan #define __SCROLLOK 0x040 /* Scrolling ok. */ 9456238Selan #define __CLEAROK 0x080 /* Clear on next refresh. */ 9556238Selan #define __WSTANDOUT 0x100 /* Standout window */ 9656238Selan #define __LEAVEOK 0x200 /* If curser left */ 9756238Selan u_int flags; 9855990Sbostic } WINDOW; 9955990Sbostic 10055990Sbostic /* Termcap capabilities. */ 10155990Sbostic extern char AM, BS, CA, DA, EO, HC, HZ, IN, MI, MS, NC, NS, OS, 10255990Sbostic PC, UL, XB, XN, XT, XS, XX; 10319900Sbloom extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, 10419900Sbloom *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, 10519900Sbloom *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, 10619900Sbloom *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, 10719900Sbloom *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, 10856300Selan *VE, *al, *dl, *sf, *sr, 10955990Sbostic *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM, 11055990Sbostic *RIGHT_PARM; 1112244Sarnold 11255990Sbostic /* Curses external declarations. */ 11355990Sbostic extern WINDOW *curscr; /* Current screen. */ 11455990Sbostic extern WINDOW *stdscr; /* Standard screen. */ 1152244Sarnold 11655990Sbostic extern struct termios origtermio; /* Original terminal modes. */ 1172244Sarnold 11855990Sbostic extern int COLS; /* Columns on the screen. */ 11955990Sbostic extern int LINES; /* Lines on the screen. */ 1202244Sarnold 12155990Sbostic extern char GT; /* Gtty indicates tabs. */ 12255990Sbostic extern char NONL; /* Term can't hack LF doing a CR. */ 12355990Sbostic extern char UPPERCASE; /* Terminal is uppercase only. */ 12455990Sbostic extern char *ttytype; /* Full name of current terminal. */ 12555990Sbostic extern char *__unctrl[0x80]; /* Control strings. */ 12655990Sbostic extern char __unctrllen[0x80]; /* Control strings length. */ 1272244Sarnold 12855990Sbostic #define ERR (0) /* Error return. */ 12955990Sbostic #define OK (1) /* Success return. */ 1302244Sarnold 13155990Sbostic /* Standard screen pseudo functions. */ 13255990Sbostic #define addbytes(da, co) waddbytes(stdscr, da, co) 13355990Sbostic #define addch(ch) waddch(stdscr, ch) 13455990Sbostic #define addstr(str) waddbytes(stdscr, str, strlen(str)) 13555990Sbostic #define clear() wclear(stdscr) 13655990Sbostic #define clrtobot() wclrtobot(stdscr) 13755990Sbostic #define clrtoeol() wclrtoeol(stdscr) 13855990Sbostic #define delch() wdelch(stdscr) 13955990Sbostic #define deleteln() wdeleteln(stdscr) 14055990Sbostic #define erase() werase(stdscr) 14155990Sbostic #define getch() wgetch(stdscr) 14255990Sbostic #define getstr(str) wgetstr(stdscr, str) 14355990Sbostic #define inch() winch(stdscr) 14455990Sbostic #define insch(ch)) winsch(stdscr, ch) 14555990Sbostic #define insertln() winsertln(stdscr) 14655990Sbostic #define move(y, x) wmove(stdscr, y, x) 14755990Sbostic #define refresh() wrefresh(stdscr) 14855990Sbostic #define standend() wstandend(stdscr) 14955990Sbostic #define standout() wstandout(stdscr) 1502244Sarnold 15155990Sbostic /* Standard screen plus movement pseudo functions. */ 15255990Sbostic #define mvaddbytes(y, x, da, co) \ 15355990Sbostic mvwaddbytes(stdscr, y, x, da, co) 15455990Sbostic #define mvaddch(y, x, ch) mvwaddch(stdscr, y, x, ch) 15555990Sbostic #define mvaddstr(y, x, str) mvwaddstr(stdscr, y, x, str) 15655990Sbostic #define mvdelch(y, x) mvwdelch(stdscr, y, x) 15755990Sbostic #define mvgetch(y, x) mvwgetch(stdscr, y, x) 15855990Sbostic #define mvgetstr(y, x, str) mvwgetstr(stdscr, y, x, str) 15955990Sbostic #define mvinch(y, x) mvwinch(stdscr, y, x) 16055990Sbostic #define mvinsch(y, x, c) mvwinsch(stdscr, y, x, c) 16155990Sbostic #define mvwaddbytes(win, y, x, da, co) \ 16255990Sbostic (wmove(win, y, x) == ERR ? \ 16355990Sbostic ERR : waddbytes(win, da, co)) 16455990Sbostic #define mvwaddch(win, y, x, ch) (wmove(win, y, x) == ERR ? \ 16555990Sbostic ERR : waddch(win, ch)) 16655990Sbostic #define mvwaddstr(win, y, x, str) \ 16755990Sbostic (wmove(win, y, x) == ERR ? \ 16855990Sbostic ERR : waddbytes(win, str, strlen(str))) 16955990Sbostic #define mvwdelch(win, y, x) (wmove(win, y, x) == ERR ? ERR : wdelch(win)) 17055990Sbostic #define mvwgetch(win, y, x) (wmove(win, y, x) == ERR ? ERR : wgetch(win)) 17155990Sbostic #define mvwgetstr(win, y, x, str) \ 17255990Sbostic (wmove(win, y, x) == ERR ? \ 17355990Sbostic ERR : wgetstr(win, str)) 17455990Sbostic #define mvwinch(win, y, x) (wmove(win, y, x) == ERR ? ERR : winch(win)) 17555990Sbostic #define mvwinsch(win, y, x, c) (wmove(win, y, x) == ERR ? ERR : winsch(win, c)) 1762244Sarnold 17755990Sbostic /* Random psuedo functions. */ 17856238Selan #define clearok(win, bf) ((bf) ? (win->flags |= __CLEAROK) : \ 17956238Selan (win->flags &= ~__CLEAROK)) 18056238Selan #define flushok(win, bf) ((bf) ? (win->flags |= __FLUSH) : \ 18156238Selan (win->flags &= ~__FLUSH)) 18256238Selan #define scrollok(win, bf) ((bf) ? (win->flags |= __SCROLLOK) : \ 18356238Selan (win->flags &= ~__SCROLLOK)) 18456238Selan #define leaveok(win, bf) ((bf) ? (win->flags |= __LEAVEOK) : \ 18556238Selan (win->flags &= ~__LEAVEOK)) 18656238Selan #define getyx(win, y, x) (y) = win->cury, (x) = win->curx 18756238Selan #define winch(win) (win->lines[win->cury]->line[win->curx] & 0177) 1882244Sarnold 18955990Sbostic /* Public function prototypes. */ 19055990Sbostic void __cputchar __P((int)); 19155990Sbostic int _sprintw __P((WINDOW *, const char *, _BSD_VA_LIST_)); 19255990Sbostic int box __P((WINDOW *, int, int)); 19355990Sbostic int cbreak __P((void)); 19455990Sbostic int delwin __P((WINDOW *)); 19555990Sbostic int echo __P((void)); 19655990Sbostic int endwin __P((void)); 19755990Sbostic char *fullname __P((char *, char *)); 19855990Sbostic char *getcap __P((char *)); 19955990Sbostic int gettmode __P((void)); 20055990Sbostic void idlok __P((WINDOW *, int)); 20155990Sbostic WINDOW *initscr __P((void)); 20255990Sbostic char *longname __P((char *, char *)); 20355990Sbostic int mvcur __P((int, int, int, int)); 20455990Sbostic int mvprintw __P((int, int, const char *, ...)); 20555990Sbostic int mvscanw __P((int, int, const char *, ...)); 20655990Sbostic int mvwin __P((WINDOW *, int, int)); 20755990Sbostic int mvwprintw __P((WINDOW *, int, int, const char *, ...)); 20855990Sbostic int mvwscanw __P((WINDOW *, int, int, const char *, ...)); 20955990Sbostic WINDOW *newwin __P((int, int, int, int)); 21055990Sbostic int nl __P((void)); 21155990Sbostic int nocbreak __P((void)); 21255990Sbostic int noecho __P((void)); 21355990Sbostic int nonl __P((void)); 21455990Sbostic int noraw __P((void)); 21555990Sbostic int overlay __P((WINDOW *, WINDOW *)); 21655990Sbostic int overwrite __P((WINDOW *, WINDOW *)); 21755990Sbostic int printw __P((const char *, ...)); 21855990Sbostic int raw __P((void)); 21955990Sbostic int resetty __P((void)); 22055990Sbostic int savetty __P((void)); 22155990Sbostic int scanw __P((const char *, ...)); 22255990Sbostic int scroll __P((WINDOW *)); 22355990Sbostic int setterm __P((char *)); 22455990Sbostic int sscans __P((WINDOW *, const char *, _BSD_VA_LIST_)); 22555990Sbostic WINDOW *subwin __P((WINDOW *, int, int, int, int)); 22655990Sbostic int suspendwin __P((void)); 22755990Sbostic int touchline __P((WINDOW *, int, int, int)); 22855990Sbostic int touchoverlap __P((WINDOW *, WINDOW *)); 22955990Sbostic int touchwin __P((WINDOW *)); 23055990Sbostic void tstp __P((int)); 23155990Sbostic int waddch __P((WINDOW *, int)); 23255990Sbostic int waddstr __P((WINDOW *, char *)); 23355990Sbostic int wclear __P((WINDOW *)); 23455990Sbostic int wclrtobot __P((WINDOW *)); 23555990Sbostic int wclrtoeol __P((WINDOW *)); 23655990Sbostic int wdelch __P((WINDOW *)); 23755990Sbostic int wdeleteln __P((WINDOW *)); 23855990Sbostic int werase __P((WINDOW *)); 23955990Sbostic int wgetch __P((WINDOW *)); 24055990Sbostic int wgetstr __P((WINDOW *, char *)); 24155990Sbostic int winsch __P((WINDOW *, int)); 24255990Sbostic int winsertln __P((WINDOW *)); 24355990Sbostic int wmove __P((WINDOW *, int, int)); 24455990Sbostic int wprintw __P((WINDOW *, const char *, ...)); 24555990Sbostic int wrefresh __P((WINDOW *)); 24655990Sbostic int wscanw __P((WINDOW *, const char *, ...)); 24755990Sbostic char *wstandend __P((WINDOW *)); 24855990Sbostic char *wstandout __P((WINDOW *)); 2492244Sarnold 25055990Sbostic #ifdef _CURSES_PRIVATE 25155990Sbostic /* Private function prototypes. */ 25255990Sbostic void __id_subwins __P((WINDOW *)); 25355990Sbostic void __set_subwin __P((WINDOW *, WINDOW *)); 25455990Sbostic void __swflags __P((WINDOW *)); 25555990Sbostic void __TRACE __P((const char *, ...)); 25655990Sbostic int waddbytes __P((WINDOW *, char *, int)); 25756300Selan char *tscroll __P((const char *, int)); 2582244Sarnold 25955990Sbostic /* Private #defines. */ 26055990Sbostic #define min(a,b) (a < b ? a : b) 26155990Sbostic #define max(a,b) (a > b ? a : b) 2622244Sarnold 26355990Sbostic /* Private externs. */ 26455990Sbostic extern int __echoit; 26555990Sbostic extern int __endwin; 26655990Sbostic extern int __pfast; 26755990Sbostic extern int __rawmode; 26856300Selan extern int __noqch; 26955990Sbostic #endif 2702244Sarnold 27155990Sbostic /* Termcap functions. */ 27255990Sbostic int tgetent __P((char *, char *)); 27355990Sbostic int tgetnum __P((char *)); 27455990Sbostic int tgetflag __P((char *)); 27555990Sbostic char *tgetstr __P((char *, char **)); 27655990Sbostic char *tgoto __P((char *, int, int)); 27755990Sbostic int tputs __P((char *, int, void (*)(int))); 2782244Sarnold 27955990Sbostic #endif /* !_CURSES_H_ */ 280