1327Sjkh/*
2327Sjkh |	new_curse.h
3327Sjkh |
4327Sjkh |	A subset of curses developed for use with ae.
5327Sjkh |
6327Sjkh |	written by Hugh Mahon
7327Sjkh |
8327Sjkh |	THIS MATERIAL IS PROVIDED "AS IS".  THERE ARE
9327Sjkh |	NO WARRANTIES OF ANY KIND WITH REGARD TO THIS
10327Sjkh |	MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE
11327Sjkh |	IMPLIED WARRANTIES OF MERCHANTABILITY AND
12327Sjkh |	FITNESS FOR A PARTICULAR PURPOSE.  Neither
13327Sjkh |	Hewlett-Packard nor Hugh Mahon shall be liable
14327Sjkh |	for errors contained herein, nor for
15327Sjkh |	incidental or consequential damages in
16327Sjkh |	connection with the furnishing, performance or
17327Sjkh |	use of this material.  Neither Hewlett-Packard
18327Sjkh |	nor Hugh Mahon assumes any responsibility for
19327Sjkh |	the use or reliability of this software or
20327Sjkh |	documentation.  This software and
2193520Sobrien |	documentation is totally UNSUPPORTED.  There
2293520Sobrien |	is no support contract available.  Hewlett-
2393520Sobrien |	Packard has done NO Quality Assurance on ANY
24327Sjkh |	of the program or documentation.  You may find
25327Sjkh |	the quality of the materials inferior to
2672174Ssobomax |	supported materials.
27327Sjkh |
28327Sjkh |	This software is not a product of Hewlett-Packard, Co., or any
29327Sjkh |	other company.  No support is implied or offered with this software.
3096613Ssobomax |	You've got the source, and you're on your own.
3174699Ssobomax |
3284745Ssobomax |	This software may be distributed under the terms of Larry Wall's
3396613Ssobomax |	Artistic license, a copy of which is included in this distribution.
34131275Seik |
35327Sjkh |	This notice must be included with this software and any derivatives.
36327Sjkh |
37327Sjkh |	Copyright (c) 1986, 1987, 1988, 1991, 1995 Hugh Mahon
38327Sjkh |	All are rights reserved.
3973134Ssobomax |
4073134Ssobomax */
4173134Ssobomax
42327Sjkh#include <stdio.h>
43327Sjkh
44327Sjkh#ifdef SYS5
45327Sjkh#include <termio.h>
46131275Seik#else
47131275Seik#include <sgtty.h>
48131275Seik#include <fcntl.h>
49131280Seik#endif
5072174Ssobomax
5174699Ssobomax#define KEY_BREAK	0401
5296613Ssobomax#define KEY_DOWN	0402
5396030Ssobomax#define KEY_UP		0403
5496613Ssobomax#define KEY_LEFT	0404
5516404Sjkh#define KEY_RIGHT	0405
568857Srgrimes#define KEY_HOME	0406
5773134Ssobomax#define KEY_BACKSPACE	0407
5873134Ssobomax#define KEY_F0		0410
5973134Ssobomax#define KEY_F(n) 	(KEY_F0+(n))
6073134Ssobomax#define KEY_DL		0510
6173134Ssobomax#define KEY_IL		0511
6272174Ssobomax#define KEY_DC		0512
6373134Ssobomax#define KEY_IC		0513
6473134Ssobomax#define KEY_EIC		0514
6573134Ssobomax#define KEY_CLEAR	0515
6673134Ssobomax#define KEY_EOS		0516
6773134Ssobomax#define KEY_EOL		0517
6873134Ssobomax#define KEY_SF		0520
6973134Ssobomax#define KEY_SR		0521
7073134Ssobomax#define KEY_NPAGE	0522
7173134Ssobomax#define KEY_PPAGE	0523
7273134Ssobomax#define KEY_STAB	0524
73131275Seik#define KEY_CTAB	0525
7473134Ssobomax#define KEY_CATAB	0526
7572174Ssobomax#define KEY_ENTER	0527
7673134Ssobomax#define KEY_SRESET	0530
7773134Ssobomax#define KEY_RESET	0531
7873134Ssobomax#define KEY_PRINT	0532
7916404Sjkh#define KEY_LL		0533
8073134Ssobomax#define KEY_A1	0534
8172174Ssobomax#define KEY_A3	0535
8273134Ssobomax#define KEY_B2	0536
8373134Ssobomax#define KEY_C1	0537
8472174Ssobomax#define KEY_C3	0540
85327Sjkh#define KEY_BTAB	0541
86327Sjkh#define KEY_BEG	0542
87327Sjkh#define KEY_CANCEL	0543
88327Sjkh#define KEY_CLOSE	0544
89327Sjkh#define KEY_COMMAND	0545
90327Sjkh#define KEY_COPY	0546
918086Sjkh#define KEY_CREATE	0547
92327Sjkh#define KEY_END	0550
93131280Seik#define KEY_EXIT	0551
94327Sjkh#define KEY_FIND	0552
95327Sjkh#define KEY_HELP	0553
968086Sjkh#define KEY_MARK	0554
97194497Sbrian#define KEY_MESSAGE	0555
988086Sjkh#define KEY_MOVE	0556
99327Sjkh#define KEY_NEXT	0557
1008086Sjkh#define KEY_OPEN	0560
101154145Sflz#define KEY_OPTIONS	0561
102178246Sflz#define KEY_PREVIOUS	0562
103178246Sflz#define KEY_REDO	0563
1048086Sjkh#define KEY_REFERENCE	0564
105178246Sflz#define KEY_REFRESH	0565
106178246Sflz#define KEY_REPLACE	0566
1078086Sjkh#define KEY_RESTART	0567
1088086Sjkh#define KEY_RESUME	0570
1099782Sache#define KEY_SAVE	0571
1108086Sjkh#define KEY_SBEG	0572
111327Sjkh#define KEY_SCANCEL	0573
1128423Sjkh#define KEY_SCOMMAND	0574
1138423Sjkh#define KEY_SCOPY	0575
1148423Sjkh#define KEY_SCREATE	0576
1158423Sjkh#define KEY_SDC	0577
1168423Sjkh#define KEY_SDL	0600
1178423Sjkh#define KEY_SELECT	0601
1188423Sjkh#define KEY_SEND	0602
1198423Sjkh#define KEY_SEOL	0603
1208086Sjkh#define KEY_SEXIT	0604
1218086Sjkh#define KEY_SFIND	0605
1228086Sjkh#define KEY_SHELP	0606
12311780Sjkh#define KEY_SHOME	0607
1248086Sjkh#define KEY_SIC	0610
1258086Sjkh#define KEY_SLEFT	0611
1268086Sjkh#define KEY_SMESSAGE	0612
127178246Sflz#define KEY_SMOVE	0613
128178246Sflz#define KEY_SNEXT	0614
129178246Sflz#define KEY_SOPTIONS	0615
130178246Sflz#define KEY_SPREVIOUS	0616
131178246Sflz#define KEY_SPRINT	0617
132178246Sflz#define KEY_SREDO	0620
133178246Sflz#define KEY_SREPLACE	0621
134178246Sflz#define KEY_SRIGHT	0622
135178246Sflz#define KEY_SRSUME	0623
136178246Sflz#define KEY_SSAVE	0624
137178246Sflz#define KEY_SSUSPEND	0625
138178246Sflz#define KEY_SUNDO	0626
139194497Sbrian#define KEY_SUSPEND	0627
140178246Sflz#define KEY_UNDO	0630
141178246Sflz
142178246Sflz#define TRUE 1
143178246Sflz#define FALSE 0
144178246Sflz
1453364Sjkh#define A_STANDOUT 0001		/* standout mode		*/
146327Sjkh#define A_NC_BIG5  0x0100	/* Handle Chinese Big5 characters	*/
147131280Seik#define SCROLL 1		/* text has been scrolled	*/
148327Sjkh#define CLEAR  2		/* window has been cleared	*/
149131280Seik#define CHANGE 3		/* window has been changed	*/
150131280Seik#define UP 1			/* direction of scroll		*/
151131280Seik#define DOWN 2
152131280Seik
153131280Seikstruct _line {
15481046Ssobomax	struct _line *next_screen;
155327Sjkh	struct _line *prev_screen;
156327Sjkh	char *row;
15796613Ssobomax	char *attributes;
158327Sjkh	int last_char;
15930221Scharnier	int changed;
160327Sjkh	int scroll;
161327Sjkh	int number;
162327Sjkh	};
163327Sjkh
164327Sjkhstruct _line *top_of_win;
165327Sjkh
166327Sjkhtypedef struct WIND {
167327Sjkh	int SR;		/* starting row		*/
168327Sjkh	int SC;		/* starting column	*/
16930221Scharnier	int LC;		/* last column		*/
1708086Sjkh	int LX;		/* last cursor column position	*/
1718086Sjkh	int LY;		/* last cursor row position	*/
172327Sjkh	int Attrib;	/* attributes active in window	*/
173327Sjkh	int Num_lines;	/* number of lines		*/
174327Sjkh	int Num_cols;	/* number of columns		*/
175327Sjkh	int scroll_up;	/* number of lines moved	*/
176327Sjkh	int scroll_down;
177327Sjkh	int SCROLL_CLEAR;	/* indicates that window has been scrolled or cleared	*/
178327Sjkh	struct _line *first_line;
179327Sjkh	struct _line **line_array;
180327Sjkh	} WINDOW;
181327Sjkh
1828086Sjkhextern WINDOW *curscr;
183327Sjkhextern WINDOW *stdscr;
1848086Sjkh
1858086Sjkhextern int LINES, COLS;
186327Sjkh
187327Sjkh#if defined(__STDC__) || defined(__cplusplus)
188327Sjkh#define P_(s) s
189411Sjkh#else
190411Sjkh#define P_(s) ()
191112572Smdodd#endif
192112572Smdodd
193327Sjkhextern void copy_window P_((WINDOW *origin, WINDOW *destination));
194379Sjkhextern void reinitscr P_((int));
195131280Seikextern void initscr P_((void));
19684745Ssobomaxextern int Get_int P_((void));
1974996Sjkhextern int INFO_PARSE P_((void));
1984996Sjkhextern int AtoI P_((void));
199327Sjkhextern void Key_Get P_((void));
200379Sjkhextern void keys_vt100 P_((void));
2014996Sjkhextern struct _line *Screenalloc P_((int columns));
2024996Sjkhextern WINDOW *newwin P_((int lines, int cols, int start_l, int start_c));
203327Sjkhextern int Operation P_((int Temp_Stack[], int place));
20484745Ssobomaxextern void Info_Out P_((char *string, int p_list[], int place));
205131280Seikextern void wmove P_((WINDOW *window, int row, int column));
206131280Seikextern void clear_line P_((struct _line *line, int column, int cols));
207327Sjkhextern void werase P_((WINDOW *window));
208379Sjkhextern void wclrtoeol P_((WINDOW *window));
20941866Sjkhextern void wrefresh P_((WINDOW *window));
21041866Sjkhextern void touchwin P_((WINDOW *window));
211327Sjkhextern void wnoutrefresh P_((WINDOW *window));
212379Sjkhextern void flushinp P_((void));
21341866Sjkhextern void ungetch P_((int c));
21441866Sjkhextern int wgetch P_((WINDOW *window));
2154996Sjkhextern void Clear P_((int));
2164996Sjkhextern int Get_key P_((int first_char));
217327Sjkhextern void waddch P_((WINDOW *window, int c));
21884745Ssobomaxextern void winsertln P_((WINDOW *window));
219411Sjkhextern void wdeleteln P_((WINDOW *window));
220411Sjkhextern void wclrtobot P_((WINDOW *window));
22162775Ssobomaxextern void wstandout P_((WINDOW *window));
22262775Ssobomaxextern void wstandend P_((WINDOW *window));
22371965Sjkhextern void waddstr P_((WINDOW *window, char *string));
22471965Sjkhextern void clearok P_((WINDOW *window, int flag));
22567454Ssobomaxextern void echo P_((void));
22667454Ssobomaxextern void noecho P_((void));
22784750Ssobomaxextern void raw P_((void));
22884750Ssobomaxextern void noraw P_((void));
229411Sjkhextern void nl P_((void));
230411Sjkhextern void nonl P_((void));
231327Sjkhextern void saveterm P_((void));
232327Sjkhextern void fixterm P_((void));
2338086Sjkhextern void resetterm P_((void));
23433427Sjkhextern void nodelay P_((WINDOW *window, int flag));
2358086Sjkhextern void idlok P_((WINDOW *window, int flag));
2368086Sjkhextern void keypad P_((WINDOW *window, int flag));
2378086Sjkhextern void savetty P_((void));
238327Sjkhextern void resetty P_((void));
239327Sjkhextern void endwin P_((void));
240327Sjkhextern void delwin P_((WINDOW *window));
241327Sjkhextern void wprintw P_((WINDOW *window, const char* format, ...));
242327Sjkhextern void iout P_((WINDOW *window, int value));
24333427Sjkhextern int Comp_line P_((struct _line *line1, struct _line *line2));
24433427Sjkhextern struct _line *Insert_line P_((int row, int end_row, WINDOW *window));
24533427Sjkhextern struct _line *Delete_line P_((int row, int end_row, WINDOW *window));
24633427Sjkhextern void CLEAR_TO_EOL P_((WINDOW *window, int row, int column));
24772174Ssobomaxextern int check_delete P_((WINDOW *window, int line, int offset, struct _line *pointer_new, struct _line *pointer_old));
24833427Sjkhextern int check_insert P_((WINDOW *window, int line, int offset, struct _line *pointer_new, struct _line *pointer_old));
24939068Sjkhextern void doupdate P_((void));
25039068Sjkhextern void Position P_((WINDOW *window, int row, int col));
251327Sjkhextern void Char_del P_((char *line, char *attrib, int offset, int maxlen));
25249300Sjdpextern void Char_ins P_((char *line, char *attrib, int newc, int newatt, int offset, int maxlen));
25374699Ssobomaxextern void attribute_on P_((void));
25474808Ssobomaxextern void attribute_off P_((void));
25574808Ssobomaxextern void Char_out P_((int newc, int newatt, char *line, char *attrib, int offset));
25674808Ssobomax
25774808Ssobomaxextern void nc_setattrib P_((int));
25884745Ssobomaxextern void nc_clearattrib P_((int));
25974808Ssobomax#undef P_
26074808Ssobomax
26174808Ssobomax