Back to index

tetex-bin  3.0
curses.priv.h
Go to the documentation of this file.
00001 /****************************************************************************
00002  * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
00003  *                                                                          *
00004  * Permission is hereby granted, free of charge, to any person obtaining a  *
00005  * copy of this software and associated documentation files (the            *
00006  * "Software"), to deal in the Software without restriction, including      *
00007  * without limitation the rights to use, copy, modify, merge, publish,      *
00008  * distribute, distribute with modifications, sublicense, and/or sell       *
00009  * copies of the Software, and to permit persons to whom the Software is    *
00010  * furnished to do so, subject to the following conditions:                 *
00011  *                                                                          *
00012  * The above copyright notice and this permission notice shall be included  *
00013  * in all copies or substantial portions of the Software.                   *
00014  *                                                                          *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
00016  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
00017  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
00018  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
00019  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
00020  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
00021  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
00022  *                                                                          *
00023  * Except as contained in this notice, the name(s) of the above copyright   *
00024  * holders shall not be used in advertising or otherwise to promote the     *
00025  * sale, use or other dealings in this Software without prior written       *
00026  * authorization.                                                           *
00027  ****************************************************************************/
00028 
00029 /****************************************************************************
00030  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
00031  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
00032  *     and: Thomas E. Dickey                        1996-on                 *
00033  ****************************************************************************/
00034 
00035 
00036 /*
00037  * $Id: curses.priv.h,v 1.260 2004/10/16 15:19:14 tom Exp $
00038  *
00039  *     curses.priv.h
00040  *
00041  *     Header file for curses library objects which are private to
00042  *     the library.
00043  *
00044  */
00045 
00046 #ifndef CURSES_PRIV_H
00047 #define CURSES_PRIV_H 1
00048 
00049 #include <ncurses_dll.h>
00050 
00051 #ifdef __cplusplus
00052 extern "C" {
00053 #endif
00054 
00055 #include <ncurses_cfg.h>
00056 
00057 #if USE_RCS_IDS
00058 #define MODULE_ID(id) static const char Ident[] = id;
00059 #else
00060 #define MODULE_ID(id) /*nothing*/
00061 #endif
00062 
00063 #include <stdlib.h>
00064 #include <string.h>
00065 #include <sys/types.h>
00066 
00067 #if HAVE_UNISTD_H
00068 #include <unistd.h>
00069 #endif
00070 
00071 #if HAVE_SYS_BSDTYPES_H
00072 #include <sys/bsdtypes.h>   /* needed for ISC */
00073 #endif
00074 
00075 #if HAVE_LIMITS_H
00076 # include <limits.h>
00077 #elif HAVE_SYS_PARAM_H
00078 # include <sys/param.h>
00079 #endif
00080 
00081 #include <assert.h>
00082 #include <stdio.h>
00083 
00084 #include <errno.h>
00085 
00086 #ifndef PATH_MAX
00087 # if defined(_POSIX_PATH_MAX)
00088 #  define PATH_MAX _POSIX_PATH_MAX
00089 # elif defined(MAXPATHLEN)
00090 #  define PATH_MAX MAXPATHLEN
00091 # else
00092 #  define PATH_MAX 255      /* the Posix minimum path-size */
00093 # endif
00094 #endif
00095 
00096 #if DECL_ERRNO
00097 extern int errno;
00098 #endif
00099 
00100 #include <nc_panel.h>
00101 
00102 /* Some systems have a broken 'select()', but workable 'poll()'.  Use that */
00103 #if HAVE_WORKING_POLL
00104 #define USE_FUNC_POLL 1
00105 #if HAVE_POLL_H
00106 #include <poll.h>
00107 #else
00108 #include <sys/poll.h>
00109 #endif
00110 #else
00111 #define USE_FUNC_POLL 0
00112 #endif
00113 
00114 /* include signal.h before curses.h to work-around defect in glibc 2.1.3 */
00115 #include <signal.h>
00116 
00117 /* Alessandro Rubini's GPM (general-purpose mouse) */
00118 #if HAVE_LIBGPM && HAVE_GPM_H
00119 #define USE_GPM_SUPPORT 1
00120 #else
00121 #define USE_GPM_SUPPORT 0
00122 #endif
00123 
00124 /* QNX mouse support */
00125 #if defined(__QNX__) && !defined(__QNXNTO__)
00126 #define USE_QNX_MOUSE 1
00127 #else
00128 #define USE_QNX_MOUSE 0
00129 #endif
00130 
00131 /* EMX mouse support */
00132 #ifdef __EMX__
00133 #define USE_EMX_MOUSE 1
00134 #else
00135 #define USE_EMX_MOUSE 0
00136 #endif
00137 
00138 #define DEFAULT_MAXCLICK 166
00139 #define EV_MAX              8      /* size of mouse circular event queue */
00140 
00141 /*
00142  * If we don't have signals to support it, don't add a sigwinch handler.
00143  * In any case, resizing is an extended feature.  Use it if we've got it.
00144  */
00145 #if !NCURSES_EXT_FUNCS
00146 #undef HAVE_SIZECHANGE
00147 #define HAVE_SIZECHANGE 0
00148 #endif
00149 
00150 #if HAVE_SIZECHANGE && defined(SIGWINCH)
00151 #define USE_SIZECHANGE 1
00152 #else
00153 #define USE_SIZECHANGE 0
00154 #undef USE_SIGWINCH
00155 #define USE_SIGWINCH 0
00156 #endif
00157 
00158 /*
00159  * If desired, one can configure this, disabling environment variables that
00160  * point to custom terminfo/termcap locations.
00161  */
00162 #ifdef USE_ROOT_ENVIRON
00163 #define use_terminfo_vars() 1
00164 #else
00165 #define use_terminfo_vars() _nc_env_access()
00166 extern NCURSES_EXPORT(int) _nc_env_access (void);
00167 #endif
00168 
00169 /*
00170  * Not all platforms have memmove; some have an equivalent bcopy.  (Some may
00171  * have neither).
00172  */
00173 #if USE_OK_BCOPY
00174 #define memmove(d,s,n) bcopy(s,d,n)
00175 #elif USE_MY_MEMMOVE
00176 #define memmove(d,s,n) _nc_memmove(d,s,n)
00177 extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t);
00178 #endif
00179 
00180 /*
00181  * Scroll hints are useless when hashmap is used
00182  */
00183 #if !USE_SCROLL_HINTS
00184 #if !USE_HASHMAP
00185 #define USE_SCROLL_HINTS 1
00186 #else
00187 #define USE_SCROLL_HINTS 0
00188 #endif
00189 #endif
00190 
00191 #if USE_SCROLL_HINTS
00192 #define if_USE_SCROLL_HINTS(stmt) stmt
00193 #else
00194 #define if_USE_SCROLL_HINTS(stmt) /*nothing*/
00195 #endif
00196 
00197 /*
00198  * Note:  ht/cbt expansion flakes out randomly under Linux 1.1.47, but only
00199  * when we're throwing control codes at the screen at high volume.  To see
00200  * this, re-enable USE_HARD_TABS and run worm for a while.  Other systems
00201  * probably don't want to define this either due to uncertainties about tab
00202  * delays and expansion in raw mode.
00203  */
00204 
00205 struct tries {
00206        struct tries    *child;     /* ptr to child.  NULL if none          */
00207        struct tries    *sibling;   /* ptr to sibling.  NULL if none        */
00208        unsigned char    ch;        /* character at this node               */
00209        unsigned short   value;     /* code of string so far.  0 if none.   */
00210 };
00211 
00212 /*
00213  * Definitions for color pairs
00214  */
00215 #define C_SHIFT 8           /* we need more bits than there are colors */
00216 #define C_MASK  ((1 << C_SHIFT) - 1)
00217 
00218 #define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
00219 
00220 /*
00221  * Common/troublesome character definitions
00222  */
00223 #define L_BRACE '{'
00224 #define R_BRACE '}'
00225 #define S_QUOTE '\''
00226 #define D_QUOTE '"'
00227 
00228 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
00229 
00230 /*
00231  * Structure for palette tables
00232  */
00233 
00234 typedef struct
00235 {
00236     short red, green, blue; /* what color_content() returns */
00237     short r, g, b;          /* params to init_color() */
00238     int init;               /* true if we called init_color() */
00239 }
00240 color_t;
00241 
00242 #define MAXCOLUMNS    135
00243 #define MAXLINES      66
00244 #define FIFO_SIZE     MAXCOLUMNS+2  /* for nocbreak mode input */
00245 
00246 #define ACS_LEN       128
00247 
00248 #define WINDOWLIST struct _win_list
00249 
00250 #if USE_WIDEC_SUPPORT
00251 #define _nc_bkgd    _bkgrnd
00252 #else
00253 #undef _XOPEN_SOURCE_EXTENDED
00254 #define _nc_bkgd    _bkgd
00255 #define wgetbkgrnd(win, wch)       *wch = win->_bkgd
00256 #define wbkgrnd          wbkgd
00257 #endif
00258 
00259 #include <curses.h>  /* we'll use -Ipath directive to get the right one! */
00260 #include <term.h>
00261 
00262 struct ldat
00263 {
00264        NCURSES_CH_T  *text;        /* text of the line */
00265        NCURSES_SIZE_T       firstchar;    /* first changed character in the line */
00266        NCURSES_SIZE_T       lastchar;     /* last changed character in the line */
00267        NCURSES_SIZE_T       oldindex;     /* index of the line at last update */
00268 };
00269 
00270 typedef enum {
00271        M_XTERM       = -1          /* use xterm's mouse tracking? */
00272        ,M_NONE = 0          /* no mouse device */
00273 #if USE_GPM_SUPPORT
00274        ,M_GPM               /* use GPM */
00275 #endif
00276 #if USE_SYSMOUSE
00277        ,M_SYSMOUSE          /* FreeBSD sysmouse on console */
00278 #endif
00279 } MouseType;
00280 
00281 /*
00282  * Structure for soft labels.
00283  */
00284 
00285 typedef struct
00286 {
00287        char *ent_text;         /* text for the label */
00288        char *form_text;        /* formatted text (left/center/...) */
00289        int ent_x;              /* x coordinate of this field */
00290        char dirty;             /* this label has changed */
00291        char visible;           /* field is visible */
00292 } slk_ent;
00293 
00294 typedef struct {
00295        char dirty;             /* all labels have changed */
00296        char hidden;            /* soft labels are hidden */
00297        WINDOW *win;
00298        slk_ent *ent;
00299        short  maxlab;          /* number of available labels */
00300        short  labcnt;          /* number of allocated labels */
00301        short  maxlen;          /* length of labels */
00302        chtype attr;            /* soft label attribute */
00303 } SLK;
00304 
00305 typedef struct {
00306        unsigned long hashval;
00307        int oldcount, newcount;
00308        int oldindex, newindex;
00309 } HASHMAP;
00310 
00311 typedef       struct {
00312        int    line;           /* lines to take, < 0 => from bottom*/
00313        int    (*hook)(WINDOW *, int); /* callback for user        */
00314        WINDOW *w;              /* maybe we need this for cleanup   */
00315 } ripoff_t;
00316 
00317 struct screen {
00318        int             _ifd;           /* input file ptr for screen        */
00319        FILE            *_ofp;          /* output file ptr for screen       */
00320        char            *_setbuf;       /* buffered I/O for output          */
00321        int           _buffered;      /* setvbuf uses _setbuf data        */
00322        int             _checkfd;       /* filedesc for typeahead check     */
00323        TERMINAL        *_term;         /* terminal type information        */
00324        short           _lines;         /* screen lines                     */
00325        short           _columns;       /* screen columns                   */
00326 
00327        short           _lines_avail;   /* lines available for stdscr       */
00328        short           _topstolen;     /* lines stolen from top            */
00329        ripoff_t      _rippedoff[5];       /* list of lines stolen                */
00330        int           _rip_count;   /* ...and total lines stolen           */
00331 
00332        WINDOW          *_curscr;       /* current screen                   */
00333        WINDOW          *_newscr;       /* virtual screen to be updated to  */
00334        WINDOW          *_stdscr;       /* screen's full-window context     */
00335 
00336        struct tries    *_keytry;       /* "Try" for use with keypad mode   */
00337        struct tries    *_key_ok;       /* Disabled keys via keyok(,FALSE)  */
00338        bool            _tried;         /* keypad mode was initialized      */
00339        bool            _keypad_on;     /* keypad mode is currently on      */
00340 
00341        bool          _called_wgetch;      /* check for recursion in wgetch()  */
00342        int                   _fifo[FIFO_SIZE];       /* input push-back buffer   */
00343        short           _fifohead,      /* head of fifo queue               */
00344                        _fifotail,      /* tail of fifo queue               */
00345                        _fifopeek,      /* where to peek for next char      */
00346                        _fifohold;      /* set if breakout marked           */
00347 
00348        int             _endwin;        /* are we out of window mode?       */
00349        attr_t          _current_attr;  /* terminal attribute current set   */
00350        int             _coloron;       /* is color enabled?                */
00351        int           _color_defs;  /* are colors modified                 */
00352        int             _cursor;        /* visibility of the cursor         */
00353        int             _cursrow;       /* physical cursor row              */
00354        int             _curscol;       /* physical cursor column           */
00355        bool          _notty;              /* true if we cannot switch non-tty */
00356        int             _nl;            /* True if NL -> CR/NL is on        */
00357        int             _raw;           /* True if in raw mode              */
00358        int             _cbreak;        /* 1 if in cbreak mode              */
00359                                        /* > 1 if in halfdelay mode         */
00360        int             _echo;          /* True if echo on                  */
00361        int             _use_meta;      /* use the meta key?                */
00362        SLK             *_slk;          /* ptr to soft key struct / NULL    */
00363         int             slk_format;     /* selected format for this screen  */
00364        /* cursor movement costs; units are 10ths of milliseconds */
00365 #if NCURSES_NO_PADDING
00366        int             _no_padding;    /* flag to set if padding disabled  */
00367 #endif
00368        int             _char_padding;  /* cost of character put            */
00369        int             _cr_cost;       /* cost of (carriage_return)        */
00370        int             _cup_cost;      /* cost of (cursor_address)         */
00371        int             _home_cost;     /* cost of (cursor_home)            */
00372        int             _ll_cost;       /* cost of (cursor_to_ll)           */
00373 #if USE_HARD_TABS
00374        int             _ht_cost;       /* cost of (tab)                    */
00375        int             _cbt_cost;      /* cost of (backtab)                */
00376 #endif /* USE_HARD_TABS */
00377        int             _cub1_cost;     /* cost of (cursor_left)            */
00378        int             _cuf1_cost;     /* cost of (cursor_right)           */
00379        int             _cud1_cost;     /* cost of (cursor_down)            */
00380        int             _cuu1_cost;     /* cost of (cursor_up)              */
00381        int             _cub_cost;      /* cost of (parm_cursor_left)       */
00382        int             _cuf_cost;      /* cost of (parm_cursor_right)      */
00383        int             _cud_cost;      /* cost of (parm_cursor_down)       */
00384        int             _cuu_cost;      /* cost of (parm_cursor_up)         */
00385        int             _hpa_cost;      /* cost of (column_address)         */
00386        int             _vpa_cost;      /* cost of (row_address)            */
00387        /* used in tty_update.c, must be chars */
00388        int             _ed_cost;       /* cost of (clr_eos)                */
00389        int             _el_cost;       /* cost of (clr_eol)                */
00390        int             _el1_cost;      /* cost of (clr_bol)                */
00391        int             _dch1_cost;     /* cost of (delete_character)       */
00392        int             _ich1_cost;     /* cost of (insert_character)       */
00393        int             _dch_cost;      /* cost of (parm_dch)               */
00394        int             _ich_cost;      /* cost of (parm_ich)               */
00395        int             _ech_cost;      /* cost of (erase_chars)            */
00396        int             _rep_cost;      /* cost of (repeat_char)            */
00397        int             _hpa_ch_cost;   /* cost of (column_address)         */
00398        int             _cup_ch_cost;   /* cost of (cursor_address)         */
00399        int             _cuf_ch_cost;   /* cost of (parm_cursor_right)      */
00400        int             _inline_cost;   /* cost of inline-move              */
00401        int             _smir_cost; /* cost of (enter_insert_mode)      */
00402        int             _rmir_cost; /* cost of (exit_insert_mode)       */
00403        int             _ip_cost;       /* cost of (insert_padding)         */
00404        /* used in lib_mvcur.c */
00405        char *          _address_cursor;
00406        /* used in tty_update.c */
00407        int             _scrolling;     /* 1 if terminal's smart enough to  */
00408 
00409        /* used in lib_color.c */
00410        color_t         *_color_table;  /* screen's color palette            */
00411        int             _color_count;   /* count of colors in palette        */
00412        unsigned short  *_color_pairs;  /* screen's color pair list          */
00413        int             _pair_count;    /* count of color pairs              */
00414 #if NCURSES_EXT_FUNCS
00415        bool            _default_color; /* use default colors                */
00416        bool            _has_sgr_39_49; /* has ECMA default color support    */
00417        int             _default_fg;    /* assumed default foreground        */
00418        int             _default_bg;    /* assumed default background        */
00419 #endif
00420        chtype          _xmc_suppress;  /* attributes to suppress if xmc     */
00421        chtype          _xmc_triggers;  /* attributes to process if xmc      */
00422        chtype          _acs_map[ACS_LEN]; /* the real alternate-charset map */
00423 
00424        /* used in lib_vidattr.c */
00425        bool            _use_rmso;  /* true if we may use 'rmso'         */
00426        bool            _use_rmul;  /* true if we may use 'rmul'         */
00427 
00428        /*
00429         * These data correspond to the state of the idcok() and idlok()
00430         * functions.  A caveat is in order here:  the XSI and SVr4
00431         * documentation specify that these functions apply to the window which
00432         * is given as an argument.  However, ncurses implements this logic
00433         * only for the newscr/curscr update process, _not_ per-window.
00434         */
00435        bool            _nc_sp_idlok;
00436        bool            _nc_sp_idcok;
00437 #define _nc_idlok SP->_nc_sp_idlok
00438 #define _nc_idcok SP->_nc_sp_idcok
00439 
00440        /*
00441         * These are the data that support the mouse interface.
00442         */
00443        MouseType     _mouse_type;
00444        int             _maxclick;
00445        bool            (*_mouse_event) (SCREEN *);
00446        bool            (*_mouse_inline)(SCREEN *);
00447        bool            (*_mouse_parse) (int);
00448        void            (*_mouse_resume)(SCREEN *);
00449        void            (*_mouse_wrap)  (SCREEN *);
00450        int             _mouse_fd;      /* file-descriptor, if any */
00451        NCURSES_CONST char *_mouse_xtermcap; /* string to enable/disable mouse */
00452 #if USE_SYSMOUSE
00453        MEVENT        _sysmouse_fifo[FIFO_SIZE];
00454        int           _sysmouse_head;
00455        int           _sysmouse_tail;
00456        int           _sysmouse_char_width;       /* character width */
00457        int           _sysmouse_char_height;      /* character height */
00458        int           _sysmouse_old_buttons;
00459        int           _sysmouse_new_buttons;
00460 #endif
00461 
00462        /*
00463         * This supports automatic resizing
00464         */
00465 #if USE_SIZECHANGE
00466        int           (*_resize)(int,int);
00467 #endif
00468 
00469         /*
00470         * These are data that support the proper handling of the panel stack on an
00471         * per screen basis.
00472         */
00473         struct panelhook _panelHook;
00474        /*
00475         * Linked-list of all windows, to support '_nc_resizeall()' and
00476         * '_nc_freeall()'
00477         */
00478        WINDOWLIST      *_nc_sp_windows;
00479 #define _nc_windows SP->_nc_sp_windows
00480 
00481        bool            _sig_winch;
00482        SCREEN          *_next_screen;
00483 
00484        /* hashes for old and new lines */
00485        unsigned long *oldhash, *newhash;
00486        HASHMAP       *hashtab;
00487        int           hashtab_len;
00488 
00489        bool            _cleanup;   /* cleanup after int/quit signal */
00490        int             (*_outch)(int);    /* output handler if not putc */
00491 
00492        /* recent versions of 'screen' have partially-working support for
00493         * UTF-8, but do not permit ACS at the same time (see tty_update.c).
00494         */
00495 #if USE_WIDEC_SUPPORT
00496        bool          _legacy_coding;
00497        bool          _screen_acs_fix;
00498 #endif
00499        bool          _screen_acs_map[ACS_LEN];
00500 };
00501 
00502 extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
00503 
00504 #if NCURSES_NOMACROS
00505 #include <nomacros.h>
00506 #endif
00507 
00508        WINDOWLIST {
00509        WINDOW win;   /* first, so WINDOW_EXT() works */
00510        WINDOWLIST *next;
00511 #ifdef _XOPEN_SOURCE_EXTENDED
00512        char addch_work[(MB_LEN_MAX * 9) + 1];
00513        int addch_used;
00514        int addch_x;
00515        int addch_y;
00516 #endif
00517 };
00518 
00519 #define WINDOW_EXT(win,field) (((WINDOWLIST *)(win))->field)
00520 
00521 /* usually in <limits.h> */
00522 #ifndef UCHAR_MAX
00523 #define UCHAR_MAX 255
00524 #endif
00525 
00526 /* The terminfo source is assumed to be 7-bit ASCII */
00527 #define is7bits(c)   ((unsigned)(c) < 128)
00528 
00529 /* Checks for isprint() should be done on 8-bit characters (non-wide) */
00530 #define is8bits(c)   ((unsigned)(c) <= UCHAR_MAX)
00531 
00532 #ifndef min
00533 #define min(a,b)     ((a) > (b)  ?  (b)  :  (a))
00534 #endif
00535 
00536 #ifndef max
00537 #define max(a,b)     ((a) < (b)  ?  (b)  :  (a))
00538 #endif
00539 
00540 /* usually in <unistd.h> */
00541 #ifndef STDIN_FILENO
00542 #define STDIN_FILENO 0
00543 #endif
00544 
00545 #ifndef STDOUT_FILENO
00546 #define STDOUT_FILENO 1
00547 #endif
00548 
00549 #ifndef STDERR_FILENO
00550 #define STDERR_FILENO 2
00551 #endif
00552 
00553 #ifndef EXIT_SUCCESS
00554 #define EXIT_SUCCESS 0
00555 #endif
00556 
00557 #ifndef EXIT_FAILURE
00558 #define EXIT_FAILURE 1
00559 #endif
00560 
00561 #ifndef R_OK
00562 #define       R_OK   4             /* Test for read permission.  */
00563 #endif
00564 #ifndef W_OK
00565 #define       W_OK   2             /* Test for write permission.  */
00566 #endif
00567 #ifndef X_OK
00568 #define       X_OK   1             /* Test for execute permission.  */
00569 #endif
00570 #ifndef F_OK
00571 #define       F_OK   0             /* Test for existence.  */
00572 #endif
00573 
00574 #if HAVE_FCNTL_H
00575 #include <fcntl.h>          /* may define O_BINARY      */
00576 #endif
00577 
00578 #ifndef O_BINARY
00579 #define O_BINARY 0
00580 #endif
00581 
00582 #ifdef TRACE
00583 #define TRACE_OUTCHARS(n) _nc_outchars += (n);
00584 #else
00585 #define TRACE_OUTCHARS(n) /* nothing */
00586 #endif
00587 
00588 #define UChar(c)     ((unsigned char)(c))
00589 #define ChCharOf(c)  ((c) & (chtype)A_CHARTEXT)
00590 #define ChAttrOf(c)     ((c) & (chtype)A_ATTRIBUTES)
00591 
00592 #ifndef MB_LEN_MAX
00593 #define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
00594 #endif
00595 
00596 #if USE_WIDEC_SUPPORT /* { */
00597 #define NulChar             0,0,0,0       /* FIXME: see CCHARW_MAX */
00598 #define CharOf(c)    ((c).chars[0])
00599 #define AttrOf(c)    ((c).attr)
00600 #define AddAttr(c,a) (c).attr |= a
00601 #define RemAttr(c,a) (c).attr &= ~(a)
00602 #define SetAttr(c,a) (c).attr = a
00603 #define NewChar(ch)  { ChAttrOf(ch), { ChCharOf(ch), NulChar } }
00604 #define NewChar2(c,a)       { a, { c, NulChar } }
00605 #define CharEq(a,b)  (!memcmp(&a, &b, sizeof(a)))
00606 #define SetChar(ch,c,a)     do {                                                 \
00607                          NCURSES_CH_T *_cp = &ch;                                \
00608                          memset(_cp,0,sizeof(ch)); _cp->chars[0] = c; _cp->attr = a; \
00609                      } while (0)
00610 #define CHREF(wch)   (&wch)
00611 #define CHDEREF(wch) (*wch)
00612 #define ARG_CH_T     NCURSES_CH_T *
00613 #define CARG_CH_T    const NCURSES_CH_T *
00614 #define PUTC_DATA    char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \
00615                      mbstate_t PUT_st; wchar_t PUTC_ch
00616 #define PUTC_INIT    memset (&PUT_st, '\0', sizeof (PUT_st));             \
00617                      PUTC_i = 0
00618 #define PUTC(ch,b)   do { if(!isnac(ch)) {                                       \
00619                      if (Charable(ch)) {                                  \
00620                          fputc(CharOf(ch), b);                            \
00621                          TRACE_OUTCHARS(1);                                      \
00622                      } else {                                             \
00623                          PUTC_INIT;                                              \
00624                          do {                                             \
00625                             PUTC_ch = PUTC_i < CCHARW_MAX ?                      \
00626                                        (ch).chars[PUTC_i] : L'\0';               \
00627                             PUTC_n = wcrtomb(PUTC_buf,                    \
00628                                            (ch).chars[PUTC_i], &PUT_st);         \
00629                             if (PUTC_ch == L'\0')                                \
00630                                 --PUTC_n;                                 \
00631                             if (PUTC_n <= 0)                              \
00632                                 break;                                    \
00633                             fwrite(PUTC_buf, (unsigned) PUTC_n, 1, b);           \
00634                             ++PUTC_i;                                     \
00635                          } while (PUTC_ch != L'\0');                             \
00636                          TRACE_OUTCHARS(PUTC_i);                          \
00637                      } } } while (0)
00638 
00639 #define BLANK        { WA_NORMAL, {' '} }
00640 #define ISBLANK(ch)  ((ch).chars[0] == L' ' && (ch).chars[1] == L'\0')
00641 
00642 #define WA_NAC              1
00643 #define isnac(ch)    (AttrOf(ch) & WA_NAC)
00644 #define if_WIDEC(code)  code
00645 #define Charable(ch) ((SP != 0 && SP->_legacy_coding)          \
00646                       || (AttrOf(ch) & A_ALTCHARSET)                  \
00647                       || (!isnac(ch) &&                        \
00648                           (ch).chars[1] == L'\0' &&                   \
00649                              _nc_is_charable(CharOf(ch))))
00650 
00651 #define L(ch)        L ## ch
00652 #else /* }{ */
00653 #define CharOf(c)    ChCharOf(c)
00654 #define AttrOf(c)    ChAttrOf(c)
00655 #define AddAttr(c,a) c |= a
00656 #define RemAttr(c,a) c &= ~(a & A_ATTRIBUTES)
00657 #define SetAttr(c,a) c = (c & ~A_ATTRIBUTES) | a
00658 #define NewChar(ch)  (ch)
00659 #define NewChar2(c,a)       (c | a)
00660 #define CharEq(a,b)  (a == b)
00661 #define SetChar(ch,c,a)     ch = c | a
00662 #define CHREF(wch)   wch
00663 #define CHDEREF(wch) wch
00664 #define ARG_CH_T     NCURSES_CH_T
00665 #define CARG_CH_T    NCURSES_CH_T
00666 #define PUTC_DATA    int data = 0
00667 #define PUTC(a,b)    do { data = CharOf(ch); putc(data,b); } while (0)
00668 
00669 #define BLANK        (' '|A_NORMAL)
00670 #define ISBLANK(ch)  (CharOf(ch) == ' ')
00671 
00672 #define isnac(ch)    (0)
00673 #define if_WIDEC(code) /* nothing */
00674 
00675 #define L(ch)        ch
00676 #endif /* } */
00677 
00678 #define AttrOfD(ch)  AttrOf(CHDEREF(ch))
00679 #define CharOfD(ch)  CharOf(CHDEREF(ch))
00680 #define SetChar2(wch,ch)    SetChar(wch,ChCharOf(ch),ChAttrOf(ch))
00681 
00682 #define BLANK_ATTR   A_NORMAL
00683 #define BLANK_TEXT   L(' ')
00684 
00685 #define CHANGED     -1
00686 
00687 #define CHANGED_CELL(line,col) \
00688        if (line->firstchar == _NOCHANGE) \
00689               line->firstchar = line->lastchar = col; \
00690        else if ((col) < line->firstchar) \
00691               line->firstchar = col; \
00692        else if ((col) > line->lastchar) \
00693               line->lastchar = col
00694 
00695 #define CHANGED_RANGE(line,start,end) \
00696        if (line->firstchar == _NOCHANGE \
00697         || line->firstchar > (start)) \
00698               line->firstchar = start; \
00699        if (line->lastchar == _NOCHANGE \
00700         || line->lastchar < (end)) \
00701               line->lastchar = end
00702 
00703 #define CHANGED_TO_EOL(line,start,end) \
00704        if (line->firstchar == _NOCHANGE \
00705         || line->firstchar > (start)) \
00706               line->firstchar = start; \
00707        line->lastchar = end
00708 
00709 #define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
00710 
00711 #define FreeIfNeeded(p)  if ((p) != 0) free(p)
00712 
00713 /* FreeAndNull() is not a comma-separated expression because some compilers
00714  * do not accept a mixture of void with values.
00715  */
00716 #define FreeAndNull(p)   free(p); p = 0
00717 
00718 #include <nc_alloc.h>
00719 
00720 /*
00721  * Prefixes for call/return points of library function traces.  We use these to
00722  * instrument the public functions so that the traces can be easily transformed
00723  * into regression scripts.
00724  */
00725 #define T_CALLED(fmt) "called {" fmt
00726 #define T_CREATE(fmt) "create :" fmt
00727 #define T_RETURN(fmt) "return }" fmt
00728 
00729 #ifdef TRACE
00730 
00731 #define START_TRACE() \
00732        if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
00733            int t = _nc_getenv_num("NCURSES_TRACE"); \
00734            if (t >= 0) \
00735               trace((unsigned) t); \
00736        }
00737 
00738 #define TR(n, a)     if (_nc_tracing & (n)) _tracef a
00739 #define T(a)         TR(TRACE_CALLS, a)
00740 #define TPUTS_TRACE(s)      _nc_tputs_trace = s;
00741 #define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
00742 
00743 #define returnAttr(code) TRACE_RETURN(code,attr_t)
00744 #define returnChar(code) TRACE_RETURN(code,chtype)
00745 #define returnBool(code) TRACE_RETURN(code,bool)
00746 #define returnBits(code) TRACE_RETURN(code,unsigned)
00747 #define returnCode(code) TRACE_RETURN(code,int)
00748 #define returnPtr(code)  TRACE_RETURN(code,ptr)
00749 #define returnSP(code)   TRACE_RETURN(code,sp)
00750 #define returnVoid       T((T_RETURN(""))); return
00751 #define returnWin(code)  TRACE_RETURN(code,win)
00752 
00753 extern NCURSES_EXPORT(NCURSES_BOOL)     _nc_retrace_bool (NCURSES_BOOL);
00754 extern NCURSES_EXPORT(SCREEN *)         _nc_retrace_sp (SCREEN *);
00755 extern NCURSES_EXPORT(WINDOW *)         _nc_retrace_win (WINDOW *);
00756 extern NCURSES_EXPORT(attr_t)           _nc_retrace_attr_t (attr_t);
00757 extern NCURSES_EXPORT(char *)           _nc_retrace_ptr (char *);
00758 extern NCURSES_EXPORT(char *)           _nc_trace_ttymode(TTY *tty);
00759 extern NCURSES_EXPORT(char *)           _nc_varargs (const char *, va_list);
00760 extern NCURSES_EXPORT(chtype)           _nc_retrace_chtype (chtype);
00761 extern NCURSES_EXPORT(const char *)     _nc_altcharset_name(attr_t, chtype);
00762 extern NCURSES_EXPORT(int)              _nc_retrace_int (int);
00763 extern NCURSES_EXPORT(unsigned)         _nc_retrace_unsigned (unsigned);
00764 extern NCURSES_EXPORT(void)             _nc_fifo_dump (void);
00765 extern NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace;
00766 extern NCURSES_EXPORT_VAR(long)         _nc_outchars;
00767 extern NCURSES_EXPORT_VAR(unsigned)     _nc_tracing;
00768 
00769 #if USE_WIDEC_SUPPORT
00770 extern NCURSES_EXPORT(const char *) _nc_viswbuf2 (int, const wchar_t *);
00771 extern NCURSES_EXPORT(const char *) _nc_viswbufn (const wchar_t *, int);
00772 extern NCURSES_EXPORT(const char *) _nc_viscbuf2 (int, const cchar_t *, int);
00773 extern NCURSES_EXPORT(const char *) _nc_viscbuf (const cchar_t *, int);
00774 #endif
00775 
00776 #else /* !TRACE */
00777 
00778 #define START_TRACE() /* nothing */
00779 
00780 #define T(a)
00781 #define TR(n, a)
00782 #define TPUTS_TRACE(s)
00783 
00784 #define returnAttr(code) return code
00785 #define returnBits(code) return code
00786 #define returnBool(code) return code
00787 #define returnChar(code) return code
00788 #define returnCode(code) return code
00789 #define returnPtr(code)  return code
00790 #define returnSP(code)   return code
00791 #define returnVoid       return
00792 #define returnWin(code)  return code
00793 
00794 #endif /* TRACE/!TRACE */
00795 
00796 extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
00797 extern NCURSES_EXPORT(const char *) _nc_visbufn (const char *, int);
00798 
00799 #define empty_module(name) \
00800 extern NCURSES_EXPORT(void) name (void); \
00801        NCURSES_EXPORT(void) name (void) { }
00802 
00803 #define ALL_BUT_COLOR ((chtype)~(A_COLOR))
00804 #define IGNORE_COLOR_OFF FALSE
00805 #define NONBLANK_ATTR (A_NORMAL|A_BOLD|A_DIM|A_BLINK)
00806 #define XMC_CHANGES(c) ((c) & SP->_xmc_suppress)
00807 
00808 #define toggle_attr_on(S,at) {\
00809    if (PAIR_NUMBER(at) > 0)\
00810       (S) = ((S) & ALL_BUT_COLOR) | (at);\
00811    else\
00812       (S) |= (at);\
00813    TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
00814 
00815 
00816 #define toggle_attr_off(S,at) {\
00817    if (IGNORE_COLOR_OFF == TRUE) {\
00818       if (PAIR_NUMBER(at) == 0xff) /* turn off color */\
00819         (S) &= ~(at);\
00820       else /* leave color alone */\
00821         (S) &= ~((at)&ALL_BUT_COLOR);\
00822    } else {\
00823       if (PAIR_NUMBER(at) > 0x00) /* turn off color */\
00824         (S) &= ~(at|A_COLOR);\
00825       else /* leave color alone */\
00826         (S) &= ~(at);\
00827    }\
00828    TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
00829 
00830 #define DelCharCost(count) \
00831               ((parm_dch != 0) \
00832               ? SP->_dch_cost \
00833               : ((delete_character != 0) \
00834                      ? (SP->_dch1_cost * count) \
00835                      : INFINITY))
00836 
00837 #define InsCharCost(count) \
00838               ((parm_ich != 0) \
00839               ? SP->_ich_cost \
00840               : ((enter_insert_mode && exit_insert_mode) \
00841                 ? SP->_smir_cost + SP->_rmir_cost + (SP->_ip_cost * count) \
00842                 : ((insert_character != 0) \
00843                   ? ((SP->_ich1_cost + SP->_ip_cost) * count) \
00844                   : INFINITY)))
00845 
00846 #if USE_XMC_SUPPORT
00847 #define UpdateAttrs(a)      if (SP->_current_attr != (a)) { \
00848                             attr_t chg = SP->_current_attr; \
00849                             vidattr((a)); \
00850                             if (magic_cookie_glitch > 0 \
00851                              && XMC_CHANGES((chg ^ SP->_current_attr))) { \
00852                                    T(("%s @%d before glitch %d,%d", \
00853                                           __FILE__, __LINE__, \
00854                                           SP->_cursrow, \
00855                                           SP->_curscol)); \
00856                                    _nc_do_xmc_glitch(chg); \
00857                             } \
00858                      }
00859 #else
00860 #define UpdateAttrs(a)      if (SP->_current_attr != (a)) \
00861                             vidattr((a));
00862 #endif
00863 
00864 /*
00865  * Macros to make additional parameter to implement wgetch_events()
00866  */
00867 #ifdef NCURSES_WGETCH_EVENTS
00868 #define EVENTLIST_0th(param) param
00869 #define EVENTLIST_1st(param) param
00870 #define EVENTLIST_2nd(param) , param
00871 #else
00872 #define EVENTLIST_0th(param) void
00873 #define EVENTLIST_1st(param) /* nothing */
00874 #define EVENTLIST_2nd(param) /* nothing */
00875 #endif
00876 
00877 #if NCURSES_EXPANDED && NCURSES_EXT_FUNCS
00878 
00879 #undef  toggle_attr_on
00880 #define toggle_attr_on(S,at) _nc_toggle_attr_on(&(S), at)
00881 extern NCURSES_EXPORT(void) _nc_toggle_attr_on (attr_t *, attr_t);
00882 
00883 #undef  toggle_attr_off
00884 #define toggle_attr_off(S,at) _nc_toggle_attr_off(&(S), at)
00885 extern NCURSES_EXPORT(void) _nc_toggle_attr_off (attr_t *, attr_t);
00886 
00887 #undef  DelCharCost
00888 #define DelCharCost(count) _nc_DelCharCost(count)
00889 extern NCURSES_EXPORT(int) _nc_DelCharCost (int);
00890 
00891 #undef  InsCharCost
00892 #define InsCharCost(count) _nc_InsCharCost(count)
00893 extern NCURSES_EXPORT(int) _nc_InsCharCost (int);
00894 
00895 #undef  UpdateAttrs
00896 #define UpdateAttrs(c) _nc_UpdateAttrs(c)
00897 extern NCURSES_EXPORT(void) _nc_UpdateAttrs (chtype);
00898 
00899 #else
00900 
00901 extern NCURSES_EXPORT(void) _nc_expanded (void);
00902 
00903 #endif
00904 
00905 #if !HAVE_GETCWD
00906 #define getcwd(buf,len) getwd(buf)
00907 #endif
00908 
00909 /* charable.c */
00910 #if USE_WIDEC_SUPPORT
00911 extern NCURSES_EXPORT(bool) _nc_is_charable(wchar_t);
00912 extern NCURSES_EXPORT(int) _nc_to_char(wint_t);
00913 extern NCURSES_EXPORT(wint_t) _nc_to_widechar(int);
00914 #endif
00915 
00916 /* doupdate.c */
00917 #if USE_XMC_SUPPORT
00918 extern NCURSES_EXPORT(void) _nc_do_xmc_glitch (attr_t);
00919 #endif
00920 
00921 /* hardscroll.c */
00922 #if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
00923 extern NCURSES_EXPORT(void) _nc_linedump (void);
00924 #endif
00925 
00926 /* lib_acs.c */
00927 extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
00928 extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int);  /* used by 'tack' program */
00929 
00930 /* lib_addstr.c */
00931 #if USE_WIDEC_SUPPORT
00932 extern NCURSES_EXPORT(int) _nc_wchstrlen(const cchar_t *);
00933 #endif
00934 
00935 /* lib_color.c */
00936 extern NCURSES_EXPORT(bool) _nc_reset_colors(void);
00937 
00938 /* lib_getch.c */
00939 extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, unsigned long *, int EVENTLIST_2nd(_nc_eventlist *));
00940 
00941 /* lib_insch.c */
00942 extern NCURSES_EXPORT(void) _nc_insert_ch(WINDOW *, chtype);
00943 
00944 /* lib_mvcur.c */
00945 #define INFINITY     1000000       /* cost: too high to use */
00946 
00947 extern NCURSES_EXPORT(void) _nc_mvcur_init (void);
00948 extern NCURSES_EXPORT(void) _nc_mvcur_resume (void);
00949 extern NCURSES_EXPORT(void) _nc_mvcur_wrap (void);
00950 
00951 extern NCURSES_EXPORT(int) _nc_scrolln (int, int, int, int);
00952 
00953 extern NCURSES_EXPORT(void) _nc_screen_init (void);
00954 extern NCURSES_EXPORT(void) _nc_screen_resume (void);
00955 extern NCURSES_EXPORT(void) _nc_screen_wrap (void);
00956 
00957 /* lib_mouse.c */
00958 extern NCURSES_EXPORT(int) _nc_has_mouse (void);
00959 
00960 /* lib_mvcur.c */
00961 #define INFINITY     1000000       /* cost: too high to use */
00962 #define BAUDBYTE     9      /* 9 = 7 bits + 1 parity + 1 stop */
00963 
00964 /* lib_setup.c */
00965 extern NCURSES_EXPORT(char *) _nc_get_locale(void);
00966 extern NCURSES_EXPORT(int) _nc_unicode_locale(void);
00967 extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(void);
00968 
00969 /* lib_wacs.c */
00970 #if USE_WIDEC_SUPPORT
00971 extern NCURSES_EXPORT(void) _nc_init_wacs(void);
00972 #endif
00973 
00974 typedef struct {
00975     char *s_head;    /* beginning of the string (may be null) */
00976     char *s_tail;    /* end of the string (may be null) */
00977     size_t s_size;   /* current remaining size available */
00978     size_t s_init;   /* total size available */
00979 } string_desc;
00980 
00981 /* strings.c */
00982 extern NCURSES_EXPORT(string_desc *) _nc_str_init (string_desc *, char *, size_t);
00983 extern NCURSES_EXPORT(string_desc *) _nc_str_null (string_desc *, size_t);
00984 extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, string_desc *);
00985 extern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc *, const char *);
00986 extern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc *, const char *);
00987 
00988 extern NCURSES_EXPORT(void) _nc_mvcur_init (void);
00989 extern NCURSES_EXPORT(void) _nc_mvcur_resume (void);
00990 extern NCURSES_EXPORT(void) _nc_mvcur_wrap (void);
00991 
00992 extern NCURSES_EXPORT(int) _nc_scrolln (int, int, int, int);
00993 
00994 extern NCURSES_EXPORT(void) _nc_screen_init (void);
00995 extern NCURSES_EXPORT(void) _nc_screen_resume (void);
00996 extern NCURSES_EXPORT(void) _nc_screen_wrap (void);
00997 
00998 #if !HAVE_STRSTR
00999 #define strstr _nc_strstr
01000 extern NCURSES_EXPORT(char *) _nc_strstr (const char *, const char *);
01001 #endif
01002 
01003 /* safe_sprintf.c */
01004 extern NCURSES_EXPORT(char *) _nc_printf_string (const char *, va_list);
01005 
01006 /* tries.c */
01007 extern NCURSES_EXPORT(void) _nc_add_to_try (struct tries **, const char *, unsigned short);
01008 extern NCURSES_EXPORT(char *) _nc_expand_try (struct tries *, unsigned short, int *, size_t);
01009 extern NCURSES_EXPORT(int) _nc_remove_key (struct tries **, unsigned short);
01010 extern NCURSES_EXPORT(int) _nc_remove_string (struct tries **, const char *);
01011 
01012 /* elsewhere ... */
01013 extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
01014 extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
01015 extern NCURSES_EXPORT(char *) _nc_home_terminfo (void);
01016 extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
01017 extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *);
01018 extern NCURSES_EXPORT(int) _nc_access (const char *, int);
01019 extern NCURSES_EXPORT(int) _nc_baudrate (int);
01020 extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
01021 extern NCURSES_EXPORT(int) _nc_getenv_num (const char *);
01022 extern NCURSES_EXPORT(int) _nc_keypad (bool);
01023 extern NCURSES_EXPORT(int) _nc_ospeed (int);
01024 extern NCURSES_EXPORT(int) _nc_outch (int);
01025 extern NCURSES_EXPORT(int) _nc_setupscreen (short, short const, FILE *);
01026 extern NCURSES_EXPORT(int) _nc_timed_wait(int, int, int * EVENTLIST_2nd(_nc_eventlist *));
01027 extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T);
01028 extern NCURSES_EXPORT(void) _nc_do_color (int, int, bool, int (*)(int));
01029 extern NCURSES_EXPORT(void) _nc_flush (void);
01030 extern NCURSES_EXPORT(void) _nc_freeall (void);
01031 extern NCURSES_EXPORT(void) _nc_hash_map (void);
01032 extern NCURSES_EXPORT(void) _nc_init_keytry (void);
01033 extern NCURSES_EXPORT(void) _nc_keep_tic_dir (const char *);
01034 extern NCURSES_EXPORT(void) _nc_make_oldhash (int i);
01035 extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot);
01036 extern NCURSES_EXPORT(void) _nc_scroll_optimize (void);
01037 extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, short const, short const, NCURSES_CH_T);
01038 extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, bool);
01039 extern NCURSES_EXPORT(void) _nc_signal_handler (bool);
01040 extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *);
01041 extern NCURSES_EXPORT(void) _nc_trace_tries (struct tries *);
01042 
01043 #if USE_SIZECHANGE
01044 extern NCURSES_EXPORT(void) _nc_update_screensize (void);
01045 #endif
01046 
01047 #if HAVE_RESIZETERM
01048 extern NCURSES_EXPORT(void) _nc_resize_margins (WINDOW *);
01049 #else
01050 #define _nc_resize_margins(wp) /* nothing */
01051 #endif
01052 
01053 #ifdef NCURSES_WGETCH_EVENTS
01054 extern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *);
01055 #else
01056 #define wgetch_events(win, evl) wgetch(win)
01057 #define wgetnstr_events(win, str, maxlen, evl) wgetnstr(win, str, maxlen)
01058 #endif
01059 
01060 /*
01061  * Not everyone has vsscanf(), but we'd like to use it for scanw().
01062  */
01063 #if !HAVE_VSSCANF
01064 extern int vsscanf(const char *str, const char *format, va_list __arg);
01065 #endif
01066 
01067 /* scroll indices */
01068 extern NCURSES_EXPORT_VAR(int *) _nc_oldnums;
01069 
01070 #define USE_SETBUF_0 0
01071 
01072 #define NC_BUFFERED(flag) _nc_set_buffer(SP->_ofp, flag)
01073 
01074 #define NC_OUTPUT ((SP != 0) ? SP->_ofp : stdout)
01075 
01076 /*
01077  * On systems with a broken linker, define 'SP' as a function to force the
01078  * linker to pull in the data-only module with 'SP'.
01079  */
01080 #if BROKEN_LINKER
01081 #define SP _nc_screen()
01082 extern NCURSES_EXPORT(SCREEN *) _nc_screen (void);
01083 extern NCURSES_EXPORT(int) _nc_alloc_screen (void);
01084 extern NCURSES_EXPORT(void) _nc_set_screen (SCREEN *);
01085 #else
01086 /* current screen is private data; avoid possible linking conflicts too */
01087 extern NCURSES_EXPORT_VAR(SCREEN *) SP;
01088 #define _nc_alloc_screen() ((SP = typeCalloc(SCREEN, 1)) != 0)
01089 #define _nc_set_screen(sp) SP = sp
01090 #endif
01091 
01092 /*
01093  * We don't want to use the lines or columns capabilities internally, because
01094  * if the application is running multiple screens under X, it's quite possible
01095  * they could all have type xterm but have different sizes!  So...
01096  */
01097 #define screen_lines SP->_lines
01098 #define screen_columns      SP->_columns
01099 
01100 extern NCURSES_EXPORT_VAR(int) _nc_slk_format;  /* != 0 if slk_init() called */
01101 extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int);
01102 
01103 /*
01104  * Some constants related to SLK's
01105  */
01106 #define MAX_SKEY_OLD    8   /* count of soft keys */
01107 #define MAX_SKEY_LEN_OLD   8       /* max length of soft key text */
01108 #define MAX_SKEY_PC       12    /* This is what most PC's have */
01109 #define MAX_SKEY_LEN_PC    5
01110 
01111 /* Macro to check whether or not we use a standard format */
01112 #define SLK_STDFMT(fmt) (fmt < 3)
01113 /* Macro to determine height of label window */
01114 #define SLK_LINES(fmt)  (SLK_STDFMT(fmt) ? 1 : ((fmt) - 2))
01115 
01116 #define MAX_SKEY(fmt)     (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC)
01117 #define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC)
01118 
01119 extern NCURSES_EXPORT(int) _nc_ripoffline (int line, int (*init)(WINDOW *,int));
01120 
01121 /*
01122  * Common error messages
01123  */
01124 #define MSG_NO_MEMORY "Out of memory"
01125 #define MSG_NO_INPUTS "Premature EOF"
01126 
01127 #ifdef __cplusplus
01128 }
01129 #endif
01130 
01131 #endif /* CURSES_PRIV_H */