1 /* $LynxId: LYCurses.h,v 1.90 2013/05/31 00:23:39 tom Exp $ */
2 #ifndef LYCURSES_H
3 #define LYCURSES_H
4 
5 #ifndef HTUTILS_H
6 #include <HTUtils.h>
7 #endif
8 
9 /*
10  * Because we have to configure PDCURSES last, we may get bogus definitions
11  * from the system curses library - cancel these now.
12  */
13 #ifdef HAVE_XCURSES
14 
15 #undef ASSUME_DEFAULT_COLORS
16 #undef COLOR_CURSES
17 #undef FANCY_CURSES
18 #undef HAVE_CBREAK
19 #undef HAVE_RESIZETERM
20 #undef HAVE_USE_DEFAULT_COLORS
21 #undef NCURSES
22 #undef USE_DEFAULT_COLORS
23 
24 #define HAVE_CBREAK 1
25 #define COLOR_CURSES 1
26 #define FANCY_CURSES 1
27 
28 #endif
29 
30 /*
31  * The simple color scheme maps the 8 combinations of bold/underline/reverse
32  * to the standard 8 ANSI colors (with some variations based on context).
33  */
34 #undef USE_COLOR_TABLE
35 
36 #ifdef USE_COLOR_STYLE
37 #define USE_COLOR_TABLE 1	/* default color logic is used */
38 #else
39 #if defined(USE_SLANG) || defined(COLOR_CURSES)
40 #define USE_COLOR_TABLE 1
41 #endif
42 #endif
43 
44 #ifdef TRUE
45 #undef TRUE			/* to prevent parse error :( */
46 #endif /* TRUE */
47 #ifdef FALSE
48 #undef FALSE			/* to prevent parse error :( */
49 #endif /* FALSE */
50 
51 #ifdef USE_SLANG
52 #define ENABLE_SLFUTURE_CONST 1
53 #include <slang.h>
54 #ifndef SLFUTURE_CONST
55 #define SLFUTURE_CONST		/* nothing */
56 #endif
57 typedef unsigned long chtype;
58 
59 #undef WINDOW
60 typedef struct {
61     int top_y;
62     int left_x;
63     int height;
64     int width;
65 } WINDOW;
66 
67 /* slang doesn't really do windows... */
68 #define waddch(w,c)  LYaddch(c)
69 #define waddstr(w,s) addstr(s)
70 #define wmove(win, row, col) SLsmg_gotorc(((win)?(win)->top_y:0) + (row), ((win)?(win)->left_x:0) + (col))
71 
72 #ifndef SLSMG_UARROW_CHAR
73 #define SLSMG_UARROW_CHAR '^'
74 #endif
75 
76 #ifndef SLSMG_DARROW_CHAR
77 #define SLSMG_DARROW_CHAR 'v'
78 #endif
79 
80 #ifndef SLSMG_LARROW_CHAR
81 #define SLSMG_LARROW_CHAR '<'
82 #endif
83 
84 #ifndef SLSMG_RARROW_CHAR
85 #define SLSMG_RARROW_CHAR '>'
86 #endif
87 
88 #ifndef SLSMG_CKBRD_CHAR
89 #define SLSMG_CKBRD_CHAR '#'
90 #endif
91 
92 #ifndef SLSMG_BLOCK_CHAR
93 #define SLSMG_BLOCK_CHAR '#'
94 #endif
95 
96 #ifndef ACS_UARROW
97 #define ACS_UARROW  SLSMG_UARROW_CHAR
98 #endif
99 
100 #ifndef ACS_DARROW
101 #define ACS_DARROW  SLSMG_DARROW_CHAR
102 #endif
103 
104 #ifndef ACS_LARROW
105 #define ACS_LARROW  SLSMG_LARROW_CHAR
106 #endif
107 
108 #ifndef ACS_RARROW
109 #define ACS_RARROW  SLSMG_RARROW_CHAR
110 #endif
111 
112 #ifndef ACS_CKBOARD
113 #define ACS_CKBOARD SLSMG_CKBRD_CHAR
114 #endif
115 
116 #ifndef ACS_BLOCK
117 #define ACS_BLOCK   SLSMG_BLOCK_CHAR
118 #endif
119 
120 #else /* Using curses: */
121 
122 #ifdef VMS
123 #define FANCY_CURSES
124 
125 #endif /* VMS */
126 
127 #ifndef HAVE_TYPE_CHTYPE
128 
129 #ifdef __PDCURSES__
130 #define HAVE_TYPE_CHTYPE 1
131 #endif
132 
133 #if defined(_VMS_CURSES) || defined(VMS)
134 typedef char chtype;
135 
136 #define HAVE_TYPE_CHTYPE 1
137 #endif
138 
139 #endif /* ! HAVE_TYPE_CHTYPE */
140 
141 /*
142  *	CR may be defined before the curses.h include occurs.
143  *	There is a conflict between the termcap char *CR and the define.
144  *	Assuming that the definition of CR will always be carriage return.
145  *	06-09-94 Lynx 2-3-1 Garrett Arch Blythe
146  */
147 #ifdef CR
148 #undef CR			/* to prevent parse error :( */
149 #define REDEFINE_CR
150 #endif /* CR */
151 
152 #ifdef HZ
153 #undef HZ			/* to prevent parse error :( */
154 #endif /* HZ */
155 
156 /* SunOS 4.x has a redefinition between ioctl.h and termios.h */
157 #if defined(sun) && !defined(__SVR4)
158 #undef NL0
159 #undef NL1
160 #undef CR0
161 #undef CR1
162 #undef CR2
163 #undef CR3
164 #undef TAB0
165 #undef TAB1
166 #undef TAB2
167 #undef XTABS
168 #undef BS0
169 #undef BS1
170 #undef FF0
171 #undef FF1
172 #undef ECHO
173 #undef NOFLSH
174 #undef TOSTOP
175 #undef FLUSHO
176 #undef PENDIN
177 #endif
178 
179 #if defined(_MSC_VER)
180 #undef MOUSE_MOVED		/* conflict between PDCURSES and _WIN32 */
181 #endif /* _MSC_VER */
182 
183 /*
184  * Do this to build with glibc 2.1.3 (apparently it was not used to build a
185  * system before release).
186  */
187 #include <signal.h>
188 
189 #undef CS			/* some BSD versions of curses use this */
190 #define CS curses_CS		/* ...but we don't */
191 
192 #ifdef ERR
193 #undef ERR			/* all versions of curses define this */
194 #endif
195 
196 #ifdef KEY_EVENT
197 #undef KEY_EVENT		/* wincon.h or Cygwin's copy of it */
198 #endif
199 
200 #ifdef MOUSE_MOVED
201 #undef MOUSE_MOVED		/* wincon.h or MINGW32's copy of it */
202 #endif
203 
204 #ifdef HAVE_CONFIG_H
205 # ifdef HAVE_NCURSESW_NCURSES_H
206 #  undef GCC_PRINTFLIKE		/* <libutf8.h> may define 'printf' */
207 #  include <ncursesw/ncurses.h>
208 #  undef printf			/* but we don't want that... */
209 # else
210 #  ifdef HAVE_NCURSES_NCURSES_H
211 #   include <ncurses/ncurses.h>
212 #  else
213 #   ifdef HAVE_NCURSES_H
214 #    include <ncurses.h>
215 #   else
216 #    ifdef HAVE_CURSESX_H
217 #     include <cursesX.h>	/* Ultrix */
218 #    else
219 #     ifdef HAVE_JCURSES_H
220 #      include <jcurses.h>	/* sony_news */
221 #     else
222 #      ifdef HAVE_XCURSES
223 #       include <xcurses.h>	/* PDCurses' UNIX port */
224 #      else
225 #       include <curses.h>	/* default */
226 #      endif
227 #     endif
228 #    endif
229 #   endif
230 #  endif
231 # endif
232 
233 # if defined(wgetbkgd) && !defined(getbkgd)
234 #  define getbkgd(w) wgetbkgd(w)	/* workaround pre-1.9.9g bug */
235 # endif
236 
237 # ifdef FANCY_CURSES
238 #  if defined(NCURSES) && defined(HAVE_NCURSESW_TERM_H)
239 #    include <ncursesw/term.h>
240 #  else
241 #    if defined(NCURSES) && defined(HAVE_NCURSES_TERM_H)
242 #      include <ncurses/term.h>
243 #    else
244 #     if defined(HAVE_NCURSESW_NCURSES_H) || defined(HAVE_NCURSES_NCURSES_H) || defined(HAVE_XCURSES)
245 #       undef HAVE_TERM_H	/* only use one in comparable path! */
246 #     endif
247 #     if defined(HAVE_TERM_H)
248 #      include <term.h>
249 #     endif
250 #   endif
251 #  endif
252 # endif
253 
254 # if defined(NCURSES_VERSION) && defined(HAVE_DEFINE_KEY)
255 #  define USE_KEYMAPS		1
256 # endif
257 
258 #else
259 # if defined(VMS) && defined(__GNUC__)
260 #  include <LYGCurses.h>
261 #  else
262 #   include <curses.h>		/* everything else */
263 # endif	/* VMS && __GNUC__ */
264 #endif /* HAVE_CONFIG_H */
265 
266 /*
267  * PDCurses' mouse code does nothing in the DJGPP configuration.
268  */
269 #if defined(PDCURSES) && !defined(__DJGPP__) && !defined(HAVE_XCURSES)
270 #define USE_MOUSE 1
271 #endif
272 
273 /*
274  * Pick up the native ncurses name:
275  */
276 #if defined(NCURSES_MOUSE_VERSION)
277 #define USE_MOUSE 1
278 #endif
279 
280 /*
281  * For systems where select() does not work for TTY's, we can poll using
282  * curses.
283  */
284 #if defined(_WINDOWS) || defined(__MINGW32__)
285 #if defined(PDCURSES) && defined(PDC_BUILD) && PDC_BUILD >= 2401
286 #define USE_CURSES_NODELAY 1
287 #endif
288 
289 #if defined(NCURSES_VERSION)
290 #define USE_CURSES_NODELAY 1
291 #endif
292 #endif /* _WINDOWS || __MINGW32__ */
293 
294 #if defined(NCURSES_VERSION) && defined(__BEOS__)
295 #define USE_CURSES_NODELAY 1
296 #endif
297 
298 /*
299  * If we have pads, use them to implement left/right scrolling.
300  */
301 #if defined(HAVE_NEWPAD) && defined(HAVE_PNOUTREFRESH) && !defined(PDCURSES)
302 #define USE_CURSES_PADS 1
303 #endif
304 
305 /*
306  * ncurses 1.9.9e won't work for pads, but 4.2 does (1.9.9g doesn't have a
307  * convenient ifdef, though it would work).
308  */
309 #if defined(NCURSES_VERSION) && !defined(NCURSES_VERSION_MAJOR)
310 #undef USE_CURSES_PADS
311 #endif
312 
313 /*
314  * Most implementations of curses treat pair 0 specially, as the default
315  * foreground and background color.  Also, the COLORS variable corresponds to
316  * the total number of colors.
317  *
318  * PDCurses does not follow these rules.  Its COLORS variable claims it has
319  * 8 colors, but it actually implements 16.  That makes it hard to optimize
320  * color settings against color pair 0 in a portable fashion.
321  */
322 #if defined(COLOR_CURSES)
323 #if defined(PDCURSES) || defined(HAVE_XCURSES)
324 #define COLORS 16		/* should be a variable... */
325 #else
326 #define USE_CURSES_PAIR_0
327 #endif
328 #endif
329 
330 #if defined(_WINDOWS) && defined(PDCURSES) && defined(PDC_BUILD) && PDC_BUILD >= 2401
331 #define USE_MAXSCREEN_TOGGLE 1
332 extern void maxmizeWindowSize(void);
333 extern void recoverWindowSize(void);
334 #endif
335 
336 #endif /* USE_SLANG */
337 
338 #ifdef __cplusplus
339 extern "C" {
340 #endif
341 #ifdef USE_SLANG
342 #define LYstopPopup()		/* nothing */
343 #define LYtopwindow() LYwin
344 #else
345     extern void LYsubwindow(WINDOW * param);
346     extern WINDOW *LYtopwindow(void);
347 
348 #define LYstopPopup() LYsubwindow(0)
349 #endif				/* NCURSES */
350 
351     extern void LYbox(WINDOW * win, int formfield);
352     extern WINDOW *LYstartPopup(int *top_y, int *left_x, int *height, int *width);
353 
354 /*
355  * Useful macros not in PDCurses or very old ncurses headers.
356  */
357 #if !defined(HAVE_GETBEGX) && !defined(getbegx)
358 #define getbegx(win) ((win)->_begx)
359 #endif
360 #if !defined(HAVE_GETBEGY) && !defined(getbegy)
361 #define getbegy(win) ((win)->_begy)
362 #endif
363 #if !defined(HAVE_GETBKGD) && !defined(getbkgd)
364 #define getbkgd(win) ((win)->_bkgd)
365 #endif
366 
367 #if defined(HAVE_WATTR_GET)
368     extern long LYgetattrs(WINDOW * win);
369 
370 #else
371 #if defined(HAVE_GETATTRS) || defined(getattrs)
372 #define LYgetattrs(win) getattrs(win)
373 #else
374 #define LYgetattrs(win) ((win)->_attrs)
375 #endif
376 #endif				/* HAVE_WATTR_GET */
377 
378 #if defined(PDCURSES)
379 #define HAVE_GETBKGD 1		/* can use fallback definition */
380 #define HAVE_NAPMS 1		/* can use millisecond-delays */
381 #  if defined(PDC_BUILD) && PDC_BUILD >= 2401
382     extern int saved_scrsize_x;
383     extern int saved_scrsize_y;
384 #  endif
385 #endif
386 
387 #ifdef HAVE_NAPMS
388 #define SECS2Secs(n) (1000 * (n))
389 #define Secs2SECS(n) ((n) / 1000.0)
390 #define SECS_FMT "%.3f"
391 #else
392 #define SECS2Secs(n) (n)
393 #define Secs2SECS(n) (n)
394 #define SECS_FMT "%.0f"
395 #endif
396 
397 #ifdef NCURSES_VERSION
398     extern void _nc_freeall(void);	/* HAVE__NC_FREEALL */
399     extern void _nc_free_and_exit(int);		/* HAVE__NC_FREE_AND_EXIT */
400 #endif
401 
402 /* Both slang and curses: */
403 #ifndef TRUE
404 #define TRUE  1
405 #endif				/* !TRUE */
406 #ifndef FALSE
407 #define FALSE 0
408 #endif				/* !FALSE */
409 
410 #ifdef REDEFINE_CR
411 #define CR FROMASCII('\015')
412 #endif				/* REDEFINE_CR */
413 
414 #ifdef ALT_CHAR_SET
415 #define BOXVERT 0		/* use alt char set for popup window vertical borders */
416 #define BOXHORI 0		/* use alt char set for popup window vertical borders */
417 #endif
418 
419 #ifndef BOXVERT
420 #define BOXVERT '*'		/* character for popup window vertical borders */
421 #endif
422 #ifndef BOXHORI
423 #define BOXHORI '*'		/* character for popup window horizontal borders */
424 #endif
425 
426 #ifndef KEY_DOWN
427 #undef HAVE_KEYPAD		/* avoid confusion with bogus 'keypad()' */
428 #endif
429 
430     extern int LYlines;		/* replaces LINES */
431     extern int LYcols;		/* replaces COLS */
432 
433 /*
434  * The scrollbar, if used, occupies the rightmost column.
435  */
436 #ifdef USE_SCROLLBAR
437 #define LYbarWidth (LYShowScrollbar ? 1 : 0)
438 #else
439 #define LYbarWidth 0
440 #endif
441 
442 /*
443  * Usable limits for display:
444  */
445 #if defined(FANCY_CURSES) || defined(USE_SLANG)
446 #if defined(PDCURSES)
447 #define LYcolLimit (LYcols - LYbarWidth - 1)	/* PDCurses wrapping is buggy */
448 #else
449 #define LYcolLimit (LYcols - LYbarWidth)
450 #endif
451 #else
452 #define LYcolLimit (LYcols - 1)
453 #endif
454 
455 #ifdef USE_CURSES_PADS
456     extern WINDOW *LYwin;
457     extern int LYshiftWin;
458     extern int LYwideLines;
459     extern int LYtableCols;
460     extern BOOLEAN LYuseCursesPads;
461 
462 #else
463 #define LYwin stdscr
464 #define LYshiftWin	0
465 #define LYwideLines	0
466 #define LYtableCols	0
467 #endif
468 
469     extern BOOLEAN setup(char *terminal);
470     extern int LYscreenHeight(void);
471     extern int LYscreenWidth(void);
472     extern int LYstrExtent(const char *string, int len, int maxCells);
473     extern int LYstrExtent2(const char *string, int len);
474     extern int LYstrFittable(const char *string, int maxCells);
475     extern int LYstrCells(const char *string);
476     extern void LYclear(void);
477     extern void LYclrtoeol(void);
478     extern void LYerase(void);
479     extern void LYmove(int y, int x);
480     extern void LYnoVideo(int mask);
481     extern void LYnormalColor(void);
482     extern void LYpaddstr(WINDOW * w, int width, const char *s);
483     extern void LYrefresh(void);
484     extern void LYstartTargetEmphasis(void);
485     extern void LYstopTargetEmphasis(void);
486     extern void LYtouchline(int row);
487     extern void LYwaddnstr(WINDOW * w, const char *s, size_t len);
488     extern void start_curses(void);
489     extern void stop_curses(void);
490 
491 #define LYaddstr(s)      LYwaddnstr(LYwin, s, strlen(s))
492 
493 #ifdef VMS
494     extern int DCLsystem(char *command);
495     extern void VMSexit();
496     extern int ttopen();
497     extern int ttclose();
498     extern int ttgetc();
499     extern void VMSsignal(int sig, void (*func) ());
500 #endif				/* VMS */
501 
502 #if defined(USE_COLOR_STYLE)
503     extern void curses_css(char *name, int dir);
504     extern void curses_style(int style, int dir);
505     extern void curses_w_style(WINDOW * win, int style, int dir);
506     extern void setHashStyle(int style, int color, int cattr, int mono, const char *element);
507     extern void setStyle(int style, int color, int cattr, int mono);
508     extern void update_color_style(void);
509     extern void wcurses_css(WINDOW * win, char *name, int dir);
510 
511 #  define LynxChangeStyle(style,dir) curses_style(style,dir)
512 #  define LynxWChangeStyle(win,style,dir) curses_w_style(win,style,dir)
513 #else
514 #  define LynxWChangeStyle(win,style,dir)	(void)1
515 #endif				/* USE_COLOR_STYLE */
516 
517 #ifdef USE_COLOR_TABLE
518     extern void LYaddAttr(int a);
519     extern void LYsubAttr(int a);
520     extern void lynx_setup_colors(void);
521     extern unsigned Lynx_Color_Flags;
522 #endif
523 
524 #if defined(USE_COLOR_TABLE) || defined(USE_SLANG)
525     extern int Current_Attr;
526 #endif
527 
528 #ifdef USE_SLANG
529 #define SHOW_WHEREIS_TARGETS 1
530 
531 #if !defined(VMS) && !defined(DJGPP)
532 #define USE_MOUSE              1
533 #endif
534 
535 #if !defined(__DJGPP__) && !defined(__CYGWIN__)
536 #define USE_KEYMAPS		1
537 #endif
538 
539 #define SL_LYNX_USE_COLOR	1
540 #define SL_LYNX_OVERRIDE_COLOR	2
541 
542 #define start_bold()      	LYaddAttr(LYUnderlineLinks ? 4 : 1)
543 #define start_reverse()   	LYaddAttr(2)
544 #define start_underline() 	LYaddAttr(LYUnderlineLinks ? 1 : 4)
545 #define stop_bold()       	LYsubAttr(LYUnderlineLinks ? 4 : 1)
546 #define stop_reverse()    	LYsubAttr(2)
547 #define stop_underline()  	LYsubAttr(LYUnderlineLinks ? 1 : 4)
548 
549 #ifdef FANCY_CURSES
550 #undef FANCY_CURSES
551 #endif				/* FANCY_CURSES */
552 
553 /*
554  *  Map some curses functions to slang functions.
555  */
556 #define stdscr ((WINDOW *)0)
557 #ifdef SLANG_MBCS_HACK
558     extern int PHYSICAL_SLtt_Screen_Cols;
559 
560 #define COLS PHYSICAL_SLtt_Screen_Cols
561 #else
562 #define COLS SLtt_Screen_Cols
563 #endif				/* SLANG_MBCS_HACK */
564 #define LINES SLtt_Screen_Rows
565 #define move SLsmg_gotorc
566 #define addstr SLsmg_write_string
567     extern void LY_SLerase(void);
568 
569 #define erase LY_SLerase
570 #define clear LY_SLerase
571 #define standout SLsmg_reverse_video
572 #define standend  SLsmg_normal_video
573 #define clrtoeol SLsmg_erase_eol
574 
575 #ifdef SLSMG_NEWLINE_SCROLLS
576 #define scrollok(a,b) SLsmg_Newline_Behavior \
577    = ((b) ? SLSMG_NEWLINE_SCROLLS : SLSMG_NEWLINE_MOVES)
578 #else
579 #define scrollok(a,b) SLsmg_Newline_Moves = ((b) ? 1 : -1)
580 #endif
581 
582 #define LYaddch(ch)   SLsmg_write_char(ch)
583 
584 #if SLANG_VERSION >= 20000
585 #define addch_raw(ch) do {                                \
586                         SLsmg_Char_Type buf;              \
587                         buf.nchars = 1;                   \
588                         buf.wchars[0] = ch;               \
589                         buf.color = Current_Attr;         \
590                         SLsmg_write_raw (&buf, 1);        \
591                       } while (0)
592 #else
593 #define addch_raw(ch) do {                                \
594                         SLsmg_Char_Type buf;              \
595                         buf = (ch) | (Current_Attr << 4); \
596                         SLsmg_write_raw (&buf, 1);        \
597                       } while (0)
598 #endif				/* SLANG_VERSION >= 20000 */
599 
600 #define echo()
601 #define printw        SLsmg_printf
602 
603     extern int curscr;
604     extern BOOLEAN FullRefresh;
605 
606 #ifdef clearok
607 #undef clearok
608 #endif				/* clearok */
609 #define clearok(a,b) { FullRefresh = (BOOLEAN)b; }
610     extern void LY_SLrefresh(void);
611 
612 #ifdef refresh
613 #undef refresh
614 #endif				/* refresh */
615 #define refresh LY_SLrefresh
616 
617 #ifdef VMS
618     extern void VTHome(void);
619 
620 #define endwin() LYclear(),refresh(),SLsmg_reset_smg(),VTHome()
621 #else
622 #define endwin SLsmg_reset_smg(),SLang_reset_tty
623 #endif				/* VMS */
624 
625 #else				/* Define curses functions: */
626 
627 #ifdef FANCY_CURSES
628 #define SHOW_WHEREIS_TARGETS 1
629 
630 #ifdef VMS
631 /*
632  *  For VMS curses, [w]setattr() and [w]clrattr()
633  *  add and subtract, respectively, the attributes
634  *  _UNDERLINE, _BOLD, _REVERSE, and _BLINK. - FM
635  */
636 #define start_bold()		setattr(LYUnderlineLinks ? _UNDERLINE : _BOLD)
637 #define stop_bold()		clrattr(LYUnderlineLinks ? _UNDERLINE : _BOLD)
638 #define start_underline()	setattr(LYUnderlineLinks ? _BOLD : _UNDERLINE)
639 #define stop_underline()	clrattr(LYUnderlineLinks ? _BOLD : _UNDERLINE)
640 #define start_reverse()		setattr(_REVERSE)
641 #define wstart_reverse(w)	wsetattr(w, _REVERSE)
642 #define stop_reverse()		clrattr(_REVERSE)
643 #define wstop_reverse(w)	wclrattr(w, _REVERSE)
644 
645 #else				/* Not VMS: */
646 
647     extern int string_to_attr(const char *name);
648 
649 /*
650  *  For Unix FANCY_FANCY curses we interpose
651  *  our own functions to add or subtract the
652  *  A_foo attributes. - FM
653  */
654 #if defined(USE_COLOR_TABLE) && !defined(USE_COLOR_STYLE)
655     extern void LYaddWAttr(WINDOW * win, int a);
656     extern void LYsubWAttr(WINDOW * win, int a);
657     extern void LYaddWAttr(WINDOW * win, int a);
658     extern void LYsubWAttr(WINDOW * win, int a);
659 
660 #undef  standout
661 #define standout() 		lynx_standout(TRUE)
662 #undef  standend
663 #define standend() 		lynx_standout(FALSE)
664 #else
665 #define LYaddAttr(attr)		LYaddWAttr(LYwin,attr)
666 #define LYaddWAttr(win,attr)	wattron(win,attr)
667 #define LYsubAttr(attr)		LYsubWAttr(LYwin,attr)
668 #define LYsubWAttr(win,attr)	wattroff(win,attr)
669 #endif
670 
671 #if defined(USE_COLOR_TABLE)
672     extern void lynx_set_color(int a);
673     extern void lynx_standout(int a);
674     extern char *LYgetTableString(int code);
675     extern int LYgetTableAttr(void);
676     extern int lynx_chg_color(int, int, int);
677 #endif
678 
679 #define start_bold()		LYaddAttr(LYUnderlineLinks ? A_UNDERLINE : A_BOLD)
680 #define stop_bold()		LYsubAttr(LYUnderlineLinks ? A_UNDERLINE : A_BOLD)
681 #define start_underline()	LYaddAttr(LYUnderlineLinks ? A_BOLD : A_UNDERLINE)
682 #define stop_underline()	LYsubAttr(LYUnderlineLinks ? A_BOLD : A_UNDERLINE)
683 
684 #if defined(SNAKE) && defined(HP_TERMINAL)
685 #define start_reverse()		LYaddWAttr(LYwin, A_DIM)
686 #define wstart_reverse(w)	LYaddWAttr(w, A_DIM)
687 #define stop_reverse()		LYsubWAttr(LYwin, A_DIM)
688 #define wstop_reverse(w)	LYsubWAttr(w, A_DIM)
689 #else
690 #define start_reverse()		LYaddAttr(A_REVERSE)
691 #define wstart_reverse(w)	LYaddWAttr(w, A_REVERSE)
692 #define stop_reverse()		LYsubAttr(A_REVERSE)
693 #define wstop_reverse(w)	LYsubWAttr(w, A_REVERSE)
694 #endif				/* SNAKE && HP_TERMINAL */
695 
696 #endif				/* VMS */
697 
698 #else				/* Not FANCY_CURSES: */
699 /* *INDENT-OFF* */
700 #ifdef COLOR_CURSES
701 #undef COLOR_CURSES
702 Error FANCY_CURSES
703 There is a problem with the configuration.  We expect to have FANCY_CURSES
704 defined when COLOR_CURSES is defined, since we build on the attributes used in
705 FANCY_CURSES.  Check your config.log to see why the FANCY_CURSES test failed.
706 #endif
707 /* *INDENT-ON* */
708 
709 /*
710  *  We only have [w]standout() and [w]standin(),
711  *  so we'll use them synonymously for bold and
712  *  reverse, and ignore underline. - FM
713  */
714 #define start_bold()		standout()
715 #define start_underline()	/* nothing */
716 #define start_reverse()		standout()
717 #define wstart_reverse(a)	wstandout(a)
718 #define stop_bold()		standend()
719 #define stop_underline()	/* nothing */
720 #define stop_reverse()		standend()
721 #define wstop_reverse(a)	wstandend(a)
722 
723 #endif				/* FANCY_CURSES */
724 
725 #ifdef __hpux			/* FIXME: configure check */
726 #undef ACS_UARROW
727 #undef ACS_DARROW
728 #undef ACS_LARROW
729 #undef ACS_RARROW
730 #undef ACS_BLOCK
731 #undef ACS_CKBOARD
732 #endif
733 
734 #ifndef ACS_UARROW
735 #define ACS_UARROW  '^'
736 #endif
737 
738 #ifndef ACS_DARROW
739 #define ACS_DARROW  'V'
740 #endif
741 
742 #ifndef ACS_LARROW
743 #define ACS_LARROW '{'
744 #endif
745 
746 #ifndef ACS_RARROW
747 #define ACS_RARROW '}'
748 #endif
749 
750 #ifndef ACS_BLOCK
751 #define ACS_BLOCK  '}'
752 #endif
753 
754 #ifndef ACS_CKBOARD
755 #define ACS_CKBOARD '}'
756 #endif
757 
758 #define LYaddch(ch)		waddch(LYwin, ch)
759 
760 #define addch_raw(ch)           LYaddch(ch)
761 
762 #endif				/* USE_SLANG */
763 
764 #ifdef USE_SLANG
765 #define LYGetYX(y, x)   y = SLsmg_get_row(), x = SLsmg_get_column()
766 #else
767 #ifdef getyx
768 #define LYGetYX(y, x)   getyx(LYwin, y, x)
769 #else
770 #define LYGetYX(y, x)   y = LYwin->_cury, x = LYwin->_curx
771 #endif				/* getyx */
772 #endif				/* USE_SLANG */
773 
774 /*
775  * If the screen library allows us to specify "default" color, allow user to
776  * control it.
777  */
778 #ifdef USE_DEFAULT_COLORS
779 #if defined(USE_SLANG) || defined(HAVE_ASSUME_DEFAULT_COLORS)
780 #define EXP_ASSUMED_COLOR 1
781 #endif
782 #endif
783 
784     extern void lynx_enable_mouse(int);
785     extern void lynx_force_repaint(void);
786     extern void lynx_nl2crlf(int normal);
787     extern void lynx_start_title_color(void);
788     extern void lynx_stop_title_color(void);
789     extern void lynx_start_link_color(int flag, int pending);
790     extern void lynx_stop_link_color(int flag, int pending);
791     extern void lynx_stop_target_color(void);
792     extern void lynx_start_target_color(void);
793     extern void lynx_start_status_color(void);
794     extern void lynx_stop_status_color(void);
795     extern void lynx_start_h1_color(void);
796     extern void lynx_stop_h1_color(void);
797     extern void lynx_start_prompt_color(void);
798     extern void lynx_stop_prompt_color(void);
799     extern void lynx_start_radio_color(void);
800     extern void lynx_stop_radio_color(void);
801     extern void lynx_stop_all_colors(void);
802 
803     extern void lynx_start_bold(void);
804     extern void lynx_start_reverse(void);
805     extern void lynx_start_underline(void);
806     extern void lynx_stop_bold(void);
807     extern void lynx_stop_reverse(void);
808     extern void lynx_stop_underline(void);
809 
810     extern void restart_curses(void);
811 
812 /*
813  * To prevent corrupting binary data on DOS, MS-WINDOWS or OS/2 we open files
814  * and stdout in BINARY mode by default.  Where necessary we should open and
815  * (close!) TEXT mode.
816  *
817  * Note:  EMX has no corresponding variable like _fmode on DOS, but it does
818  * have setmode.
819  */
820 #if defined(_WINDOWS) || defined(DJGPP) || defined(__EMX__) || defined(WIN_EX)
821 #define SetOutputMode(mode) fflush(stdout), setmode(fileno(stdout), mode)
822 #else
823 #define SetOutputMode(mode)	/* nothing */
824 #endif
825 
826 #if defined(_WINDOWS) || defined(DJGPP)
827 #define SetDefaultMode(mode) _fmode = mode
828 #else
829 #define SetDefaultMode(mode)	/* nothing */
830 #endif
831 
832 /*
833  * Very old versions of curses cannot put the cursor on the lower right corner.
834  * Adjust our "hidden" cursor position accordingly.
835  */
836 #if defined(FANCY_CURSES) || defined(USE_SLANG)
837 #define LYHideCursor() LYmove((LYlines - 1), (LYcolLimit - 1))
838 #else
839 #define LYHideCursor() LYmove((LYlines - 1), (LYcolLimit - 2))
840 #endif
841 
842     extern void LYstowCursor(WINDOW * win, int row, int col);
843     extern void LYSetDisplayLines(void);
844 
845 #ifdef __cplusplus
846 }
847 #endif
848 #endif				/* LYCURSES_H */
849