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