X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fcurses.priv.h;h=1f5507b2a02a25d926ff237de409ffd5fa016e78;hp=caf71161f2dc395d26e6bea145a97e3499077562;hb=fb24ca09eab8f14b9be7ea60acf174aae46df43d;hpb=5b7f4de105080e2a715b0564ede4bb7eb6767659 diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index caf71161..1f5507b2 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -35,7 +35,7 @@ /* - * $Id: curses.priv.h,v 1.430 2009/07/04 20:40:42 tom Exp $ + * $Id: curses.priv.h,v 1.442 2009/10/31 20:33:43 tom Exp $ * * curses.priv.h * @@ -196,11 +196,10 @@ extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t); /* * Options for terminal drivers, etc... */ -#if 0 +#ifdef USE_TERM_DRIVER #define USE_SP_RIPOFF 1 #define USE_SP_TERMTYPE 1 #define USE_SP_WINDOWLIST 1 -#define USE_TERM_DRIVER 1 #endif /* @@ -374,12 +373,14 @@ extern NCURSES_EXPORT(void) _nc_set_no_padding(SCREEN *); #define GET_SCREEN_PAIR(s) GetPair(SCREEN_ATTRS(s)) #define SET_SCREEN_PAIR(s,p) SetPair(SCREEN_ATTRS(s), p) -#if USE_REENTRANT - +#if USE_REENTRANT || NCURSES_SP_FUNCS NCURSES_EXPORT(int *) _nc_ptr_Lines (SCREEN *); NCURSES_EXPORT(int *) _nc_ptr_Cols (SCREEN *); NCURSES_EXPORT(int *) _nc_ptr_Tabsize (SCREEN *); NCURSES_EXPORT(int *) _nc_ptr_Escdelay (SCREEN *); +#endif + +#if USE_REENTRANT #define ptrLines(sp) (sp ? &(sp->_LINES) : &(_nc_prescreen._LINES)) #define ptrCols(sp) (sp ? &(sp->_COLS) : &(_nc_prescreen._COLS)) @@ -479,6 +480,36 @@ extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *); #endif /* USE_PTHREADS */ +/* + * When using sp-funcs, locks are targeted to SCREEN-level granularity. + * So the locking is done in the non-sp-func (which calls the sp-func) rather + * than in the sp-func itself. + * + * Use the _nc_nonsp_XXX functions in the function using "NCURSES_SP_NAME()". + * Use the _nc_sp_XXX functions in the function using "#if NCURSES_SP_FUNCS". + */ +#if NCURSES_SP_FUNCS + +#define _nc_nonsp_lock_global(name) /* nothing */ +#define _nc_nonsp_try_global(name) 0 +#define _nc_nonsp_unlock_global(name) /* nothing */ + +#define _nc_sp_lock_global(name) _nc_lock_global(name) +#define _nc_sp_try_global(name) _nc_try_global(name) +#define _nc_sp_unlock_global(name) _nc_unlock_global(name) + +#else + +#define _nc_nonsp_lock_global(name) _nc_lock_global(name) +#define _nc_nonsp_try_global(name) _nc_try_global(name) +#define _nc_nonsp_unlock_global(name) _nc_unlock_global(name) + +#define _nc_sp_lock_global(name) /* nothing */ +#define _nc_sp_try_global(name) 0 +#define _nc_sp_unlock_global(name) /* nothing */ + +#endif + #if HAVE_GETTIMEOFDAY # define PRECISE_GETTIME 1 # define TimeType struct timeval @@ -937,9 +968,6 @@ struct screen { bool _nc_sp_idlok; bool _nc_sp_idcok; -#define _nc_idlok SP_PARM->_nc_sp_idlok -#define _nc_idcok SP_PARM->_nc_sp_idcok - /* * These are the data that support the mouse interface. */ @@ -1229,7 +1257,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; putc(PUTC_ch,b); \ break; \ } \ - fwrite(PUTC_buf, (unsigned) PUTC_n, 1, b); \ + IGNORE_RC(fwrite(PUTC_buf, (unsigned) PUTC_n, 1, b)); \ } \ COUNT_OUTCHARS(PUTC_i); \ } } } while (0) @@ -1472,6 +1500,15 @@ extern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int); #endif /* TRACE/!TRACE */ +/* + * Workaround for defective implementation of gcc attribute warn_unused_result + */ +#if defined(__GNUC__) && defined(_FORTIFY_SOURCE) +#define IGNORE_RC(func) errno = func +#else +#define IGNORE_RC(func) (void) func +#endif /* gcc workarounds */ + /* * Return-codes for tgetent() and friends. */ @@ -1682,7 +1719,7 @@ extern NCURSES_EXPORT(char *) _nc_get_locale(void); extern NCURSES_EXPORT(int) _nc_unicode_locale(void); extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *); extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, bool); -extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *); +extern NCURSES_EXPORT(void) _nc_tinfo_cmdch(TERMINAL *, char); /* lib_set_term.c */ extern NCURSES_EXPORT(int) _nc_ripoffline(int, int(*)(WINDOW*, int)); @@ -1730,6 +1767,7 @@ extern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *); /* elsewhere ... */ extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry (ENTRY *, TERMTYPE *); extern NCURSES_EXPORT(SCREEN *) _nc_screen_of (WINDOW *); +extern NCURSES_EXPORT(TERMINAL*) _nc_get_cur_term (void); extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int); extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t); extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *); @@ -1780,6 +1818,10 @@ extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T); extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, NCURSES_SIZE_T const, NCURSES_SIZE_T const, NCURSES_CH_T); #endif +#if USE_WIDEC_SUPPORT +extern NCURSES_EXPORT(int) _nc_insert_wch(WINDOW *, const cchar_t *); +#endif + #if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB) extern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *); #endif @@ -1801,6 +1843,26 @@ extern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *); #define wgetnstr_events(win, str, maxlen, evl) wgetnstr(win, str, maxlen) #endif +/* + * Wide-character macros to hide some platform-differences. + */ +#if USE_WIDEC_SUPPORT +#if HAVE_MBTOWC && HAVE_MBLEN +#define reset_mbytes(state) IGNORE_RC(mblen(NULL, 0)), IGNORE_RC(mbtowc(NULL, NULL, 0)) +#define count_mbytes(buffer,length,state) mblen(buffer,length) +#define check_mbytes(wch,buffer,length,state) \ + (int) mbtowc(&wch, buffer, length) +#define state_unused +#elif HAVE_MBRTOWC && HAVE_MBRLEN +#define reset_mbytes(state) init_mb(state) +#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state) +#define check_mbytes(wch,buffer,length,state) \ + (int) mbrtowc(&wch, buffer, length, &state) +#else +make an error +#endif +#endif + /* * Not everyone has vsscanf(), but we'd like to use it for scanw(). */ @@ -1836,7 +1898,7 @@ extern NCURSES_EXPORT_VAR(SCREEN *) SP; #define _nc_set_screen(sp) SP = sp #endif -#if NCURSES_SP_FUNCS && 0 +#if NCURSES_SP_FUNCS #define CURRENT_SCREEN_PRE (IsPreScreen(CURRENT_SCREEN) ? CURRENT_SCREEN : new_prescr()) #else #define CURRENT_SCREEN_PRE CURRENT_SCREEN @@ -1895,6 +1957,7 @@ extern NCURSES_EXPORT(int) _nc_get_tty_mode(TTY *); }\ sp->jump = outc +#ifdef USE_TERM_DRIVER struct DriverTCB; /* Terminal Control Block forward declaration */ typedef void* TERM_HANDLE; @@ -1956,7 +2019,6 @@ typedef struct term_driver { bool (*kyExist)(struct DriverTCB*, int); } TERM_DRIVER; - typedef struct DriverTCB { TERMINAL term; /* needs to be the first Element !!! */ @@ -1985,18 +2047,56 @@ typedef struct DriverTCB extern NCURSES_EXPORT_VAR(const color_t*) _nc_cga_palette; extern NCURSES_EXPORT_VAR(const color_t*) _nc_hls_palette; -#ifdef USE_TERM_DRIVER -extern NCURSES_EXPORT(int) _nc_tinfo_has_key(SCREEN*, int); -extern NCURSES_EXPORT(int) _nc_tinfo_doupdate(SCREEN *sp); -extern NCURSES_EXPORT(int) _nc_tinfo_mvcur(SCREEN*,int,int,int,int); extern NCURSES_EXPORT(int) _nc_get_driver(TERMINAL_CONTROL_BLOCK*, const char*, int*); +extern NCURSES_EXPORT(void) _nc_get_screensize_ex(SCREEN *, TERMINAL *, int *, int *); +#endif /* USE_TERM_DRIVER */ + +/* + * Entrypoints which are actually provided in the terminal driver, which would + * be an sp-name otherwise. + */ +#ifdef USE_TERM_DRIVER +#define TINFO_HAS_KEY _nc_tinfo_has_key +#define TINFO_DOUPDATE _nc_tinfo_doupdate +#define TINFO_MVCUR _nc_tinfo_mvcur +extern NCURSES_EXPORT(int) TINFO_HAS_KEY(SCREEN*, int); +extern NCURSES_EXPORT(int) TINFO_DOUPDATE(SCREEN *); +extern NCURSES_EXPORT(int) TINFO_MVCUR(SCREEN*, int, int, int, int); +#else +#define TINFO_HAS_KEY NCURSES_SP_NAME(has_key) +#define TINFO_DOUPDATE NCURSES_SP_NAME(doupdate) +#define TINFO_MVCUR NCURSES_SP_NAME(mvcur) #endif +/* + * Entrypoints using an extra parameter with the terminal driver. + */ +#ifdef USE_TERM_DRIVER +extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, TERMINAL *, int *, int *); +extern NCURSES_EXPORT(int) _nc_setupterm_ex(TERMINAL **, NCURSES_CONST char *, int , int *, bool); +#define TINFO_GET_SIZE(sp, tp, lp, cp) \ + _nc_get_screensize(sp, tp, lp, cp) +#define TINFO_SET_CURTERM(sp, tp) \ + NCURSES_SP_NAME(set_curterm)(sp, tp) +#define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \ + _nc_setupterm_ex(tpp, name, fd, err, reuse) +#else /* !USE_TERM_DRIVER */ +extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *); +#define TINFO_GET_SIZE(sp, tp, lp, cp) \ + _nc_get_screensize(sp, lp, cp) +#define TINFO_SET_CURTERM(sp, tp) \ + set_curterm(tp) +#define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \ + _nc_setupterm(name, fd, err, reuse) +#endif /* !USE_TERM_DRIVER */ + +#ifdef USE_TERM_DRIVER #ifdef __MINGW32__ #include extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_WIN_DRIVER; #endif extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER; +#endif #ifdef USE_TERM_DRIVER #define IsTermInfo(sp) (TCBOf(sp) && ((TCBOf(sp)->drv->isTerminfo))) @@ -2017,7 +2117,6 @@ extern NCURSES_EXPORT(WINDOW *) _nc_stdscr_of(SCREEN*); extern NCURSES_EXPORT(int) _nc_outc_wrapper(SCREEN*,int); #if USE_REENTRANT -extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(_nc_ttytype)(SCREEN*); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_TABSIZE)(SCREEN*); extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname)(SCREEN*); #endif @@ -2030,7 +2129,7 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tabsize)(SCREEN*, int); * We put the safe versions of various calls here as they are not published * part of the API up to now */ -extern NCURSES_EXPORT(TERMINAL*) NCURSES_SP_NAME(cur_term)(SCREEN *sp); +extern NCURSES_EXPORT(TERMINAL*) NCURSES_SP_NAME(_nc_get_cur_term) (SCREEN *sp); extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(_nc_makenew) (SCREEN*, int, int, int, int, int); extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(_nc_reset_colors)(SCREEN*); extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(_nc_printf_string)(SCREEN*, const char *, va_list);