150276Speter/**************************************************************************** 2262685Sdelphij * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter/**************************************************************************** 3050276Speter * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 3150276Speter * and: Eric S. Raymond <esr@snark.thyrsus.com> * 32166124Srafan * and: Thomas E. Dickey 1996-on * 33262629Sdelphij * and: Juergen Pfeifer * 3450276Speter ****************************************************************************/ 3550276Speter 3650276Speter/* 37262685Sdelphij * $Id: curses.priv.h,v 1.530 2014/02/01 22:09:27 tom Exp $ 3850276Speter * 3950276Speter * curses.priv.h 4050276Speter * 4150276Speter * Header file for curses library objects which are private to 4250276Speter * the library. 4350276Speter * 4450276Speter */ 4550276Speter 4650276Speter#ifndef CURSES_PRIV_H 4750276Speter#define CURSES_PRIV_H 1 48262629Sdelphij/* *INDENT-OFF* */ 4950276Speter 5076726Speter#include <ncurses_dll.h> 5176726Speter 5250276Speter#ifdef __cplusplus 5350276Speterextern "C" { 5450276Speter#endif 5550276Speter 5650276Speter#include <ncurses_cfg.h> 5750276Speter 5850276Speter#if USE_RCS_IDS 5950276Speter#define MODULE_ID(id) static const char Ident[] = id; 6050276Speter#else 6150276Speter#define MODULE_ID(id) /*nothing*/ 6250276Speter#endif 6350276Speter 64262629Sdelphij#include <stddef.h> /* for offsetof */ 6550276Speter#include <stdlib.h> 6650276Speter#include <string.h> 6750276Speter#include <sys/types.h> 68262685Sdelphij#include <sys/stat.h> 6950276Speter 7050276Speter#if HAVE_UNISTD_H 7150276Speter#include <unistd.h> 7250276Speter#endif 7350276Speter 7450276Speter#if HAVE_SYS_BSDTYPES_H 7550276Speter#include <sys/bsdtypes.h> /* needed for ISC */ 7650276Speter#endif 7750276Speter 7850276Speter#if HAVE_LIMITS_H 7950276Speter# include <limits.h> 8050276Speter#elif HAVE_SYS_PARAM_H 8150276Speter# include <sys/param.h> 8250276Speter#endif 8350276Speter 84166124Srafan#include <assert.h> 85166124Srafan#include <stdio.h> 86166124Srafan 87166124Srafan#include <errno.h> 88166124Srafan 89262685Sdelphij#if defined __hpux 90262685Sdelphij# ifndef EILSEQ 91262685Sdelphij# define EILSEQ 47 92262685Sdelphij# endif 93262685Sdelphij#endif 94262685Sdelphij 9550276Speter#ifndef PATH_MAX 9650276Speter# if defined(_POSIX_PATH_MAX) 9750276Speter# define PATH_MAX _POSIX_PATH_MAX 9850276Speter# elif defined(MAXPATHLEN) 9950276Speter# define PATH_MAX MAXPATHLEN 10050276Speter# else 10150276Speter# define PATH_MAX 255 /* the Posix minimum path-size */ 10250276Speter# endif 10350276Speter#endif 10450276Speter 10550276Speter#if DECL_ERRNO 10650276Speterextern int errno; 10750276Speter#endif 10850276Speter 10950276Speter/* Some systems have a broken 'select()', but workable 'poll()'. Use that */ 11062449Speter#if HAVE_WORKING_POLL 11150276Speter#define USE_FUNC_POLL 1 11266963Speter#if HAVE_POLL_H 11362449Speter#include <poll.h> 11450276Speter#else 11562449Speter#include <sys/poll.h> 11662449Speter#endif 11762449Speter#else 11850276Speter#define USE_FUNC_POLL 0 11950276Speter#endif 12050276Speter 121262685Sdelphij#if HAVE_INTTYPES_H 122262685Sdelphij# include <inttypes.h> 123262685Sdelphij#else 124262685Sdelphij# if HAVE_STDINT_H 125262685Sdelphij# include <stdint.h> 126262685Sdelphij# endif 127262685Sdelphij#endif 128262685Sdelphij 12997049Speter/* include signal.h before curses.h to work-around defect in glibc 2.1.3 */ 13097049Speter#include <signal.h> 13197049Speter 13250276Speter/* Alessandro Rubini's GPM (general-purpose mouse) */ 13350276Speter#if HAVE_LIBGPM && HAVE_GPM_H 13450276Speter#define USE_GPM_SUPPORT 1 13550276Speter#else 13650276Speter#define USE_GPM_SUPPORT 0 13750276Speter#endif 13850276Speter 13950276Speter/* QNX mouse support */ 14050276Speter#if defined(__QNX__) && !defined(__QNXNTO__) 14150276Speter#define USE_QNX_MOUSE 1 14250276Speter#else 14350276Speter#define USE_QNX_MOUSE 0 14450276Speter#endif 14550276Speter 14650276Speter/* EMX mouse support */ 14750276Speter#ifdef __EMX__ 148166124Srafan#define USE_EMX_MOUSE 1 149166124Srafan#else 150166124Srafan#define USE_EMX_MOUSE 0 15150276Speter#endif 15250276Speter 153262685Sdelphij/* kLIBC keyboard/mouse support */ 154262685Sdelphij#if defined(__OS2__) && defined(__KLIBC__) 155262685Sdelphij#define USE_KLIBC_KBD 1 156262685Sdelphij#define USE_KLIBC_MOUSE 1 157262685Sdelphij#else 158262685Sdelphij#define USE_KLIBC_KBD 0 159262685Sdelphij#define USE_KLIBC_MOUSE 0 160262685Sdelphij#endif 161262685Sdelphij 16250276Speter#define DEFAULT_MAXCLICK 166 16350276Speter#define EV_MAX 8 /* size of mouse circular event queue */ 16450276Speter 16550276Speter/* 16650276Speter * If we don't have signals to support it, don't add a sigwinch handler. 16750276Speter * In any case, resizing is an extended feature. Use it if we've got it. 16850276Speter */ 16966963Speter#if !NCURSES_EXT_FUNCS 17050276Speter#undef HAVE_SIZECHANGE 171166124Srafan#define HAVE_SIZECHANGE 0 17250276Speter#endif 17350276Speter 174184989Srafan#if HAVE_SIZECHANGE && USE_SIGWINCH && defined(SIGWINCH) 17550276Speter#define USE_SIZECHANGE 1 17650276Speter#else 177166124Srafan#define USE_SIZECHANGE 0 17850276Speter#undef USE_SIGWINCH 179166124Srafan#define USE_SIGWINCH 0 18050276Speter#endif 18150276Speter 18250276Speter/* 18366963Speter * If desired, one can configure this, disabling environment variables that 18466963Speter * point to custom terminfo/termcap locations. 18566963Speter */ 18666963Speter#ifdef USE_ROOT_ENVIRON 18766963Speter#define use_terminfo_vars() 1 18866963Speter#else 18966963Speter#define use_terminfo_vars() _nc_env_access() 19076726Speterextern NCURSES_EXPORT(int) _nc_env_access (void); 19166963Speter#endif 19266963Speter 19366963Speter/* 19450276Speter * Not all platforms have memmove; some have an equivalent bcopy. (Some may 19550276Speter * have neither). 19650276Speter */ 19750276Speter#if USE_OK_BCOPY 19850276Speter#define memmove(d,s,n) bcopy(s,d,n) 19950276Speter#elif USE_MY_MEMMOVE 20050276Speter#define memmove(d,s,n) _nc_memmove(d,s,n) 20176726Speterextern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t); 20250276Speter#endif 20350276Speter 20450276Speter/* 205262629Sdelphij * If we have va_copy(), use it for assigning va_list's. 206262629Sdelphij */ 207262629Sdelphij#if defined(HAVE___VA_COPY) 208262629Sdelphij#define begin_va_copy(dst,src) __va_copy(dst, src) 209262629Sdelphij#define end_va_copy(dst) va_end(dst) 210262629Sdelphij#elif defined(va_copy) || defined(HAVE_VA_COPY) 211262629Sdelphij#define begin_va_copy(dst,src) va_copy(dst, src) 212262629Sdelphij#define end_va_copy(dst) va_end(dst) 213262629Sdelphij#else 214262629Sdelphij#define begin_va_copy(dst,src) (dst) = (src) 215262629Sdelphij#define end_va_copy(dst) /* nothing */ 216262629Sdelphij#endif 217262629Sdelphij 218262629Sdelphij/* 219262685Sdelphij * Either/both S_ISxxx and/or S_IFxxx are defined in sys/types.h; some systems 220262685Sdelphij * lack one or the other. 221262685Sdelphij */ 222262685Sdelphij#ifndef S_ISDIR 223262685Sdelphij#define S_ISDIR(mode) ((mode & S_IFMT) == S_IFDIR) 224262685Sdelphij#endif 225262685Sdelphij 226262685Sdelphij#ifndef S_ISREG 227262685Sdelphij#define S_ISREG(mode) ((mode & S_IFMT) == S_IFREG) 228262685Sdelphij#endif 229262685Sdelphij 230262685Sdelphij/* 23150276Speter * Scroll hints are useless when hashmap is used 23250276Speter */ 23350276Speter#if !USE_SCROLL_HINTS 23450276Speter#if !USE_HASHMAP 23550276Speter#define USE_SCROLL_HINTS 1 23650276Speter#else 23750276Speter#define USE_SCROLL_HINTS 0 23850276Speter#endif 23950276Speter#endif 24050276Speter 24150276Speter#if USE_SCROLL_HINTS 24250276Speter#define if_USE_SCROLL_HINTS(stmt) stmt 24350276Speter#else 24450276Speter#define if_USE_SCROLL_HINTS(stmt) /*nothing*/ 24550276Speter#endif 24650276Speter 247262685Sdelphij#include <nc_string.h> 248262685Sdelphij 24950276Speter/* 250262629Sdelphij * Options for terminal drivers, etc... 251262629Sdelphij */ 252262629Sdelphij#ifdef USE_TERM_DRIVER 253262629Sdelphij#define USE_SP_RIPOFF 1 254262629Sdelphij#define USE_SP_TERMTYPE 1 255262629Sdelphij#define USE_SP_WINDOWLIST 1 256262629Sdelphij#endif 257262629Sdelphij 258262629Sdelphij/* 25950276Speter * Note: ht/cbt expansion flakes out randomly under Linux 1.1.47, but only 26050276Speter * when we're throwing control codes at the screen at high volume. To see 26150276Speter * this, re-enable USE_HARD_TABS and run worm for a while. Other systems 26250276Speter * probably don't want to define this either due to uncertainties about tab 26350276Speter * delays and expansion in raw mode. 26450276Speter */ 26550276Speter 266174993Srafan#define TRIES struct tries 267174993Srafantypedef TRIES { 268174993Srafan TRIES *child; /* ptr to child. NULL if none */ 269174993Srafan TRIES *sibling; /* ptr to sibling. NULL if none */ 27050276Speter unsigned char ch; /* character at this node */ 27150276Speter unsigned short value; /* code of string so far. 0 if none. */ 272174993Srafan#undef TRIES 273174993Srafan} TRIES; 27450276Speter 27550276Speter/* 27650276Speter * Common/troublesome character definitions 27750276Speter */ 278174993Srafan#define StringOf(ch) {ch, 0} 279174993Srafan 28050276Speter#define L_BRACE '{' 28150276Speter#define R_BRACE '}' 28250276Speter#define S_QUOTE '\'' 28397049Speter#define D_QUOTE '"' 28450276Speter 285104977Sache#define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~" 286104977Sache 28750276Speter/* 28850276Speter * Structure for palette tables 28950276Speter */ 29050276Speter 29150276Speter#define MAXCOLUMNS 135 29250276Speter#define MAXLINES 66 29350276Speter#define FIFO_SIZE MAXCOLUMNS+2 /* for nocbreak mode input */ 29450276Speter 29550276Speter#define ACS_LEN 128 29650276Speter 29750276Speter#define WINDOWLIST struct _win_list 29850276Speter 29997049Speter#if USE_WIDEC_SUPPORT 30097049Speter#define _nc_bkgd _bkgrnd 30197049Speter#else 30297049Speter#undef _XOPEN_SOURCE_EXTENDED 303262629Sdelphij#undef _XPG5 30497049Speter#define _nc_bkgd _bkgd 30597049Speter#define wgetbkgrnd(win, wch) *wch = win->_bkgd 30697049Speter#define wbkgrnd wbkgd 30797049Speter#endif 30897049Speter 309174993Srafan#undef NCURSES_OPAQUE 310174993Srafan#define NCURSES_INTERNALS 1 311174993Srafan#define NCURSES_OPAQUE 0 312174993Srafan 31350276Speter#include <curses.h> /* we'll use -Ipath directive to get the right one! */ 314262629Sdelphij 315262685Sdelphijtypedef struct 316262685Sdelphij{ 317262685Sdelphij NCURSES_COLOR_T red, green, blue; /* what color_content() returns */ 318262685Sdelphij NCURSES_COLOR_T r, g, b; /* params to init_color() */ 319262685Sdelphij int init; /* true if we called init_color() */ 320262685Sdelphij} 321262685Sdelphijcolor_t; 322262685Sdelphij 323262629Sdelphij/* 324262629Sdelphij * If curses.h did not expose the SCREEN-functions, then we do not need the 325262629Sdelphij * parameter in the corresponding unextended functions. 326262629Sdelphij */ 327262629Sdelphij 328262629Sdelphij#define USE_SP_FUNC_SUPPORT NCURSES_SP_FUNCS 329262629Sdelphij#define USE_EXT_SP_FUNC_SUPPORT (NCURSES_SP_FUNCS && NCURSES_EXT_FUNCS) 330262629Sdelphij 331262629Sdelphij#if NCURSES_SP_FUNCS 332262629Sdelphij#define SP_PARM sp /* use parameter */ 333262629Sdelphij#define NCURSES_SP_ARG SP_PARM 334262629Sdelphij#define NCURSES_SP_DCL SCREEN *NCURSES_SP_ARG 335262629Sdelphij#define NCURSES_SP_DCL0 NCURSES_SP_DCL 336262629Sdelphij#define NCURSES_SP_ARGx NCURSES_SP_ARG, 337262629Sdelphij#define NCURSES_SP_DCLx SCREEN *NCURSES_SP_ARGx 338262629Sdelphij#else 339262629Sdelphij#define SP_PARM SP /* use global variable */ 340262629Sdelphij#define NCURSES_SP_ARG 341262629Sdelphij#define NCURSES_SP_DCL 342262629Sdelphij#define NCURSES_SP_DCL0 void 343262629Sdelphij#define NCURSES_SP_ARGx 344262629Sdelphij#define NCURSES_SP_DCLx 345262629Sdelphij#endif 346262629Sdelphij 347262629Sdelphij#include <nc_panel.h> 348262629Sdelphij 349262629Sdelphij#define IsPreScreen(sp) (((sp) != 0) && sp->_prescreen) 350262629Sdelphij#define HasTerminal(sp) (((sp) != 0) && (0 != ((sp)->_term))) 351262629Sdelphij#define IsValidScreen(sp) (HasTerminal(sp) && !IsPreScreen(sp)) 352262629Sdelphij 353262685Sdelphij#if USE_REENTRANT 354262629Sdelphij#define CurTerm _nc_prescreen._cur_term 355262629Sdelphij#else 356262629Sdelphij#define CurTerm cur_term 357262629Sdelphij#endif 358262629Sdelphij 359262629Sdelphij#if NCURSES_SP_FUNCS 360262629Sdelphij#define TerminalOf(sp) ((sp) ? ((sp)->_term ? (sp)->_term : CurTerm) : CurTerm) 361262629Sdelphij#else 362262629Sdelphij#define TerminalOf(sp) CurTerm 363262629Sdelphij#endif 364262629Sdelphij 36598503Speter#include <term.h> 366262685Sdelphij#include <nc_termios.h> 367262629Sdelphij 368262629Sdelphij/* 369262629Sdelphij * Reduce dependency on cur_term global by using terminfo data from SCREEN's 370262629Sdelphij * pointer to this data. 371262629Sdelphij */ 372262629Sdelphij#ifdef USE_SP_TERMTYPE 373262629Sdelphij#undef CUR 374262629Sdelphij#endif 375262629Sdelphij 376262629Sdelphij#define SP_TERMTYPE TerminalOf(sp)->type. 377262629Sdelphij 378166124Srafan#include <term_entry.h> 379262629Sdelphij 380166124Srafan#include <nc_tparm.h> 38150276Speter 382262629Sdelphij/* 383262685Sdelphij * Simplify ifdef's for the "*_ATTR" macros in case italics are not configured. 384262685Sdelphij */ 385262685Sdelphij#ifdef A_ITALIC 386262685Sdelphij#define USE_ITALIC 1 387262685Sdelphij#else 388262685Sdelphij#define USE_ITALIC 0 389262685Sdelphij#define A_ITALIC 0 390262685Sdelphij#endif 391262685Sdelphij 392262685Sdelphij/* 393262629Sdelphij * Use these macros internally, to make tracing less verbose. But leave the 394262629Sdelphij * option for compiling the tracing into the library. 395262629Sdelphij */ 396262629Sdelphij#if 1 397262629Sdelphij#define ColorPair(n) NCURSES_BITS(n, 0) 398262629Sdelphij#define PairNumber(a) (NCURSES_CAST(int,(((unsigned long)(a) & A_COLOR) >> NCURSES_ATTR_SHIFT))) 399262629Sdelphij#else 400262629Sdelphij#define ColorPair(pair) COLOR_PAIR(pair) 401262629Sdelphij#define PairNumber(attr) PAIR_NUMBER(attr) 402262629Sdelphij#endif 403262629Sdelphij 404262629Sdelphij#define unColor(n) unColor2(AttrOf(n)) 405262629Sdelphij#define unColor2(a) ((a) & ALL_BUT_COLOR) 406262629Sdelphij 407262629Sdelphij/* 408262629Sdelphij * Extended-colors stores the color pair in a separate struct-member than the 409262629Sdelphij * attributes. But for compatibility, we handle most cases where a program 410262629Sdelphij * written for non-extended colors stores the color in the attributes by 411262629Sdelphij * checking for a color pair in both places. 412262629Sdelphij */ 413262629Sdelphij#if NCURSES_EXT_COLORS 414166124Srafan#define if_EXT_COLORS(stmt) stmt 415262629Sdelphij#define SetPair(value,p) SetPair2((value).ext_color, AttrOf(value), p) 416262629Sdelphij#define SetPair2(c,a,p) c = (p), \ 417262685Sdelphij a = (unColor2(a) | (A_COLOR & (unsigned) ColorPair(oldColor(c)))) 418262629Sdelphij#define GetPair(value) GetPair2((value).ext_color, AttrOf(value)) 419262629Sdelphij#define GetPair2(c,a) ((c) ? (c) : PairNumber(a)) 420262629Sdelphij#define oldColor(p) (((p) > 255) ? 255 : (p)) 421262629Sdelphij#define GET_WINDOW_PAIR(w) GetPair2((w)->_color, (w)->_attrs) 422166124Srafan#define SET_WINDOW_PAIR(w,p) (w)->_color = (p) 423166124Srafan#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b)) 424262629Sdelphij 425262685Sdelphij#define VIDATTR(sp,attr,pair) NCURSES_SP_NAME(vid_puts)(NCURSES_SP_ARGx attr, (short) pair, 0, NCURSES_OUTC_FUNC) 426262629Sdelphij 427262629Sdelphij#else /* !NCURSES_EXT_COLORS */ 428262629Sdelphij 429166124Srafan#define if_EXT_COLORS(stmt) /* nothing */ 430166124Srafan#define SetPair(value,p) RemAttr(value, A_COLOR), \ 431262629Sdelphij SetAttr(value, AttrOf(value) | (A_COLOR & (attr_t) ColorPair(p))) 432262629Sdelphij#define GetPair(value) PairNumber(AttrOf(value)) 433262629Sdelphij#define GET_WINDOW_PAIR(w) PairNumber(WINDOW_ATTRS(w)) 434166124Srafan#define SET_WINDOW_PAIR(w,p) WINDOW_ATTRS(w) &= ALL_BUT_COLOR, \ 435262629Sdelphij WINDOW_ATTRS(w) |= (A_COLOR & (attr_t) ColorPair(p)) 436166124Srafan#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b)) 437262629Sdelphij 438262685Sdelphij#define VIDATTR(sp,attr,pair) NCURSES_SP_NAME(vidputs)(NCURSES_SP_ARGx attr, NCURSES_OUTC_FUNC) 439166124Srafan 440262629Sdelphij#endif /* NCURSES_EXT_COLORS */ 441262629Sdelphij 442262685Sdelphij#define NCURSES_OUTC_FUNC NCURSES_SP_NAME(_nc_outch) 443262685Sdelphij#define NCURSES_PUTP2(name,value) NCURSES_SP_NAME(_nc_putp)(NCURSES_SP_ARGx name, value) 444262685Sdelphij#define NCURSES_PUTP2_FLUSH(name,value) NCURSES_SP_NAME(_nc_putp_flush)(NCURSES_SP_ARGx name, value) 445262685Sdelphij 446184989Srafan#if NCURSES_NO_PADDING 447184989Srafan#define GetNoPadding(sp) ((sp) ? (sp)->_no_padding : _nc_prescreen._no_padding) 448184989Srafan#define SetNoPadding(sp) _nc_set_no_padding(sp) 449262629Sdelphijextern NCURSES_EXPORT(void) _nc_set_no_padding(SCREEN *); 450184989Srafan#else 451184989Srafan#define GetNoPadding(sp) FALSE 452184989Srafan#define SetNoPadding(sp) /*nothing*/ 453184989Srafan#endif 454184989Srafan 455166124Srafan#define WINDOW_ATTRS(w) ((w)->_attrs) 456166124Srafan 457166124Srafan#define SCREEN_ATTRS(s) (*((s)->_current_attr)) 458166124Srafan#define GET_SCREEN_PAIR(s) GetPair(SCREEN_ATTRS(s)) 459166124Srafan#define SET_SCREEN_PAIR(s,p) SetPair(SCREEN_ATTRS(s), p) 460166124Srafan 461262629Sdelphij#if USE_REENTRANT || NCURSES_SP_FUNCS 462262629SdelphijNCURSES_EXPORT(int *) _nc_ptr_Lines (SCREEN *); 463262629SdelphijNCURSES_EXPORT(int *) _nc_ptr_Cols (SCREEN *); 464262629SdelphijNCURSES_EXPORT(int *) _nc_ptr_Tabsize (SCREEN *); 465262629SdelphijNCURSES_EXPORT(int *) _nc_ptr_Escdelay (SCREEN *); 466262629Sdelphij#endif 467262629Sdelphij 468174993Srafan#if USE_REENTRANT 469262629Sdelphij 470262629Sdelphij#define ptrLines(sp) (sp ? &(sp->_LINES) : &(_nc_prescreen._LINES)) 471262629Sdelphij#define ptrCols(sp) (sp ? &(sp->_COLS) : &(_nc_prescreen._COLS)) 472262629Sdelphij#define ptrTabsize(sp) (sp ? &(sp->_TABSIZE) : &(_nc_prescreen._TABSIZE)) 473262629Sdelphij#define ptrEscdelay(sp) (sp ? &(sp->_ESCDELAY) : &(_nc_prescreen._ESCDELAY)) 474262629Sdelphij 475262629Sdelphij#define SET_LINES(value) *_nc_ptr_Lines(SP_PARM) = value 476262629Sdelphij#define SET_COLS(value) *_nc_ptr_Cols(SP_PARM) = value 477262629Sdelphij#define SET_TABSIZE(value) *_nc_ptr_Tabsize(SP_PARM) = value 478262629Sdelphij#define SET_ESCDELAY(value) *_nc_ptr_Escdelay(SP_PARM) = value 479262629Sdelphij 480174993Srafan#else 481262629Sdelphij 482262629Sdelphij#define ptrLines(sp) &LINES 483262629Sdelphij#define ptrCols(sp) &COLS 484262629Sdelphij#define ptrTabsize(sp) &TABSIZE 485262629Sdelphij#define ptrEscdelay(sp) &ESCDELAY 486262629Sdelphij 487262629Sdelphij#define SET_LINES(value) LINES = value 488262629Sdelphij#define SET_COLS(value) COLS = value 489262629Sdelphij#define SET_TABSIZE(value) TABSIZE = value 490262629Sdelphij#define SET_ESCDELAY(value) ESCDELAY = value 491262629Sdelphij 492174993Srafan#endif 493174993Srafan 494174993Srafan#define TR_MUTEX(data) _tracef("%s@%d: me:%08lX COUNT:%2u/%2d/%6d/%2d/%s%9u: " #data, \ 495174993Srafan __FILE__, __LINE__, \ 496174993Srafan (unsigned long) (pthread_self()), \ 497174993Srafan data.__data.__lock, \ 498174993Srafan data.__data.__count, \ 499174993Srafan data.__data.__owner, \ 500174993Srafan data.__data.__kind, \ 501174993Srafan (data.__data.__nusers > 5) ? " OOPS " : "", \ 502174993Srafan data.__data.__nusers) 503174993Srafan#define TR_GLOBAL_MUTEX(name) TR_MUTEX(_nc_globals.mutex_##name) 504174993Srafan 505262629Sdelphij#if USE_WEAK_SYMBOLS 506262629Sdelphij#if defined(__GNUC__) 507262629Sdelphij# if defined __USE_ISOC99 508262629Sdelphij# define _cat_pragma(exp) _Pragma(#exp) 509262629Sdelphij# define _weak_pragma(exp) _cat_pragma(weak name) 510262629Sdelphij# else 511262629Sdelphij# define _weak_pragma(exp) 512262629Sdelphij# endif 513262629Sdelphij# define _declare(name) __extension__ extern __typeof__(name) name 514262629Sdelphij# define weak_symbol(name) _weak_pragma(name) _declare(name) __attribute__((weak)) 515262685Sdelphij#else 516262685Sdelphij# undef USE_WEAK_SYMBOLS 517262685Sdelphij# define USE_WEAK_SYMBOLS 0 518262629Sdelphij#endif 519262629Sdelphij#endif 520262629Sdelphij 521174993Srafan#ifdef USE_PTHREADS 522178866Srafan 523174993Srafan#if USE_REENTRANT 524174993Srafan#include <pthread.h> 525184989Srafanextern NCURSES_EXPORT(void) _nc_init_pthreads(void); 526178866Srafanextern NCURSES_EXPORT(void) _nc_mutex_init(pthread_mutex_t *); 527176187Srafanextern NCURSES_EXPORT(int) _nc_mutex_lock(pthread_mutex_t *); 528176187Srafanextern NCURSES_EXPORT(int) _nc_mutex_trylock(pthread_mutex_t *); 529176187Srafanextern NCURSES_EXPORT(int) _nc_mutex_unlock(pthread_mutex_t *); 530176187Srafan#define _nc_lock_global(name) _nc_mutex_lock(&_nc_globals.mutex_##name) 531176187Srafan#define _nc_try_global(name) _nc_mutex_trylock(&_nc_globals.mutex_##name) 532176187Srafan#define _nc_unlock_global(name) _nc_mutex_unlock(&_nc_globals.mutex_##name) 533174993Srafan 534174993Srafan#else 535174993Srafan#error POSIX threads requires --enable-reentrant option 536174993Srafan#endif 537178866Srafan 538184989Srafan#ifdef USE_PTHREADS 539184989Srafan# if USE_WEAK_SYMBOLS 540184989Srafanweak_symbol(pthread_sigmask); 541262629Sdelphijweak_symbol(pthread_kill); 542184989Srafanweak_symbol(pthread_self); 543184989Srafanweak_symbol(pthread_equal); 544184989Srafanweak_symbol(pthread_mutex_init); 545184989Srafanweak_symbol(pthread_mutex_lock); 546184989Srafanweak_symbol(pthread_mutex_unlock); 547184989Srafanweak_symbol(pthread_mutex_trylock); 548184989Srafanweak_symbol(pthread_mutexattr_settype); 549184989Srafanweak_symbol(pthread_mutexattr_init); 550184989Srafanextern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *); 551184989Srafan# undef sigprocmask 552184989Srafan# define sigprocmask _nc_sigprocmask 553184989Srafan# endif 554184989Srafan#endif 555184989Srafan 556178866Srafan#if HAVE_NANOSLEEP 557178866Srafan#undef HAVE_NANOSLEEP 558178866Srafan#define HAVE_NANOSLEEP 0 /* nanosleep suspends all threads */ 559178866Srafan#endif 560178866Srafan 561178866Srafan#else /* !USE_PTHREADS */ 562178866Srafan 563262629Sdelphij#if USE_PTHREADS_EINTR 564262629Sdelphij# if USE_WEAK_SYMBOLS 565262629Sdelphij#include <pthread.h> 566262629Sdelphijweak_symbol(pthread_sigmask); 567262629Sdelphijweak_symbol(pthread_kill); 568262629Sdelphijweak_symbol(pthread_self); 569262629Sdelphijweak_symbol(pthread_equal); 570262629Sdelphijextern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *); 571262629Sdelphij# undef sigprocmask 572262629Sdelphij# define sigprocmask _nc_sigprocmask 573262629Sdelphij# endif 574262629Sdelphij#endif /* USE_PTHREADS_EINTR */ 575262629Sdelphij 576184989Srafan#define _nc_init_pthreads() /* nothing */ 577178866Srafan#define _nc_mutex_init(obj) /* nothing */ 578178866Srafan 579174993Srafan#define _nc_lock_global(name) /* nothing */ 580174993Srafan#define _nc_try_global(name) 0 581174993Srafan#define _nc_unlock_global(name) /* nothing */ 582174993Srafan 583178866Srafan#endif /* USE_PTHREADS */ 584178866Srafan 585262629Sdelphij/* 586262629Sdelphij * When using sp-funcs, locks are targeted to SCREEN-level granularity. 587262629Sdelphij * So the locking is done in the non-sp-func (which calls the sp-func) rather 588262629Sdelphij * than in the sp-func itself. 589262629Sdelphij * 590262629Sdelphij * Use the _nc_nonsp_XXX functions in the function using "NCURSES_SP_NAME()". 591262629Sdelphij * Use the _nc_sp_XXX functions in the function using "#if NCURSES_SP_FUNCS". 592262629Sdelphij */ 593262629Sdelphij#if NCURSES_SP_FUNCS 594262629Sdelphij 595262629Sdelphij#define _nc_nonsp_lock_global(name) /* nothing */ 596262629Sdelphij#define _nc_nonsp_try_global(name) 0 597262629Sdelphij#define _nc_nonsp_unlock_global(name) /* nothing */ 598262629Sdelphij 599262629Sdelphij#define _nc_sp_lock_global(name) _nc_lock_global(name) 600262629Sdelphij#define _nc_sp_try_global(name) _nc_try_global(name) 601262629Sdelphij#define _nc_sp_unlock_global(name) _nc_unlock_global(name) 602262629Sdelphij 603262629Sdelphij#else 604262629Sdelphij 605262629Sdelphij#define _nc_nonsp_lock_global(name) _nc_lock_global(name) 606262629Sdelphij#define _nc_nonsp_try_global(name) _nc_try_global(name) 607262629Sdelphij#define _nc_nonsp_unlock_global(name) _nc_unlock_global(name) 608262629Sdelphij 609262629Sdelphij#define _nc_sp_lock_global(name) /* nothing */ 610262629Sdelphij#define _nc_sp_try_global(name) 0 611262629Sdelphij#define _nc_sp_unlock_global(name) /* nothing */ 612262629Sdelphij 613262629Sdelphij#endif 614262629Sdelphij 615178866Srafan#if HAVE_GETTIMEOFDAY 616178866Srafan# define PRECISE_GETTIME 1 617178866Srafan# define TimeType struct timeval 618178866Srafan#else 619178866Srafan# define PRECISE_GETTIME 0 620178866Srafan# define TimeType time_t 621174993Srafan#endif 622174993Srafan 623166124Srafan/* 624166124Srafan * Definitions for color pairs 625166124Srafan */ 626166124Srafantypedef unsigned colorpair_t; /* type big enough to store PAIR_OF() */ 627166124Srafan#define C_SHIFT 9 /* we need more bits than there are colors */ 628166124Srafan#define C_MASK ((1 << C_SHIFT) - 1) 629262629Sdelphij#define PAIR_OF(fg, bg) (colorpair_t) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK)) 630262629Sdelphij#define FORE_OF(c) (((c) >> C_SHIFT) & C_MASK) 631262629Sdelphij#define BACK_OF(c) ((c) & C_MASK) 632166124Srafan#define isDefaultColor(c) ((c) >= COLOR_DEFAULT || (c) < 0) 633166124Srafan 634166124Srafan#define COLOR_DEFAULT C_MASK 635166124Srafan 636262629Sdelphij#if defined(USE_BUILD_CC) || (defined(USE_TERMLIB) && !defined(NEED_NCURSES_CH_T)) 637166124Srafan 638166124Srafan#undef NCURSES_CH_T /* this is not a termlib feature */ 639166124Srafan#define NCURSES_CH_T void /* ...but we need a pointer in SCREEN */ 640166124Srafan 641166124Srafan#endif /* USE_TERMLIB */ 642166124Srafan 643166124Srafan#ifndef USE_TERMLIB 64497049Speterstruct ldat 64597049Speter{ 646166124Srafan NCURSES_CH_T *text; /* text of the line */ 647166124Srafan NCURSES_SIZE_T firstchar; /* first changed character in the line */ 648166124Srafan NCURSES_SIZE_T lastchar; /* last changed character in the line */ 649166124Srafan NCURSES_SIZE_T oldindex; /* index of the line at last update */ 65097049Speter}; 651166124Srafan#endif /* USE_TERMLIB */ 65297049Speter 653166124Srafantypedef enum { 654166124Srafan M_XTERM = -1 /* use xterm's mouse tracking? */ 655166124Srafan ,M_NONE = 0 /* no mouse device */ 656166124Srafan#if USE_GPM_SUPPORT 657166124Srafan ,M_GPM /* use GPM */ 658166124Srafan#endif 659166124Srafan#if USE_SYSMOUSE 660166124Srafan ,M_SYSMOUSE /* FreeBSD sysmouse on console */ 661166124Srafan#endif 662262629Sdelphij#ifdef USE_TERM_DRIVER 663262629Sdelphij ,M_TERM_DRIVER /* Win32 console, etc */ 664262629Sdelphij#endif 665166124Srafan} MouseType; 666166124Srafan 66750276Speter/* 668166124Srafan * Structures for scrolling. 66950276Speter */ 67050276Speter 671166124Srafantypedef struct { 672166124Srafan unsigned long hashval; 673166124Srafan int oldcount, newcount; 674166124Srafan int oldindex, newindex; 675166124Srafan} HASHMAP; 676166124Srafan 677166124Srafan/* 678166124Srafan * Structures for soft labels. 679166124Srafan */ 680166124Srafan 681166124Srafanstruct _SLK; 682166124Srafan 683262629Sdelphij#if !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) 684166124Srafan 68550276Spetertypedef struct 68650276Speter{ 687166124Srafan char *ent_text; /* text for the label */ 688166124Srafan char *form_text; /* formatted text (left/center/...) */ 689166124Srafan int ent_x; /* x coordinate of this field */ 690166124Srafan char dirty; /* this label has changed */ 691166124Srafan char visible; /* field is visible */ 69250276Speter} slk_ent; 69350276Speter 694166124Srafantypedef struct _SLK { 695262629Sdelphij bool dirty; /* all labels have changed */ 696262629Sdelphij bool hidden; /* soft labels are hidden */ 697262629Sdelphij WINDOW *win; 69850276Speter slk_ent *ent; 699262629Sdelphij short maxlab; /* number of available labels */ 700262629Sdelphij short labcnt; /* number of allocated labels */ 701262629Sdelphij short maxlen; /* length of labels */ 702166124Srafan NCURSES_CH_T attr; /* soft label attribute */ 70350276Speter} SLK; 70450276Speter 705166124Srafan#endif /* USE_TERMLIB */ 70697049Speter 707166124Srafantypedef struct { 708176187Srafan WINDOW *win; /* the window used in the hook */ 709166124Srafan int line; /* lines to take, < 0 => from bottom*/ 710166124Srafan int (*hook)(WINDOW *, int); /* callback for user */ 711166124Srafan} ripoff_t; 712166124Srafan 713166124Srafan#if USE_GPM_SUPPORT 714166124Srafan#undef buttons /* term.h defines this, and gpm uses it! */ 715166124Srafan#include <gpm.h> 716262685Sdelphij#if USE_WEAK_SYMBOLS 717262685Sdelphijweak_symbol(Gpm_Wgetch); 718262685Sdelphij#endif 719166124Srafan 720166124Srafan#ifdef HAVE_LIBDL 721166124Srafan/* link dynamically to GPM */ 722166124Srafantypedef int *TYPE_gpm_fd; 723166124Srafantypedef int (*TYPE_Gpm_Open) (Gpm_Connect *, int); 724166124Srafantypedef int (*TYPE_Gpm_Close) (void); 725166124Srafantypedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *); 726166124Srafan 727262629Sdelphij#define my_gpm_fd SP_PARM->_mouse_gpm_fd 728262629Sdelphij#define my_Gpm_Open SP_PARM->_mouse_Gpm_Open 729262629Sdelphij#define my_Gpm_Close SP_PARM->_mouse_Gpm_Close 730262629Sdelphij#define my_Gpm_GetEvent SP_PARM->_mouse_Gpm_GetEvent 731166124Srafan#else 732166124Srafan/* link statically to GPM */ 733166124Srafan#define my_gpm_fd &gpm_fd 734166124Srafan#define my_Gpm_Open Gpm_Open 735166124Srafan#define my_Gpm_Close Gpm_Close 736166124Srafan#define my_Gpm_GetEvent Gpm_GetEvent 737166124Srafan#endif /* HAVE_LIBDL */ 738166124Srafan#endif /* USE_GPM_SUPPORT */ 739166124Srafan 740174993Srafantypedef struct { 741174993Srafan long sequence; 742174993Srafan bool last_used; 743174993Srafan char *fix_sgr0; /* this holds the filtered sgr0 string */ 744174993Srafan char *last_bufp; /* help with fix_sgr0 leak */ 745174993Srafan TERMINAL *last_term; 746174993Srafan} TGETENT_CACHE; 747174993Srafan 748174993Srafan#define TGETENT_MAX 4 749174993Srafan 750166124Srafan/* 751174993Srafan * State of tparm(). 752174993Srafan */ 753174993Srafan#define STACKSIZE 20 754174993Srafan 755174993Srafantypedef struct { 756174993Srafan union { 757174993Srafan int num; 758174993Srafan char *str; 759174993Srafan } data; 760174993Srafan bool num_type; 761174993Srafan} STACK_FRAME; 762174993Srafan 763174993Srafan#define NUM_VARS 26 764174993Srafan 765174993Srafantypedef struct { 766174993Srafan#ifdef TRACE 767174993Srafan const char *tname; 768174993Srafan#endif 769174993Srafan const char *tparam_base; 770174993Srafan 771174993Srafan STACK_FRAME stack[STACKSIZE]; 772174993Srafan int stack_ptr; 773174993Srafan 774174993Srafan char *out_buff; 775174993Srafan size_t out_size; 776174993Srafan size_t out_used; 777174993Srafan 778174993Srafan char *fmt_buff; 779174993Srafan size_t fmt_size; 780174993Srafan 781174993Srafan int dynamic_var[NUM_VARS]; 782174993Srafan int static_vars[NUM_VARS]; 783174993Srafan} TPARM_STATE; 784174993Srafan 785174993Srafantypedef struct { 786174993Srafan char *text; 787174993Srafan size_t size; 788174993Srafan} TRACEBUF; 789174993Srafan 790174993Srafan/* 791174993Srafan * The filesystem database normally uses a single-letter for the lower level 792174993Srafan * of directories. Use a hexadecimal code for filesystems which do not 793174993Srafan * preserve mixed-case names. 794174993Srafan */ 795174993Srafan#if MIXEDCASE_FILENAMES 796174993Srafan#define LEAF_FMT "%c" 797262629Sdelphij#define LEAF_LEN 1 798174993Srafan#else 799174993Srafan#define LEAF_FMT "%02x" 800262629Sdelphij#define LEAF_LEN 2 801174993Srafan#endif 802174993Srafan 803174993Srafan/* 804174993Srafan * TRACEMSE_FMT is no longer than 80 columns, there are 5 numbers that 805174993Srafan * could at most have 10 digits, and the mask contains no more than 32 bits 806174993Srafan * with each bit representing less than 15 characters. Usually the whole 807174993Srafan * string is less than 80 columns, but this buffer size is an absolute 808174993Srafan * limit. 809174993Srafan */ 810174993Srafan#define TRACEMSE_MAX (80 + (5 * 10) + (32 * 15)) 811174993Srafan#define TRACEMSE_FMT "id %2d at (%2d, %2d, %2d) state %4lx = {" /* } */ 812174993Srafan 813262629Sdelphij#ifdef USE_TERM_DRIVER 814262629Sdelphijstruct DriverTCB; /* Terminal Control Block forward declaration */ 815262629Sdelphij#define INIT_TERM_DRIVER() _nc_globals.term_driver = _nc_get_driver 816262629Sdelphij#else 817262629Sdelphij#define INIT_TERM_DRIVER() /* nothing */ 818262629Sdelphij#endif 819262629Sdelphij 820262685Sdelphijtypedef struct { 821262685Sdelphij const char *name; 822262685Sdelphij char *value; 823262685Sdelphij} ITERATOR_VARS; 824262685Sdelphij 825174993Srafan/* 826174993Srafan * Global data which is not specific to a screen. 827174993Srafan */ 828174993Srafantypedef struct { 829262685Sdelphij SIG_ATOMIC_T have_sigtstp; 830174993Srafan SIG_ATOMIC_T have_sigwinch; 831174993Srafan SIG_ATOMIC_T cleanup_nested; 832174993Srafan 833174993Srafan bool init_signals; 834174993Srafan bool init_screen; 835174993Srafan 836262685Sdelphij char *comp_sourcename; 837174993Srafan char *comp_termtype; 838174993Srafan 839174993Srafan bool have_tic_directory; 840174993Srafan bool keep_tic_directory; 841174993Srafan const char *tic_directory; 842174993Srafan 843174993Srafan char *dbi_list; 844174993Srafan int dbi_size; 845174993Srafan 846174993Srafan char *first_name; 847174993Srafan char **keyname_table; 848262685Sdelphij int init_keyname; 849174993Srafan 850176187Srafan int slk_format; 851176187Srafan 852174993Srafan char *safeprint_buf; 853174993Srafan size_t safeprint_used; 854174993Srafan 855174993Srafan TGETENT_CACHE tgetent_cache[TGETENT_MAX]; 856174993Srafan int tgetent_index; 857174993Srafan long tgetent_sequence; 858174993Srafan 859262685Sdelphij char *dbd_blob; /* string-heap for dbd_list[] */ 860262685Sdelphij char **dbd_list; /* distinct places to look for data */ 861262685Sdelphij int dbd_size; /* length of dbd_list[] */ 862262685Sdelphij time_t dbd_time; /* cache last updated */ 863262685Sdelphij ITERATOR_VARS dbd_vars[dbdLAST]; 864262685Sdelphij 865262629Sdelphij#ifndef USE_SP_WINDOWLIST 866178866Srafan WINDOWLIST *_nc_windowlist; 867262629Sdelphij#define WindowList(sp) _nc_globals._nc_windowlist 868262629Sdelphij#endif 869178866Srafan 870174993Srafan#if USE_HOME_TERMINFO 871174993Srafan char *home_terminfo; 872174993Srafan#endif 873174993Srafan 874174993Srafan#if !USE_SAFE_SPRINTF 875174993Srafan int safeprint_cols; 876174993Srafan int safeprint_rows; 877174993Srafan#endif 878174993Srafan 879262629Sdelphij#ifdef USE_TERM_DRIVER 880262629Sdelphij int (*term_driver)(struct DriverTCB*, const char*, int*); 881262629Sdelphij#endif 882262629Sdelphij 883174993Srafan#ifdef TRACE 884174993Srafan bool init_trace; 885174993Srafan char trace_fname[PATH_MAX]; 886174993Srafan int trace_level; 887174993Srafan FILE *trace_fp; 888174993Srafan 889174993Srafan char *tracearg_buf; 890174993Srafan size_t tracearg_used; 891174993Srafan 892174993Srafan TRACEBUF *tracebuf_ptr; 893174993Srafan size_t tracebuf_used; 894174993Srafan 895174993Srafan char tracechr_buf[40]; 896174993Srafan 897174993Srafan char *tracedmp_buf; 898174993Srafan size_t tracedmp_used; 899174993Srafan 900174993Srafan unsigned char *tracetry_buf; 901174993Srafan size_t tracetry_used; 902174993Srafan 903174993Srafan char traceatr_color_buf[2][80]; 904174993Srafan int traceatr_color_sel; 905174993Srafan int traceatr_color_last; 906262629Sdelphij#if !defined(USE_PTHREADS) && USE_REENTRANT 907262629Sdelphij int nested_tracef; 908262629Sdelphij#endif 909174993Srafan#endif /* TRACE */ 910174993Srafan 911174993Srafan#ifdef USE_PTHREADS 912184989Srafan pthread_mutex_t mutex_curses; 913184989Srafan pthread_mutex_t mutex_tst_tracef; 914184989Srafan pthread_mutex_t mutex_tracef; 915184989Srafan int nested_tracef; 916184989Srafan int use_pthreads; 917184989Srafan#define _nc_use_pthreads _nc_globals.use_pthreads 918174993Srafan#endif 919262629Sdelphij#if USE_PTHREADS_EINTR 920262629Sdelphij pthread_t read_thread; /* The reading thread */ 921262629Sdelphij#endif 922174993Srafan} NCURSES_GLOBALS; 923174993Srafan 924174993Srafanextern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals; 925174993Srafan 926174993Srafan#define N_RIPS 5 927174993Srafan 928174993Srafan/* 929178866Srafan * Global data which can be swept up into a SCREEN when one is created. 930174993Srafan * It may be modified before the next SCREEN is created. 931174993Srafan */ 932174993Srafantypedef struct { 933174993Srafan bool use_env; 934174993Srafan bool filter_mode; 935174993Srafan attr_t previous_attr; 936262629Sdelphij#ifndef USE_SP_RIPOFF 937174993Srafan ripoff_t rippedoff[N_RIPS]; 938174993Srafan ripoff_t *rsp; 939262629Sdelphij#endif 940174993Srafan TPARM_STATE tparm_state; 941174993Srafan TTY *saved_tty; /* savetty/resetty information */ 942184989Srafan#if NCURSES_NO_PADDING 943184989Srafan bool _no_padding; /* flag to set if padding disabled */ 944184989Srafan#endif 945262629Sdelphij NCURSES_SP_OUTC _outch; /* output handler if not putc */ 946174993Srafan#if BROKEN_LINKER || USE_REENTRANT 947174993Srafan chtype *real_acs_map; 948174993Srafan int _LINES; 949174993Srafan int _COLS; 950262629Sdelphij int _TABSIZE; 951262629Sdelphij int _ESCDELAY; 952184989Srafan TERMINAL *_cur_term; 953174993Srafan#ifdef TRACE 954174993Srafan long _outchars; 955174993Srafan const char *_tputs_trace; 956174993Srafan#endif 957174993Srafan#endif 958262685Sdelphij bool use_tioctl; 959174993Srafan} NCURSES_PRESCREEN; 960174993Srafan 961262629Sdelphij/* 962262629Sdelphij * Use screen-specific ripoff data (for softkeys) rather than global. 963262629Sdelphij */ 964262629Sdelphij#ifdef USE_SP_RIPOFF 965262629Sdelphij#define safe_ripoff_sp (sp)->rsp 966262629Sdelphij#define safe_ripoff_stack (sp)->rippedoff 967262629Sdelphij#else 968262629Sdelphij#define safe_ripoff_sp _nc_prescreen.rsp 969262629Sdelphij#define safe_ripoff_stack _nc_prescreen.rippedoff 970262629Sdelphij#endif 971176187Srafan 972174993Srafanextern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen; 973174993Srafan 974174993Srafan/* 975166124Srafan * The SCREEN structure. 976166124Srafan */ 977166124Srafan 97850276Speterstruct screen { 979262685Sdelphij int _ifd; /* input file descriptor for screen */ 980262685Sdelphij int _ofd; /* output file descriptor for screen */ 981166124Srafan FILE *_ofp; /* output file ptr for screen */ 982262685Sdelphij char *out_buffer; /* output buffer */ 983262685Sdelphij size_t out_limit; /* output buffer size */ 984262685Sdelphij size_t out_inuse; /* output buffer current use */ 985166124Srafan bool _filtered; /* filter() was called */ 986262629Sdelphij bool _prescreen; /* is in prescreen phase */ 987262629Sdelphij bool _use_env; /* LINES & COLS from environment? */ 988166124Srafan int _checkfd; /* filedesc for typeahead check */ 989166124Srafan TERMINAL *_term; /* terminal type information */ 990174993Srafan TTY _saved_tty; /* savetty/resetty information */ 991174993Srafan NCURSES_SIZE_T _lines; /* screen lines */ 992174993Srafan NCURSES_SIZE_T _columns; /* screen columns */ 99350276Speter 994174993Srafan NCURSES_SIZE_T _lines_avail; /* lines available for stdscr */ 995174993Srafan NCURSES_SIZE_T _topstolen; /* lines stolen from top */ 99650276Speter 997166124Srafan WINDOW *_curscr; /* current screen */ 998166124Srafan WINDOW *_newscr; /* virtual screen to be updated to */ 999166124Srafan WINDOW *_stdscr; /* screen's full-window context */ 100050276Speter 1001262629Sdelphij#define CurScreen(sp) (sp)->_curscr 1002262629Sdelphij#define NewScreen(sp) (sp)->_newscr 1003262629Sdelphij#define StdScreen(sp) (sp)->_stdscr 1004262629Sdelphij 1005174993Srafan TRIES *_keytry; /* "Try" for use with keypad mode */ 1006174993Srafan TRIES *_key_ok; /* Disabled keys via keyok(,FALSE) */ 1007166124Srafan bool _tried; /* keypad mode was initialized */ 1008166124Srafan bool _keypad_on; /* keypad mode is currently on */ 100950276Speter 1010166124Srafan bool _called_wgetch; /* check for recursion in wgetch() */ 1011166124Srafan int _fifo[FIFO_SIZE]; /* input push-back buffer */ 1012166124Srafan short _fifohead, /* head of fifo queue */ 1013166124Srafan _fifotail, /* tail of fifo queue */ 1014166124Srafan _fifopeek, /* where to peek for next char */ 1015166124Srafan _fifohold; /* set if breakout marked */ 1016166124Srafan 1017166124Srafan int _endwin; /* are we out of window mode? */ 1018166124Srafan NCURSES_CH_T *_current_attr; /* holds current attributes set */ 1019166124Srafan int _coloron; /* is color enabled? */ 1020166124Srafan int _color_defs; /* are colors modified */ 1021166124Srafan int _cursor; /* visibility of the cursor */ 1022166124Srafan int _cursrow; /* physical cursor row */ 1023166124Srafan int _curscol; /* physical cursor column */ 1024166124Srafan bool _notty; /* true if we cannot switch non-tty */ 1025166124Srafan int _nl; /* True if NL -> CR/NL is on */ 1026166124Srafan int _raw; /* True if in raw mode */ 1027166124Srafan int _cbreak; /* 1 if in cbreak mode */ 1028166124Srafan /* > 1 if in halfdelay mode */ 1029166124Srafan int _echo; /* True if echo on */ 1030166124Srafan int _use_meta; /* use the meta key? */ 1031166124Srafan struct _SLK *_slk; /* ptr to soft key struct / NULL */ 1032166124Srafan int slk_format; /* selected format for this screen */ 103350276Speter /* cursor movement costs; units are 10ths of milliseconds */ 103466963Speter#if NCURSES_NO_PADDING 1035184989Srafan bool _no_padding; /* flag to set if padding disabled */ 103650276Speter#endif 1037166124Srafan int _char_padding; /* cost of character put */ 1038166124Srafan int _cr_cost; /* cost of (carriage_return) */ 1039166124Srafan int _cup_cost; /* cost of (cursor_address) */ 1040166124Srafan int _home_cost; /* cost of (cursor_home) */ 1041166124Srafan int _ll_cost; /* cost of (cursor_to_ll) */ 104250276Speter#if USE_HARD_TABS 1043166124Srafan int _ht_cost; /* cost of (tab) */ 1044166124Srafan int _cbt_cost; /* cost of (backtab) */ 104550276Speter#endif /* USE_HARD_TABS */ 1046166124Srafan int _cub1_cost; /* cost of (cursor_left) */ 1047166124Srafan int _cuf1_cost; /* cost of (cursor_right) */ 1048166124Srafan int _cud1_cost; /* cost of (cursor_down) */ 1049166124Srafan int _cuu1_cost; /* cost of (cursor_up) */ 1050166124Srafan int _cub_cost; /* cost of (parm_cursor_left) */ 1051166124Srafan int _cuf_cost; /* cost of (parm_cursor_right) */ 1052166124Srafan int _cud_cost; /* cost of (parm_cursor_down) */ 1053166124Srafan int _cuu_cost; /* cost of (parm_cursor_up) */ 1054166124Srafan int _hpa_cost; /* cost of (column_address) */ 1055166124Srafan int _vpa_cost; /* cost of (row_address) */ 105662449Speter /* used in tty_update.c, must be chars */ 1057166124Srafan int _ed_cost; /* cost of (clr_eos) */ 1058166124Srafan int _el_cost; /* cost of (clr_eol) */ 1059166124Srafan int _el1_cost; /* cost of (clr_bol) */ 1060166124Srafan int _dch1_cost; /* cost of (delete_character) */ 1061166124Srafan int _ich1_cost; /* cost of (insert_character) */ 1062166124Srafan int _dch_cost; /* cost of (parm_dch) */ 1063166124Srafan int _ich_cost; /* cost of (parm_ich) */ 1064166124Srafan int _ech_cost; /* cost of (erase_chars) */ 1065166124Srafan int _rep_cost; /* cost of (repeat_char) */ 1066166124Srafan int _hpa_ch_cost; /* cost of (column_address) */ 1067166124Srafan int _cup_ch_cost; /* cost of (cursor_address) */ 1068166124Srafan int _cuf_ch_cost; /* cost of (parm_cursor_right) */ 1069166124Srafan int _inline_cost; /* cost of inline-move */ 1070166124Srafan int _smir_cost; /* cost of (enter_insert_mode) */ 1071166124Srafan int _rmir_cost; /* cost of (exit_insert_mode) */ 1072166124Srafan int _ip_cost; /* cost of (insert_padding) */ 107350276Speter /* used in lib_mvcur.c */ 1074166124Srafan char * _address_cursor; 107566963Speter /* used in tty_update.c */ 1076166124Srafan int _scrolling; /* 1 if terminal's smart enough to */ 107750276Speter 107850276Speter /* used in lib_color.c */ 1079166124Srafan color_t *_color_table; /* screen's color palette */ 1080166124Srafan int _color_count; /* count of colors in palette */ 1081166124Srafan colorpair_t *_color_pairs; /* screen's color pair list */ 1082166124Srafan int _pair_count; /* count of color pairs */ 1083262629Sdelphij int _pair_limit; /* actual limit of color-pairs */ 108466963Speter#if NCURSES_EXT_FUNCS 1085262685Sdelphij bool _assumed_color; /* use assumed colors */ 1086166124Srafan bool _default_color; /* use default colors */ 1087166124Srafan bool _has_sgr_39_49; /* has ECMA default color support */ 1088166124Srafan int _default_fg; /* assumed default foreground */ 1089166124Srafan int _default_bg; /* assumed default background */ 1090262629Sdelphij int _default_pairs; /* count pairs using default color */ 109162449Speter#endif 1092166124Srafan chtype _ok_attributes; /* valid attributes for terminal */ 1093166124Srafan chtype _xmc_suppress; /* attributes to suppress if xmc */ 1094166124Srafan chtype _xmc_triggers; /* attributes to process if xmc */ 1095166124Srafan chtype * _acs_map; /* the real alternate-charset map */ 1096166124Srafan bool * _screen_acs_map; 109750276Speter 1098166124Srafan 109950276Speter /* used in lib_vidattr.c */ 1100166124Srafan bool _use_rmso; /* true if we may use 'rmso' */ 1101166124Srafan bool _use_rmul; /* true if we may use 'rmul' */ 1102262685Sdelphij#if USE_ITALIC 1103262685Sdelphij bool _use_ritm; /* true if we may use 'ritm' */ 1104262685Sdelphij#endif 110550276Speter 1106262685Sdelphij#if USE_KLIBC_KBD 1107262685Sdelphij bool _extended_key; /* true if an extended key */ 1108262685Sdelphij#endif 1109262685Sdelphij 111050276Speter /* 111150276Speter * These data correspond to the state of the idcok() and idlok() 111250276Speter * functions. A caveat is in order here: the XSI and SVr4 111350276Speter * documentation specify that these functions apply to the window which 111450276Speter * is given as an argument. However, ncurses implements this logic 111550276Speter * only for the newscr/curscr update process, _not_ per-window. 111650276Speter */ 1117166124Srafan bool _nc_sp_idlok; 1118166124Srafan bool _nc_sp_idcok; 111950276Speter 112050276Speter /* 112150276Speter * These are the data that support the mouse interface. 112250276Speter */ 1123166124Srafan bool _mouse_initialized; 1124166124Srafan MouseType _mouse_type; 1125166124Srafan int _maxclick; 1126166124Srafan bool (*_mouse_event) (SCREEN *); 1127166124Srafan bool (*_mouse_inline)(SCREEN *); 1128184989Srafan bool (*_mouse_parse) (SCREEN *, int); 1129166124Srafan void (*_mouse_resume)(SCREEN *); 1130166124Srafan void (*_mouse_wrap) (SCREEN *); 1131166124Srafan int _mouse_fd; /* file-descriptor, if any */ 1132166124Srafan bool _mouse_active; /* true if initialized */ 1133262685Sdelphij mmask_t _mouse_mask; /* set via mousemask() */ 1134262685Sdelphij mmask_t _mouse_mask2; /* OR's in press/release bits */ 1135262685Sdelphij mmask_t _mouse_bstate; 1136166124Srafan NCURSES_CONST char *_mouse_xtermcap; /* string to enable/disable mouse */ 1137166124Srafan MEVENT _mouse_events[EV_MAX]; /* hold the last mouse event seen */ 1138166124Srafan MEVENT *_mouse_eventp; /* next free slot in event queue */ 113950276Speter 1140166124Srafan#if USE_GPM_SUPPORT 1141166124Srafan bool _mouse_gpm_loaded; 1142166124Srafan bool _mouse_gpm_found; 1143166124Srafan#ifdef HAVE_LIBDL 1144184989Srafan void *_dlopen_gpm; 1145166124Srafan TYPE_gpm_fd _mouse_gpm_fd; 1146166124Srafan TYPE_Gpm_Open _mouse_Gpm_Open; 1147166124Srafan TYPE_Gpm_Close _mouse_Gpm_Close; 1148166124Srafan TYPE_Gpm_GetEvent _mouse_Gpm_GetEvent; 1149166124Srafan#endif 1150166124Srafan Gpm_Connect _mouse_gpm_connect; 1151166124Srafan#endif /* USE_GPM_SUPPORT */ 1152166124Srafan 1153166124Srafan#if USE_EMX_MOUSE 1154166124Srafan int _emxmouse_wfd; 1155166124Srafan int _emxmouse_thread; 1156166124Srafan int _emxmouse_activated; 1157166124Srafan char _emxmouse_buttons[4]; 1158166124Srafan#endif 1159166124Srafan 1160166124Srafan#if USE_SYSMOUSE 1161166124Srafan MEVENT _sysmouse_fifo[FIFO_SIZE]; 1162166124Srafan int _sysmouse_head; 1163166124Srafan int _sysmouse_tail; 1164166124Srafan int _sysmouse_char_width; /* character width */ 1165166124Srafan int _sysmouse_char_height; /* character height */ 1166166124Srafan int _sysmouse_old_buttons; 1167166124Srafan int _sysmouse_new_buttons; 1168166124Srafan#endif 1169166124Srafan 1170262629Sdelphij#ifdef USE_TERM_DRIVER 1171262629Sdelphij MEVENT _drv_mouse_fifo[FIFO_SIZE]; 1172262629Sdelphij int _drv_mouse_head; 1173262629Sdelphij int _drv_mouse_tail; 1174262629Sdelphij int _drv_mouse_old_buttons; 1175262629Sdelphij int _drv_mouse_new_buttons; 1176262629Sdelphij#endif 117750276Speter /* 117850276Speter * This supports automatic resizing 117950276Speter */ 118050276Speter#if USE_SIZECHANGE 1181262629Sdelphij int (*_resize)(NCURSES_SP_DCLx int y, int x); 1182262685Sdelphij int (*_ungetch)(SCREEN *, int); 118350276Speter#endif 118450276Speter 1185166124Srafan /* 118650276Speter * These are data that support the proper handling of the panel stack on an 118750276Speter * per screen basis. 118850276Speter */ 1189166124Srafan struct panelhook _panelHook; 119050276Speter 1191166124Srafan bool _sig_winch; 1192166124Srafan SCREEN *_next_screen; 119350276Speter 119450276Speter /* hashes for old and new lines */ 119550276Speter unsigned long *oldhash, *newhash; 1196166124Srafan HASHMAP *hashtab; 119797049Speter int hashtab_len; 1198174993Srafan int *_oldnum_list; 1199174993Srafan int _oldnum_size; 120056639Speter 1201262629Sdelphij NCURSES_SP_OUTC _outch; /* output handler if not putc */ 1202166124Srafan 1203166124Srafan int _legacy_coding; /* see use_legacy_coding() */ 1204166124Srafan 1205174993Srafan#if USE_REENTRANT 1206174993Srafan char _ttytype[NAMESIZE]; 1207174993Srafan int _ESCDELAY; 1208174993Srafan int _TABSIZE; 1209174993Srafan int _LINES; 1210174993Srafan int _COLS; 1211174993Srafan#ifdef TRACE 1212178866Srafan long _outchars; 1213174993Srafan const char *_tputs_trace; 1214174993Srafan#endif 1215174993Srafan#endif 1216184989Srafan 1217184989Srafan#ifdef TRACE 1218184989Srafan char tracechr_buf[40]; 1219184989Srafan char tracemse_buf[TRACEMSE_MAX]; 1220184989Srafan#endif 1221262629Sdelphij#ifdef USE_SP_WINDOWLIST 1222262629Sdelphij WINDOWLIST* _windowlist; 1223262629Sdelphij#define WindowList(sp) (sp)->_windowlist 1224262629Sdelphij#endif 1225262629Sdelphij NCURSES_OUTC jump; 1226262629Sdelphij 1227262629Sdelphij ripoff_t rippedoff[N_RIPS]; 1228262629Sdelphij ripoff_t *rsp; 1229262629Sdelphij 1230166124Srafan /* 1231166124Srafan * ncurses/ncursesw are the same up to this point. 1232166124Srafan */ 1233166124Srafan#if USE_WIDEC_SUPPORT 1234166124Srafan /* recent versions of 'screen' have partially-working support for 1235166124Srafan * UTF-8, but do not permit ACS at the same time (see tty_update.c). 1236166124Srafan */ 1237166124Srafan bool _screen_acs_fix; 1238262685Sdelphij bool _screen_unicode; 1239166124Srafan#endif 1240262685Sdelphij 1241262685Sdelphij bool _use_tioctl; 124250276Speter}; 124350276Speter 124476726Speterextern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain; 1245174993Srafanextern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; 124650276Speter 124750276Speter WINDOWLIST { 124850276Speter WINDOWLIST *next; 1249184989Srafan SCREEN *screen; /* screen containing the window */ 1250262629Sdelphij WINDOW win; /* WINDOW_EXT() needs to account for offset */ 1251262685Sdelphij#if NCURSES_WIDECHAR 1252166124Srafan char addch_work[(MB_LEN_MAX * 9) + 1]; 1253166124Srafan unsigned addch_used; /* number of bytes in addch_work[] */ 1254166124Srafan int addch_x; /* x-position for addch_work[] */ 1255166124Srafan int addch_y; /* y-position for addch_work[] */ 125697049Speter#endif 125750276Speter}; 125850276Speter 1259262629Sdelphij#define WINDOW_EXT(w,m) (((WINDOWLIST *)((void *)((char *)(w) - offsetof(WINDOWLIST, win))))->m) 126050276Speter 1261262629Sdelphij#define SP_PRE_INIT(sp) \ 1262262629Sdelphij sp->_cursrow = -1; \ 1263262629Sdelphij sp->_curscol = -1; \ 1264262629Sdelphij sp->_nl = TRUE; \ 1265262629Sdelphij sp->_raw = FALSE; \ 1266262629Sdelphij sp->_cbreak = 0; \ 1267262629Sdelphij sp->_echo = TRUE; \ 1268262629Sdelphij sp->_fifohead = -1; \ 1269262629Sdelphij sp->_endwin = TRUE; \ 1270262629Sdelphij sp->_cursor = -1; \ 1271262629Sdelphij WindowList(sp) = 0; \ 1272262685Sdelphij sp->_outch = NCURSES_OUTC_FUNC; \ 1273262629Sdelphij sp->jump = 0 \ 1274262629Sdelphij 1275166124Srafan/* usually in <limits.h> */ 1276166124Srafan#ifndef UCHAR_MAX 1277166124Srafan#define UCHAR_MAX 255 1278166124Srafan#endif 1279166124Srafan 128050276Speter/* The terminfo source is assumed to be 7-bit ASCII */ 128150276Speter#define is7bits(c) ((unsigned)(c) < 128) 128250276Speter 1283166124Srafan/* Checks for isprint() should be done on 8-bit characters (non-wide) */ 1284166124Srafan#define is8bits(c) ((unsigned)(c) <= UCHAR_MAX) 1285166124Srafan 128650276Speter#ifndef min 128750276Speter#define min(a,b) ((a) > (b) ? (b) : (a)) 128850276Speter#endif 128950276Speter 129050276Speter#ifndef max 129150276Speter#define max(a,b) ((a) < (b) ? (b) : (a)) 129250276Speter#endif 129350276Speter 129450276Speter/* usually in <unistd.h> */ 129550276Speter#ifndef STDIN_FILENO 129650276Speter#define STDIN_FILENO 0 129750276Speter#endif 129850276Speter 129950276Speter#ifndef STDOUT_FILENO 130050276Speter#define STDOUT_FILENO 1 130150276Speter#endif 130250276Speter 130350276Speter#ifndef STDERR_FILENO 130450276Speter#define STDERR_FILENO 2 130550276Speter#endif 130650276Speter 130750276Speter#ifndef EXIT_SUCCESS 130850276Speter#define EXIT_SUCCESS 0 130950276Speter#endif 131050276Speter 131150276Speter#ifndef EXIT_FAILURE 131250276Speter#define EXIT_FAILURE 1 131350276Speter#endif 131450276Speter 131550276Speter#ifndef R_OK 131650276Speter#define R_OK 4 /* Test for read permission. */ 131750276Speter#endif 131850276Speter#ifndef W_OK 131950276Speter#define W_OK 2 /* Test for write permission. */ 132050276Speter#endif 132150276Speter#ifndef X_OK 132250276Speter#define X_OK 1 /* Test for execute permission. */ 132350276Speter#endif 132450276Speter#ifndef F_OK 132550276Speter#define F_OK 0 /* Test for existence. */ 132650276Speter#endif 132750276Speter 132862449Speter#if HAVE_FCNTL_H 132962449Speter#include <fcntl.h> /* may define O_BINARY */ 133062449Speter#endif 133162449Speter 133262449Speter#ifndef O_BINARY 133362449Speter#define O_BINARY 0 133462449Speter#endif 133562449Speter 1336166124Srafan#ifdef TRACE 1337174993Srafan#if USE_REENTRANT 1338174993Srafan#define COUNT_OUTCHARS(n) _nc_count_outchars(n); 1339166124Srafan#else 1340174993Srafan#define COUNT_OUTCHARS(n) _nc_outchars += (n); 1341166124Srafan#endif 1342174993Srafan#else 1343174993Srafan#define COUNT_OUTCHARS(n) /* nothing */ 1344174993Srafan#endif 1345166124Srafan 1346174993Srafan#define RESET_OUTCHARS() COUNT_OUTCHARS(-_nc_outchars) 1347174993Srafan 134897049Speter#define UChar(c) ((unsigned char)(c)) 1349262629Sdelphij#define UShort(c) ((unsigned short)(c)) 1350262685Sdelphij#define ChCharOf(c) ((chtype)(c) & (chtype)A_CHARTEXT) 1351262685Sdelphij#define ChAttrOf(c) ((chtype)(c) & (chtype)A_ATTRIBUTES) 135250276Speter 1353166124Srafan#ifndef MB_LEN_MAX 1354166124Srafan#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */ 1355166124Srafan#endif 1356166124Srafan 135797049Speter#if USE_WIDEC_SUPPORT /* { */ 1358174993Srafan#define isEILSEQ(status) (((size_t)status == (size_t)-1) && (errno == EILSEQ)) 1359166124Srafan 1360166124Srafan#define init_mb(state) memset(&state, 0, sizeof(state)) 1361166124Srafan 1362166124Srafan#if NCURSES_EXT_COLORS 1363166124Srafan#define NulColor , 0 1364166124Srafan#else 1365166124Srafan#define NulColor /* nothing */ 1366166124Srafan#endif 1367166124Srafan 1368166124Srafan#define NulChar 0,0,0,0 /* FIXME: see CCHARW_MAX */ 136997049Speter#define CharOf(c) ((c).chars[0]) 137097049Speter#define AttrOf(c) ((c).attr) 1371174993Srafan 1372174993Srafan#define AddAttr(c,a) AttrOf(c) |= ((a) & A_ATTRIBUTES) 1373166124Srafan#define RemAttr(c,a) AttrOf(c) &= ~((a) & A_ATTRIBUTES) 1374174993Srafan#define SetAttr(c,a) AttrOf(c) = ((a) & A_ATTRIBUTES) | WidecExt(c) 1375174993Srafan 1376166124Srafan#define NewChar2(c,a) { a, { c, NulChar } NulColor } 1377166124Srafan#define NewChar(ch) NewChar2(ChCharOf(ch), ChAttrOf(ch)) 1378174993Srafan 1379174993Srafan#if CCHARW_MAX == 5 1380174993Srafan#define CharEq(a,b) (((a).attr == (b).attr) \ 1381174993Srafan && (a).chars[0] == (b).chars[0] \ 1382174993Srafan && (a).chars[1] == (b).chars[1] \ 1383174993Srafan && (a).chars[2] == (b).chars[2] \ 1384174993Srafan && (a).chars[3] == (b).chars[3] \ 1385174993Srafan && (a).chars[4] == (b).chars[4] \ 1386174993Srafan if_EXT_COLORS(&& (a).ext_color == (b).ext_color)) 1387174993Srafan#else 1388166124Srafan#define CharEq(a,b) (!memcmp(&(a), &(b), sizeof(a))) 1389174993Srafan#endif 1390174993Srafan 1391166124Srafan#define SetChar(ch,c,a) do { \ 139297049Speter NCURSES_CH_T *_cp = &ch; \ 1393166124Srafan memset(_cp, 0, sizeof(ch)); \ 1394262629Sdelphij _cp->chars[0] = (wchar_t) (c); \ 1395166124Srafan _cp->attr = (a); \ 1396262629Sdelphij if_EXT_COLORS(SetPair(ch, PairNumber(a))); \ 139797049Speter } while (0) 139897049Speter#define CHREF(wch) (&wch) 139997049Speter#define CHDEREF(wch) (*wch) 140097049Speter#define ARG_CH_T NCURSES_CH_T * 140197049Speter#define CARG_CH_T const NCURSES_CH_T * 140297049Speter#define PUTC_DATA char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \ 140397049Speter mbstate_t PUT_st; wchar_t PUTC_ch 1404166124Srafan#define PUTC_INIT init_mb (PUT_st) 1405262685Sdelphij#define PUTC(ch) do { if(!isWidecExt(ch)) { \ 1406166124Srafan if (Charable(ch)) { \ 1407262685Sdelphij NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch)); \ 1408174993Srafan COUNT_OUTCHARS(1); \ 1409166124Srafan } else { \ 1410166124Srafan PUTC_INIT; \ 1411166124Srafan for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { \ 1412166124Srafan PUTC_ch = (ch).chars[PUTC_i]; \ 1413166124Srafan if (PUTC_ch == L'\0') \ 1414166124Srafan break; \ 1415262629Sdelphij PUTC_n = (int) wcrtomb(PUTC_buf, \ 1416262629Sdelphij (ch).chars[PUTC_i], &PUT_st); \ 1417166124Srafan if (PUTC_n <= 0) { \ 1418166124Srafan if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) \ 1419262685Sdelphij NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch)); \ 142097049Speter break; \ 1421262685Sdelphij } else { \ 1422262685Sdelphij int PUTC_j; \ 1423262685Sdelphij for (PUTC_j = 0; PUTC_j < PUTC_n; ++PUTC_j) { \ 1424262685Sdelphij NCURSES_OUTC_FUNC (NCURSES_SP_ARGx PUTC_buf[PUTC_j]); \ 1425262685Sdelphij } \ 1426166124Srafan } \ 1427166124Srafan } \ 1428174993Srafan COUNT_OUTCHARS(PUTC_i); \ 1429166124Srafan } } } while (0) 143050276Speter 1431174993Srafan#define BLANK NewChar2(' ', WA_NORMAL) 1432174993Srafan#define ZEROS NewChar2('\0', WA_NORMAL) 143397049Speter#define ISBLANK(ch) ((ch).chars[0] == L' ' && (ch).chars[1] == L'\0') 143497049Speter 1435166124Srafan /* 1436166124Srafan * Wide characters cannot be represented in the A_CHARTEXT mask of 1437166124Srafan * attr_t's but an application might have set a narrow character there. 1438166124Srafan * But even in that case, it would only be a printable character, or 1439166124Srafan * zero. Otherwise we can use those bits to tell if a cell is the 1440166124Srafan * first or extension part of a wide character. 1441166124Srafan */ 1442262629Sdelphij#define WidecExt(ch) (int) (AttrOf(ch) & A_CHARTEXT) 1443166124Srafan#define isWidecBase(ch) (WidecExt(ch) == 1) 1444166124Srafan#define isWidecExt(ch) (WidecExt(ch) > 1 && WidecExt(ch) < 32) 1445166124Srafan#define SetWidecExt(dst, ext) AttrOf(dst) &= ~A_CHARTEXT, \ 1446262629Sdelphij AttrOf(dst) |= (attr_t) (ext + 1) 1447166124Srafan 144897049Speter#define if_WIDEC(code) code 1449262685Sdelphij#define Charable(ch) ((SP_PARM->_legacy_coding) \ 1450166124Srafan || (AttrOf(ch) & A_ALTCHARSET) \ 1451166124Srafan || (!isWidecExt(ch) && \ 1452166124Srafan (ch).chars[1] == L'\0' && \ 1453166124Srafan _nc_is_charable(CharOf(ch)))) 145497049Speter 145597049Speter#define L(ch) L ## ch 145697049Speter#else /* }{ */ 145797049Speter#define CharOf(c) ChCharOf(c) 145897049Speter#define AttrOf(c) ChAttrOf(c) 1459166124Srafan#define AddAttr(c,a) c |= (a) 1460166124Srafan#define RemAttr(c,a) c &= ~((a) & A_ATTRIBUTES) 1461166124Srafan#define SetAttr(c,a) c = ((c) & ~A_ATTRIBUTES) | (a) 146297049Speter#define NewChar(ch) (ch) 1463166124Srafan#define NewChar2(c,a) ((c) | (a)) 1464166124Srafan#define CharEq(a,b) ((a) == (b)) 1465166124Srafan#define SetChar(ch,c,a) ch = (c) | (a) 146697049Speter#define CHREF(wch) wch 146797049Speter#define CHDEREF(wch) wch 146897049Speter#define ARG_CH_T NCURSES_CH_T 146997049Speter#define CARG_CH_T NCURSES_CH_T 1470262685Sdelphij#define PUTC_DATA /* nothing */ 1471262685Sdelphij#define PUTC(ch) NCURSES_OUTC_FUNC (NCURSES_SP_ARGx (int) ch) 147297049Speter 147397049Speter#define BLANK (' '|A_NORMAL) 1474166124Srafan#define ZEROS ('\0'|A_NORMAL) 147597049Speter#define ISBLANK(ch) (CharOf(ch) == ' ') 147697049Speter 1477166124Srafan#define isWidecExt(ch) (0) 147897049Speter#define if_WIDEC(code) /* nothing */ 147997049Speter 148097049Speter#define L(ch) ch 148197049Speter#endif /* } */ 148297049Speter 148397049Speter#define AttrOfD(ch) AttrOf(CHDEREF(ch)) 148497049Speter#define CharOfD(ch) CharOf(CHDEREF(ch)) 148597049Speter#define SetChar2(wch,ch) SetChar(wch,ChCharOf(ch),ChAttrOf(ch)) 148697049Speter 148797049Speter#define BLANK_ATTR A_NORMAL 148897049Speter#define BLANK_TEXT L(' ') 148997049Speter 149050276Speter#define CHANGED -1 149150276Speter 1492166124Srafan#define LEGALYX(w, y, x) \ 1493166124Srafan ((w) != 0 && \ 1494166124Srafan ((x) >= 0 && (x) <= (w)->_maxx && \ 1495166124Srafan (y) >= 0 && (y) <= (w)->_maxy)) 1496166124Srafan 149750276Speter#define CHANGED_CELL(line,col) \ 149850276Speter if (line->firstchar == _NOCHANGE) \ 1499262685Sdelphij line->firstchar = line->lastchar = (NCURSES_SIZE_T) (col); \ 150050276Speter else if ((col) < line->firstchar) \ 1501262685Sdelphij line->firstchar = (NCURSES_SIZE_T) (col); \ 150250276Speter else if ((col) > line->lastchar) \ 1503262685Sdelphij line->lastchar = (NCURSES_SIZE_T) (col) 150450276Speter 150550276Speter#define CHANGED_RANGE(line,start,end) \ 150650276Speter if (line->firstchar == _NOCHANGE \ 150750276Speter || line->firstchar > (start)) \ 1508262685Sdelphij line->firstchar = (NCURSES_SIZE_T) (start); \ 150950276Speter if (line->lastchar == _NOCHANGE \ 151050276Speter || line->lastchar < (end)) \ 1511262685Sdelphij line->lastchar = (NCURSES_SIZE_T) (end) 151250276Speter 151350276Speter#define CHANGED_TO_EOL(line,start,end) \ 151450276Speter if (line->firstchar == _NOCHANGE \ 151550276Speter || line->firstchar > (start)) \ 1516262685Sdelphij line->firstchar = (NCURSES_SIZE_T) (start); \ 1517262685Sdelphij line->lastchar = (NCURSES_SIZE_T) (end) 151850276Speter 151950276Speter#define SIZEOF(v) (sizeof(v)/sizeof(v[0])) 152062449Speter 152162449Speter#define FreeIfNeeded(p) if ((p) != 0) free(p) 152262449Speter 152362449Speter/* FreeAndNull() is not a comma-separated expression because some compilers 152462449Speter * do not accept a mixture of void with values. 152562449Speter */ 152650276Speter#define FreeAndNull(p) free(p); p = 0 152750276Speter 152850276Speter#include <nc_alloc.h> 152950276Speter 153050276Speter/* 1531262685Sdelphij * Use these for tic/infocmp malloc failures. Generally the ncurses library 1532262685Sdelphij * tries to limp along after a failure. 1533262685Sdelphij */ 1534262685Sdelphij#define TYPE_MALLOC(type, size, name) \ 1535262685Sdelphij name = typeMalloc(type, size); \ 1536262685Sdelphij if (name == 0) \ 1537262685Sdelphij _nc_err_abort(MSG_NO_MEMORY) 1538262685Sdelphij 1539262685Sdelphij#define TYPE_REALLOC(type, size, name) \ 1540262685Sdelphij name = typeRealloc(type, size, name); \ 1541262685Sdelphij if (name == 0) \ 1542262685Sdelphij _nc_err_abort(MSG_NO_MEMORY) 1543262685Sdelphij 1544262685Sdelphij/* 1545166124Srafan * TTY bit definition for converting tabs to spaces. 1546166124Srafan */ 1547166124Srafan#ifdef TAB3 1548166124Srafan# define OFLAGS_TABS TAB3 /* POSIX specifies TAB3 */ 1549166124Srafan#else 1550166124Srafan# ifdef XTABS 1551166124Srafan# define OFLAGS_TABS XTABS /* XTABS is usually the "same" */ 1552166124Srafan# else 1553166124Srafan# ifdef OXTABS 1554166124Srafan# define OFLAGS_TABS OXTABS /* the traditional BSD equivalent */ 1555166124Srafan# else 1556166124Srafan# define OFLAGS_TABS 0 1557166124Srafan# endif 1558166124Srafan# endif 1559166124Srafan#endif 1560166124Srafan 1561166124Srafan/* 1562178866Srafan * Standardize/simplify common loops 1563178866Srafan */ 1564178866Srafan#define each_screen(p) p = _nc_screen_chain; p != 0; p = (p)->_next_screen 1565262629Sdelphij#define each_window(sp,p) p = WindowList(sp); p != 0; p = (p)->next 1566262629Sdelphij#define each_ripoff(p) p = safe_ripoff_stack; (p - safe_ripoff_stack) < N_RIPS; ++p 1567178866Srafan 1568178866Srafan/* 156950276Speter * Prefixes for call/return points of library function traces. We use these to 157050276Speter * instrument the public functions so that the traces can be easily transformed 157150276Speter * into regression scripts. 157250276Speter */ 157397049Speter#define T_CALLED(fmt) "called {" fmt 157497049Speter#define T_CREATE(fmt) "create :" fmt 157597049Speter#define T_RETURN(fmt) "return }" fmt 157650276Speter 157750276Speter#ifdef TRACE 1578166124Srafan 1579174993Srafan#if USE_REENTRANT 1580174993Srafan#define TPUTS_TRACE(s) _nc_set_tputs_trace(s); 1581174993Srafan#else 1582174993Srafan#define TPUTS_TRACE(s) _nc_tputs_trace = s; 1583174993Srafan#endif 1584174993Srafan 1585166124Srafan#define START_TRACE() \ 1586166124Srafan if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \ 1587166124Srafan int t = _nc_getenv_num("NCURSES_TRACE"); \ 1588166124Srafan if (t >= 0) \ 1589166124Srafan trace((unsigned) t); \ 1590166124Srafan } 1591166124Srafan 1592174993Srafan/* 1593174993Srafan * Many of the _tracef() calls use static buffers; lock the trace state before 1594174993Srafan * trying to fill them. 1595174993Srafan */ 1596174993Srafan#if USE_REENTRANT 1597174993Srafan#define USE_TRACEF(mask) _nc_use_tracef(mask) 1598174993Srafanextern NCURSES_EXPORT(int) _nc_use_tracef (unsigned); 1599174993Srafanextern NCURSES_EXPORT(void) _nc_locked_tracef (const char *, ...) GCC_PRINTFLIKE(1,2); 1600174993Srafan#else 1601174993Srafan#define USE_TRACEF(mask) (_nc_tracing & (mask)) 1602174993Srafan#define _nc_locked_tracef _tracef 1603174993Srafan#endif 1604174993Srafan 1605174993Srafan#define TR(n, a) if (USE_TRACEF(n)) _nc_locked_tracef a 160650276Speter#define T(a) TR(TRACE_CALLS, a) 1607262629Sdelphij#define TRACE_RETURN(value,type) return _nc_retrace_##type(value) 1608262629Sdelphij#define TRACE_RETURN2(value,dst,src) return _nc_retrace_##dst##_##src(value) 1609262629Sdelphij#define TRACE_RETURN_SP(value,type) return _nc_retrace_##type(SP_PARM, value) 1610166124Srafan 1611262629Sdelphij#define NonNull(s) ((s) != 0 ? s : "<null>") 1612262629Sdelphij 1613166124Srafan#define returnAttr(code) TRACE_RETURN(code,attr_t) 1614166124Srafan#define returnBits(code) TRACE_RETURN(code,unsigned) 1615166124Srafan#define returnBool(code) TRACE_RETURN(code,bool) 1616166124Srafan#define returnCPtr(code) TRACE_RETURN(code,cptr) 1617166124Srafan#define returnCVoidPtr(code) TRACE_RETURN(code,cvoid_ptr) 1618262629Sdelphij#define returnChar(code) TRACE_RETURN(code,char) 1619262629Sdelphij#define returnChtype(code) TRACE_RETURN(code,chtype) 1620166124Srafan#define returnCode(code) TRACE_RETURN(code,int) 1621262629Sdelphij#define returnIntAttr(code) TRACE_RETURN2(code,int,attr_t) 1622262629Sdelphij#define returnMMask(code) TRACE_RETURN_SP(code,mmask_t) 1623166124Srafan#define returnPtr(code) TRACE_RETURN(code,ptr) 1624166124Srafan#define returnSP(code) TRACE_RETURN(code,sp) 1625166124Srafan#define returnVoid T((T_RETURN(""))); return 1626166124Srafan#define returnVoidPtr(code) TRACE_RETURN(code,void_ptr) 1627166124Srafan#define returnWin(code) TRACE_RETURN(code,win) 1628166124Srafan 1629262685Sdelphijextern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (int); 1630166124Srafanextern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *); 1631166124Srafanextern NCURSES_EXPORT(SCREEN *) _nc_retrace_sp (SCREEN *); 1632166124Srafanextern NCURSES_EXPORT(WINDOW *) _nc_retrace_win (WINDOW *); 1633166124Srafanextern NCURSES_EXPORT(attr_t) _nc_retrace_attr_t (attr_t); 1634166124Srafanextern NCURSES_EXPORT(char *) _nc_retrace_ptr (char *); 1635166124Srafanextern NCURSES_EXPORT(char *) _nc_trace_ttymode(TTY *tty); 1636166124Srafanextern NCURSES_EXPORT(char *) _nc_varargs (const char *, va_list); 1637166124Srafanextern NCURSES_EXPORT(chtype) _nc_retrace_chtype (chtype); 1638166124Srafanextern NCURSES_EXPORT(const char *) _nc_altcharset_name(attr_t, chtype); 1639166124Srafanextern NCURSES_EXPORT(const char *) _nc_retrace_cptr (const char *); 1640262685Sdelphijextern NCURSES_EXPORT(char) _nc_retrace_char (int); 1641166124Srafanextern NCURSES_EXPORT(int) _nc_retrace_int (int); 1642262629Sdelphijextern NCURSES_EXPORT(int) _nc_retrace_int_attr_t (attr_t); 1643262629Sdelphijextern NCURSES_EXPORT(mmask_t) _nc_retrace_mmask_t (SCREEN *, mmask_t); 1644166124Srafanextern NCURSES_EXPORT(unsigned) _nc_retrace_unsigned (unsigned); 1645166124Srafanextern NCURSES_EXPORT(void *) _nc_retrace_void_ptr (void *); 1646178866Srafanextern NCURSES_EXPORT(void) _nc_fifo_dump (SCREEN *); 1647174993Srafan 1648174993Srafan#if USE_REENTRANT 1649174993SrafanNCURSES_WRAPPED_VAR(long, _nc_outchars); 1650174993SrafanNCURSES_WRAPPED_VAR(const char *, _nc_tputs_trace); 1651174993Srafan#define _nc_outchars NCURSES_PUBLIC_VAR(_nc_outchars()) 1652174993Srafan#define _nc_tputs_trace NCURSES_PUBLIC_VAR(_nc_tputs_trace()) 1653174993Srafanextern NCURSES_EXPORT(void) _nc_set_tputs_trace (const char *); 1654174993Srafanextern NCURSES_EXPORT(void) _nc_count_outchars (long); 1655174993Srafan#else 165676726Speterextern NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace; 1657166124Srafanextern NCURSES_EXPORT_VAR(long) _nc_outchars; 1658174993Srafan#endif 1659174993Srafan 1660166124Srafanextern NCURSES_EXPORT_VAR(unsigned) _nc_tracing; 1661166124Srafan 166297049Speter#if USE_WIDEC_SUPPORT 166397049Speterextern NCURSES_EXPORT(const char *) _nc_viswbuf2 (int, const wchar_t *); 1664166124Srafanextern NCURSES_EXPORT(const char *) _nc_viswbufn (const wchar_t *, int); 166597049Speter#endif 1666166124Srafan 1667166124Srafanextern NCURSES_EXPORT(const char *) _nc_viscbuf2 (int, const NCURSES_CH_T *, int); 1668166124Srafanextern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int); 1669166124Srafan 1670166124Srafan#else /* !TRACE */ 1671166124Srafan 1672166124Srafan#define START_TRACE() /* nothing */ 1673166124Srafan 167450276Speter#define T(a) 167550276Speter#define TR(n, a) 167650276Speter#define TPUTS_TRACE(s) 167750276Speter 1678166124Srafan#define returnAttr(code) return code 1679166124Srafan#define returnBits(code) return code 1680166124Srafan#define returnBool(code) return code 1681166124Srafan#define returnCPtr(code) return code 1682166124Srafan#define returnCVoidPtr(code) return code 1683262629Sdelphij#define returnChar(code) return ((char) code) 1684262629Sdelphij#define returnChtype(code) return code 1685166124Srafan#define returnCode(code) return code 1686262629Sdelphij#define returnIntAttr(code) return code 1687262629Sdelphij#define returnMMask(code) return code 1688166124Srafan#define returnPtr(code) return code 1689166124Srafan#define returnSP(code) return code 1690166124Srafan#define returnVoid return 1691166124Srafan#define returnVoidPtr(code) return code 1692166124Srafan#define returnWin(code) return code 1693166124Srafan 1694166124Srafan#endif /* TRACE/!TRACE */ 1695166124Srafan 1696166124Srafan/* 1697262629Sdelphij * Workaround for defective implementation of gcc attribute warn_unused_result 1698262629Sdelphij */ 1699262629Sdelphij#if defined(__GNUC__) && defined(_FORTIFY_SOURCE) 1700262629Sdelphij#define IGNORE_RC(func) errno = (int) func 1701262629Sdelphij#else 1702262629Sdelphij#define IGNORE_RC(func) (void) func 1703262629Sdelphij#endif /* gcc workarounds */ 1704262629Sdelphij 1705262629Sdelphij/* 1706166124Srafan * Return-codes for tgetent() and friends. 1707166124Srafan */ 1708166124Srafan#define TGETENT_YES 1 /* entry is found */ 1709166124Srafan#define TGETENT_NO 0 /* entry is not found */ 1710166124Srafan#define TGETENT_ERR -1 /* an error occurred */ 1711166124Srafan 1712166124Srafanextern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *); 1713166124Srafanextern NCURSES_EXPORT(const char *) _nc_visbufn (const char *, int); 1714166124Srafan 1715184989Srafan#define EMPTY_MODULE(name) \ 171697049Speterextern NCURSES_EXPORT(void) name (void); \ 171797049Speter NCURSES_EXPORT(void) name (void) { } 171897049Speter 171950276Speter#define ALL_BUT_COLOR ((chtype)~(A_COLOR)) 1720262685Sdelphij#define NONBLANK_ATTR (A_BOLD | A_DIM | A_BLINK | A_ITALIC) 1721262685Sdelphij#define TPARM_ATTR (A_STANDOUT | A_UNDERLINE | A_REVERSE | A_BLINK | A_DIM | A_BOLD | A_ALTCHARSET | A_INVIS | A_PROTECT) 1722262685Sdelphij#define XMC_CONFLICT (A_STANDOUT | A_UNDERLINE | A_REVERSE | A_BLINK | A_DIM | A_BOLD | A_INVIS | A_PROTECT | A_ITALIC) 1723262629Sdelphij#define XMC_CHANGES(c) ((c) & SP_PARM->_xmc_suppress) 172450276Speter 172562449Speter#define toggle_attr_on(S,at) {\ 1726262629Sdelphij if (PairNumber(at) > 0) {\ 1727262629Sdelphij (S) = ((S) & ALL_BUT_COLOR) | (attr_t) (at);\ 1728166124Srafan } else {\ 1729262629Sdelphij (S) |= (attr_t) (at);\ 1730166124Srafan }\ 173166963Speter TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));} 173250276Speter 173350276Speter 173462449Speter#define toggle_attr_off(S,at) {\ 1735262629Sdelphij if (PairNumber(at) > 0) {\ 1736166124Srafan (S) &= ~(at|A_COLOR);\ 173750276Speter } else {\ 1738166124Srafan (S) &= ~(at);\ 173950276Speter }\ 174066963Speter TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));} 174150276Speter 1742262629Sdelphij#define DelCharCost(sp,count) \ 174350276Speter ((parm_dch != 0) \ 1744262629Sdelphij ? sp->_dch_cost \ 174550276Speter : ((delete_character != 0) \ 1746262629Sdelphij ? (sp->_dch1_cost * count) \ 174750276Speter : INFINITY)) 174850276Speter 1749262629Sdelphij#define InsCharCost(sp,count) \ 175050276Speter ((parm_ich != 0) \ 1751262629Sdelphij ? sp->_ich_cost \ 175250276Speter : ((enter_insert_mode && exit_insert_mode) \ 1753262629Sdelphij ? sp->_smir_cost + sp->_rmir_cost + (sp->_ip_cost * count) \ 175450276Speter : ((insert_character != 0) \ 1755262629Sdelphij ? ((sp->_ich1_cost + sp->_ip_cost) * count) \ 175650276Speter : INFINITY))) 175750276Speter 175850276Speter#if USE_XMC_SUPPORT 1759262629Sdelphij#define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \ 1760262629Sdelphij attr_t chg = AttrOf(SCREEN_ATTRS(sp)); \ 1761262629Sdelphij VIDATTR(sp, AttrOf(c), GetPair(c)); \ 176250276Speter if (magic_cookie_glitch > 0 \ 1763262629Sdelphij && XMC_CHANGES((chg ^ AttrOf(SCREEN_ATTRS(sp))))) { \ 176497049Speter T(("%s @%d before glitch %d,%d", \ 176550276Speter __FILE__, __LINE__, \ 1766262629Sdelphij sp->_cursrow, \ 1767262629Sdelphij sp->_curscol)); \ 1768262629Sdelphij NCURSES_SP_NAME(_nc_do_xmc_glitch)(NCURSES_SP_ARGx chg); \ 176950276Speter } \ 177050276Speter } 177150276Speter#else 1772262629Sdelphij#define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \ 1773262629Sdelphij VIDATTR(sp, AttrOf(c), GetPair(c)); \ 1774262629Sdelphij } 177550276Speter#endif 177650276Speter 1777166124Srafan/* 1778166124Srafan * Macros to make additional parameter to implement wgetch_events() 1779166124Srafan */ 1780166124Srafan#ifdef NCURSES_WGETCH_EVENTS 1781166124Srafan#define EVENTLIST_0th(param) param 1782166124Srafan#define EVENTLIST_1st(param) param 1783166124Srafan#define EVENTLIST_2nd(param) , param 1784262629Sdelphij#define TWAIT_MASK (TW_ANY | TW_EVENT) 1785166124Srafan#else 1786166124Srafan#define EVENTLIST_0th(param) void 1787166124Srafan#define EVENTLIST_1st(param) /* nothing */ 1788166124Srafan#define EVENTLIST_2nd(param) /* nothing */ 1789262629Sdelphij#define TWAIT_MASK TW_ANY 1790166124Srafan#endif 1791166124Srafan 179266963Speter#if NCURSES_EXPANDED && NCURSES_EXT_FUNCS 179350276Speter 179450276Speter#undef toggle_attr_on 179550276Speter#define toggle_attr_on(S,at) _nc_toggle_attr_on(&(S), at) 179676726Speterextern NCURSES_EXPORT(void) _nc_toggle_attr_on (attr_t *, attr_t); 179750276Speter 179850276Speter#undef toggle_attr_off 179950276Speter#define toggle_attr_off(S,at) _nc_toggle_attr_off(&(S), at) 180076726Speterextern NCURSES_EXPORT(void) _nc_toggle_attr_off (attr_t *, attr_t); 180150276Speter 180250276Speter#undef DelCharCost 1803262629Sdelphij#define DelCharCost(sp, count) NCURSES_SP_NAME(_nc_DelCharCost)(NCURSES_SP_ARGx count) 180450276Speter 180550276Speter#undef InsCharCost 1806262629Sdelphij#define InsCharCost(sp, count) NCURSES_SP_NAME(_nc_InsCharCost)(NCURSES_SP_ARGx count) 180750276Speter 1808262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_DelCharCost) (NCURSES_SP_DCLx int _c); 1809262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_InsCharCost) (NCURSES_SP_DCLx int _c); 1810262629Sdelphij 181150276Speter#undef UpdateAttrs 1812262629Sdelphij#define UpdateAttrs(sp,c) NCURSES_SP_NAME(_nc_UpdateAttrs)(NCURSES_SP_ARGx CHREF(c)) 181350276Speter 1814262629Sdelphij#if USE_WIDEC_SUPPORT || defined(NEED_NCURSES_CH_T) 1815262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx CARG_CH_T _c); 181650276Speter#else 1817262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx chtype c); 1818262629Sdelphij#endif 181950276Speter 1820262629Sdelphij#if NCURSES_SP_FUNCS 1821262629Sdelphijextern NCURSES_EXPORT(int) _nc_DelCharCost (int); 1822262629Sdelphijextern NCURSES_EXPORT(int) _nc_InsCharCost (int); 1823262629Sdelphijextern NCURSES_EXPORT(void) _nc_UpdateAttrs (CARG_CH_T); 1824262629Sdelphij#endif /* NCURSES_SP_FUNCS */ 1825262629Sdelphij 1826262629Sdelphij#else 1827262629Sdelphij 182876726Speterextern NCURSES_EXPORT(void) _nc_expanded (void); 182950276Speter 183050276Speter#endif 183150276Speter 1832184989Srafan#if !NCURSES_EXT_FUNCS 1833184989Srafan#define set_escdelay(value) ESCDELAY = value 1834184989Srafan#endif 1835184989Srafan 183650276Speter#if !HAVE_GETCWD 183750276Speter#define getcwd(buf,len) getwd(buf) 183850276Speter#endif 183950276Speter 1840166124Srafan/* charable.c */ 1841166124Srafan#if USE_WIDEC_SUPPORT 1842166124Srafanextern NCURSES_EXPORT(bool) _nc_is_charable(wchar_t); 1843166124Srafanextern NCURSES_EXPORT(int) _nc_to_char(wint_t); 1844166124Srafanextern NCURSES_EXPORT(wint_t) _nc_to_widechar(int); 1845166124Srafan#endif 1846166124Srafan 1847174993Srafan/* comp_captab.c */ 1848174993Srafantypedef struct { 1849174993Srafan short nte_name; /* offset of name to hash on */ 1850174993Srafan int nte_type; /* BOOLEAN, NUMBER or STRING */ 1851174993Srafan short nte_index; /* index of associated variable in its array */ 1852174993Srafan short nte_link; /* index in table of next hash, or -1 */ 1853174993Srafan} name_table_data; 1854174993Srafan 1855174993Srafantypedef struct 1856174993Srafan{ 1857174993Srafan short from; 1858174993Srafan short to; 1859174993Srafan short source; 1860174993Srafan} alias_table_data; 1861174993Srafan 186250276Speter/* doupdate.c */ 186350276Speter#if USE_XMC_SUPPORT 186476726Speterextern NCURSES_EXPORT(void) _nc_do_xmc_glitch (attr_t); 186550276Speter#endif 186650276Speter 186750276Speter/* hardscroll.c */ 186850276Speter#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG) 186976726Speterextern NCURSES_EXPORT(void) _nc_linedump (void); 187050276Speter#endif 187150276Speter 187250276Speter/* lib_acs.c */ 1873262629Sdelphijextern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */ 1874262629Sdelphijextern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int); /* used by 'tack' program */ 187550276Speter 1876166124Srafan/* lib_addch.c */ 1877166124Srafan#if USE_WIDEC_SUPPORT 1878166124SrafanNCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch); 1879166124Srafan#endif 1880166124Srafan 188197049Speter/* lib_addstr.c */ 1882262629Sdelphij#if USE_WIDEC_SUPPORT && !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) 188397049Speterextern NCURSES_EXPORT(int) _nc_wchstrlen(const cchar_t *); 188497049Speter#endif 188597049Speter 1886166124Srafan/* lib_color.c */ 1887166124Srafanextern NCURSES_EXPORT(bool) _nc_reset_colors(void); 1888166124Srafan 188997049Speter/* lib_getch.c */ 1890262629Sdelphijextern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, int *, int EVENTLIST_2nd(_nc_eventlist *)); 189197049Speter 1892166124Srafan/* lib_insch.c */ 1893262629Sdelphijextern NCURSES_EXPORT(int) _nc_insert_ch(SCREEN *, WINDOW *, chtype); 1894166124Srafan 189550276Speter/* lib_mvcur.c */ 189650276Speter#define INFINITY 1000000 /* cost: too high to use */ 189750276Speter 1898262685Sdelphijextern NCURSES_EXPORT(int) _nc_mvcur(int yold, int xold, int ynew, int xnew); 1899262685Sdelphij 190076726Speterextern NCURSES_EXPORT(void) _nc_mvcur_init (void); 190176726Speterextern NCURSES_EXPORT(void) _nc_mvcur_resume (void); 190276726Speterextern NCURSES_EXPORT(void) _nc_mvcur_wrap (void); 190350276Speter 190476726Speterextern NCURSES_EXPORT(int) _nc_scrolln (int, int, int, int); 190550276Speter 190676726Speterextern NCURSES_EXPORT(void) _nc_screen_init (void); 190776726Speterextern NCURSES_EXPORT(void) _nc_screen_resume (void); 190876726Speterextern NCURSES_EXPORT(void) _nc_screen_wrap (void); 190950276Speter 191066963Speter/* lib_mouse.c */ 1911262629Sdelphijextern NCURSES_EXPORT(bool) _nc_has_mouse (SCREEN *); 191266963Speter 191366963Speter/* lib_mvcur.c */ 191466963Speter#define INFINITY 1000000 /* cost: too high to use */ 1915166124Srafan#define BAUDBYTE 9 /* 9 = 7 bits + 1 parity + 1 stop */ 191666963Speter 1917166124Srafan/* lib_setup.c */ 1918166124Srafanextern NCURSES_EXPORT(char *) _nc_get_locale(void); 1919262629Sdelphijextern NCURSES_EXPORT(int) _nc_unicode_locale(void); 1920262629Sdelphijextern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *); 1921262685Sdelphijextern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, int); 1922262685Sdelphijextern NCURSES_EXPORT(void) _nc_tinfo_cmdch(TERMINAL *, int); 1923166124Srafan 1924262629Sdelphij/* lib_set_term.c */ 1925262629Sdelphijextern NCURSES_EXPORT(int) _nc_ripoffline(int, int(*)(WINDOW*, int)); 1926262629Sdelphij 1927262685Sdelphij/* lib_setup.c */ 1928262685Sdelphij#define ret_error(code, fmt, arg) if (errret) {\ 1929262685Sdelphij *errret = code;\ 1930262685Sdelphij returnCode(ERR);\ 1931262685Sdelphij } else {\ 1932262685Sdelphij fprintf(stderr, fmt, arg);\ 1933262685Sdelphij exit(EXIT_FAILURE);\ 1934262685Sdelphij } 1935262685Sdelphij 1936262685Sdelphij#define ret_error1(code, fmt, arg) ret_error(code, "'%s': " fmt, arg) 1937262685Sdelphij 1938262685Sdelphij#define ret_error0(code, msg) if (errret) {\ 1939262685Sdelphij *errret = code;\ 1940262685Sdelphij returnCode(ERR);\ 1941262685Sdelphij } else {\ 1942262685Sdelphij fprintf(stderr, msg);\ 1943262685Sdelphij exit(EXIT_FAILURE);\ 1944262685Sdelphij } 1945262685Sdelphij 1946166124Srafan/* lib_tstp.c */ 1947166124Srafan#if USE_SIGWINCH 1948178866Srafanextern NCURSES_EXPORT(int) _nc_handle_sigwinch(SCREEN *); 1949166124Srafan#else 1950166124Srafan#define _nc_handle_sigwinch(a) /* nothing */ 1951166124Srafan#endif 1952166124Srafan 195397049Speter/* lib_wacs.c */ 195497049Speter#if USE_WIDEC_SUPPORT 195597049Speterextern NCURSES_EXPORT(void) _nc_init_wacs(void); 195697049Speter#endif 195797049Speter 195866963Spetertypedef struct { 1959166124Srafan char *s_head; /* beginning of the string (may be null) */ 1960166124Srafan char *s_tail; /* end of the string (may be null) */ 1961166124Srafan size_t s_size; /* current remaining size available */ 1962166124Srafan size_t s_init; /* total size available */ 196366963Speter} string_desc; 196466963Speter 196566963Speter/* strings.c */ 196697049Speterextern NCURSES_EXPORT(string_desc *) _nc_str_init (string_desc *, char *, size_t); 196797049Speterextern NCURSES_EXPORT(string_desc *) _nc_str_null (string_desc *, size_t); 196897049Speterextern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, string_desc *); 196997049Speterextern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc *, const char *); 197097049Speterextern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc *, const char *); 197166963Speter 197250276Speter#if !HAVE_STRSTR 197350276Speter#define strstr _nc_strstr 197476726Speterextern NCURSES_EXPORT(char *) _nc_strstr (const char *, const char *); 197550276Speter#endif 197650276Speter 197750276Speter/* safe_sprintf.c */ 197897049Speterextern NCURSES_EXPORT(char *) _nc_printf_string (const char *, va_list); 197950276Speter 198050276Speter/* tries.c */ 1981174993Srafanextern NCURSES_EXPORT(int) _nc_add_to_try (TRIES **, const char *, unsigned); 1982174993Srafanextern NCURSES_EXPORT(char *) _nc_expand_try (TRIES *, unsigned, int *, size_t); 1983174993Srafanextern NCURSES_EXPORT(int) _nc_remove_key (TRIES **, unsigned); 1984174993Srafanextern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *); 198550276Speter 198650276Speter/* elsewhere ... */ 1987184989Srafanextern NCURSES_EXPORT(ENTRY *) _nc_delink_entry (ENTRY *, TERMTYPE *); 1988184989Srafanextern NCURSES_EXPORT(SCREEN *) _nc_screen_of (WINDOW *); 1989262629Sdelphijextern NCURSES_EXPORT(TERMINAL*) _nc_get_cur_term (void); 199076726Speterextern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int); 199176726Speterextern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t); 1992166124Srafanextern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *); 1993184989Srafanextern NCURSES_EXPORT(char *) _nc_tracechar (SCREEN *, int); 1994184989Srafanextern NCURSES_EXPORT(char *) _nc_tracemouse (SCREEN *, MEVENT const *); 1995166124Srafanextern NCURSES_EXPORT(int) _nc_access (const char *, int); 199676726Speterextern NCURSES_EXPORT(int) _nc_baudrate (int); 199797049Speterextern NCURSES_EXPORT(int) _nc_freewin (WINDOW *); 199876726Speterextern NCURSES_EXPORT(int) _nc_getenv_num (const char *); 1999262685Sdelphijextern NCURSES_EXPORT(int) _nc_keypad (SCREEN *, int); 200076726Speterextern NCURSES_EXPORT(int) _nc_ospeed (int); 200176726Speterextern NCURSES_EXPORT(int) _nc_outch (int); 2002262685Sdelphijextern NCURSES_EXPORT(int) _nc_putchar (int); 2003262629Sdelphijextern NCURSES_EXPORT(int) _nc_putp(const char *, const char *); 2004262629Sdelphijextern NCURSES_EXPORT(int) _nc_putp_flush(const char *, const char *); 2005166124Srafanextern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const); 2006262629Sdelphijextern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE *); 2007262685Sdelphijextern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, int, int); 2008184989Srafanextern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *)); 2009262685Sdelphijextern NCURSES_EXPORT(void) _nc_do_color (int, int, int, NCURSES_OUTC); 201076726Speterextern NCURSES_EXPORT(void) _nc_flush (void); 2011262629Sdelphijextern NCURSES_EXPORT(void) _nc_free_and_exit (int) GCC_NORETURN; 2012184989Srafanextern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, TERMTYPE *); 201376726Speterextern NCURSES_EXPORT(void) _nc_freeall (void); 201476726Speterextern NCURSES_EXPORT(void) _nc_hash_map (void); 2015178866Srafanextern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *); 201676726Speterextern NCURSES_EXPORT(void) _nc_keep_tic_dir (const char *); 201776726Speterextern NCURSES_EXPORT(void) _nc_make_oldhash (int i); 201876726Speterextern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot); 201976726Speterextern NCURSES_EXPORT(void) _nc_scroll_optimize (void); 2020262685Sdelphijextern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, int); 2021262685Sdelphijextern NCURSES_EXPORT(void) _nc_setenv_num (const char *, int); 2022262685Sdelphijextern NCURSES_EXPORT(void) _nc_signal_handler (int); 202397049Speterextern NCURSES_EXPORT(void) _nc_synchook (WINDOW *); 2024174993Srafanextern NCURSES_EXPORT(void) _nc_trace_tries (TRIES *); 202550276Speter 2026166124Srafan#if NO_LEAKS 2027166124Srafanextern NCURSES_EXPORT(void) _nc_alloc_entry_leaks(void); 2028166124Srafanextern NCURSES_EXPORT(void) _nc_captoinfo_leaks(void); 2029174993Srafanextern NCURSES_EXPORT(void) _nc_codes_leaks(void); 2030174993Srafanextern NCURSES_EXPORT(void) _nc_comp_captab_leaks(void); 2031262685Sdelphijextern NCURSES_EXPORT(void) _nc_comp_error_leaks(void); 2032166124Srafanextern NCURSES_EXPORT(void) _nc_comp_scan_leaks(void); 2033262685Sdelphijextern NCURSES_EXPORT(void) _nc_db_iterator_leaks(void); 2034166124Srafanextern NCURSES_EXPORT(void) _nc_keyname_leaks(void); 2035174993Srafanextern NCURSES_EXPORT(void) _nc_names_leaks(void); 2036166124Srafanextern NCURSES_EXPORT(void) _nc_tgetent_leaks(void); 2037166124Srafan#endif 2038166124Srafan 2039262629Sdelphij#if !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) 2040166124Srafanextern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T); 2041166124Srafanextern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T); 2042262685Sdelphijextern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, int const, int const, NCURSES_CH_T); 2043166124Srafan#endif 2044166124Srafan 2045262629Sdelphij#if USE_WIDEC_SUPPORT 2046262629Sdelphijextern NCURSES_EXPORT(int) _nc_insert_wch(WINDOW *, const cchar_t *); 2047262629Sdelphij#endif 2048262629Sdelphij 2049262629Sdelphij#if USE_WIDEC_SUPPORT && !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) 2050166124Srafanextern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *); 2051166124Srafan#endif 2052166124Srafan 205350276Speter#if USE_SIZECHANGE 2054178866Srafanextern NCURSES_EXPORT(void) _nc_update_screensize (SCREEN *); 205550276Speter#endif 205650276Speter 205797049Speter#if HAVE_RESIZETERM 205897049Speterextern NCURSES_EXPORT(void) _nc_resize_margins (WINDOW *); 205997049Speter#else 206097049Speter#define _nc_resize_margins(wp) /* nothing */ 206162449Speter#endif 206262449Speter 2063166124Srafan#ifdef NCURSES_WGETCH_EVENTS 2064166124Srafanextern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *); 2065166124Srafan#else 2066166124Srafan#define wgetch_events(win, evl) wgetch(win) 2067166124Srafan#define wgetnstr_events(win, str, maxlen, evl) wgetnstr(win, str, maxlen) 2068166124Srafan#endif 2069166124Srafan 207097049Speter/* 2071262629Sdelphij * Wide-character macros to hide some platform-differences. 2072262629Sdelphij */ 2073262629Sdelphij#if USE_WIDEC_SUPPORT 2074262685Sdelphij 2075262685Sdelphij#if defined(__MINGW32__) 2076262685Sdelphij/* 2077262685Sdelphij * MinGW has wide-character functions, but they do not work correctly. 2078262685Sdelphij */ 2079262685Sdelphij 2080262685Sdelphijextern int __MINGW_NOTHROW _nc_wctomb(char *, wchar_t); 2081262685Sdelphij#define wctomb(s,wc) _nc_wctomb(s,wc) 2082262685Sdelphij#define wcrtomb(s,wc,n) _nc_wctomb(s,wc) 2083262685Sdelphij 2084262685Sdelphijextern int __MINGW_NOTHROW _nc_mbtowc(wchar_t *, const char *, size_t); 2085262685Sdelphij#define mbtowc(pwc,s,n) _nc_mbtowc(pwc,s,n) 2086262685Sdelphij 2087262685Sdelphijextern int __MINGW_NOTHROW _nc_mblen(const char *, size_t); 2088262685Sdelphij#define mblen(s,n) _nc_mblen(s, n) 2089262685Sdelphij 2090262685Sdelphij#endif /* __MINGW32__ */ 2091262685Sdelphij 2092262629Sdelphij#if HAVE_MBTOWC && HAVE_MBLEN 2093262685Sdelphij#define reset_mbytes(state) IGNORE_RC(mblen(NULL, (size_t) 0)), IGNORE_RC(mbtowc(NULL, NULL, (size_t) 0)) 2094262629Sdelphij#define count_mbytes(buffer,length,state) mblen(buffer,length) 2095262629Sdelphij#define check_mbytes(wch,buffer,length,state) \ 2096262629Sdelphij (int) mbtowc(&wch, buffer, length) 2097262629Sdelphij#define state_unused 2098262629Sdelphij#elif HAVE_MBRTOWC && HAVE_MBRLEN 2099262629Sdelphij#define reset_mbytes(state) init_mb(state) 2100262629Sdelphij#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state) 2101262629Sdelphij#define check_mbytes(wch,buffer,length,state) \ 2102262629Sdelphij (int) mbrtowc(&wch, buffer, length, &state) 2103262629Sdelphij#else 2104262629Sdelphijmake an error 2105262629Sdelphij#endif 2106262629Sdelphij 2107262685Sdelphij#endif /* USE_WIDEC_SUPPORT */ 2108262685Sdelphij 2109262629Sdelphij/* 211097049Speter * Not everyone has vsscanf(), but we'd like to use it for scanw(). 211197049Speter */ 211297049Speter#if !HAVE_VSSCANF 211397049Speterextern int vsscanf(const char *str, const char *format, va_list __arg); 211497049Speter#endif 211597049Speter 211650276Speter/* scroll indices */ 211776726Speterextern NCURSES_EXPORT_VAR(int *) _nc_oldnums; 211850276Speter 211950276Speter#define USE_SETBUF_0 0 212050276Speter 2121262629Sdelphij#define NC_BUFFERED(sp,flag) NCURSES_SP_NAME(_nc_set_buffer)(NCURSES_SP_ARGx sp->_ofp, flag) 212250276Speter 2123262629Sdelphij#define NC_OUTPUT(sp) ((sp != 0) ? sp->_ofp : stdout) 212456639Speter 212550276Speter/* 212650276Speter * On systems with a broken linker, define 'SP' as a function to force the 212750276Speter * linker to pull in the data-only module with 'SP'. 212850276Speter */ 2129262629Sdelphij#define _nc_alloc_screen_sp() typeCalloc(SCREEN, 1) 2130262629Sdelphij 213150276Speter#if BROKEN_LINKER 213250276Speter#define SP _nc_screen() 213376726Speterextern NCURSES_EXPORT(SCREEN *) _nc_screen (void); 2134262629Sdelphijextern NCURSES_EXPORT(int) _nc_alloc_screen (void); 2135262629Sdelphijextern NCURSES_EXPORT(void) _nc_set_screen (SCREEN *); 2136262629Sdelphij#define CURRENT_SCREEN _nc_screen() 213750276Speter#else 213850276Speter/* current screen is private data; avoid possible linking conflicts too */ 213976726Speterextern NCURSES_EXPORT_VAR(SCREEN *) SP; 2140262629Sdelphij#define CURRENT_SCREEN SP 2141262629Sdelphij#define _nc_alloc_screen() ((SP = _nc_alloc_screen_sp()) != 0) 2142262629Sdelphij#define _nc_set_screen(sp) SP = sp 214350276Speter#endif 214450276Speter 2145262629Sdelphij#if NCURSES_SP_FUNCS 2146262629Sdelphij#define CURRENT_SCREEN_PRE (IsPreScreen(CURRENT_SCREEN) ? CURRENT_SCREEN : new_prescr()) 2147262629Sdelphij#else 2148262629Sdelphij#define CURRENT_SCREEN_PRE CURRENT_SCREEN 2149262629Sdelphij#endif 2150262629Sdelphij 215150276Speter/* 215297049Speter * We don't want to use the lines or columns capabilities internally, because 215397049Speter * if the application is running multiple screens under X, it's quite possible 215497049Speter * they could all have type xterm but have different sizes! So... 215550276Speter */ 2156262629Sdelphij#define screen_lines(sp) (sp)->_lines 2157262629Sdelphij#define screen_columns(sp) (sp)->_columns 215850276Speter 215976726Speterextern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int); 2160262629Sdelphijextern NCURSES_EXPORT(int) _nc_format_slks (NCURSES_SP_DCLx int _c); 216150276Speter 216250276Speter/* 216350276Speter * Some constants related to SLK's 216450276Speter */ 216550276Speter#define MAX_SKEY_OLD 8 /* count of soft keys */ 216650276Speter#define MAX_SKEY_LEN_OLD 8 /* max length of soft key text */ 216750276Speter#define MAX_SKEY_PC 12 /* This is what most PC's have */ 216850276Speter#define MAX_SKEY_LEN_PC 5 216950276Speter 217050276Speter/* Macro to check whether or not we use a standard format */ 217150276Speter#define SLK_STDFMT(fmt) (fmt < 3) 217250276Speter/* Macro to determine height of label window */ 217350276Speter#define SLK_LINES(fmt) (SLK_STDFMT(fmt) ? 1 : ((fmt) - 2)) 217450276Speter 217550276Speter#define MAX_SKEY(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC) 217650276Speter#define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC) 217750276Speter 2178166124Srafan/* 2179166124Srafan * Common error messages 2180166124Srafan */ 2181166124Srafan#define MSG_NO_MEMORY "Out of memory" 2182166124Srafan#define MSG_NO_INPUTS "Premature EOF" 2183166124Srafan 2184262629Sdelphijextern NCURSES_EXPORT(int) _nc_set_tty_mode(TTY *); 2185262629Sdelphijextern NCURSES_EXPORT(int) _nc_get_tty_mode(TTY *); 2186262629Sdelphij 2187262629Sdelphij/* timed_wait flag definitions */ 2188262629Sdelphij#define TW_NONE 0 2189262629Sdelphij#define TW_INPUT 1 2190262629Sdelphij#define TW_MOUSE 2 2191262629Sdelphij#define TW_ANY (TW_INPUT | TW_MOUSE) 2192262629Sdelphij#define TW_EVENT 4 2193262629Sdelphij 2194262629Sdelphij#define SetSafeOutcWrapper(outc) \ 2195262629Sdelphij SCREEN* sp = CURRENT_SCREEN; \ 2196262685Sdelphij struct screen outc_wrapper; \ 2197262629Sdelphij if (sp==0) { \ 2198262685Sdelphij sp = &outc_wrapper; \ 2199262629Sdelphij memset(sp,0,sizeof(struct screen)); \ 2200262629Sdelphij sp->_outch = _nc_outc_wrapper; \ 2201262629Sdelphij }\ 2202262629Sdelphij sp->jump = outc 2203262629Sdelphij 2204262629Sdelphij#ifdef USE_TERM_DRIVER 2205262629Sdelphijtypedef void* TERM_HANDLE; 2206262629Sdelphij 2207262629Sdelphijtypedef struct _termInfo 2208262629Sdelphij{ 2209262629Sdelphij bool caninit; 2210262629Sdelphij 2211262629Sdelphij bool hascolor; 2212262629Sdelphij bool initcolor; 2213262629Sdelphij bool canchange; 2214262629Sdelphij 2215262629Sdelphij int tabsize; 2216262629Sdelphij 2217262629Sdelphij int maxcolors; 2218262629Sdelphij int maxpairs; 2219262629Sdelphij int nocolorvideo; 2220262629Sdelphij 2221262629Sdelphij int numbuttons; 2222262629Sdelphij int numlabels; 2223262629Sdelphij int labelwidth; 2224262629Sdelphij int labelheight; 2225262629Sdelphij 2226262629Sdelphij const color_t* defaultPalette; 2227262629Sdelphij} TerminalInfo; 2228262629Sdelphij 2229262629Sdelphijtypedef struct term_driver { 2230262629Sdelphij bool isTerminfo; 2231262685Sdelphij bool (*CanHandle)(struct DriverTCB*, const char*, int*); 2232262629Sdelphij void (*init)(struct DriverTCB*); 2233262629Sdelphij void (*release)(struct DriverTCB*); 2234262629Sdelphij int (*size)(struct DriverTCB*, int* Line, int *Cols); 2235262685Sdelphij int (*sgmode)(struct DriverTCB*, int setFlag, TTY*); 2236262629Sdelphij chtype (*conattr)(struct DriverTCB*); 2237262629Sdelphij int (*hwcur)(struct DriverTCB*, int yold, int xold, int y, int x); 2238262685Sdelphij int (*mode)(struct DriverTCB*, int progFlag, int defFlag); 2239262629Sdelphij bool (*rescol)(struct DriverTCB*); 2240262629Sdelphij bool (*rescolors)(struct DriverTCB*); 2241262685Sdelphij void (*color)(struct DriverTCB*, int fore, int color, int(*)(SCREEN*, int)); 2242262685Sdelphij int (*doBeepOrFlash)(struct DriverTCB*, int); 2243262685Sdelphij void (*initpair)(struct DriverTCB*, int, int, int); 2244262685Sdelphij void (*initcolor)(struct DriverTCB*, int, int, int, int); 2245262685Sdelphij void (*docolor)(struct DriverTCB*, int, int, int, int(*)(SCREEN*, int)); 2246262629Sdelphij void (*initmouse)(struct DriverTCB*); 2247262685Sdelphij int (*testmouse)(struct DriverTCB*, int EVENTLIST_2nd(_nc_eventlist*)); 2248262629Sdelphij void (*setfilter)(struct DriverTCB*); 2249262685Sdelphij void (*hwlabel)(struct DriverTCB*, int, char*); 2250262685Sdelphij void (*hwlabelOnOff)(struct DriverTCB*, int); 2251262629Sdelphij int (*update)(struct DriverTCB*); 2252262685Sdelphij int (*defaultcolors)(struct DriverTCB*, int, int); 2253262685Sdelphij int (*print)(struct DriverTCB*, char*, int); 2254262685Sdelphij int (*getsize)(struct DriverTCB*, int*, int*); 2255262685Sdelphij int (*setsize)(struct DriverTCB*, int, int); 2256262685Sdelphij void (*initacs)(struct DriverTCB*, chtype*, chtype*); 2257262629Sdelphij void (*scinit)(SCREEN *); 2258262629Sdelphij void (*scexit)(SCREEN *); 2259262685Sdelphij int (*twait)(struct DriverTCB*, int, int, int* EVENTLIST_2nd(_nc_eventlist*)); 2260262685Sdelphij int (*read)(struct DriverTCB*, int*); 2261262685Sdelphij int (*nap)(struct DriverTCB*, int); 2262262685Sdelphij int (*kpad)(struct DriverTCB*, int); 2263262685Sdelphij int (*kyOk)(struct DriverTCB*, int, int); 2264262629Sdelphij bool (*kyExist)(struct DriverTCB*, int); 2265262629Sdelphij} TERM_DRIVER; 2266262629Sdelphij 2267262629Sdelphijtypedef struct DriverTCB 2268262629Sdelphij{ 2269262629Sdelphij TERMINAL term; /* needs to be the first Element !!! */ 2270262629Sdelphij TERM_HANDLE inp; /* The input handle of the Terminal */ 2271262629Sdelphij TERM_HANDLE out; /* The output handle of the Terminal in shell mode */ 2272262629Sdelphij TERM_HANDLE hdl; /* The output handle of the Terminal in prog mode */ 2273262629Sdelphij TERM_DRIVER* drv; /* The driver for that Terminal */ 2274262629Sdelphij SCREEN* csp; /* The screen that owns that Terminal */ 2275262629Sdelphij TerminalInfo info; /* Driver independent core capabilities of the Terminal */ 2276262629Sdelphij void* prop; /* Driver dependent property storage to be used by the Driver */ 2277262629Sdelphij long magic; 2278262629Sdelphij} TERMINAL_CONTROL_BLOCK; 2279262629Sdelphij 2280262629Sdelphij#define NCDRV_MAGIC(id) (0x47110000 | (id&0xffff)) 2281262629Sdelphij#define NCDRV_TINFO 0x01 2282262629Sdelphij#define NCDRV_WINCONSOLE 0x02 2283262629Sdelphij 2284262629Sdelphij#define TCBOf(sp) ((TERMINAL_CONTROL_BLOCK*)(TerminalOf(sp))) 2285262629Sdelphij#define InfoOf(sp) TCBOf(sp)->info 2286262629Sdelphij#define CallDriver(sp,method) TCBOf(sp)->drv->method(TCBOf(sp)) 2287262629Sdelphij#define CallDriver_1(sp,method,arg1) TCBOf(sp)->drv->method(TCBOf(sp),arg1) 2288262629Sdelphij#define CallDriver_2(sp,method,arg1,arg2) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2) 2289262629Sdelphij#define CallDriver_3(sp,method,arg1,arg2,arg3) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2,arg3) 2290262629Sdelphij#define CallDriver_4(sp,method,arg1,arg2,arg3,arg4) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2,arg3,arg4) 2291262629Sdelphij 2292262629Sdelphijextern NCURSES_EXPORT_VAR(const color_t*) _nc_cga_palette; 2293262629Sdelphijextern NCURSES_EXPORT_VAR(const color_t*) _nc_hls_palette; 2294262629Sdelphij 2295262629Sdelphijextern NCURSES_EXPORT(int) _nc_get_driver(TERMINAL_CONTROL_BLOCK*, const char*, int*); 2296262629Sdelphijextern NCURSES_EXPORT(void) _nc_get_screensize_ex(SCREEN *, TERMINAL *, int *, int *); 2297262629Sdelphij#endif /* USE_TERM_DRIVER */ 2298262629Sdelphij 2299262629Sdelphij/* 2300262629Sdelphij * Entrypoints which are actually provided in the terminal driver, which would 2301262629Sdelphij * be an sp-name otherwise. 2302262629Sdelphij */ 2303262629Sdelphij#ifdef USE_TERM_DRIVER 2304262629Sdelphij#define TINFO_HAS_KEY _nc_tinfo_has_key 2305262629Sdelphij#define TINFO_DOUPDATE _nc_tinfo_doupdate 2306262629Sdelphij#define TINFO_MVCUR _nc_tinfo_mvcur 2307262629Sdelphijextern NCURSES_EXPORT(int) TINFO_HAS_KEY(SCREEN*, int); 2308262629Sdelphijextern NCURSES_EXPORT(int) TINFO_DOUPDATE(SCREEN *); 2309262629Sdelphijextern NCURSES_EXPORT(int) TINFO_MVCUR(SCREEN*, int, int, int, int); 2310262629Sdelphij#else 2311262629Sdelphij#define TINFO_HAS_KEY NCURSES_SP_NAME(has_key) 2312262629Sdelphij#define TINFO_DOUPDATE NCURSES_SP_NAME(doupdate) 2313262685Sdelphij#define TINFO_MVCUR NCURSES_SP_NAME(_nc_mvcur) 2314262629Sdelphij#endif 2315262629Sdelphij 2316262629Sdelphij/* 2317262629Sdelphij * Entrypoints using an extra parameter with the terminal driver. 2318262629Sdelphij */ 2319262629Sdelphij#ifdef USE_TERM_DRIVER 2320262629Sdelphijextern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, TERMINAL *, int *, int *); 2321262685Sdelphijextern NCURSES_EXPORT(int) _nc_setupterm_ex(TERMINAL **, NCURSES_CONST char *, int , int *, int); 2322262629Sdelphij#define TINFO_GET_SIZE(sp, tp, lp, cp) \ 2323262629Sdelphij _nc_get_screensize(sp, tp, lp, cp) 2324262629Sdelphij#define TINFO_SET_CURTERM(sp, tp) \ 2325262629Sdelphij NCURSES_SP_NAME(set_curterm)(sp, tp) 2326262629Sdelphij#define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \ 2327262629Sdelphij _nc_setupterm_ex(tpp, name, fd, err, reuse) 2328262629Sdelphij#else /* !USE_TERM_DRIVER */ 2329262629Sdelphijextern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *); 2330262629Sdelphij#define TINFO_GET_SIZE(sp, tp, lp, cp) \ 2331262629Sdelphij _nc_get_screensize(sp, lp, cp) 2332262629Sdelphij#define TINFO_SET_CURTERM(sp, tp) \ 2333262629Sdelphij set_curterm(tp) 2334262629Sdelphij#define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \ 2335262629Sdelphij _nc_setupterm(name, fd, err, reuse) 2336262629Sdelphij#endif /* !USE_TERM_DRIVER */ 2337262629Sdelphij 2338262629Sdelphij#ifdef USE_TERM_DRIVER 2339262629Sdelphij#ifdef __MINGW32__ 2340262629Sdelphij#include <nc_mingw.h> 2341262629Sdelphijextern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_WIN_DRIVER; 2342262629Sdelphij#endif 2343262629Sdelphijextern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER; 2344262629Sdelphij#endif 2345262629Sdelphij 2346262629Sdelphij#ifdef USE_TERM_DRIVER 2347262685Sdelphij#define IsTermInfo(sp) ((TCBOf(sp) != 0) && ((TCBOf(sp)->drv->isTerminfo))) 2348262685Sdelphij#define HasTInfoTerminal(sp) ((0 != TerminalOf(sp)) && IsTermInfo(sp)) 2349262629Sdelphij#else 2350262629Sdelphij#define IsTermInfo(sp) TRUE 2351262685Sdelphij#define HasTInfoTerminal(sp) (0 != TerminalOf(sp)) 2352262629Sdelphij#endif 2353262629Sdelphij 2354262629Sdelphij#define IsValidTIScreen(sp) (HasTInfoTerminal(sp)) 2355262629Sdelphij 2356262629Sdelphij/* 2357262629Sdelphij * Exported entrypoints beyond the published API 2358262629Sdelphij */ 2359262629Sdelphij#if NCURSES_SP_FUNCS 2360262629Sdelphijextern NCURSES_EXPORT(WINDOW *) _nc_curscr_of(SCREEN*); 2361262629Sdelphijextern NCURSES_EXPORT(WINDOW *) _nc_newscr_of(SCREEN*); 2362262629Sdelphijextern NCURSES_EXPORT(WINDOW *) _nc_stdscr_of(SCREEN*); 2363262629Sdelphijextern NCURSES_EXPORT(int) _nc_outc_wrapper(SCREEN*,int); 2364262629Sdelphij 2365262629Sdelphij#if USE_REENTRANT 2366262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_TABSIZE)(SCREEN*); 2367262629Sdelphijextern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname)(SCREEN*); 2368262629Sdelphij#endif 2369262629Sdelphij 2370262629Sdelphij#if NCURSES_EXT_FUNCS 2371262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tabsize)(SCREEN*, int); 2372262629Sdelphij#endif 2373262629Sdelphij 2374262629Sdelphij/* 2375262629Sdelphij * We put the safe versions of various calls here as they are not published 2376262629Sdelphij * part of the API up to now 2377262629Sdelphij */ 2378262629Sdelphijextern NCURSES_EXPORT(TERMINAL*) NCURSES_SP_NAME(_nc_get_cur_term) (SCREEN *sp); 2379262629Sdelphijextern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(_nc_makenew) (SCREEN*, int, int, int, int, int); 2380262629Sdelphijextern NCURSES_EXPORT(bool) NCURSES_SP_NAME(_nc_reset_colors)(SCREEN*); 2381262629Sdelphijextern NCURSES_EXPORT(char *) NCURSES_SP_NAME(_nc_printf_string)(SCREEN*, const char *, va_list); 2382262629Sdelphijextern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(_nc_acs_char)(SCREEN*,int); 2383262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_curs_set)(SCREEN*,int); 2384262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_get_tty_mode)(SCREEN*,TTY*); 2385262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_mcprint)(SCREEN*,char*, int); 2386262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_msec_cost)(SCREEN*, const char *, int); 2387262685Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_mvcur)(SCREEN*, int, int, int, int); 2388262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_outch)(SCREEN*, int); 2389262685Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putchar)(SCREEN*, int); 2390262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp)(SCREEN*, const char *, const char*); 2391262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp_flush)(SCREEN*, const char *, const char *); 2392262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_resetty)(SCREEN*); 2393262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_resize_term)(SCREEN*,int,int); 2394262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_ripoffline)(SCREEN*, int, int (*)(WINDOW *,int)); 2395262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_savetty)(SCREEN*); 2396262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scr_init)(SCREEN*,const char*); 2397262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scr_restore)(SCREEN*, const char*); 2398262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scrolln)(SCREEN*, int, int, int, int); 2399262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tty_mode)(SCREEN*, TTY*); 2400262685Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_setupscreen)(SCREEN**, int, int, FILE *, int, int); 2401262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tgetent)(SCREEN*,char*,const char *); 2402262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tigetnum)(SCREEN*,NCURSES_CONST char*); 2403262685Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_vid_attr)(SCREEN *, attr_t, NCURSES_COLOR_T, void *); 2404262629Sdelphijextern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_vidputs)(SCREEN*,chtype,int(*) (SCREEN*, int)); 2405262685Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_color)(SCREEN*, int, int, int, NCURSES_SP_OUTC); 2406262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_xmc_glitch)(SCREEN*, attr_t); 2407262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_flush)(SCREEN*); 2408262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int) GCC_NORETURN; 2409262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_freeall)(SCREEN*); 2410262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_hash_map)(SCREEN*); 2411262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_init_acs)(SCREEN*); 2412262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_make_oldhash)(SCREEN*, int i); 2413262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_init)(SCREEN*); 2414262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_resume)(SCREEN*); 2415262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_wrap)(SCREEN*); 2416262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_init)(SCREEN*); 2417262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_resume)(SCREEN*); 2418262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_wrap)(SCREEN*); 2419262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_scroll_oldhash)(SCREEN*, int n, int top, int bot); 2420262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_scroll_optimize)(SCREEN*); 2421262685Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_set_buffer)(SCREEN*, FILE *, int); 2422262629Sdelphij 2423262629Sdelphijextern NCURSES_EXPORT(void) _nc_cookie_init(SCREEN *sp); 2424262629Sdelphij 2425262629Sdelphij#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG) 2426262629Sdelphijextern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_linedump)(SCREEN*); 2427262629Sdelphij#endif 2428262629Sdelphij 2429262629Sdelphij#if USE_WIDEC_SUPPORT 2430262629Sdelphijextern NCURSES_EXPORT(wchar_t *) NCURSES_SP_NAME(_nc_wunctrl)(SCREEN*, cchar_t *); 2431262629Sdelphij#endif 2432262629Sdelphij 2433262629Sdelphij#endif /* NCURSES_SP_FUNCS */ 2434262629Sdelphij 2435262629Sdelphij#if NCURSES_SP_FUNCS 2436262629Sdelphij 2437262629Sdelphij#define safe_keyname NCURSES_SP_NAME(keyname) 2438262629Sdelphij#define safe_unctrl NCURSES_SP_NAME(unctrl) 2439262629Sdelphij#define safe_ungetch NCURSES_SP_NAME(ungetch) 2440262629Sdelphij 2441262629Sdelphij#else 2442262629Sdelphij 2443262629Sdelphij#define safe_keyname _nc_keyname 2444262629Sdelphij#define safe_unctrl _nc_unctrl 2445262629Sdelphij#define safe_ungetch _nc_ungetch 2446262629Sdelphij 2447262629Sdelphijextern NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *, int); 2448262629Sdelphijextern NCURSES_EXPORT(int) _nc_ungetch (SCREEN *, int); 2449262629Sdelphijextern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype); 2450262629Sdelphij 2451262629Sdelphij#endif 2452262629Sdelphij 245350276Speter#ifdef __cplusplus 245450276Speter} 245550276Speter#endif 245650276Speter 2457262629Sdelphij/* *INDENT-ON* */ 2458262629Sdelphij 245950276Speter#endif /* CURSES_PRIV_H */ 2460