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