1 /****************************************************************************
2 * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
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: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
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. *
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 *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
31 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
32 * and: Thomas E. Dickey 1996-2002 *
33 ****************************************************************************/
37 * $Id: curses.priv.h,v 1.219 2002/05/25 12:22:43 tom Exp $
41 * Header file for curses library objects which are private to
47 #define CURSES_PRIV_H 1
49 #include <ncurses_dll.h>
55 #include <ncurses_cfg.h>
58 #define MODULE_ID(id) static const char Ident[] = id;
60 #define MODULE_ID(id) /*nothing*/
65 #include <sys/types.h>
71 #if HAVE_SYS_BSDTYPES_H
72 #include <sys/bsdtypes.h> /* needed for ISC */
77 #elif HAVE_SYS_PARAM_H
78 # include <sys/param.h>
82 # if defined(_POSIX_PATH_MAX)
83 # define PATH_MAX _POSIX_PATH_MAX
84 # elif defined(MAXPATHLEN)
85 # define PATH_MAX MAXPATHLEN
87 # define PATH_MAX 255 /* the Posix minimum path-size */
100 #include <nc_panel.h>
102 /* Some systems have a broken 'select()', but workable 'poll()'. Use that */
103 #if HAVE_WORKING_POLL
104 #define USE_FUNC_POLL 1
108 #include <sys/poll.h>
111 #define USE_FUNC_POLL 0
114 /* include signal.h before curses.h to work-around defect in glibc 2.1.3 */
117 /* Alessandro Rubini's GPM (general-purpose mouse) */
118 #if HAVE_LIBGPM && HAVE_GPM_H
119 #define USE_GPM_SUPPORT 1
121 #define USE_GPM_SUPPORT 0
124 /* QNX mouse support */
125 #if defined(__QNX__) && !defined(__QNXNTO__)
126 #define USE_QNX_MOUSE 1
128 #define USE_QNX_MOUSE 0
131 /* EMX mouse support */
133 #define USE_EMX_MOUSE
136 #define DEFAULT_MAXCLICK 166
137 #define EV_MAX 8 /* size of mouse circular event queue */
140 * If we don't have signals to support it, don't add a sigwinch handler.
141 * In any case, resizing is an extended feature. Use it if we've got it.
143 #if !NCURSES_EXT_FUNCS
144 #undef HAVE_SIZECHANGE
147 #if HAVE_SIZECHANGE && defined(SIGWINCH)
148 #define USE_SIZECHANGE 1
154 * If desired, one can configure this, disabling environment variables that
155 * point to custom terminfo/termcap locations.
157 #ifdef USE_ROOT_ENVIRON
158 #define use_terminfo_vars() 1
160 #define use_terminfo_vars() _nc_env_access()
161 extern NCURSES_EXPORT(int) _nc_env_access (void);
165 * Not all platforms have memmove; some have an equivalent bcopy. (Some may
169 #define memmove(d,s,n) bcopy(s,d,n)
171 #define memmove(d,s,n) _nc_memmove(d,s,n)
172 extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t);
176 * Scroll hints are useless when hashmap is used
178 #if !USE_SCROLL_HINTS
180 #define USE_SCROLL_HINTS 1
182 #define USE_SCROLL_HINTS 0
187 #define if_USE_SCROLL_HINTS(stmt) stmt
189 #define if_USE_SCROLL_HINTS(stmt) /*nothing*/
193 * Note: ht/cbt expansion flakes out randomly under Linux 1.1.47, but only
194 * when we're throwing control codes at the screen at high volume. To see
195 * this, re-enable USE_HARD_TABS and run worm for a while. Other systems
196 * probably don't want to define this either due to uncertainties about tab
197 * delays and expansion in raw mode.
201 struct tries *child; /* ptr to child. NULL if none */
202 struct tries *sibling; /* ptr to sibling. NULL if none */
203 unsigned char ch; /* character at this node */
204 unsigned short value; /* code of string so far. 0 if none. */
208 * Definitions for color pairs
210 #define C_SHIFT 8 /* we need more bits than there are colors */
211 #define C_MASK ((1 << C_SHIFT) - 1)
213 #define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
216 * Common/troublesome character definitions
223 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
226 * Structure for palette tables
231 short red, green, blue;
235 #define MAXCOLUMNS 135
237 #define FIFO_SIZE MAXCOLUMNS+2 /* for nocbreak mode input */
241 #define WINDOWLIST struct _win_list
243 #if USE_WIDEC_SUPPORT
244 #define _nc_bkgd _bkgrnd
246 #undef _XOPEN_SOURCE_EXTENDED
247 #define _nc_bkgd _bkgd
248 #define wgetbkgrnd(win, wch) *wch = win->_bkgd
249 #define wbkgrnd wbkgd
252 #include <curses.h> /* we'll use -Ipath directive to get the right one! */
257 NCURSES_CH_T *text; /* text of the line */
258 NCURSES_SIZE_T firstchar; /* first changed character in the line */
259 NCURSES_SIZE_T lastchar; /* last changed character in the line */
260 NCURSES_SIZE_T oldindex; /* index of the line at last update */
264 * Structure for soft labels.
269 char *text; /* text for the label */
270 char *form_text; /* formatted text (left/center/...) */
271 int x; /* x coordinate of this field */
272 char dirty; /* this label has changed */
273 char visible; /* field is visible */
277 char dirty; /* all labels have changed */
278 char hidden; /* soft labels are hidden */
281 char* buffer; /* buffer for labels */
282 short maxlab; /* number of available labels */
283 short labcnt; /* number of allocated labels */
284 short maxlen; /* length of labels */
285 chtype attr; /* soft label attribute */
289 unsigned long hashval;
290 int oldcount, newcount;
291 int oldindex, newindex;
295 int _ifd; /* input file ptr for screen */
296 FILE *_ofp; /* output file ptr for screen */
297 char *_setbuf; /* buffered I/O for output */
298 int _buffered; /* setvbuf uses _setbuf data */
299 int _checkfd; /* filedesc for typeahead check */
300 struct term *_term; /* terminal type information */
301 short _lines; /* screen lines */
302 short _columns; /* screen columns */
303 short _lines_avail; /* lines available for stdscr */
304 short _topstolen; /* lines stolen from top */
306 WINDOW *_curscr; /* current screen */
307 WINDOW *_newscr; /* virtual screen to be updated to */
308 WINDOW *_stdscr; /* screen's full-window context */
310 struct tries *_keytry; /* "Try" for use with keypad mode */
311 struct tries *_key_ok; /* Disabled keys via keyok(,FALSE) */
312 bool _tried; /* keypad mode was initialized */
313 bool _keypad_on; /* keypad mode is currently on */
315 unsigned int _fifo[FIFO_SIZE]; /* input push-back buffer */
316 short _fifohead, /* head of fifo queue */
317 _fifotail, /* tail of fifo queue */
318 _fifopeek, /* where to peek for next char */
319 _fifohold; /* set if breakout marked */
321 int _endwin; /* are we out of window mode? */
322 attr_t _current_attr; /* terminal attribute current set */
323 int _coloron; /* is color enabled? */
324 int _cursor; /* visibility of the cursor */
325 int _cursrow; /* physical cursor row */
326 int _curscol; /* physical cursor column */
327 int _nl; /* True if NL -> CR/NL is on */
328 int _raw; /* True if in raw mode */
329 int _cbreak; /* 1 if in cbreak mode */
330 /* > 1 if in halfdelay mode */
331 int _echo; /* True if echo on */
332 int _use_meta; /* use the meta key? */
333 SLK *_slk; /* ptr to soft key struct / NULL */
334 int slk_format; /* selected format for this screen */
335 /* cursor movement costs; units are 10ths of milliseconds */
336 #if NCURSES_NO_PADDING
337 int _no_padding; /* flag to set if padding disabled */
339 int _char_padding; /* cost of character put */
340 int _cr_cost; /* cost of (carriage_return) */
341 int _cup_cost; /* cost of (cursor_address) */
342 int _home_cost; /* cost of (cursor_home) */
343 int _ll_cost; /* cost of (cursor_to_ll) */
345 int _ht_cost; /* cost of (tab) */
346 int _cbt_cost; /* cost of (backtab) */
347 #endif /* USE_HARD_TABS */
348 int _cub1_cost; /* cost of (cursor_left) */
349 int _cuf1_cost; /* cost of (cursor_right) */
350 int _cud1_cost; /* cost of (cursor_down) */
351 int _cuu1_cost; /* cost of (cursor_up) */
352 int _cub_cost; /* cost of (parm_cursor_left) */
353 int _cuf_cost; /* cost of (parm_cursor_right) */
354 int _cud_cost; /* cost of (parm_cursor_down) */
355 int _cuu_cost; /* cost of (parm_cursor_up) */
356 int _hpa_cost; /* cost of (column_address) */
357 int _vpa_cost; /* cost of (row_address) */
358 /* used in tty_update.c, must be chars */
359 int _ed_cost; /* cost of (clr_eos) */
360 int _el_cost; /* cost of (clr_eol) */
361 int _el1_cost; /* cost of (clr_bol) */
362 int _dch1_cost; /* cost of (delete_character) */
363 int _ich1_cost; /* cost of (insert_character) */
364 int _dch_cost; /* cost of (parm_dch) */
365 int _ich_cost; /* cost of (parm_ich) */
366 int _ech_cost; /* cost of (erase_chars) */
367 int _rep_cost; /* cost of (repeat_char) */
368 int _hpa_ch_cost; /* cost of (column_address) */
369 int _cup_ch_cost; /* cost of (cursor_address) */
370 int _cuf_ch_cost; /* cost of (parm_cursor_right) */
371 int _inline_cost; /* cost of inline-move */
372 int _smir_cost; /* cost of (enter_insert_mode) */
373 int _rmir_cost; /* cost of (exit_insert_mode) */
374 int _ip_cost; /* cost of (insert_padding) */
375 /* used in lib_mvcur.c */
376 char * _address_cursor;
377 /* used in tty_update.c */
378 int _scrolling; /* 1 if terminal's smart enough to */
380 /* used in lib_color.c */
381 color_t *_color_table; /* screen's color palette */
382 int _color_count; /* count of colors in palette */
383 unsigned short *_color_pairs; /* screen's color pair list */
384 int _pair_count; /* count of color pairs */
385 #if NCURSES_EXT_FUNCS
386 bool _default_color; /* use default colors */
387 bool _has_sgr_39_49; /* has ECMA default color support */
388 int _default_fg; /* assumed default foreground */
389 int _default_bg; /* assumed default background */
391 chtype _xmc_suppress; /* attributes to suppress if xmc */
392 chtype _xmc_triggers; /* attributes to process if xmc */
393 chtype _acs_map[ACS_LEN];
395 /* used in lib_vidattr.c */
396 bool _use_rmso; /* true if we may use 'rmso' */
397 bool _use_rmul; /* true if we may use 'rmul' */
400 * These data correspond to the state of the idcok() and idlok()
401 * functions. A caveat is in order here: the XSI and SVr4
402 * documentation specify that these functions apply to the window which
403 * is given as an argument. However, ncurses implements this logic
404 * only for the newscr/curscr update process, _not_ per-window.
408 #define _nc_idlok SP->_nc_sp_idlok
409 #define _nc_idcok SP->_nc_sp_idcok
412 * These are the data that support the mouse interface.
415 bool (*_mouse_event) (SCREEN *);
416 bool (*_mouse_inline)(SCREEN *);
417 bool (*_mouse_parse) (int);
418 void (*_mouse_resume)(SCREEN *);
419 void (*_mouse_wrap) (SCREEN *);
420 int _mouse_fd; /* file-descriptor, if any */
423 * This supports automatic resizing
426 int (*_resize)(int,int);
430 * These are data that support the proper handling of the panel stack on an
433 struct panelhook _panelHook;
435 * Linked-list of all windows, to support '_nc_resizeall()' and
438 WINDOWLIST *_nc_sp_windows;
439 #define _nc_windows SP->_nc_sp_windows
442 SCREEN *_next_screen;
444 /* hashes for old and new lines */
445 unsigned long *oldhash, *newhash;
449 bool _cleanup; /* cleanup after int/quit signal */
450 int (*_outch)(int); /* output handler if not putc */
453 extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
456 #include <nomacros.h>
460 * The margins are used in resizeterm() to retain the original layout after
475 int line; /* lines to take, < 0 => from bottom*/
476 int (*hook)(struct _win_st *, int); /* callback for user */
477 struct _win_st *w; /* maybe we need this for cleanup */
480 /* The terminfo source is assumed to be 7-bit ASCII */
481 #define is7bits(c) ((unsigned)(c) < 128)
484 #define min(a,b) ((a) > (b) ? (b) : (a))
488 #define max(a,b) ((a) < (b) ? (b) : (a))
491 /* usually in <unistd.h> */
493 #define STDIN_FILENO 0
496 #ifndef STDOUT_FILENO
497 #define STDOUT_FILENO 1
500 #ifndef STDERR_FILENO
501 #define STDERR_FILENO 2
505 #define EXIT_SUCCESS 0
509 #define EXIT_FAILURE 1
513 #define R_OK 4 /* Test for read permission. */
516 #define W_OK 2 /* Test for write permission. */
519 #define X_OK 1 /* Test for execute permission. */
522 #define F_OK 0 /* Test for existence. */
526 #include <fcntl.h> /* may define O_BINARY */
533 #define UChar(c) ((unsigned char)(c))
534 #define ChCharOf(c) ((c) & (chtype)A_CHARTEXT)
535 #define ChAttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
537 #if USE_WIDEC_SUPPORT /* { */
538 #define CharOf(c) ((c).chars[0])
539 #define AttrOf(c) ((c).attr)
540 #define AddAttr(c,a) (c).attr |= a
541 #define RemAttr(c,a) (c).attr &= ~(a)
542 #define SetAttr(c,a) (c).attr = a
543 #define NewChar(ch) { ChAttrOf(ch), { ChCharOf(ch) } }
544 #define NewChar2(c,a) { a, { c } }
545 #define CharEq(a,b) (!memcmp(&a, &b, sizeof(a)))
546 #define SetChar(ch,c,a) do { \
547 NCURSES_CH_T *_cp = &ch; \
548 memset(_cp,0,sizeof(ch)); _cp->chars[0] = c; _cp->attr = a; \
550 #define CHREF(wch) (&wch)
551 #define CHDEREF(wch) (*wch)
552 #define ARG_CH_T NCURSES_CH_T *
553 #define CARG_CH_T const NCURSES_CH_T *
554 #define PUTC_DATA char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \
555 mbstate_t PUT_st; wchar_t PUTC_ch
556 #define PUTC(ch,b) do { if(!isnac(ch)) { \
557 memset (&PUT_st, '\0', sizeof (PUT_st)); \
560 PUTC_ch = PUTC_i < CCHARW_MAX ? \
561 (ch).chars[PUTC_i] : L'\0'; \
562 PUTC_n = wcrtomb(PUTC_buf, \
563 (ch).chars[PUTC_i], &PUT_st); \
564 if (PUTC_ch == L'\0') \
568 fwrite(PUTC_buf, (unsigned) PUTC_n, 1, b); \
570 } while (PUTC_ch != L'\0'); \
573 #define BLANK { WA_NORMAL, ' ' }
574 #define ISBLANK(ch) ((ch).chars[0] == L' ' && (ch).chars[1] == L'\0')
577 #define isnac(ch) (AttrOf(ch) & WA_NAC)
578 #define if_WIDEC(code) code
579 #define Charable(ch) (!isnac(ch) && \
580 (ch).chars[1] == L'\0' && \
581 (wctob(CharOf(ch)) == (char)CharOf(ch)))
583 #define L(ch) L ## ch
585 #define CharOf(c) ChCharOf(c)
586 #define AttrOf(c) ChAttrOf(c)
587 #define AddAttr(c,a) c |= a
588 #define RemAttr(c,a) c &= ~(a & A_ATTRIBUTES)
589 #define SetAttr(c,a) c = (c & ~A_ATTRIBUTES) | a
590 #define NewChar(ch) (ch)
591 #define NewChar2(c,a) (c | a)
592 #define CharEq(a,b) (a == b)
593 #define SetChar(ch,c,a) ch = c | a
594 #define CHREF(wch) wch
595 #define CHDEREF(wch) wch
596 #define ARG_CH_T NCURSES_CH_T
597 #define CARG_CH_T NCURSES_CH_T
598 #define PUTC_DATA int data = 0
599 #define PUTC(a,b) do { data = CharOf(ch); putc(data,b); } while (0)
601 #define BLANK (' '|A_NORMAL)
602 #define ISBLANK(ch) (CharOf(ch) == ' ')
604 #define isnac(ch) (0)
605 #define if_WIDEC(code) /* nothing */
610 #define AttrOfD(ch) AttrOf(CHDEREF(ch))
611 #define CharOfD(ch) CharOf(CHDEREF(ch))
612 #define SetChar2(wch,ch) SetChar(wch,ChCharOf(ch),ChAttrOf(ch))
614 #define BLANK_ATTR A_NORMAL
615 #define BLANK_TEXT L(' ')
619 #define CHANGED_CELL(line,col) \
620 if (line->firstchar == _NOCHANGE) \
621 line->firstchar = line->lastchar = col; \
622 else if ((col) < line->firstchar) \
623 line->firstchar = col; \
624 else if ((col) > line->lastchar) \
627 #define CHANGED_RANGE(line,start,end) \
628 if (line->firstchar == _NOCHANGE \
629 || line->firstchar > (start)) \
630 line->firstchar = start; \
631 if (line->lastchar == _NOCHANGE \
632 || line->lastchar < (end)) \
635 #define CHANGED_TO_EOL(line,start,end) \
636 if (line->firstchar == _NOCHANGE \
637 || line->firstchar > (start)) \
638 line->firstchar = start; \
641 #define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
643 #define FreeIfNeeded(p) if ((p) != 0) free(p)
645 /* FreeAndNull() is not a comma-separated expression because some compilers
646 * do not accept a mixture of void with values.
648 #define FreeAndNull(p) free(p); p = 0
650 #include <nc_alloc.h>
653 * Prefixes for call/return points of library function traces. We use these to
654 * instrument the public functions so that the traces can be easily transformed
655 * into regression scripts.
657 #define T_CALLED(fmt) "called {" fmt
658 #define T_CREATE(fmt) "create :" fmt
659 #define T_RETURN(fmt) "return }" fmt
662 #define TR(n, a) if (_nc_tracing & (n)) _tracef a
663 #define T(a) TR(TRACE_CALLS, a)
664 #define TPUTS_TRACE(s) _nc_tputs_trace = s;
665 #define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
666 #define returnAttr(code) TRACE_RETURN(code,attr_t)
667 #define returnChar(code) TRACE_RETURN(code,chtype)
668 #define returnCode(code) TRACE_RETURN(code,int)
669 #define returnPtr(code) TRACE_RETURN(code,ptr)
670 #define returnSP(code) TRACE_RETURN(code,sp)
671 #define returnVoid T((T_RETURN(""))); return
672 #define returnWin(code) TRACE_RETURN(code,win)
673 extern NCURSES_EXPORT(SCREEN *) _nc_retrace_sp (SCREEN *);
674 extern NCURSES_EXPORT(WINDOW *) _nc_retrace_win (WINDOW *);
675 extern NCURSES_EXPORT(attr_t) _nc_retrace_attr_t (attr_t);
676 extern NCURSES_EXPORT(attr_t) _nc_retrace_chtype (chtype);
677 extern NCURSES_EXPORT(char *) _nc_retrace_ptr (char *);
678 extern NCURSES_EXPORT(char *) _nc_trace_ttymode(TTY *tty);
679 extern NCURSES_EXPORT(char *) _nc_varargs (const char *, va_list);
680 extern NCURSES_EXPORT(const char *) _nc_altcharset_name(attr_t, chtype);
681 extern NCURSES_EXPORT(int) _nc_retrace_int (int);
682 extern NCURSES_EXPORT(void) _nc_fifo_dump (void);
683 extern NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace;
684 extern NCURSES_EXPORT_VAR(long) _nc_outchars;
685 extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
686 #if USE_WIDEC_SUPPORT
687 extern NCURSES_EXPORT(const char *) _nc_viswbuf2 (int, const wchar_t *);
688 extern NCURSES_EXPORT(const char *) _nc_viscbuf2 (int, const cchar_t *, int);
689 extern NCURSES_EXPORT(const char *) _nc_viscbuf (const cchar_t *, int);
694 #define TPUTS_TRACE(s)
695 #define returnAttr(code) return code
696 #define returnChar(code) return code
697 #define returnCode(code) return code
698 #define returnPtr(code) return code
699 #define returnSP(code) return code
700 #define returnVoid return
701 #define returnWin(code) return code
704 #define empty_module(name) \
705 extern NCURSES_EXPORT(void) name (void); \
706 NCURSES_EXPORT(void) name (void) { }
708 /* used in _nc_visbuf() whether or not we're tracing */
709 extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
711 #define ALL_BUT_COLOR ((chtype)~(A_COLOR))
712 #define IGNORE_COLOR_OFF FALSE
713 #define NONBLANK_ATTR (A_BOLD|A_DIM|A_BLINK)
714 #define XMC_CHANGES(c) ((c) & SP->_xmc_suppress)
717 #define toggle_attr_on(S,at) {\
718 if (PAIR_NUMBER(at) > 0)\
719 (S) = ((S) & ALL_BUT_COLOR) | (at);\
722 TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
725 #define toggle_attr_off(S,at) {\
726 if (IGNORE_COLOR_OFF == TRUE) {\
727 if (PAIR_NUMBER(at) == 0xff) /* turn off color */\
729 else /* leave color alone */\
730 (S) &= ~((at)&ALL_BUT_COLOR);\
732 if (PAIR_NUMBER(at) > 0x00) /* turn off color */\
733 (S) &= ~(at|A_COLOR);\
734 else /* leave color alone */\
737 TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
739 #define DelCharCost(count) \
742 : ((delete_character != 0) \
743 ? (SP->_dch1_cost * count) \
746 #define InsCharCost(count) \
749 : ((enter_insert_mode && exit_insert_mode) \
750 ? SP->_smir_cost + SP->_rmir_cost + (SP->_ip_cost * count) \
751 : ((insert_character != 0) \
752 ? (SP->_ich1_cost * count) \
756 #define UpdateAttrs(a) if (SP->_current_attr != (a)) { \
757 attr_t chg = SP->_current_attr; \
759 if (magic_cookie_glitch > 0 \
760 && XMC_CHANGES((chg ^ SP->_current_attr))) { \
761 T(("%s @%d before glitch %d,%d", \
762 __FILE__, __LINE__, \
765 _nc_do_xmc_glitch(chg); \
769 #define UpdateAttrs(a) if (SP->_current_attr != (a)) \
773 #if NCURSES_EXPANDED && NCURSES_EXT_FUNCS
775 #undef toggle_attr_on
776 #define toggle_attr_on(S,at) _nc_toggle_attr_on(&(S), at)
777 extern NCURSES_EXPORT(void) _nc_toggle_attr_on (attr_t *, attr_t);
779 #undef toggle_attr_off
780 #define toggle_attr_off(S,at) _nc_toggle_attr_off(&(S), at)
781 extern NCURSES_EXPORT(void) _nc_toggle_attr_off (attr_t *, attr_t);
784 #define DelCharCost(count) _nc_DelCharCost(count)
785 extern NCURSES_EXPORT(int) _nc_DelCharCost (int);
788 #define InsCharCost(count) _nc_InsCharCost(count)
789 extern NCURSES_EXPORT(int) _nc_InsCharCost (int);
792 #define UpdateAttrs(c) _nc_UpdateAttrs(c)
793 extern NCURSES_EXPORT(void) _nc_UpdateAttrs (chtype);
797 extern NCURSES_EXPORT(void) _nc_expanded (void);
802 #define getcwd(buf,len) getwd(buf)
807 extern NCURSES_EXPORT(void) _nc_do_xmc_glitch (attr_t);
811 #if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
812 extern NCURSES_EXPORT(void) _nc_linedump (void);
816 extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
817 extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int); /* used by 'tack' program */
820 #if USE_WIDEC_SUPPORT
821 extern NCURSES_EXPORT(int) _nc_wchstrlen(const cchar_t *);
825 extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, unsigned long *, int);
828 #define INFINITY 1000000 /* cost: too high to use */
830 extern NCURSES_EXPORT(void) _nc_mvcur_init (void);
831 extern NCURSES_EXPORT(void) _nc_mvcur_resume (void);
832 extern NCURSES_EXPORT(void) _nc_mvcur_wrap (void);
834 extern NCURSES_EXPORT(int) _nc_scrolln (int, int, int, int);
836 extern NCURSES_EXPORT(void) _nc_screen_init (void);
837 extern NCURSES_EXPORT(void) _nc_screen_resume (void);
838 extern NCURSES_EXPORT(void) _nc_screen_wrap (void);
841 extern NCURSES_EXPORT(int) _nc_has_mouse (void);
844 #define INFINITY 1000000 /* cost: too high to use */
847 #if USE_WIDEC_SUPPORT
848 extern NCURSES_EXPORT(void) _nc_init_wacs(void);
858 extern NCURSES_EXPORT(string_desc *) _nc_str_init (string_desc *, char *, size_t);
859 extern NCURSES_EXPORT(string_desc *) _nc_str_null (string_desc *, size_t);
860 extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, string_desc *);
861 extern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc *, const char *);
862 extern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc *, const char *);
864 extern NCURSES_EXPORT(void) _nc_mvcur_init (void);
865 extern NCURSES_EXPORT(void) _nc_mvcur_resume (void);
866 extern NCURSES_EXPORT(void) _nc_mvcur_wrap (void);
868 extern NCURSES_EXPORT(int) _nc_scrolln (int, int, int, int);
870 extern NCURSES_EXPORT(void) _nc_screen_init (void);
871 extern NCURSES_EXPORT(void) _nc_screen_resume (void);
872 extern NCURSES_EXPORT(void) _nc_screen_wrap (void);
875 #define strstr _nc_strstr
876 extern NCURSES_EXPORT(char *) _nc_strstr (const char *, const char *);
880 extern NCURSES_EXPORT(char *) _nc_printf_string (const char *, va_list);
883 extern NCURSES_EXPORT(void) _nc_add_to_try (struct tries **, const char *, unsigned short);
884 extern NCURSES_EXPORT(char *) _nc_expand_try (struct tries *, unsigned short, int *, size_t);
885 extern NCURSES_EXPORT(int) _nc_remove_key (struct tries **, unsigned short);
886 extern NCURSES_EXPORT(int) _nc_remove_string (struct tries **, char *);
889 extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
890 extern NCURSES_EXPORT(char *) _nc_home_terminfo (void);
891 extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
892 extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
893 extern NCURSES_EXPORT(int) _nc_access (const char *, int);
894 extern NCURSES_EXPORT(int) _nc_baudrate (int);
895 extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
896 extern NCURSES_EXPORT(int) _nc_getenv_num (const char *);
897 extern NCURSES_EXPORT(int) _nc_keypad (bool);
898 extern NCURSES_EXPORT(int) _nc_ospeed (int);
899 extern NCURSES_EXPORT(int) _nc_outch (int);
900 extern NCURSES_EXPORT(int) _nc_setupscreen (short, short const, FILE *);
901 extern NCURSES_EXPORT(int) _nc_timed_wait (int, int, int *);
902 extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T);
903 extern NCURSES_EXPORT(void) _nc_do_color (int, int, bool, int (*)(int));
904 extern NCURSES_EXPORT(void) _nc_flush (void);
905 extern NCURSES_EXPORT(void) _nc_freeall (void);
906 extern NCURSES_EXPORT(void) _nc_hash_map (void);
907 extern NCURSES_EXPORT(void) _nc_init_keytry (void);
908 extern NCURSES_EXPORT(void) _nc_keep_tic_dir (const char *);
909 extern NCURSES_EXPORT(void) _nc_make_oldhash (int i);
910 extern NCURSES_EXPORT(void) _nc_outstr (const char *str);
911 extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot);
912 extern NCURSES_EXPORT(void) _nc_scroll_optimize (void);
913 extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, short const, short const, NCURSES_CH_T);
914 extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, bool);
915 extern NCURSES_EXPORT(void) _nc_signal_handler (bool);
916 extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *);
917 extern NCURSES_EXPORT(void) _nc_trace_tries (struct tries *);
920 extern NCURSES_EXPORT(void) _nc_update_screensize (void);
924 extern NCURSES_EXPORT(void) _nc_resize_margins (WINDOW *);
926 #define _nc_resize_margins(wp) /* nothing */
930 * Not everyone has vsscanf(), but we'd like to use it for scanw().
933 extern int vsscanf(const char *str, const char *format, va_list __arg);
937 extern NCURSES_EXPORT_VAR(int *) _nc_oldnums;
939 #define USE_SETBUF_0 0
941 #define NC_BUFFERED(flag) \
942 if ((SP->_buffered != 0) != flag) \
943 _nc_set_buffer(SP->_ofp, flag)
945 #define NC_OUTPUT ((SP != 0) ? SP->_ofp : stdout)
948 * On systems with a broken linker, define 'SP' as a function to force the
949 * linker to pull in the data-only module with 'SP'.
952 #define SP _nc_screen()
953 extern NCURSES_EXPORT(SCREEN *) _nc_screen (void);
954 extern NCURSES_EXPORT(int) _nc_alloc_screen (void);
955 extern NCURSES_EXPORT(void) _nc_set_screen (SCREEN *);
957 /* current screen is private data; avoid possible linking conflicts too */
958 extern NCURSES_EXPORT_VAR(SCREEN *) SP;
959 #define _nc_alloc_screen() ((SP = typeCalloc(SCREEN, 1)) != 0)
960 #define _nc_set_screen(sp) SP = sp
964 * We don't want to use the lines or columns capabilities internally, because
965 * if the application is running multiple screens under X, it's quite possible
966 * they could all have type xterm but have different sizes! So...
968 #define screen_lines SP->_lines
969 #define screen_columns SP->_columns
971 extern NCURSES_EXPORT_VAR(int) _nc_slk_format; /* != 0 if slk_init() called */
972 extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int);
975 * Some constants related to SLK's
977 #define MAX_SKEY_OLD 8 /* count of soft keys */
978 #define MAX_SKEY_LEN_OLD 8 /* max length of soft key text */
979 #define MAX_SKEY_PC 12 /* This is what most PC's have */
980 #define MAX_SKEY_LEN_PC 5
982 /* Macro to check whether or not we use a standard format */
983 #define SLK_STDFMT(fmt) (fmt < 3)
984 /* Macro to determine height of label window */
985 #define SLK_LINES(fmt) (SLK_STDFMT(fmt) ? 1 : ((fmt) - 2))
987 #define MAX_SKEY(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC)
988 #define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC)
990 extern NCURSES_EXPORT(int) _nc_ripoffline (int line, int (*init)(WINDOW *,int));
996 #endif /* CURSES_PRIV_H */