about summary refs log tree commit diff stats
path: root/src/LYCurses.h
blob: f9858eeb2af07b92127d24f5c51bf4e44504c8eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
/* $LynxId: LYCurses.h,v 1.91 2013/10/10 23:28:33 tom Exp $ */
#ifndef LYCURSES_H
#define LYCURSES_H

#ifndef HTUTILS_H
#include <HTUtils.h>
#endif

/*
 * Because we have to configure PDCURSES last, we may get bogus definitions
 * from the system curses library - cancel these now.
 */
#ifdef HAVE_XCURSES

#undef ASSUME_DEFAULT_COLORS
#undef COLOR_CURSES
#undef FANCY_CURSES
#undef HAVE_CBREAK
#undef HAVE_RESIZETERM
#undef HAVE_USE_DEFAULT_COLORS
#undef NCURSES
#undef USE_DEFAULT_COLORS

#define HAVE_CBREAK 1
#define COLOR_CURSES 1
#define FANCY_CURSES 1

#endif

/*
 * The simple color scheme maps the 8 combinations of bold/underline/reverse
 * to the standard 8 ANSI colors (with some variations based on context).
 */
#undef USE_COLOR_TABLE

#ifdef USE_COLOR_STYLE
#define USE_COLOR_TABLE 1	/* default color logic is used */
#else
#if defined(USE_SLANG) || defined(COLOR_CURSES)
#define USE_COLOR_TABLE 1
#endif
#endif

#ifdef TRUE
#undef TRUE			/* to prevent parse error :( */
#endif /* TRUE */
#ifdef FALSE
#undef FALSE			/* to prevent parse error :( */
#endif /* FALSE */

#ifdef USE_SLANG
#define ENABLE_SLFUTURE_CONST 1
#include <slang.h>
#ifndef SLFUTURE_CONST
#define SLFUTURE_CONST		/* nothing */
#endif
typedef unsigned long chtype;

#undef WINDOW
typedef struct {
    int top_y;
    int left_x;
    int height;
    int width;
} WINDOW;

/* slang doesn't really do windows... */
#define waddch(w,c)  LYaddch(c)
#define waddstr(w,s) addstr(s)
#define wmove(win, row, col) SLsmg_gotorc(((win)?(win)->top_y:0) + (row), ((win)?(win)->left_x:0) + (col))

#ifndef SLSMG_UARROW_CHAR
#define SLSMG_UARROW_CHAR '^'
#endif

#ifndef SLSMG_DARROW_CHAR
#define SLSMG_DARROW_CHAR 'v'
#endif

#ifndef SLSMG_LARROW_CHAR
#define SLSMG_LARROW_CHAR '<'
#endif

#ifndef SLSMG_RARROW_CHAR
#define SLSMG_RARROW_CHAR '>'
#endif

#ifndef SLSMG_CKBRD_CHAR
#define SLSMG_CKBRD_CHAR '#'
#endif

#ifndef SLSMG_BLOCK_CHAR
#define SLSMG_BLOCK_CHAR '#'
#endif

#ifndef ACS_UARROW
#define ACS_UARROW  SLSMG_UARROW_CHAR
#endif

#ifndef ACS_DARROW
#define ACS_DARROW  SLSMG_DARROW_CHAR
#endif

#ifndef ACS_LARROW
#define ACS_LARROW  SLSMG_LARROW_CHAR
#endif

#ifndef ACS_RARROW
#define ACS_RARROW  SLSMG_RARROW_CHAR
#endif

#ifndef ACS_CKBOARD
#define ACS_CKBOARD SLSMG_CKBRD_CHAR
#endif

#ifndef ACS_BLOCK
#define ACS_BLOCK   SLSMG_BLOCK_CHAR
#endif

#else /* Using curses: */

#ifdef VMS
#define FANCY_CURSES

#endif /* VMS */

#ifndef HAVE_TYPE_CHTYPE

#ifdef __PDCURSES__
#define HAVE_TYPE_CHTYPE 1
#endif

#if defined(_VMS_CURSES) || defined(VMS)
typedef char chtype;

#define HAVE_TYPE_CHTYPE 1
#endif

#endif /* ! HAVE_TYPE_CHTYPE */

/*
 *	CR may be defined before the curses.h include occurs.
 *	There is a conflict between the termcap char *CR and the define.
 *	Assuming that the definition of CR will always be carriage return.
 *	06-09-94 Lynx 2-3-1 Garrett Arch Blythe
 */
#ifdef CR
#undef CR			/* to prevent parse error :( */
#define REDEFINE_CR
#endif /* CR */

#ifdef HZ
#undef HZ			/* to prevent parse error :( */
#endif /* HZ */

/* SunOS 4.x has a redefinition between ioctl.h and termios.h */
#if defined(sun) && !defined(__SVR4)
#undef NL0
#undef NL1
#undef CR0
#undef CR1
#undef CR2
#undef CR3
#undef TAB0
#undef TAB1
#undef TAB2
#undef XTABS
#undef BS0
#undef BS1
#undef FF0
#undef FF1
#undef ECHO
#undef NOFLSH
#undef TOSTOP
#undef FLUSHO
#undef PENDIN
#endif

#if defined(_MSC_VER)
#undef MOUSE_MOVED		/* conflict between PDCURSES and _WIN32 */
#endif /* _MSC_VER */

/*
 * Do this to build with glibc 2.1.3 (apparently it was not used to build a
 * system before release).
 */
#include <signal.h>

#undef CS			/* some BSD versions of curses use this */
#define CS curses_CS		/* ...but we don't */

#ifdef ERR
#undef ERR			/* all versions of curses define this */
#endif

#ifdef KEY_EVENT
#undef KEY_EVENT		/* wincon.h or Cygwin's copy of it */
#endif

#ifdef MOUSE_MOVED
#undef MOUSE_MOVED		/* wincon.h or MINGW32's copy of it */
#endif

#ifdef HAVE_CONFIG_H
# ifdef HAVE_NCURSESW_NCURSES_H
#  undef GCC_PRINTFLIKE		/* <libutf8.h> may define 'printf' */
#  include <ncursesw/ncurses.h>
#  undef printf			/* but we don't want that... */
# else
#  ifdef HAVE_NCURSES_NCURSES_H
#   include <ncurses/ncurses.h>
#  else
#   ifdef HAVE_NCURSES_H
#    include <ncurses.h>
#   else
#    ifdef HAVE_CURSESX_H
#     include <cursesX.h>	/* Ultrix */
#    else
#     ifdef HAVE_JCURSES_H
#      include <jcurses.h>	/* sony_news */
#     else
#      ifdef HAVE_XCURSES
#       include <xcurses.h>	/* PDCurses' UNIX port */
#      else
#       include <curses.h>	/* default */
#      endif
#     endif
#    endif
#   endif
#  endif
# endif

# if defined(wgetbkgd) && !defined(getbkgd)
#  define getbkgd(w) wgetbkgd(w)	/* workaround pre-1.9.9g bug */
# endif

# ifdef FANCY_CURSES
#  if defined(NCURSES) && defined(HAVE_NCURSESW_TERM_H)
#    include <ncursesw/term.h>
#  else
#    if defined(NCURSES) && defined(HAVE_NCURSES_TERM_H)
#      include <ncurses/term.h>
#    else
#     if defined(HAVE_NCURSESW_NCURSES_H) || defined(HAVE_NCURSES_NCURSES_H) || defined(HAVE_XCURSES)
#       undef HAVE_TERM_H	/* only use one in comparable path! */
#     endif
#     if defined(HAVE_TERM_H)
#      include <term.h>
#     endif
#   endif
#  endif
# endif

# if defined(NCURSES_VERSION) && defined(HAVE_DEFINE_KEY)
#  define USE_KEYMAPS		1
# endif

#else
# if defined(VMS) && defined(__GNUC__)
#  include <LYGCurses.h>
#  else
#   include <curses.h>		/* everything else */
# endif	/* VMS && __GNUC__ */
#endif /* HAVE_CONFIG_H */

/*
 * PDCurses' mouse code does nothing in the DJGPP configuration.
 */
#if defined(PDCURSES) && !defined(__DJGPP__) && !defined(HAVE_XCURSES)
#define USE_MOUSE 1
#endif

/*
 * Pick up the native ncurses name:
 */
#if defined(NCURSES_MOUSE_VERSION)
#define USE_MOUSE 1
#endif

/*
 * For systems where select() does not work for TTY's, we can poll using
 * curses.
 */
#if defined(_WINDOWS) || defined(__MINGW32__)
#if defined(PDCURSES) && defined(PDC_BUILD) && PDC_BUILD >= 2401
#define USE_CURSES_NODELAY 1
#endif

#if defined(NCURSES_VERSION)
#define USE_CURSES_NODELAY 1
#endif
#endif /* _WINDOWS || __MINGW32__ */

#if defined(NCURSES_VERSION) && defined(__BEOS__)
#define USE_CURSES_NODELAY 1
#endif

/*
 * If we have pads, use them to implement left/right scrolling.
 */
#if defined(HAVE_NEWPAD) && defined(HAVE_PNOUTREFRESH) && !defined(PDCURSES)
#define USE_CURSES_PADS 1
#endif

/*
 * ncurses 1.9.9e won't work for pads, but 4.2 does (1.9.9g doesn't have a
 * convenient ifdef, though it would work).
 */
#if defined(NCURSES_VERSION) && !defined(NCURSES_VERSION_MAJOR)
#undef USE_CURSES_PADS
#endif

/*
 * Most implementations of curses treat pair 0 specially, as the default
 * foreground and background color.  Also, the COLORS variable corresponds to
 * the total number of colors.
 *
 * PDCurses does not follow these rules.  Its COLORS variable claims it has
 * 8 colors, but it actually implements 16.  That makes it hard to optimize
 * color settings against color pair 0 in a portable fashion.
 */
#if defined(COLOR_CURSES)
#if defined(PDCURSES) || defined(HAVE_XCURSES)
#define COLORS 16		/* should be a variable... */
#else
#define USE_CURSES_PAIR_0
#endif
#endif

#if defined(_WINDOWS) && defined(PDCURSES) && defined(PDC_BUILD) && PDC_BUILD >= 2401
#define USE_MAXSCREEN_TOGGLE 1
extern void maxmizeWindowSize(void);
extern void recoverWindowSize(void);
#endif

#endif /* USE_SLANG */

#ifdef __cplusplus
extern "C" {
#endif
#ifdef USE_SLANG
#define LYstopPopup()		/* nothing */
#define LYtopwindow() LYwin
#else
    extern void LYsubwindow(WINDOW * param);
    extern WINDOW *LYtopwindow(void);

#define LYstopPopup() LYsubwindow(0)
#endif				/* NCURSES */

    extern void LYbox(WINDOW * win, int formfield);
    extern WINDOW *LYstartPopup(int *top_y, int *left_x, int *height, int *width);

/*
 * Useful macros not in PDCurses or very old ncurses headers.
 */
#if !defined(HAVE_GETBEGX) && !defined(getbegx)
#define getbegx(win) ((win)->_begx)
#endif
#if !defined(HAVE_GETBEGY) && !defined(getbegy)
#define getbegy(win) ((win)->_begy)
#endif
#if !defined(HAVE_GETBKGD) && !defined(getbkgd)
#define getbkgd(win) ((win)->_bkgd)
#endif

#if defined(HAVE_WATTR_GET)
    extern long LYgetattrs(WINDOW * win);

#else
#if defined(HAVE_GETATTRS) || defined(getattrs)
#define LYgetattrs(win) getattrs(win)
#else
#define LYgetattrs(win) ((win)->_attrs)
#endif
#endif				/* HAVE_WATTR_GET */

#if defined(PDCURSES)
#define HAVE_GETBKGD 1		/* can use fallback definition */
#define HAVE_NAPMS 1		/* can use millisecond-delays */
#  if defined(PDC_BUILD) && PDC_BUILD >= 2401
    extern int saved_scrsize_x;
    extern int saved_scrsize_y;
#  endif
#endif

#ifdef HAVE_NAPMS
#define SECS2Secs(n) (1000 * (n))
#define Secs2SECS(n) ((n) / 1000.0)
#define SECS_FMT "%.3f"
#else
#define SECS2Secs(n) (n)
#define Secs2SECS(n) (n)
#define SECS_FMT "%.0f"
#endif

#ifdef NCURSES_VERSION
    extern void _nc_freeall(void);	/* HAVE__NC_FREEALL */
    extern void _nc_free_and_exit(int);		/* HAVE__NC_FREE_AND_EXIT */
#endif

/* Both slang and curses: */
#ifndef TRUE
#define TRUE  1
#endif				/* !TRUE */
#ifndef FALSE
#define FALSE 0
#endif				/* !FALSE */

#ifdef REDEFINE_CR
#define CR FROMASCII('\015')
#endif				/* REDEFINE_CR */

#ifdef ALT_CHAR_SET
#define BOXVERT 0		/* use alt char set for popup window vertical borders */
#define BOXHORI 0		/* use alt char set for popup window vertical borders */
#endif

#ifndef BOXVERT
#define BOXVERT '*'		/* character for popup window vertical borders */
#endif
#ifndef BOXHORI
#define BOXHORI '*'		/* character for popup window horizontal borders */
#endif

#ifndef KEY_DOWN
#undef HAVE_KEYPAD		/* avoid confusion with bogus 'keypad()' */
#endif

    extern int LYlines;		/* replaces LINES */
    extern int LYcols;		/* replaces COLS */

/*
 * The scrollbar, if used, occupies the rightmost column.
 */
#ifdef USE_SCROLLBAR
#define LYbarWidth (LYShowScrollbar ? 1 : 0)
#else
#define LYbarWidth 0
#endif

/*
 * Usable limits for display:
 */
#if defined(FANCY_CURSES) || defined(USE_SLANG)
#if defined(PDCURSES)
#define LYcolLimit (LYcols - LYbarWidth - 1)	/* PDCurses wrapping is buggy */
#else
#define LYcolLimit (LYcols - LYbarWidth)
#endif
#else
#define LYcolLimit (LYcols - 1)
#endif

#ifdef USE_CURSES_PADS
    extern WINDOW *LYwin;
    extern int LYshiftWin;
    extern int LYwideLines;
    extern int LYtableCols;
    extern BOOLEAN LYuseCursesPads;

#else
#define LYwin stdscr
#define LYshiftWin	0
#define LYwideLines	0
#define LYtableCols	0
#endif

    extern BOOLEAN setup(char *terminal);
    extern int LYscreenHeight(void);
    extern int LYscreenWidth(void);
    extern int LYstrExtent(const char *string, int len, int maxCells);
    extern int LYstrExtent2(const char *string, int len);
    extern int LYstrFittable(const char *string, int maxCells);
    extern int LYstrCells(const char *string);
    extern void LYclear(void);
    extern void LYclrtoeol(void);
    extern void LYerase(void);
    extern void LYmove(int y, int x);
    extern void LYnoVideo(int mask);
    extern void LYnormalColor(void);
    extern void LYpaddstr(WINDOW * w, int width, const char *s);
    extern void LYrefresh(void);
    extern void LYstartTargetEmphasis(void);
    extern void LYstopTargetEmphasis(void);
    extern void LYtouchline(int row);
    extern void LYwaddnstr(WINDOW * w, const char *s, size_t len);
    extern void start_curses(void);
    extern void stop_curses(void);

#define LYaddstr(s)      LYwaddnstr(LYwin, s, strlen(s))

#ifdef VMS
    extern int DCLsystem(char *command);
    extern void VMSexit();
    extern int ttopen();
    extern int ttclose();
    extern int ttgetc();
    extern void VMSsignal(int sig, void (*func) ());
#endif				/* VMS */

#if defined(USE_COLOR_STYLE)
    extern void curses_css(char *name, int dir);
    extern void curses_style(int style, int dir);
    extern void curses_w_style(WINDOW * win, int style, int dir);
    extern void setHashStyle(int style, int color, int cattr, int mono, const char *element);
    extern void setStyle(int style, int color, int cattr, int mono);
    extern void update_color_style(void);
    extern void wcurses_css(WINDOW * win, char *name, int dir);

#  define LynxChangeStyle(style,dir) curses_style(style,dir)
#  define LynxWChangeStyle(win,style,dir) curses_w_style(win,style,dir)
#else
#  define LynxWChangeStyle(win,style,dir)	(void)1
#endif				/* USE_COLOR_STYLE */

#ifdef USE_COLOR_TABLE
    extern void LYaddAttr(int a);
    extern void LYsubAttr(int a);
    extern void lynx_setup_colors(void);
    extern unsigned Lynx_Color_Flags;
#endif

#if defined(USE_COLOR_TABLE) || defined(USE_SLANG)
    extern int Current_Attr;
#endif

#ifdef USE_SLANG
#define SHOW_WHEREIS_TARGETS 1

#if !defined(VMS) && !defined(DJGPP)
#define USE_MOUSE              1
#endif

#if !defined(__DJGPP__) && !defined(__CYGWIN__)
#define USE_KEYMAPS		1
#endif

#define SL_LYNX_USE_COLOR	1
#define SL_LYNX_OVERRIDE_COLOR	2

#define start_bold()      	LYaddAttr(LYUnderlineLinks ? 4 : 1)
#define start_reverse()   	LYaddAttr(2)
#define start_underline() 	LYaddAttr(LYUnderlineLinks ? 1 : 4)
#define stop_bold()       	LYsubAttr(LYUnderlineLinks ? 4 : 1)
#define stop_reverse()    	LYsubAttr(2)
#define stop_underline()  	LYsubAttr(LYUnderlineLinks ? 1 : 4)

#ifdef FANCY_CURSES
#undef FANCY_CURSES
#endif				/* FANCY_CURSES */

/*
 *  Map some curses functions to slang functions.
 */
#define stdscr ((WINDOW *)0)
#ifdef SLANG_MBCS_HACK
    extern int PHYSICAL_SLtt_Screen_Cols;

#define COLS PHYSICAL_SLtt_Screen_Cols
#else
#define COLS SLtt_Screen_Cols
#endif				/* SLANG_MBCS_HACK */
#define LINES SLtt_Screen_Rows
#define move SLsmg_gotorc
#define addstr SLsmg_write_string
    extern void LY_SLerase(void);

#define erase LY_SLerase
#define clear LY_SLerase
#define standout SLsmg_reverse_video
#define standend  SLsmg_normal_video
#define clrtoeol SLsmg_erase_eol

#ifdef SLSMG_NEWLINE_SCROLLS
#define scrollok(a,b) SLsmg_Newline_Behavior \
   = ((b) ? SLSMG_NEWLINE_SCROLLS : SLSMG_NEWLINE_MOVES)
#else
#define scrollok(a,b) SLsmg_Newline_Moves = ((b) ? 1 : -1)
#endif

#define LYaddch(ch)   SLsmg_write_char(ch)

#if SLANG_VERSION >= 20000
#define addch_raw(ch) do {                                \
                        SLsmg_Char_Type buf;              \
                        buf.nchars = 1;                   \
                        buf.wchars[0] = ch;               \
                        buf.color = Current_Attr;         \
                        SLsmg_write_raw (&buf, 1);        \
                      } while (0)
#else
#define addch_raw(ch) do {                                \
                        SLsmg_Char_Type buf;              \
                        buf = (ch) | (Current_Attr << 4); \
                        SLsmg_write_raw (&buf, 1);        \
                      } while (0)
#endif				/* SLANG_VERSION >= 20000 */

#define echo()
#define printw        SLsmg_printf

    extern int curscr;
    extern BOOLEAN FullRefresh;

#ifdef clearok
#undef clearok
#endif				/* clearok */
#define clearok(a,b) { FullRefresh = (BOOLEAN)b; }
    extern void LY_SLrefresh(void);

#ifdef refresh
#undef refresh
#endif				/* refresh */
#define refresh LY_SLrefresh

#ifdef VMS
    extern void VTHome(void);

#define endwin() LYclear(),refresh(),SLsmg_reset_smg(),VTHome()
#else
#define endwin SLsmg_reset_smg(),SLang_reset_tty
#endif				/* VMS */

#else				/* Define curses functions: */

#ifdef FANCY_CURSES
#define SHOW_WHEREIS_TARGETS 1

#ifdef VMS
/*
 *  For VMS curses, [w]setattr() and [w]clrattr()
 *  add and subtract, respectively, the attributes
 *  _UNDERLINE, _BOLD, _REVERSE, and _BLINK. - FM
 */
#define start_bold()		setattr(LYUnderlineLinks ? _UNDERLINE : _BOLD)
#define stop_bold()		clrattr(LYUnderlineLinks ? _UNDERLINE : _BOLD)
#define start_underline()	setattr(LYUnderlineLinks ? _BOLD : _UNDERLINE)
#define stop_underline()	clrattr(LYUnderlineLinks ? _BOLD : _UNDERLINE)
#define start_reverse()		setattr(_REVERSE)
#define wstart_reverse(w)	wsetattr(w, _REVERSE)
#define stop_reverse()		clrattr(_REVERSE)
#define wstop_reverse(w)	wclrattr(w, _REVERSE)

#else				/* Not VMS: */

    extern int string_to_attr(const char *name);

/*
 *  For Unix FANCY_FANCY curses we interpose
 *  our own functions to add or subtract the
 *  A_foo attributes. - FM
 */
#if defined(USE_COLOR_TABLE) && !defined(USE_COLOR_STYLE)
    extern void LYaddWAttr(WINDOW * win, int a);
    extern void LYsubWAttr(WINDOW * win, int a);
    extern void LYaddWAttr(WINDOW * win, int a);
    extern void LYsubWAttr(WINDOW * win, int a);

#undef  standout
#define standout() 		lynx_standout(TRUE)
#undef  standend
#define standend() 		lynx_standout(FALSE)
#else
#define LYaddAttr(attr)		LYaddWAttr(LYwin,attr)
#define LYaddWAttr(win,attr)	wattron(win,attr)
#define LYsubAttr(attr)		LYsubWAttr(LYwin,attr)
#define LYsubWAttr(win,attr)	wattroff(win,attr)
#endif

#if defined(USE_COLOR_TABLE)
    extern void lynx_set_color(int a);
    extern void lynx_standout(int a);
    extern char *LYgetTableString(int code);
    extern int LYgetTableAttr(void);
    extern int lynx_chg_color(int, int, int);
#endif

#define start_bold()		LYaddAttr(LYUnderlineLinks ? A_UNDERLINE : A_BOLD)
#define stop_bold()		LYsubAttr(LYUnderlineLinks ? A_UNDERLINE : A_BOLD)
#define start_underline()	LYaddAttr(LYUnderlineLinks ? A_BOLD : A_UNDERLINE)
#define stop_underline()	LYsubAttr(LYUnderlineLinks ? A_BOLD : A_UNDERLINE)

#if defined(SNAKE) && defined(HP_TERMINAL)
#define start_reverse()		LYaddWAttr(LYwin, A_DIM)
#define wstart_reverse(w)	LYaddWAttr(w, A_DIM)
#define stop_reverse()		LYsubWAttr(LYwin, A_DIM)
#define wstop_reverse(w)	LYsubWAttr(w, A_DIM)
#else
#define start_reverse()		LYaddAttr(A_REVERSE)
#define wstart_reverse(w)	LYaddWAttr(w, A_REVERSE)
#define stop_reverse()		LYsubAttr(A_REVERSE)
#define wstop_reverse(w)	LYsubWAttr(w, A_REVERSE)
#endif				/* SNAKE && HP_TERMINAL */

#endif				/* VMS */

#else				/* Not FANCY_CURSES: */
/* *INDENT-OFF* */
#ifdef COLOR_CURSES
#undef COLOR_CURSES
Error FANCY_CURSES
There is a problem with the configuration.  We expect to have FANCY_CURSES
defined when COLOR_CURSES is defined, since we build on the attributes used in
FANCY_CURSES.  Check your config.log to see why the FANCY_CURSES test failed.
#endif
/* *INDENT-ON* */

/*
 *  We only have [w]standout() and [w]standin(),
 *  so we'll use them synonymously for bold and
 *  reverse, and ignore underline. - FM
 */
#define start_bold()		standout()
#define start_underline()	/* nothing */
#define start_reverse()		standout()
#define wstart_reverse(a)	wstandout(a)
#define stop_bold()		standend()
#define stop_underline()	/* nothing */
#define stop_reverse()		standend()
#define wstop_reverse(a)	wstandend(a)

#endif				/* FANCY_CURSES */

#ifdef __hpux			/* FIXME: configure check */
#undef ACS_UARROW
#undef ACS_DARROW
#undef ACS_LARROW
#undef ACS_RARROW
#undef ACS_BLOCK
#undef ACS_CKBOARD
#endif

#ifndef ACS_UARROW
#define ACS_UARROW  '^'
#endif

#ifndef ACS_DARROW
#define ACS_DARROW  'V'
#endif

#ifndef ACS_LARROW
#define ACS_LARROW '{'
#endif

#ifndef ACS_RARROW
#define ACS_RARROW '}'
#endif

#ifndef ACS_BLOCK
#define ACS_BLOCK  '}'
#endif

#ifndef ACS_CKBOARD
#define ACS_CKBOARD '}'
#endif

#define LYaddch(ch)		waddch(LYwin, ch)

#define addch_raw(ch)           LYaddch(ch)

#endif				/* USE_SLANG */

#ifdef USE_SLANG
#define LYGetYX(y, x)   y = SLsmg_get_row(), x = SLsmg_get_column()
#else
#ifdef getyx
#define LYGetYX(y, x)   getyx(LYwin, y, x)
#else
#define LYGetYX(y, x)   y = LYwin->_cury, x = LYwin->_curx
#endif				/* getyx */
#endif				/* USE_SLANG */

/*
 * If the screen library allows us to specify "default" color, allow user to
 * control it.
 */
#ifdef USE_DEFAULT_COLORS
#if defined(USE_SLANG) || defined(HAVE_ASSUME_DEFAULT_COLORS)
#define EXP_ASSUMED_COLOR 1
#endif
#endif

    extern void lynx_enable_mouse(int);
    extern void lynx_force_repaint(void);
    extern void lynx_nl2crlf(int normal);
    extern void lynx_start_title_color(void);
    extern void lynx_stop_title_color(void);
    extern void lynx_start_link_color(int flag, int pending);
    extern void lynx_stop_link_color(int flag, int pending);
    extern void lynx_stop_target_color(void);
    extern void lynx_start_target_color(void);
    extern void lynx_start_status_color(void);
    extern void lynx_stop_status_color(void);
    extern void lynx_start_h1_color(void);
    extern void lynx_stop_h1_color(void);
    extern void lynx_start_prompt_color(void);
    extern void lynx_stop_prompt_color(void);
    extern void lynx_start_radio_color(void);
    extern void lynx_stop_radio_color(void);
    extern void lynx_stop_all_colors(void);

    extern void lynx_start_bold(void);
    extern void lynx_start_reverse(void);
    extern void lynx_start_underline(void);
    extern void lynx_stop_bold(void);
    extern void lynx_stop_reverse(void);
    extern void lynx_stop_underline(void);

    extern void restart_curses(void);

/*
 * To prevent corrupting binary data on DOS, MS-WINDOWS or OS/2 we open files
 * and stdout in BINARY mode by default.  Where necessary we should open and
 * (close!) TEXT mode.
 *
 * Note:  EMX has no corresponding variable like _fmode on DOS, but it does
 * have setmode.
 */
#if defined(_WINDOWS) || defined(DJGPP) || defined(__EMX__) || defined(WIN_EX)
#define SetOutputMode(mode) fflush(stdout), setmode(fileno(stdout), mode)
#else
#define SetOutputMode(mode)	/* nothing */
#endif

#if defined(_WINDOWS) || defined(DJGPP)
#define SetDefaultMode(mode) _fmode = mode
#else
#define SetDefaultMode(mode)	/* nothing */
#endif

/*
 * Very old versions of curses cannot put the cursor on the lower right corner.
 * Adjust our "hidden" cursor position accordingly.
 */
#if defined(FANCY_CURSES) || defined(USE_SLANG)
#define LYHideCursor() LYmove((LYlines - 1), (LYcolLimit - 1))
#else
#define LYHideCursor() LYmove((LYlines - 1), (LYcolLimit - 2))
#endif

#define LYParkCursor() LYmove((LYlines - 1), 0); LYclrtoeol()

    extern void LYstowCursor(WINDOW * win, int row, int col);
    extern void LYSetDisplayLines(void);

#ifdef __cplusplus
}
#endif
#endif				/* LYCURSES_H */