X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fcurses.priv.h;h=940dddf4b74bbc594bdf38f5a0bc8091b62ce4de;hp=67dcdcf8840d20238ed802bf1b41e9d8a2328ccc;hb=64f44b13d30e0a7bc2921a9d43755423f81564fd;hpb=8b06e371ed1bce3dd6f37138e6becb5e1a562fe0 diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 67dcdcf8..940dddf4 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -34,7 +34,7 @@ ****************************************************************************/ /* - * $Id: curses.priv.h,v 1.496 2012/02/22 22:10:37 tom Exp $ + * $Id: curses.priv.h,v 1.512 2012/12/08 20:19:40 tom Exp $ * * curses.priv.h * @@ -184,17 +184,6 @@ extern int errno; extern NCURSES_EXPORT(int) _nc_env_access (void); #endif -/* - * Not all platforms have memmove; some have an equivalent bcopy. (Some may - * have neither). - */ -#if USE_OK_BCOPY -#define memmove(d,s,n) bcopy(s,d,n) -#elif USE_MY_MEMMOVE -#define memmove(d,s,n) _nc_memmove(d,s,n) -extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t); -#endif - /* * If we have va_copy(), use it for assigning va_list's. */ @@ -398,7 +387,7 @@ color_t; #define if_EXT_COLORS(stmt) stmt #define SetPair(value,p) SetPair2((value).ext_color, AttrOf(value), p) #define SetPair2(c,a,p) c = (p), \ - a = (unColor2(a) | (A_COLOR & ColorPair(oldColor(c)))) + a = (unColor2(a) | (A_COLOR & (unsigned) ColorPair(oldColor(c)))) #define GetPair(value) GetPair2((value).ext_color, AttrOf(value)) #define GetPair2(c,a) ((c) ? (c) : PairNumber(a)) #define oldColor(p) (((p) > 255) ? 255 : (p)) @@ -407,9 +396,9 @@ color_t; #define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b)) #if NCURSES_SP_FUNCS -#define VIDATTR(sp,attr,pair) NCURSES_SP_NAME(vid_attr)(sp, attr, pair, 0) +#define VIDATTR(sp,attr,pair) NCURSES_SP_NAME(vid_attr)(sp, attr, (short) pair, 0) #else -#define VIDATTR(sp,attr,pair) vid_attr(attr, pair, 0) +#define VIDATTR(sp,attr,pair) vid_attr(attr, (short) pair, 0) #endif #else /* !NCURSES_EXT_COLORS */ @@ -500,6 +489,9 @@ NCURSES_EXPORT(int *) _nc_ptr_Escdelay (SCREEN *); # endif # define _declare(name) __extension__ extern __typeof__(name) name # define weak_symbol(name) _weak_pragma(name) _declare(name) __attribute__((weak)) +#else +# undef USE_WEAK_SYMBOLS +# define USE_WEAK_SYMBOLS 0 #endif #endif @@ -698,6 +690,9 @@ typedef struct { #if USE_GPM_SUPPORT #undef buttons /* term.h defines this, and gpm uses it! */ #include +#if USE_WEAK_SYMBOLS +weak_symbol(Gpm_Wgetch); +#endif #ifdef HAVE_LIBDL /* link dynamically to GPM */ @@ -808,6 +803,7 @@ typedef struct { * Global data which is not specific to a screen. */ typedef struct { + SIG_ATOMIC_T have_sigtstp; SIG_ATOMIC_T have_sigwinch; SIG_ATOMIC_T cleanup_nested; @@ -935,6 +931,7 @@ typedef struct { const char *_tputs_trace; #endif #endif + bool use_tioctl; } NCURSES_PRESCREEN; /* @@ -955,11 +952,13 @@ extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen; */ struct screen { - int _ifd; /* input file ptr for screen */ + int _ifd; /* input file descriptor for screen */ + int _ofd; /* output file descriptor for screen */ FILE *_ofp; /* output file ptr for screen */ - char *_setbuf; /* buffered I/O for output */ + char *out_buffer; /* output buffer */ + size_t out_limit; /* output buffer size */ + size_t out_inuse; /* output buffer current use */ bool _filtered; /* filter() was called */ - bool _buffered; /* setvbuf uses _setbuf data */ bool _prescreen; /* is in prescreen phase */ bool _use_env; /* LINES & COLS from environment? */ int _checkfd; /* filedesc for typeahead check */ @@ -1153,6 +1152,7 @@ struct screen { */ #if USE_SIZECHANGE int (*_resize)(NCURSES_SP_DCLx int y, int x); + int (*_ungetch)(SCREEN *, int); #endif /* @@ -1171,7 +1171,6 @@ struct screen { int *_oldnum_list; int _oldnum_size; - bool _cleanup; /* cleanup after int/quit signal */ NCURSES_SP_OUTC _outch; /* output handler if not putc */ int _legacy_coding; /* see use_legacy_coding() */ @@ -1210,6 +1209,8 @@ struct screen { */ bool _screen_acs_fix; #endif + + bool _use_tioctl; }; extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain; @@ -1373,9 +1374,9 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #define PUTC_DATA char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \ mbstate_t PUT_st; wchar_t PUTC_ch #define PUTC_INIT init_mb (PUT_st) -#define PUTC(ch,b) do { if(!isWidecExt(ch)) { \ +#define PUTC(ch) do { if(!isWidecExt(ch)) { \ if (Charable(ch)) { \ - fputc(CharOf(ch), b); \ + NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_ARGx CharOf(ch)); \ COUNT_OUTCHARS(1); \ } else { \ PUTC_INIT; \ @@ -1387,10 +1388,14 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; (ch).chars[PUTC_i], &PUT_st); \ if (PUTC_n <= 0) { \ if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) \ - putc(PUTC_ch,b); \ + NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_ARGx CharOf(ch)); \ break; \ + } else { \ + int PUTC_j; \ + for (PUTC_j = 0; PUTC_j < PUTC_n; ++PUTC_j) { \ + NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_ARGx PUTC_buf[PUTC_j]); \ + } \ } \ - IGNORE_RC(fwrite(PUTC_buf, (size_t) PUTC_n, (size_t) 1, b)); \ } \ COUNT_OUTCHARS(PUTC_i); \ } } } while (0) @@ -1434,8 +1439,8 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #define CHDEREF(wch) wch #define ARG_CH_T NCURSES_CH_T #define CARG_CH_T NCURSES_CH_T -#define PUTC_DATA int data = 0 -#define PUTC(ch,b) do { data = CharOf(ch); putc(data,b); } while (0) +#define PUTC_DATA /* nothing */ +#define PUTC(ch) NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_ARGx (int) ch) #define BLANK (' '|A_NORMAL) #define ZEROS ('\0'|A_NORMAL) @@ -1494,6 +1499,20 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #include +/* + * Use these for tic/infocmp malloc failures. Generally the ncurses library + * tries to limp along after a failure. + */ +#define TYPE_MALLOC(type, size, name) \ + name = typeMalloc(type, size); \ + if (name == 0) \ + _nc_err_abort(MSG_NO_MEMORY) + +#define TYPE_REALLOC(type, size, name) \ + name = typeRealloc(type, size, name); \ + if (name == 0) \ + _nc_err_abort(MSG_NO_MEMORY) + /* * TTY bit definition for converting tabs to spaces. */ @@ -1951,8 +1970,8 @@ extern NCURSES_EXPORT(int) _nc_outch (int); extern NCURSES_EXPORT(int) _nc_putp(const char *, const char *); extern NCURSES_EXPORT(int) _nc_putp_flush(const char *, const char *); extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const); -extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, int, int); extern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE *); +extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, int, int); extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *)); extern NCURSES_EXPORT(void) _nc_do_color (int, int, int, NCURSES_OUTC); extern NCURSES_EXPORT(void) _nc_flush (void); @@ -1966,6 +1985,7 @@ extern NCURSES_EXPORT(void) _nc_make_oldhash (int i); extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot); extern NCURSES_EXPORT(void) _nc_scroll_optimize (void); extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, int); +extern NCURSES_EXPORT(void) _nc_setenv_num (const char *, int); extern NCURSES_EXPORT(void) _nc_signal_handler (int); extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *); extern NCURSES_EXPORT(void) _nc_trace_tries (TRIES *); @@ -2018,6 +2038,23 @@ extern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *); * Wide-character macros to hide some platform-differences. */ #if USE_WIDEC_SUPPORT + +#if defined(__MINGW32__) +/* + * MinGW has wide-character functions, but they do not work correctly. + */ + +extern int __MINGW_NOTHROW _nc_wctomb(char *, wchar_t); +#define wctomb(s,wc) _nc_wctomb(s,wc) + +extern int __MINGW_NOTHROW _nc_mbtowc(wchar_t *, const char *, size_t); +#define mbtowc(pwc,s,n) _nc_mbtowc(pwc,s,n) + +extern int __MINGW_NOTHROW _nc_mblen(const char *, size_t); +#define mblen(s,n) _nc_mblen(s, n) + +#endif /* __MINGW32__ */ + #if HAVE_MBTOWC && HAVE_MBLEN #define reset_mbytes(state) IGNORE_RC(mblen(NULL, (size_t) 0)), IGNORE_RC(mbtowc(NULL, NULL, (size_t) 0)) #define count_mbytes(buffer,length,state) mblen(buffer,length) @@ -2032,7 +2069,8 @@ extern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *); #else make an error #endif -#endif + +#endif /* USE_WIDEC_SUPPORT */ /* * Not everyone has vsscanf(), but we'd like to use it for scanw(). @@ -2121,9 +2159,9 @@ extern NCURSES_EXPORT(int) _nc_get_tty_mode(TTY *); #define SetSafeOutcWrapper(outc) \ SCREEN* sp = CURRENT_SCREEN; \ + struct screen outc_wrapper; \ if (sp==0) { \ - struct screen dummy; \ - sp = &dummy; \ + sp = &outc_wrapper; \ memset(sp,0,sizeof(struct screen)); \ sp->_outch = _nc_outc_wrapper; \ }\