]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/curses.priv.h
d3d5f296ef8b5f4cab04fc4b6ab5b4e6e4df45cc
[ncurses.git] / ncurses / curses.priv.h
1 /****************************************************************************
2  * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc.              *
3  *                                                                          *
4  * Permission is hereby granted, free of charge, to any person obtaining a  *
5  * copy of this software and associated documentation files (the            *
6  * "Software"), to deal in the Software without restriction, including      *
7  * without limitation the rights to use, copy, modify, merge, publish,      *
8  * distribute, distribute with modifications, sublicense, and/or sell       *
9  * copies of the Software, and to permit persons to whom the Software is    *
10  * furnished to do so, subject to the following conditions:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22  *                                                                          *
23  * Except as contained in this notice, the name(s) of the above copyright   *
24  * holders shall not be used in advertising or otherwise to promote the     *
25  * sale, use or other dealings in this Software without prior written       *
26  * authorization.                                                           *
27  ****************************************************************************/
28
29 /****************************************************************************
30  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
31  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
32  ****************************************************************************/
33
34
35 /*
36  * $Id: curses.priv.h,v 1.162 2000/06/24 21:06:10 tom Exp $
37  *
38  *      curses.priv.h
39  *
40  *      Header file for curses library objects which are private to
41  *      the library.
42  *
43  */
44
45 #ifndef CURSES_PRIV_H
46 #define CURSES_PRIV_H 1
47
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
52 #include <ncurses_cfg.h>
53
54 #if USE_RCS_IDS
55 #define MODULE_ID(id) static const char Ident[] = id;
56 #else
57 #define MODULE_ID(id) /*nothing*/
58 #endif
59
60 #include <stdlib.h>
61 #include <string.h>
62 #include <sys/types.h>
63
64 #if HAVE_UNISTD_H
65 #include <unistd.h>
66 #endif
67
68 #if HAVE_SYS_BSDTYPES_H
69 #include <sys/bsdtypes.h>       /* needed for ISC */
70 #endif
71
72 #if HAVE_LIMITS_H
73 # include <limits.h>
74 #elif HAVE_SYS_PARAM_H
75 # include <sys/param.h>
76 #endif
77
78 #ifndef PATH_MAX
79 # if defined(_POSIX_PATH_MAX)
80 #  define PATH_MAX _POSIX_PATH_MAX
81 # elif defined(MAXPATHLEN)
82 #  define PATH_MAX MAXPATHLEN
83 # else
84 #  define PATH_MAX 255  /* the Posix minimum path-size */
85 # endif
86 #endif
87
88 #include <assert.h>
89 #include <stdio.h>
90
91 #include <errno.h>
92
93 #if DECL_ERRNO
94 extern int errno;
95 #endif
96
97 #include <nc_panel.h>
98
99 /* Some systems have a broken 'select()', but workable 'poll()'.  Use that */
100 #if HAVE_WORKING_POLL
101 #define USE_FUNC_POLL 1
102 #ifdef HAVE_POLL_H
103 #include <poll.h>
104 #else
105 #include <sys/poll.h>
106 #endif
107 #else
108 #define USE_FUNC_POLL 0
109 #endif
110
111 /* Alessandro Rubini's GPM (general-purpose mouse) */
112 #if HAVE_LIBGPM && HAVE_GPM_H
113 #define USE_GPM_SUPPORT 1
114 #else
115 #define USE_GPM_SUPPORT 0
116 #endif
117
118 /* QNX mouse support */
119 #if defined(__QNX__) && !defined(__QNXNTO__)
120 #define USE_QNX_MOUSE 1
121 #else
122 #define USE_QNX_MOUSE 0
123 #endif
124
125 /* EMX mouse support */
126 #ifdef __EMX__
127 #define USE_EMX_MOUSE
128 #endif
129
130 #define DEFAULT_MAXCLICK 166
131 #define EV_MAX          8       /* size of mouse circular event queue */
132
133 /*
134  * If we don't have signals to support it, don't add a sigwinch handler.
135  * In any case, resizing is an extended feature.  Use it if we've got it.
136  */
137 #ifndef NCURSES_EXT_FUNCS
138 #undef HAVE_SIZECHANGE
139 #endif
140
141 #if HAVE_SIZECHANGE
142 #define USE_SIZECHANGE 1
143 #else
144 #undef USE_SIGWINCH
145 #endif
146
147 /*
148  * Not all platforms have memmove; some have an equivalent bcopy.  (Some may
149  * have neither).
150  */
151 #if USE_OK_BCOPY
152 #define memmove(d,s,n) bcopy(s,d,n)
153 #elif USE_MY_MEMMOVE
154 #define memmove(d,s,n) _nc_memmove(d,s,n)
155 extern void * _nc_memmove(void *, const void *, size_t);
156 #endif
157
158 /*
159  * Scroll hints are useless when hashmap is used
160  */
161 #if !USE_SCROLL_HINTS
162 #if !USE_HASHMAP
163 #define USE_SCROLL_HINTS 1
164 #else
165 #define USE_SCROLL_HINTS 0
166 #endif
167 #endif
168
169 #if USE_SCROLL_HINTS
170 #define if_USE_SCROLL_HINTS(stmt) stmt
171 #else
172 #define if_USE_SCROLL_HINTS(stmt) /*nothing*/
173 #endif
174
175 /*
176  * Note:  ht/cbt expansion flakes out randomly under Linux 1.1.47, but only
177  * when we're throwing control codes at the screen at high volume.  To see
178  * this, re-enable USE_HARD_TABS and run worm for a while.  Other systems
179  * probably don't want to define this either due to uncertainties about tab
180  * delays and expansion in raw mode.
181  */
182
183 struct tries {
184         struct tries    *child;     /* ptr to child.  NULL if none          */
185         struct tries    *sibling;   /* ptr to sibling.  NULL if none        */
186         unsigned char    ch;        /* character at this node               */
187         unsigned short   value;     /* code of string so far.  0 if none.   */
188 };
189
190 /*
191  * Definitions for color pairs
192  */
193 #define C_SHIFT 8               /* we need more bits than there are colors */
194 #define C_MASK  ((1 << C_SHIFT) - 1)
195
196 #define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
197
198 /*
199  * Common/troublesome character definitions
200  */
201 #define L_BRACE '{'
202 #define R_BRACE '}'
203 #define S_QUOTE '\''
204
205 /*
206  * Structure for palette tables
207  */
208
209 typedef struct
210 {
211     short red, green, blue;
212 }
213 color_t;
214
215 #define MAXCOLUMNS    135
216 #define MAXLINES      66
217 #define FIFO_SIZE     MAXCOLUMNS+2  /* for nocbreak mode input */
218
219 #define ACS_LEN       128
220
221 #define WINDOWLIST struct _win_list
222
223 #include <curses.h>     /* we'll use -Ipath directive to get the right one! */
224
225 /*
226  * Structure for soft labels.
227  */
228
229 typedef struct
230 {
231         char *text;             /* text for the label */
232         char *form_text;        /* formatted text (left/center/...) */
233         int x;                  /* x coordinate of this field */
234         char dirty;             /* this label has changed */
235         char visible;           /* field is visible */
236 } slk_ent;
237
238 typedef struct {
239         char dirty;             /* all labels have changed */
240         char hidden;            /* soft labels are hidden */
241         struct _win_st *win;
242         slk_ent *ent;
243         char*  buffer;           /* buffer for labels */
244         short  maxlab;           /* number of available labels */
245         short  labcnt;           /* number of allocated labels */
246         short  maxlen;           /* length of labels */
247         chtype attr;             /* soft label attribute */
248 } SLK;
249
250 struct screen {
251         int             _ifd;           /* input file ptr for screen        */
252         FILE            *_ofp;          /* output file ptr for screen       */
253         char            *_setbuf;       /* buffered I/O for output          */
254         int             _buffered;      /* setvbuf uses _setbuf data        */
255         int             _checkfd;       /* filedesc for typeahead check     */
256         struct term     *_term;         /* terminal type information        */
257         short           _lines;         /* screen lines                     */
258         short           _columns;       /* screen columns                   */
259         short           _lines_avail;   /* lines available for stdscr       */
260         short           _topstolen;     /* lines stolen from top            */
261
262         WINDOW          *_curscr;       /* current screen                   */
263         WINDOW          *_newscr;       /* virtual screen to be updated to  */
264         WINDOW          *_stdscr;       /* screen's full-window context     */
265
266         struct tries    *_keytry;       /* "Try" for use with keypad mode   */
267         struct tries    *_key_ok;       /* Disabled keys via keyok(,FALSE)  */
268         int             _tried;         /* keypad mode was initialized      */
269
270         unsigned int    _fifo[FIFO_SIZE];       /* input push-back buffer   */
271         short           _fifohead,      /* head of fifo queue               */
272                         _fifotail,      /* tail of fifo queue               */
273                         _fifopeek,      /* where to peek for next char      */
274                         _fifohold;      /* set if breakout marked           */
275
276         int             _endwin;        /* are we out of window mode?       */
277         unsigned long   _current_attr;  /* terminal attribute current set   */
278         int             _coloron;       /* is color enabled?                */
279         int             _cursor;        /* visibility of the cursor         */
280         int             _cursrow;       /* physical cursor row              */
281         int             _curscol;       /* physical cursor column           */
282         int             _nl;            /* True if NL -> CR/NL is on        */
283         int             _raw;           /* True if in raw mode              */
284         int             _cbreak;        /* 1 if in cbreak mode              */
285                                         /* > 1 if in halfdelay mode         */
286         int             _echo;          /* True if echo on                  */
287         int             _use_meta;      /* use the meta key?                */
288         SLK             *_slk;          /* ptr to soft key struct / NULL    */
289         int             slk_format;     /* selected format for this screen  */
290         /* cursor movement costs; units are 10ths of milliseconds */
291 #ifdef NCURSES_NO_PADDING
292         int             _no_padding;    /* flag to set if padding disabled  */
293 #endif
294         int             _char_padding;  /* cost of character put            */
295         int             _cr_cost;       /* cost of (carriage_return)        */
296         int             _cup_cost;      /* cost of (cursor_address)         */
297         int             _home_cost;     /* cost of (cursor_home)            */
298         int             _ll_cost;       /* cost of (cursor_to_ll)           */
299 #if USE_HARD_TABS
300         int             _ht_cost;       /* cost of (tab)                    */
301         int             _cbt_cost;      /* cost of (backtab)                */
302 #endif /* USE_HARD_TABS */
303         int             _cub1_cost;     /* cost of (cursor_left)            */
304         int             _cuf1_cost;     /* cost of (cursor_right)           */
305         int             _cud1_cost;     /* cost of (cursor_down)            */
306         int             _cuu1_cost;     /* cost of (cursor_up)              */
307         int             _cub_cost;      /* cost of (parm_cursor_left)       */
308         int             _cuf_cost;      /* cost of (parm_cursor_right)      */
309         int             _cud_cost;      /* cost of (parm_cursor_down)       */
310         int             _cuu_cost;      /* cost of (parm_cursor_up)         */
311         int             _hpa_cost;      /* cost of (column_address)         */
312         int             _vpa_cost;      /* cost of (row_address)            */
313         /* used in tty_update.c, must be chars */
314         int             _ed_cost;       /* cost of (clr_eos)                */
315         int             _el_cost;       /* cost of (clr_eol)                */
316         int             _el1_cost;      /* cost of (clr_bol)                */
317         int             _dch1_cost;     /* cost of (delete_character)       */
318         int             _ich1_cost;     /* cost of (insert_character)       */
319         int             _dch_cost;      /* cost of (parm_dch)               */
320         int             _ich_cost;      /* cost of (parm_ich)               */
321         int             _ech_cost;      /* cost of (erase_chars)            */
322         int             _rep_cost;      /* cost of (repeat_char)            */
323         int             _hpa_ch_cost;   /* cost of (column_address)         */
324         int             _cup_ch_cost;   /* cost of (cursor_address)         */
325         int             _cuf_ch_cost;   /* cost of (parm_cursor_right)      */
326         int             _inline_cost;   /* cost of inline-move              */
327         int             _smir_cost;     /* cost of (enter_insert_mode)      */
328         int             _rmir_cost;     /* cost of (exit_insert_mode)       */
329         int             _ip_cost;       /* cost of (insert_padding)         */
330         /* used in lib_mvcur.c */
331         char *          _address_cursor;
332         int             _carriage_return_length;
333         int             _cursor_home_length;
334         int             _cursor_to_ll_length;
335         int             _scrolling;     /* 1 if terminal's smart enough to  */
336
337         /* used in lib_color.c */
338         color_t         *_color_table;  /* screen's color palette            */
339         int             _color_count;   /* count of colors in palette        */
340         unsigned short  *_color_pairs;  /* screen's color pair list          */
341         int             _pair_count;    /* count of color pairs              */
342 #ifdef NCURSES_EXT_FUNCS
343         bool            _default_color; /* use default colors                */
344         bool            _has_sgr_39_49; /* has ECMA default color support    */
345         int             _default_fg;    /* assumed default foreground        */
346         int             _default_bg;    /* assumed default background        */
347 #endif
348         chtype          _xmc_suppress;  /* attributes to suppress if xmc     */
349         chtype          _xmc_triggers;  /* attributes to process if xmc      */
350         chtype          _acs_map[ACS_LEN];
351
352         /* used in lib_vidattr.c */
353         bool            _use_rmso;      /* true if we may use 'rmso'         */
354         bool            _use_rmul;      /* true if we may use 'rmul'         */
355
356         /*
357          * These data correspond to the state of the idcok() and idlok()
358          * functions.  A caveat is in order here:  the XSI and SVr4
359          * documentation specify that these functions apply to the window which
360          * is given as an argument.  However, ncurses implements this logic
361          * only for the newscr/curscr update process, _not_ per-window.
362          */
363         bool            _nc_sp_idlok;
364         bool            _nc_sp_idcok;
365 #define _nc_idlok SP->_nc_sp_idlok
366 #define _nc_idcok SP->_nc_sp_idcok
367
368         /*
369          * These are the data that support the mouse interface.
370          */
371         int             _maxclick;
372         bool            (*_mouse_event) (SCREEN *);
373         bool            (*_mouse_inline)(SCREEN *);
374         bool            (*_mouse_parse) (int);
375         void            (*_mouse_resume)(SCREEN *);
376         void            (*_mouse_wrap)  (SCREEN *);
377         int             _mouse_fd;      /* file-descriptor, if any */
378
379         /*
380          * This supports automatic resizing
381          */
382 #if USE_SIZECHANGE
383         int             (*_resize)(int,int);
384 #endif
385
386         /*
387          * These are data that support the proper handling of the panel stack on an
388          * per screen basis.
389          */
390         struct panelhook _panelHook;
391         /*
392          * Linked-list of all windows, to support '_nc_resizeall()' and
393          * '_nc_freeall()'
394          */
395         WINDOWLIST      *_nc_sp_windows;
396 #define _nc_windows SP->_nc_sp_windows
397
398         bool            _sig_winch;
399         SCREEN          *_next_screen;
400
401         /* hashes for old and new lines */
402         unsigned long   *oldhash, *newhash;
403
404         bool            _cleanup;       /* cleanup after int/quit signal */
405         int             (*_outch)(int); /* output handler if not putc */
406 };
407
408 extern SCREEN *_nc_screen_chain;
409
410 #ifdef NCURSES_NOMACROS
411 #include <nomacros.h>
412 #endif
413
414         WINDOWLIST {
415         WINDOWLIST *next;
416         WINDOW  *win;
417 };
418
419 typedef struct {
420         int     line;                   /* lines to take, < 0 => from bottom*/
421         int     (*hook)(struct _win_st *, int); /* callback for user        */
422         struct _win_st *w;              /* maybe we need this for cleanup   */
423 } ripoff_t;
424
425 /* The terminfo source is assumed to be 7-bit ASCII */
426 #define is7bits(c)      ((unsigned)(c) < 128)
427
428 #ifndef min
429 #define min(a,b)        ((a) > (b)  ?  (b)  :  (a))
430 #endif
431
432 #ifndef max
433 #define max(a,b)        ((a) < (b)  ?  (b)  :  (a))
434 #endif
435
436 /* usually in <unistd.h> */
437 #ifndef STDIN_FILENO
438 #define STDIN_FILENO 0
439 #endif
440
441 #ifndef STDOUT_FILENO
442 #define STDOUT_FILENO 1
443 #endif
444
445 #ifndef STDERR_FILENO
446 #define STDERR_FILENO 2
447 #endif
448
449 #ifndef EXIT_SUCCESS
450 #define EXIT_SUCCESS 0
451 #endif
452
453 #ifndef EXIT_FAILURE
454 #define EXIT_FAILURE 1
455 #endif
456
457 #ifndef R_OK
458 #define R_OK    4               /* Test for read permission.  */
459 #endif
460 #ifndef W_OK
461 #define W_OK    2               /* Test for write permission.  */
462 #endif
463 #ifndef X_OK
464 #define X_OK    1               /* Test for execute permission.  */
465 #endif
466 #ifndef F_OK
467 #define F_OK    0               /* Test for existence.  */
468 #endif
469
470 #if HAVE_FCNTL_H
471 #include <fcntl.h>              /* may define O_BINARY  */
472 #endif
473
474 #ifndef O_BINARY
475 #define O_BINARY 0
476 #endif
477
478 #define TextOf(c)    ((c) & (chtype)A_CHARTEXT)
479 #define AttrOf(c)    ((c) & (chtype)A_ATTRIBUTES)
480
481 #define BLANK        (' '|A_NORMAL)
482
483 #define CHANGED     -1
484
485 #define CHANGED_CELL(line,col) \
486         if (line->firstchar == _NOCHANGE) \
487                 line->firstchar = line->lastchar = col; \
488         else if ((col) < line->firstchar) \
489                 line->firstchar = col; \
490         else if ((col) > line->lastchar) \
491                 line->lastchar = col
492
493 #define CHANGED_RANGE(line,start,end) \
494         if (line->firstchar == _NOCHANGE \
495          || line->firstchar > (start)) \
496                 line->firstchar = start; \
497         if (line->lastchar == _NOCHANGE \
498          || line->lastchar < (end)) \
499                 line->lastchar = end
500
501 #define CHANGED_TO_EOL(line,start,end) \
502         if (line->firstchar == _NOCHANGE \
503          || line->firstchar > (start)) \
504                 line->firstchar = start; \
505         line->lastchar = end
506
507 #define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
508
509 #define FreeIfNeeded(p)  if ((p) != 0) free(p)
510
511 /* FreeAndNull() is not a comma-separated expression because some compilers
512  * do not accept a mixture of void with values.
513  */
514 #define FreeAndNull(p)   free(p); p = 0
515
516 #include <nc_alloc.h>
517
518 /*
519  * Prefixes for call/return points of library function traces.  We use these to
520  * instrument the public functions so that the traces can be easily transformed
521  * into regression scripts.
522  */
523 #define T_CALLED(fmt) "called " fmt
524 #define T_CREATE(fmt) "create " fmt
525 #define T_RETURN(fmt) "return " fmt
526
527 #ifdef TRACE
528 #define TR(n, a)        if (_nc_tracing & (n)) _tracef a
529 #define T(a)            TR(TRACE_CALLS, a)
530 #define TPUTS_TRACE(s)  _nc_tputs_trace = s;
531 #define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
532 #define returnAttr(code) TRACE_RETURN(code,attr_t)
533 #define returnCode(code) TRACE_RETURN(code,int)
534 #define returnPtr(code)  TRACE_RETURN(code,ptr)
535 #define returnVoid       T((T_RETURN(""))); return
536 #define returnWin(code)  TRACE_RETURN(code,win)
537 extern WINDOW * _nc_retrace_win(WINDOW *);
538 extern attr_t _nc_retrace_attr_t(attr_t);
539 extern char *_nc_retrace_ptr(char *);
540 extern const char *_nc_tputs_trace;
541 extern int _nc_retrace_int(int);
542 extern long _nc_outchars;
543 extern void _nc_fifo_dump(void);
544 #else
545 #define T(a)
546 #define TR(n, a)
547 #define TPUTS_TRACE(s)
548 #define returnAttr(code) return code
549 #define returnCode(code) return code
550 #define returnPtr(code)  return code
551 #define returnVoid       return
552 #define returnWin(code)  return code
553 #endif
554
555 extern unsigned _nc_tracing;
556 extern const char *_nc_visbuf2(int, const char *);
557
558 #define _trace_key(ch) ((ch > KEY_MIN) ? keyname(ch) : _tracechar((unsigned char)ch))
559
560 #define ALL_BUT_COLOR ((chtype)~(A_COLOR))
561 #define IGNORE_COLOR_OFF FALSE
562 #define NONBLANK_ATTR (A_BOLD|A_DIM|A_BLINK)
563 #define XMC_CHANGES(c) ((c) & SP->_xmc_suppress)
564
565
566 #define toggle_attr_on(S,at) {\
567    if (PAIR_NUMBER(at) > 0)\
568       (S) = ((S) & ALL_BUT_COLOR) | (at);\
569    else\
570       (S) |= (at);\
571    T(("new attribute is %s", _traceattr((S))));}
572
573
574 #define toggle_attr_off(S,at) {\
575    if (IGNORE_COLOR_OFF == TRUE) {\
576       if (PAIR_NUMBER(at) == 0xff) /* turn off color */\
577          (S) &= ~(at);\
578       else /* leave color alone */\
579          (S) &= ~((at)&ALL_BUT_COLOR);\
580    } else {\
581       if (PAIR_NUMBER(at) > 0x00) /* turn off color */\
582          (S) &= ~(at|A_COLOR);\
583       else /* leave color alone */\
584          (S) &= ~(at);\
585    }\
586    T(("new attribute is %s", _traceattr((S))));}
587
588 #define DelCharCost(count) \
589                 ((parm_dch != 0) \
590                 ? SP->_dch_cost \
591                 : ((delete_character != 0) \
592                         ? (SP->_dch1_cost * count) \
593                         : INFINITY))
594
595 #define InsCharCost(count) \
596                 ((parm_ich != 0) \
597                 ? SP->_ich_cost \
598                 : ((enter_insert_mode && exit_insert_mode) \
599                   ? SP->_smir_cost + SP->_rmir_cost + (SP->_ip_cost * count) \
600                   : ((insert_character != 0) \
601                     ? (SP->_ich1_cost * count) \
602                     : INFINITY)))
603
604 #if USE_XMC_SUPPORT
605 #define UpdateAttrs(c)  if (SP->_current_attr != AttrOf(c)) { \
606                                 attr_t chg = SP->_current_attr; \
607                                 vidattr(AttrOf(c)); \
608                                 if (magic_cookie_glitch > 0 \
609                                  && XMC_CHANGES((chg ^ SP->_current_attr))) { \
610                                         T(("%s @%d before glitch %d,%d", \
611                                                 __FILE__, __LINE__, \
612                                                 SP->_cursrow, \
613                                                 SP->_curscol)); \
614                                         _nc_do_xmc_glitch(chg); \
615                                 } \
616                         }
617 #else
618 #define UpdateAttrs(c)  if (SP->_current_attr != AttrOf(c)) \
619                                 vidattr(AttrOf(c))
620 #endif
621
622 #if defined(NCURSES_EXPANDED) && defined(NCURSES_EXT_FUNCS)
623
624 #undef  toggle_attr_on
625 #define toggle_attr_on(S,at) _nc_toggle_attr_on(&(S), at)
626 extern void _nc_toggle_attr_on(attr_t *, attr_t);
627
628 #undef  toggle_attr_off
629 #define toggle_attr_off(S,at) _nc_toggle_attr_off(&(S), at)
630 extern void _nc_toggle_attr_off(attr_t *, attr_t);
631
632 #undef  DelCharCost
633 #define DelCharCost(count) _nc_DelCharCost(count)
634 extern int _nc_DelCharCost(int);
635
636 #undef  InsCharCost
637 #define InsCharCost(count) _nc_InsCharCost(count)
638 extern int _nc_InsCharCost(int);
639
640 #undef  UpdateAttrs
641 #define UpdateAttrs(c) _nc_UpdateAttrs(c)
642 extern void _nc_UpdateAttrs(chtype);
643
644 #else
645
646 extern void _nc_expanded(void);
647
648 #endif
649
650 #if !HAVE_GETCWD
651 #define getcwd(buf,len) getwd(buf)
652 #endif
653
654 /* doupdate.c */
655 #if USE_XMC_SUPPORT
656 extern void _nc_do_xmc_glitch(attr_t);
657 #endif
658
659 /* hardscroll.c */
660 #if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
661 extern void _nc_linedump(void);
662 #endif
663
664 /* lib_acs.c */
665 extern void _nc_init_acs(void); /* corresponds to traditional 'init_acs()' */
666 extern int _nc_msec_cost(const char *const, int);  /* used by 'tack' program */
667
668 /* lib_mvcur.c */
669 #define INFINITY        1000000 /* cost: too high to use */
670
671 extern void _nc_mvcur_init(void);
672 extern void _nc_mvcur_resume(void);
673 extern void _nc_mvcur_wrap(void);
674
675 extern int _nc_scrolln(int, int, int, int);
676
677 extern void _nc_screen_init(void);
678 extern void _nc_screen_resume(void);
679 extern void _nc_screen_wrap(void);
680
681 #if !HAVE_STRSTR
682 #define strstr _nc_strstr
683 extern char *_nc_strstr(const char *, const char *);
684 #endif
685
686 /* lib_mouse.c */
687 extern int _nc_has_mouse(void);
688
689 /* safe_sprintf.c */
690 extern char * _nc_printf_string(const char *fmt, va_list ap);
691
692 /* tries.c */
693 extern void _nc_add_to_try(struct tries **tree, const char *str, unsigned short code);
694 extern char *_nc_expand_try(struct tries *tree, unsigned short code, int *count, size_t len);
695 extern int _nc_remove_key(struct tries **tree, unsigned short code);
696 extern int _nc_remove_string(struct tries **tree, char *string);
697
698 /* elsewhere ... */
699 extern WINDOW *_nc_makenew(int, int, int, int, int);
700 extern char *_nc_home_terminfo(void);
701 extern char *_nc_trace_buf(int, size_t);
702 extern chtype _nc_background(WINDOW *);
703 extern chtype _nc_render(WINDOW *, chtype);
704 extern int _nc_access(const char *, int);
705 extern int _nc_baudrate(int);
706 extern int _nc_getenv_num(const char *);
707 extern int _nc_keypad(bool);
708 extern int _nc_ospeed(int);
709 extern int _nc_outch(int);
710 extern int _nc_setupscreen(short, short const, FILE *);
711 extern int _nc_timed_wait(int, int, int *);
712 extern int _nc_waddch_nosync(WINDOW *, const chtype);
713 extern void _nc_do_color(int, int, bool, int (*)(int));
714 extern void _nc_freeall(void);
715 extern void _nc_freewin(WINDOW *win);
716 extern void _nc_hash_map(void);
717 extern void _nc_init_keytry(void);
718 extern void _nc_keep_tic_dir(const char *);
719 extern void _nc_make_oldhash(int i);
720 extern void _nc_flush(void);
721 extern void _nc_outstr(const char *str);
722 extern void _nc_scroll_oldhash(int n, int top, int bot);
723 extern void _nc_scroll_optimize(void);
724 extern void _nc_scroll_window(WINDOW *, int const, short const, short const, chtype);
725 extern void _nc_set_buffer(FILE *, bool);
726 extern void _nc_signal_handler(bool);
727 extern void _nc_synchook(WINDOW *win);
728 extern void _nc_trace_tries(struct tries *tree);
729
730 #if USE_SIZECHANGE
731 extern void _nc_update_screensize(void);
732 #endif
733
734 #ifdef USE_WIDEC_SUPPORT
735 extern int _nc_utf8_outch(int);
736 #endif
737
738 /* scroll indices */
739 extern int *_nc_oldnums;
740
741 #define USE_SETBUF_0 0
742
743 #define NC_BUFFERED(flag) \
744         if ((SP->_buffered != 0) != flag) \
745                 _nc_set_buffer(SP->_ofp, flag)
746
747 #define NC_OUTPUT ((SP != 0) ? SP->_ofp : stdout)
748
749 /*
750  * On systems with a broken linker, define 'SP' as a function to force the
751  * linker to pull in the data-only module with 'SP'.
752  */
753 #ifndef BROKEN_LINKER
754 #define BROKEN_LINKER 0
755 #endif
756
757 #if BROKEN_LINKER
758 #define SP _nc_screen()
759 extern SCREEN *_nc_screen(void);
760 extern int _nc_alloc_screen(void);
761 extern void _nc_set_screen(SCREEN *);
762 #else
763 /* current screen is private data; avoid possible linking conflicts too */
764 extern SCREEN *SP;
765 #define _nc_alloc_screen() ((SP = typeCalloc(SCREEN, 1)) != 0)
766 #define _nc_set_screen(sp) SP = sp
767 #endif
768
769 /*
770  * We don't want to use the lines or columns capabilities internally,
771  * because if the application is running multiple screens under
772  * X windows, it's quite possible they could all have type xterm
773  * but have different sizes!  So...
774  */
775 #define screen_lines    SP->_lines
776 #define screen_columns  SP->_columns
777
778 extern int _nc_slk_format;  /* != 0 if slk_init() called */
779 extern int _nc_slk_initialize(WINDOW *, int);
780
781 /*
782  * Some constants related to SLK's
783  */
784 #define MAX_SKEY_OLD       8    /* count of soft keys */
785 #define MAX_SKEY_LEN_OLD   8    /* max length of soft key text */
786 #define MAX_SKEY_PC       12    /* This is what most PC's have */
787 #define MAX_SKEY_LEN_PC    5
788
789 /* Macro to check whether or not we use a standard format */
790 #define SLK_STDFMT(fmt) (fmt < 3)
791 /* Macro to determine height of label window */
792 #define SLK_LINES(fmt)  (SLK_STDFMT(fmt) ? 1 : ((fmt) - 2))
793
794 #define MAX_SKEY(fmt)     (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC)
795 #define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC)
796
797 extern int _nc_ripoffline(int line, int (*init)(WINDOW *,int));
798
799 #ifdef __cplusplus
800 }
801 #endif
802
803 #endif /* CURSES_PRIV_H */