diff --git a/NEWS b/NEWS index 4976f4fb..a4a12b38 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.1421 2009/08/15 23:09:41 tom Exp $ +-- $Id: NEWS,v 1.1422 2009/08/22 23:16:03 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,9 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20090822 + + continue integrating "sp-funcs" by Juergen Pfeifer (incomplete). + 20090815 + correct use of terminfo capabilities for initializing soft-keys, broken in 20090509 merging. diff --git a/dist.mk b/dist.mk index c19f79b2..8ca93709 100644 --- a/dist.mk +++ b/dist.mk @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.715 2009/08/10 20:48:14 tom Exp $ +# $Id: dist.mk,v 1.716 2009/08/22 16:00:41 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -37,7 +37,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 5 NCURSES_MINOR = 7 -NCURSES_PATCH = 20090815 +NCURSES_PATCH = 20090822 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/ncurses/base/lib_color.c b/ncurses/base/lib_color.c index 590b8907..42f5ea7f 100644 --- a/ncurses/base/lib_color.c +++ b/ncurses/base/lib_color.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2007,2009 Free Software Foundation, Inc. * + * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -39,16 +39,33 @@ */ #include - -#include #include #ifndef CUR #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_color.c,v 1.92 2009/06/06 20:26:16 tom Exp $") +MODULE_ID("$Id: lib_color.c,v 1.95 2009/08/22 19:04:36 tom Exp $") +#ifdef USE_TERM_DRIVER +#define CanChange InfoOf(SP_PARM).canchange +#define DefaultPalette InfoOf(SP_PARM).defaultPalette +#define HasColor InfoOf(SP_PARM).hascolor +#define InitColor InfoOf(SP_PARM).initcolor +#define MaxColors InfoOf(SP_PARM).maxcolors +#define MaxPairs InfoOf(SP_PARM).maxpairs +#define UseHlsPalette (DefaultPalette == _nc_hls_palette) +#else +#define CanChange can_change +#define DefaultPalette (hue_lightness_saturation ? hls_palette : cga_palette) +#define HasColor has_color +#define InitColor initialize_color +#define MaxColors max_colors +#define MaxPairs max_pairs +#define UseHlsPalette (hue_lightness_saturation) +#endif + +#ifndef USE_TERM_DRIVER /* * These should be screen structure members. They need to be globals for * historical reasons. So we assign them in start_color() and also in @@ -69,6 +86,7 @@ NCURSES_PUBLIC_VAR(COLORS) (void) NCURSES_EXPORT_VAR(int) COLOR_PAIRS = 0; NCURSES_EXPORT_VAR(int) COLORS = 0; #endif +#endif /* !USE_TERM_DRIVER */ #define DATA(r,g,b) {r,g,b, 0,0,0, 0} @@ -76,7 +94,7 @@ NCURSES_EXPORT_VAR(int) COLORS = 0; #define MAX_PALETTE 8 -#define OkColorHi(n) (((n) < COLORS) && ((n) < max_colors)) +#define OkColorHi(n) (((n) < COLORS) && ((n) < maxcolors)) #define InPalette(n) ((n) >= 0 && (n) < MAX_PALETTE) /* @@ -111,6 +129,12 @@ static const color_t hls_palette[] = DATA( 300, 50, 100), /* COLOR_CYAN */ DATA( 0, 50, 100), /* COLOR_WHITE */ }; + +#ifdef USE_TERM_DRIVER +NCURSES_EXPORT_VAR(const color_t*) _nc_cga_palette = cga_palette; +NCURSES_EXPORT_VAR(const color_t*) _nc_hls_palette = hls_palette; +#endif + /* *INDENT-ON* */ /* @@ -118,29 +142,30 @@ static const color_t hls_palette[] = * that the index is within the limits of the table which we allocated. */ #define ValidPair(pair) \ - ((SP != 0) && (pair >= 0) && (pair < SP->_pair_limit) && SP->_coloron) + ((SP_PARM != 0) && (pair >= 0) && (pair < SP_PARM->_pair_limit) && SP_PARM->_coloron) #if NCURSES_EXT_FUNCS /* * These are called from _nc_do_color(), which in turn is called from - * vidattr - so we have to assume that SP may be null. + * vidattr - so we have to assume that sp may be null. */ static int -default_fg(void) +default_fg(NCURSES_SP_DCL0) { - return (SP != 0) ? SP->_default_fg : COLOR_WHITE; + return (SP_PARM != 0) ? SP_PARM->_default_fg : COLOR_WHITE; } static int -default_bg(void) +default_bg(NCURSES_SP_DCL0) { - return SP != 0 ? SP->_default_bg : COLOR_BLACK; + return SP_PARM != 0 ? SP_PARM->_default_bg : COLOR_BLACK; } #else -#define default_fg() COLOR_WHITE -#define default_bg() COLOR_BLACK +#define default_fg(sp) COLOR_WHITE +#define default_bg(sp) COLOR_BLACK #endif +#ifndef USE_TERM_DRIVER /* * SVr4 curses is known to interchange color codes (1,4) and (3,6), possibly * to maintain compatibility with a pre-ANSI scheme. The same scheme is @@ -157,10 +182,14 @@ toggled_colors(int c) } return c; } +#endif static void set_background_color(NCURSES_SP_DCLx int bg, NCURSES_SP_OUTC outc) { +#ifdef USE_TERM_DRIVER + CallDriver_3(SP_PARM, color, FALSE, bg, outc); +#else if (set_a_background) { TPUTS_TRACE("set_a_background"); NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx @@ -172,11 +201,15 @@ set_background_color(NCURSES_SP_DCLx int bg, NCURSES_SP_OUTC outc) TPARM_1(set_background, toggled_colors(bg)), 1, outc); } +#endif } static void set_foreground_color(NCURSES_SP_DCLx int fg, NCURSES_SP_OUTC outc) { +#ifdef USE_TERM_DRIVER + CallDriver_3(SP_PARM, color, TRUE, fg, outc); +#else if (set_a_foreground) { TPUTS_TRACE("set_a_foreground"); NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx @@ -188,21 +221,23 @@ set_foreground_color(NCURSES_SP_DCLx int fg, NCURSES_SP_OUTC outc) TPARM_1(set_foreground, toggled_colors(fg)), 1, outc); } +#endif } static void init_color_table(NCURSES_SP_DCL0) { - const color_t *tp; + const color_t *tp = DefaultPalette; int n; - tp = (hue_lightness_saturation) ? hls_palette : cga_palette; + assert(tp != 0); + for (n = 0; n < COLORS; n++) { if (InPalette(n)) { SP_PARM->_color_table[n] = tp[n]; } else { SP_PARM->_color_table[n] = tp[n % MAX_PALETTE]; - if (hue_lightness_saturation) { + if (UseHlsPalette) { SP_PARM->_color_table[n].green = 100; } else { if (SP_PARM->_color_table[n].red) @@ -222,6 +257,9 @@ init_color_table(NCURSES_SP_DCL0) static bool reset_color_pair(NCURSES_SP_DCL0) { +#ifdef USE_TERM_DRIVER + return CallDriver(SP_PARM, rescol); +#else bool result = FALSE; if (orig_pair != 0) { @@ -230,6 +268,7 @@ reset_color_pair(NCURSES_SP_DCL0) result = TRUE; } return result; +#endif } /* @@ -237,26 +276,31 @@ reset_color_pair(NCURSES_SP_DCL0) * badly-written terminal descriptions than for the relatively rare case where * someone has changed the color definitions. */ -bool -NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_DCL0) { +NCURSES_EXPORT(bool) +NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_DCL0) +{ int result = FALSE; - T((T_CALLED("_nc_reset_colors()"))); + T((T_CALLED("_nc_reset_colors(%p)"), SP_PARM)); if (SP_PARM->_color_defs > 0) SP_PARM->_color_defs = -(SP_PARM->_color_defs); - if (reset_color_pair(NCURSES_SP_ARG)) result = TRUE; + +#ifdef USE_TERM_DRIVER + result = CallDriver(SP_PARM, rescolors); +#else if (orig_colors != 0) { TPUTS_TRACE("orig_colors"); putp(orig_colors); result = TRUE; } +#endif returnBool(result); } #if NCURSES_SP_FUNCS -bool +NCURSES_EXPORT(bool) _nc_reset_colors(void) { return NCURSES_SP_NAME(_nc_reset_colors) (CURRENT_SCREEN); @@ -267,48 +311,49 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0) { int result = ERR; + int maxpairs = 0, maxcolors = 0; - T((T_CALLED("start_color()"))); + T((T_CALLED("start_color(%p)"), SP_PARM)); if (SP_PARM == 0) { result = ERR; } else if (SP_PARM->_coloron) { result = OK; } else { - + maxpairs = MaxPairs; + maxcolors = MaxColors; if (reset_color_pair(NCURSES_SP_ARG) != TRUE) { set_foreground_color(NCURSES_SP_ARGx - default_fg(), + default_fg(NCURSES_SP_ARG), NCURSES_SP_NAME(_nc_outch)); set_background_color(NCURSES_SP_ARGx - default_bg(), + default_bg(NCURSES_SP_ARG), NCURSES_SP_NAME(_nc_outch)); } - if (max_pairs > 0 && max_colors > 0) { - SP_PARM->_pair_limit = max_pairs; + if (maxpairs > 0 && maxcolors > 0) { + SP_PARM->_pair_limit = maxpairs; #if NCURSES_EXT_FUNCS /* * If using default colors, allocate extra space in table to * allow for default-color as a component of a color-pair. */ - SP_PARM->_pair_limit += (1 + (2 * max_colors)); + SP_PARM->_pair_limit += (1 + (2 * maxcolors)); #endif - SP_PARM->_pair_count = max_pairs; - SP_PARM->_color_count = max_colors; + SP_PARM->_pair_count = maxpairs; + SP_PARM->_color_count = maxcolors; #if !USE_REENTRANT - COLOR_PAIRS = max_pairs; - COLORS = max_colors; + COLOR_PAIRS = maxpairs; + COLORS = maxcolors; #endif - SP_PARM->_color_pairs = TYPE_CALLOC(colorpair_t, - SP_PARM->_pair_limit); + SP_PARM->_color_pairs = TYPE_CALLOC(colorpair_t, SP_PARM->_pair_limit); if (SP_PARM->_color_pairs != 0) { - SP_PARM->_color_table = TYPE_CALLOC(color_t, max_colors); + SP_PARM->_color_table = TYPE_CALLOC(color_t, maxcolors); if (SP_PARM->_color_table != 0) { - SP_PARM->_color_pairs[0] = PAIR_OF(default_fg(), - default_bg()); + SP_PARM->_color_pairs[0] = PAIR_OF(default_fg(NCURSES_SP_ARG), + default_bg(NCURSES_SP_ARG)); init_color_table(NCURSES_SP_ARG); T(("started color: COLORS = %d, COLOR_PAIRS = %d", @@ -382,12 +427,15 @@ NCURSES_SP_NAME(init_pair) (NCURSES_SP_DCLx short pair, short f, short b) { colorpair_t result; colorpair_t previous; + int maxcolors; - T((T_CALLED("init_pair(%d,%d,%d)"), pair, f, b)); + T((T_CALLED("init_pair(%p,%d,%d,%d)"), SP_PARM, pair, f, b)); if (!ValidPair(pair)) returnCode(ERR); + maxcolors = MaxColors; + previous = SP_PARM->_color_pairs[pair]; #if NCURSES_EXT_FUNCS if (SP_PARM->_default_color) { @@ -463,10 +511,10 @@ NCURSES_SP_NAME(init_pair) (NCURSES_SP_DCLx short pair, short f, short b) && previous != result) { int y, x; - for (y = 0; y <= curscr->_maxy; y++) { - struct ldat *ptr = &(curscr->_line[y]); + for (y = 0; y <= CurScreen(SP_PARM)->_maxy; y++) { + struct ldat *ptr = &(CurScreen(SP_PARM)->_line[y]); bool changed = FALSE; - for (x = 0; x <= curscr->_maxx; x++) { + for (x = 0; x <= CurScreen(SP_PARM)->_maxx; x++) { if (GetPair(ptr->text[x]) == pair) { /* Set the old cell to zero to ensure it will be updated on the next doupdate() */ @@ -476,15 +524,19 @@ NCURSES_SP_NAME(init_pair) (NCURSES_SP_DCLx short pair, short f, short b) } } if (changed) - _nc_make_oldhash(y); + NCURSES_SP_NAME(_nc_make_oldhash) (NCURSES_SP_ARGx y); } } + SP_PARM->_color_pairs[pair] = result; if (GET_SCREEN_PAIR(SP_PARM) == pair) SET_SCREEN_PAIR(SP_PARM, (chtype) (~0)); /* force attribute update */ +#ifdef USE_TERM_DRIVER + CallDriver_3(SP_PARM, initpair, pair, f, b); +#else if (initialize_pair && InPalette(f) && InPalette(b)) { - const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette; + const color_t *tp = DefaultPalette; TR(TRACE_ATTRS, ("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)", @@ -498,6 +550,7 @@ NCURSES_SP_NAME(init_pair) (NCURSES_SP_DCLx short pair, short f, short b) tp[f].red, tp[f].green, tp[f].blue, tp[b].red, tp[b].green, tp[b].blue)); } +#endif returnCode(OK); } @@ -517,11 +570,16 @@ NCURSES_SP_NAME(init_color) (NCURSES_SP_DCLx short color, short r, short g, short b) { int result = ERR; + int maxcolors; - T((T_CALLED("init_color(%d,%d,%d,%d)"), color, r, g, b)); + T((T_CALLED("init_color(%p,%d,%d,%d,%d)"), SP_PARM, color, r, g, b)); - if (initialize_color != NULL - && SP_PARM != 0 + if (SP_PARM == 0) + returnCode(result); + + maxcolors = MaxColors; + + if (InitColor && SP_PARM->_coloron && (color >= 0 && OkColorHi(color)) && (okRGB(r) && okRGB(g) && okRGB(b))) { @@ -531,7 +589,7 @@ NCURSES_SP_NAME(init_color) (NCURSES_SP_DCLx SP_PARM->_color_table[color].g = g; SP_PARM->_color_table[color].b = b; - if (hue_lightness_saturation) { + if (UseHlsPalette) { rgb2hls(r, g, b, &SP_PARM->_color_table[color].red, &SP_PARM->_color_table[color].green, @@ -542,9 +600,14 @@ NCURSES_SP_NAME(init_color) (NCURSES_SP_DCLx SP_PARM->_color_table[color].blue = b; } +#ifdef USE_TERM_DRIVER + CallDriver_4(SP_PARM, initcolor, color, r, g, b); +#else TPUTS_TRACE("initialize_color"); putp(TPARM_4(initialize_color, color, r, g, b)); +#endif SP_PARM->_color_defs = max(color + 1, SP_PARM->_color_defs); + result = OK; } returnCode(result); @@ -559,10 +622,10 @@ init_color(short color, short r, short g, short b) #endif NCURSES_EXPORT(bool) -NCURSES_SP_NAME(can_change_color) (NCURSES_SP_DCL0) +NCURSES_SP_NAME(can_change_color) (NCURSES_SP_DCL) { - T((T_CALLED("can_change_color()"))); - returnCode((can_change != 0) ? TRUE : FALSE); + T((T_CALLED("can_change_color(%p)"), SP_PARM)); + returnCode((CanChange != 0) ? TRUE : FALSE); } #if NCURSES_SP_FUNCS @@ -576,13 +639,20 @@ can_change_color(void) NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_colors) (NCURSES_SP_DCL0) { + int code; + T((T_CALLED("has_colors()"))); - returnCode((VALID_NUMERIC(max_colors) && VALID_NUMERIC(max_pairs) - && (((set_foreground != NULL) - && (set_background != NULL)) - || ((set_a_foreground != NULL) - && (set_a_background != NULL)) - || set_color_pair)) ? TRUE : FALSE); +#ifdef USE_TERM_DRIVER + code = HasColor; +#else + code = ((VALID_NUMERIC(max_colors) && VALID_NUMERIC(max_pairs) + && (((set_foreground != NULL) + && (set_background != NULL)) + || ((set_a_foreground != NULL) + && (set_a_background != NULL)) + || set_color_pair)) ? TRUE : FALSE); +#endif + returnCode(code); } #if NCURSES_SP_FUNCS @@ -594,13 +664,20 @@ has_colors(void) #endif NCURSES_EXPORT(int) -NCURSES_SP_NAME(color_content) (NCURSES_SP_DCLx short color, short *r, - short *g, short *b) +NCURSES_SP_NAME(color_content) (NCURSES_SP_DCLx + short color, short *r, short *g, short *b) { - int result; + int result = ERR; + int maxcolors; - T((T_CALLED("color_content(%d,%p,%p,%p)"), color, r, g, b)); - if (color < 0 || !OkColorHi(color) || SP_PARM == 0 || !SP_PARM->_coloron) { + T((T_CALLED("color_content(%p,%d,%p,%p,%p)"), SP_PARM, color, r, g, b)); + + if (SP_PARM == 0) + returnCode(result); + + maxcolors = MaxColors; + + if (color < 0 || !OkColorHi(color) || !SP_PARM->_coloron) { result = ERR; } else { NCURSES_COLOR_T c_r = SP_PARM->_color_table[color].red; @@ -630,12 +707,12 @@ color_content(short color, short *r, short *g, short *b) #endif NCURSES_EXPORT(int) -NCURSES_SP_NAME(pair_content) (NCURSES_SP_DCLx short pair, short *f, - short *b) +NCURSES_SP_NAME(pair_content) (NCURSES_SP_DCLx + short pair, short *f, short *b) { int result; - T((T_CALLED("pair_content(%d,%p,%p)"), pair, f, b)); + T((T_CALLED("pair_content(%p,%d,%p,%p)"), SP_PARM, pair, f, b)); if (!ValidPair(pair)) { result = ERR; @@ -655,7 +732,7 @@ NCURSES_SP_NAME(pair_content) (NCURSES_SP_DCLx short pair, short *f, if (b) *b = bg; - TR(TRACE_ATTRS, ("...pair_content(%d,%d,%d)", pair, fg, bg)); + TR(TRACE_ATTRS, ("...pair_content(%p,%d,%d,%d)", SP_PARM, pair, fg, bg)); result = OK; } returnCode(result); @@ -676,6 +753,9 @@ NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx bool reverse, NCURSES_SP_OUTC outc) { +#ifdef USE_TERM_DRIVER + CallDriver_4(SP_PARM, docolor, old_pair, pair, reverse, outc); +#else NCURSES_COLOR_T fg = COLOR_DEFAULT; NCURSES_COLOR_T bg = COLOR_DEFAULT; NCURSES_COLOR_T old_fg, old_bg; @@ -725,9 +805,9 @@ NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx #if NCURSES_EXT_FUNCS if (isDefaultColor(fg)) - fg = default_fg(); + fg = default_fg(NCURSES_SP_ARG); if (isDefaultColor(bg)) - bg = default_bg(); + bg = default_bg(NCURSES_SP_ARG); #endif if (reverse) { @@ -745,6 +825,7 @@ NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx if (!isDefaultColor(bg)) { set_background_color(NCURSES_SP_ARGx bg, outc); } +#endif } #if NCURSES_SP_FUNCS diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index caf71161..31f41a88 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.435 2009/08/22 22:33:25 tom Exp $ * * curses.priv.h * @@ -374,12 +374,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)) @@ -1682,7 +1684,6 @@ 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 *); /* lib_set_term.c */ extern NCURSES_EXPORT(int) _nc_ripoffline(int, int(*)(WINDOW*, int)); @@ -1730,6 +1731,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 *); @@ -1895,6 +1897,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 +1959,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 +1987,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))) @@ -2030,7 +2070,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); diff --git a/ncurses/tinfo/lib_cur_term.c b/ncurses/tinfo/lib_cur_term.c index 26e8dc8d..d2562767 100644 --- a/ncurses/tinfo/lib_cur_term.c +++ b/ncurses/tinfo/lib_cur_term.c @@ -40,7 +40,7 @@ #include /* TTY, cur_term */ #include /* ospeed */ -MODULE_ID("$Id: lib_cur_term.c,v 1.22 2009/05/30 13:55:19 tom Exp $") +MODULE_ID("$Id: lib_cur_term.c,v 1.24 2009/08/22 22:37:13 tom Exp $") #undef CUR #define CUR termp->type. @@ -48,17 +48,33 @@ MODULE_ID("$Id: lib_cur_term.c,v 1.22 2009/05/30 13:55:19 tom Exp $") #if BROKEN_LINKER && !USE_REENTRANT NCURSES_EXPORT_VAR(TERMINAL *) cur_term = 0; #elif BROKEN_LINKER || USE_REENTRANT + +NCURSES_EXPORT(TERMINAL *) +NCURSES_SP_NAME(_nc_get_cur_term) (NCURSES_SP_DCL0) +{ + return ((0 != TerminalOf(SP_PARM)) ? TerminalOf(SP_PARM) : CurTerm); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(TERMINAL *) +_nc_get_cur_term(void) +{ + return NCURSES_SP_NAME(_nc_get_cur_term) (CURRENT_SCREEN); +} +#endif + NCURSES_EXPORT(TERMINAL *) NCURSES_PUBLIC_VAR(cur_term) (void) { - return (SP != 0 && SP->_term != 0) ? SP->_term : _nc_prescreen._cur_term; + return NCURSES_SP_NAME(_nc_get_cur_term) (NCURSES_SP_ARG); } + #else NCURSES_EXPORT_VAR(TERMINAL *) cur_term = 0; #endif NCURSES_EXPORT(TERMINAL *) -set_curterm(TERMINAL * termp) +NCURSES_SP_NAME(set_curterm) (NCURSES_SP_DCLx TERMINAL * termp) { TERMINAL *oldterm; @@ -66,20 +82,27 @@ set_curterm(TERMINAL * termp) _nc_lock_global(curses); oldterm = cur_term; - if (SP) - SP->_term = termp; + if (SP_PARM) + SP_PARM->_term = termp; #if BROKEN_LINKER && !USE_REENTRANT cur_term = termp; -#elif BROKEN_LINKER || USE_REENTRANT - _nc_prescreen._cur_term = termp; #else - cur_term = termp; + CurTerm = termp; #endif if (termp != 0) { +#ifdef USE_TERM_DRIVER + TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) termp; + ospeed = _nc_ospeed(termp->_baudrate); + if (TCB->drv->isTerminfo && termp->type.Strings) { + PC = (char) ((pad_char != NULL) ? pad_char[0] : 0); + } + TCB->csp = SP_PARM; +#else ospeed = _nc_ospeed(termp->_baudrate); if (termp->type.Strings) { PC = (char) ((pad_char != NULL) ? pad_char[0] : 0); } +#endif } _nc_unlock_global(curses); @@ -87,28 +110,52 @@ set_curterm(TERMINAL * termp) return (oldterm); } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(TERMINAL *) +set_curterm(TERMINAL * termp) +{ + return NCURSES_SP_NAME(set_curterm) (CURRENT_SCREEN, termp); +} +#endif + NCURSES_EXPORT(int) NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL * termp) { int rc = ERR; - T((T_CALLED("del_curterm(%p)"), termp)); + T((T_CALLED("del_curterm(%p, %p)"), SP_PARM, termp)); - _nc_lock_global(curses); if (termp != 0) { +#ifdef USE_TERM_DRIVER + TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) termp; +#endif + TERMINAL *cur = ( +#if BROKEN_LINKER && !USE_REENTRANT + cur_term +#elif BROKEN_LINKER || USE_REENTRANT + NCURSES_SP_NAME(_nc_get_cur_term) (NCURSES_SP_ARG) +#else + cur_term +#endif + ); + _nc_free_termtype(&(termp->type)); + if (termp == cur) + NCURSES_SP_NAME(set_curterm) (NCURSES_SP_ARGx 0); + FreeIfNeeded(termp->_termname); #if USE_HOME_TERMINFO if (_nc_globals.home_terminfo != 0) FreeAndNull(_nc_globals.home_terminfo); +#endif +#ifdef USE_TERM_DRIVER + if (TCB->drv) + TCB->drv->release(TCB); #endif free(termp); - if (termp == cur_term) - set_curterm(0); + rc = OK; } - _nc_unlock_global(curses); - returnCode(rc); } @@ -117,7 +164,11 @@ NCURSES_EXPORT(int) del_curterm(TERMINAL * termp) { int rc = ERR; + + _nc_lock_global(curses); rc = NCURSES_SP_NAME(del_curterm) (CURRENT_SCREEN, termp); + _nc_unlock_global(curses); + return (rc); } #endif diff --git a/ncurses/tinfo/lib_options.c b/ncurses/tinfo/lib_options.c index 5411f7b3..5aaef468 100644 --- a/ncurses/tinfo/lib_options.c +++ b/ncurses/tinfo/lib_options.c @@ -46,7 +46,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_options.c,v 1.69 2009/07/25 16:05:16 tom Exp $") +MODULE_ID("$Id: lib_options.c,v 1.70 2009/08/16 14:16:38 tom Exp $") NCURSES_EXPORT(int) idlok(WINDOW *win, bool flag) @@ -274,7 +274,7 @@ has_key_internal(int keycode, TRIES * tp) #ifdef USE_TERM_DRIVER NCURSES_EXPORT(int) -_nc_tinfo_has_key(SCREEN *sp, int keycode) +TINFO_HAS_KEY(SCREEN *sp, int keycode) { return IsValidTIScreen(sp) ? has_key_internal(keycode, sp->_keytry) : 0; diff --git a/ncurses/tinfo/tinfo_driver.c b/ncurses/tinfo/tinfo_driver.c index d2df9911..990b1773 100644 --- a/ncurses/tinfo/tinfo_driver.c +++ b/ncurses/tinfo/tinfo_driver.c @@ -42,7 +42,7 @@ #endif #endif -MODULE_ID("$Id: tinfo_driver.c,v 1.1 2009/05/23 22:40:30 juergen Exp $") +MODULE_ID("$Id: tinfo_driver.c,v 1.2 2009/08/16 14:17:08 tom Exp $") /* * SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS, @@ -173,7 +173,7 @@ static int drv_doupdate(TERMINAL_CONTROL_BLOCK * TCB) { AssertTCB(); - return _nc_tinfo_doupdate(TCB->csp); + return TINFO_DOUPDATE(TCB->csp); } /* @@ -945,7 +945,7 @@ drv_mvcur(TERMINAL_CONTROL_BLOCK * TCB, int yold, int xold, int ynew, int xnew) { SCREEN *sp = TCB->csp; AssertTCB(); - return _nc_tinfo_mvcur(sp, yold, xold, ynew, xnew); + return TINFO_MVCUR(sp, yold, xold, ynew, xnew); } static void @@ -1383,7 +1383,7 @@ drv_kyExist(TERMINAL_CONTROL_BLOCK * TCB, int key) AssertTCB(); if (TCB->csp) - res = _nc_tinfo_has_key(TCB->csp, key) == 0 ? FALSE : TRUE; + res = TINFO_HAS_KEY(TCB->csp, key) == 0 ? FALSE : TRUE; return res; } diff --git a/ncurses/tty/tty_update.c b/ncurses/tty/tty_update.c index 87996232..7a4c197e 100644 --- a/ncurses/tty/tty_update.c +++ b/ncurses/tty/tty_update.c @@ -43,7 +43,6 @@ * *-----------------------------------------------------------------*/ -#define NEED_NCURSES_CH_T 1 #include #ifndef CUR @@ -83,7 +82,7 @@ #include -MODULE_ID("$Id: tty_update.c,v 1.258 2009/06/27 19:16:17 tom Exp $") +MODULE_ID("$Id: tty_update.c,v 1.258.1.2 2009/08/16 14:20:30 tom Exp tom $") /* * This define controls the line-breakout optimization. Every once in a @@ -198,8 +197,10 @@ GoTo(NCURSES_SP_DCLx int const row, int const col) position_check(SP_PARM, SP_PARM->_cursrow, SP_PARM->_curscol, "GoTo"); - NCURSES_SP_NAME(mvcur) (NCURSES_SP_ARGx SP_PARM->_cursrow, - SP_PARM->_curscol, row, col); + TINFO_MVCUR(NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol, + row, col); position_check(SP_PARM, SP_PARM->_cursrow, SP_PARM->_curscol, "GoTo2"); } @@ -661,7 +662,7 @@ PutRange(NCURSES_SP_DCLx if_USE_SCROLL_HINTS(win->_line[row].oldindex = row) NCURSES_EXPORT(int) -NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) +TINFO_DOUPDATE(NCURSES_SP_DCL0) { int i; int nonempty; @@ -1004,11 +1005,11 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) returnCode(OK); } -#if NCURSES_SP_FUNCS +#if NCURSES_SP_FUNCS && !defined(USE_TERM_DRIVER) NCURSES_EXPORT(int) doupdate(void) { - return NCURSES_SP_NAME(doupdate) (CURRENT_SCREEN); + return TINFO_DOUPDATE(CURRENT_SCREEN); } #endif @@ -2162,11 +2163,11 @@ NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0) NCURSES_SP_NAME(_nc_outch)); SP_PARM->_default_color = FALSE; - NCURSES_SP_NAME(mvcur) (NCURSES_SP_ARGx - SP_PARM->_cursrow, - SP_PARM->_curscol, - screen_lines(SP_PARM) - 1, - 0); + TINFO_MVCUR(NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol, + screen_lines(SP_PARM) - 1, + 0); ClrToEOL(NCURSES_SP_ARGx blank, TRUE); }