diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1999-11-28 17:49:56 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1999-11-28 17:49:56 +0000 |
commit | f820514c542a093ae7ff2d7db431e6499126014d (patch) | |
tree | 77c8d1b77675d5d4b3e01bde3eb10e573384771e | |
parent | 6a1dbf2ca7f6d392c63cfb7febcbfd18a8330bb7 (diff) |
update to ncurses-5.0-19991127
48 files changed, 834 insertions, 686 deletions
diff --git a/lib/libcurses/base/lib_beep.c b/lib/libcurses/base/lib_beep.c index e4ca5aaaed9..071eec1b2e3 100644 --- a/lib/libcurses/base/lib_beep.c +++ b/lib/libcurses/base/lib_beep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_beep.c,v 1.1 1999/01/18 19:09:35 millert Exp $ */ +/* $OpenBSD: lib_beep.c,v 1.2 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -44,7 +44,7 @@ #include <curses.priv.h> #include <term.h> /* beep, flash */ -MODULE_ID("$From: lib_beep.c,v 1.6 1998/06/29 19:34:16 Alexander.V.Lukyanov Exp $") +MODULE_ID("$From: lib_beep.c,v 1.7 1999/10/22 21:39:09 tom Exp $") /* * beep() @@ -64,11 +64,11 @@ int beep(void) if (bell) { TPUTS_TRACE("bell"); res = putp(bell); - fflush(SP->_ofp); + _nc_flush(); } else if (flash_screen) { TPUTS_TRACE("flash_screen"); res = putp(flash_screen); - fflush(SP->_ofp); + _nc_flush(); } returnCode(res); diff --git a/lib/libcurses/base/lib_color.c b/lib/libcurses/base/lib_color.c index dceb1e8f215..a06b5bbf354 100644 --- a/lib/libcurses/base/lib_color.c +++ b/lib/libcurses/base/lib_color.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_color.c,v 1.3 1999/03/15 19:12:22 millert Exp $ */ +/* $OpenBSD: lib_color.c,v 1.4 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -36,22 +36,21 @@ /* lib_color.c * * Handles color emulation of SYS V curses - * */ #include <curses.priv.h> #include <term.h> -MODULE_ID("$From: lib_color.c,v 1.35 1999/03/15 01:45:14 Alexander.V.Lukyanov Exp $") +MODULE_ID("$From: lib_color.c,v 1.40 1999/11/27 22:24:18 tom Exp $") /* * These should be screen structure members. They need to be globals for * hystorical reasons. So we assign them in start_color() and also in * set_term()'s screen-switching logic. */ -int COLOR_PAIRS; -int COLORS; +int COLOR_PAIRS = 0; +int COLORS = 0; /* * Given a RGB range of 0..1000, we'll normally set the individual values @@ -85,6 +84,23 @@ static const color_t hls_palette[] = {0, 50, 100}, /* COLOR_WHITE */ }; +#ifdef NCURSES_EXT_FUNCS +static int +default_fg(void) +{ + return (SP->_default_fg >= 0) ? SP->_default_fg : COLOR_WHITE; +} + +static int +default_bg(void) +{ + return (SP->_default_bg >= 0) ? SP->_default_bg : COLOR_BLACK; +} +#else +#define default_fg() COLOR_WHITE +#define default_bg() COLOR_BLACK +#endif + /* * 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 @@ -147,12 +163,15 @@ static bool set_original_colors(void) int start_color(void) { + int n; + const color_t *tp; + T((T_CALLED("start_color()"))); if (set_original_colors() != TRUE) { - set_foreground_color(COLOR_WHITE, _nc_outch); - set_background_color(COLOR_BLACK, _nc_outch); + set_foreground_color(default_fg(), _nc_outch); + set_background_color(default_bg(), _nc_outch); } if (max_pairs != -1) @@ -161,7 +180,7 @@ int start_color(void) returnCode(ERR); if ((SP->_color_pairs = typeCalloc(unsigned short, max_pairs)) == 0) returnCode(ERR); - SP->_color_pairs[0] = PAIR_OF(COLOR_WHITE, COLOR_BLACK); + SP->_color_pairs[0] = PAIR_OF(default_fg(), default_bg()); if (max_colors != -1) COLORS = SP->_color_count = max_colors; else @@ -170,10 +189,24 @@ int start_color(void) if ((SP->_color_table = typeMalloc(color_t, COLORS)) == 0) returnCode(ERR); - if (hue_lightness_saturation) - memcpy(SP->_color_table, hls_palette, sizeof(color_t) * COLORS); - else - memcpy(SP->_color_table, cga_palette, sizeof(color_t) * COLORS); + tp = (hue_lightness_saturation) ? hls_palette : cga_palette; + for (n = 0; n < COLORS; n++) { + if (n < 8) { + SP->_color_table[n] = tp[n]; + } else { + SP->_color_table[n] = tp[n % 8]; + if (hue_lightness_saturation) { + SP->_color_table[n].green = 100; + } else { + if (SP->_color_table[n].red) + SP->_color_table[n].red = 1000; + if (SP->_color_table[n].green) + SP->_color_table[n].green = 1000; + if (SP->_color_table[n].blue) + SP->_color_table[n].blue = 1000; + } + } + } T(("started color: COLORS = %d, COLOR_PAIRS = %d", COLORS, COLOR_PAIRS)); @@ -228,6 +261,7 @@ int init_pair(short pair, short f, short b) if ((pair < 1) || (pair >= COLOR_PAIRS)) returnCode(ERR); +#ifdef NCURSES_EXT_FUNCS if (SP->_default_color) { if (f < 0) @@ -240,6 +274,7 @@ int init_pair(short pair, short f, short b) returnCode(ERR); } else +#endif if ((f < 0) || (f >= COLORS) || (b < 0) || (b >= COLORS)) returnCode(ERR); @@ -347,7 +382,7 @@ bool has_colors(void) int color_content(short color, short *r, short *g, short *b) { T((T_CALLED("color_content(%d,%p,%p,%p)"), color, r, g, b)); - if (color < 0 || color > COLORS) + if (color < 0 || color >= COLORS) returnCode(ERR); if (r) *r = SP->_color_table[color].red; @@ -360,7 +395,7 @@ int pair_content(short pair, short *f, short *b) { T((T_CALLED("pair_content(%d,%p,%p)"), pair, f, b)); - if ((pair < 0) || (pair > COLOR_PAIRS)) + if ((pair < 0) || (pair >= COLOR_PAIRS)) returnCode(ERR); if (f) *f = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK); if (b) *b = (SP->_color_pairs[pair] & C_MASK); @@ -374,20 +409,14 @@ void _nc_do_color(int pair, bool reverse, int (*outc)(int)) if (pair == 0) { - if (orig_pair) - { - TPUTS_TRACE("orig_pair"); - tputs(orig_pair, 1, outc); - } - else if (set_color_pair) - { - TPUTS_TRACE("set_color_pair"); - tputs(tparm(set_color_pair, pair), 1, outc); - } - else + if ( +#ifdef NCURSES_EXT_FUNCS + !SP->_default_color || +#endif + !set_original_colors()) { - set_foreground_color(COLOR_WHITE, outc); - set_background_color(COLOR_BLACK, outc); + set_foreground_color(default_fg(), outc); + set_background_color(default_bg(), outc); } } else @@ -413,9 +442,9 @@ void _nc_do_color(int pair, bool reverse, int (*outc)(int)) if (set_original_colors() != TRUE) { if (fg == C_MASK) - set_foreground_color(COLOR_WHITE, outc); + set_foreground_color(default_fg(), outc); if (bg == C_MASK) - set_background_color(COLOR_BLACK, outc); + set_background_color(default_bg(), outc); } } if (fg != C_MASK) diff --git a/lib/libcurses/base/lib_dft_fgbg.c b/lib/libcurses/base/lib_dft_fgbg.c index b1bef7ceb4d..80da38979a6 100644 --- a/lib/libcurses/base/lib_dft_fgbg.c +++ b/lib/libcurses/base/lib_dft_fgbg.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_dft_fgbg.c,v 1.1 1999/01/18 19:09:41 millert Exp $ */ +/* $OpenBSD: lib_dft_fgbg.c,v 1.2 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -29,26 +29,32 @@ ****************************************************************************/ /**************************************************************************** - * Author: Thomas E. Dickey <dickey@clark.net> 1997 * + * Author: Thomas E. Dickey <dickey@clark.net> 1997,1999 * ****************************************************************************/ #include <curses.priv.h> #include <term.h> -MODULE_ID("$From: lib_dft_fgbg.c,v 1.3 1998/02/11 12:13:54 tom Exp $") +MODULE_ID("$From: lib_dft_fgbg.c,v 1.7 1999/11/14 01:22:11 tom Exp $") /* * Modify the behavior of color-pair 0 so that the library doesn't assume that - * it is black on white. This is an extension to XSI curses. - * - * Invoke this function after 'start_color()'. + * it is white on black. This is an extension to XSI curses. */ int use_default_colors(void) { T((T_CALLED("use_default_colors()"))); + returnCode(assume_default_colors(C_MASK, C_MASK)); +} - if (!SP->_coloron) - returnCode(ERR); +/* + * Modify the behavior of color-pair 0 so that the library assumes that it + * is something specific, possibly not white on black. + */ +int +assume_default_colors(int fg, int bg) +{ + T((T_CALLED("assume_default_colors(%d,%d)"), fg, bg)); if (!orig_pair && !orig_colors) returnCode(ERR); @@ -56,7 +62,10 @@ use_default_colors(void) if (initialize_pair) /* don't know how to handle this */ returnCode(ERR); - SP->_default_color = TRUE; - SP->_color_pairs[0] = PAIR_OF(C_MASK, C_MASK); + SP->_default_color = (fg != COLOR_WHITE) || (bg != COLOR_BLACK); + SP->_default_fg = fg; + SP->_default_bg = bg; + if (SP->_color_pairs != 0) + SP->_color_pairs[0] = PAIR_OF(fg, bg); returnCode(OK); } diff --git a/lib/libcurses/base/lib_flash.c b/lib/libcurses/base/lib_flash.c index 06fea72969a..df42bd6e5cf 100644 --- a/lib/libcurses/base/lib_flash.c +++ b/lib/libcurses/base/lib_flash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_flash.c,v 1.1 1999/01/18 19:09:43 millert Exp $ */ +/* $OpenBSD: lib_flash.c,v 1.2 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -44,7 +44,7 @@ #include <curses.priv.h> #include <term.h> /* beep, flash */ -MODULE_ID("$From: lib_flash.c,v 1.3 1998/06/29 19:34:16 Alexander.V.Lukyanov Exp $") +MODULE_ID("$From: lib_flash.c,v 1.4 1999/10/22 21:39:06 tom Exp $") /* * flash() @@ -64,11 +64,11 @@ int flash(void) if (flash_screen) { TPUTS_TRACE("flash_screen"); res = putp(flash_screen); - fflush(SP->_ofp); + _nc_flush(); } else if (bell) { TPUTS_TRACE("bell"); res = putp(bell); - fflush(SP->_ofp); + _nc_flush(); } returnCode(res); diff --git a/lib/libcurses/base/lib_freeall.c b/lib/libcurses/base/lib_freeall.c index 0a07e5b71c0..116d0fcb4b7 100644 --- a/lib/libcurses/base/lib_freeall.c +++ b/lib/libcurses/base/lib_freeall.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_freeall.c,v 1.2 1999/05/08 20:29:00 millert Exp $ */ +/* $OpenBSD: lib_freeall.c,v 1.3 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -41,96 +41,101 @@ extern int malloc_errfd; /* FIXME */ #endif -MODULE_ID("$From: lib_freeall.c,v 1.14 1999/04/03 23:17:06 tom Exp $") +MODULE_ID("$From: lib_freeall.c,v 1.16 1999/11/28 01:34:11 tom Exp $") -static void free_slk(SLK *p) +static void +free_slk(SLK *p) { - if (p != 0) { - FreeIfNeeded(p->ent); - FreeIfNeeded(p->buffer); - free(p); - } + if (p != 0) { + FreeIfNeeded(p->ent); + FreeIfNeeded(p->buffer); + free(p); + } } -static void free_tries(struct tries *p) +static void +free_tries(struct tries *p) { - struct tries *q; - - while (p != 0) { - q = p->sibling; - if (p->child != 0) - free_tries(p->child); - free(p); - p = q; - } + struct tries *q; + + while (p != 0) { + q = p->sibling; + if (p->child != 0) + free_tries(p->child); + free(p); + p = q; + } } /* * Free all ncurses data. This is used for testing only (there's no practical * use for it as an extension). */ -void _nc_freeall(void) +void +_nc_freeall(void) { - WINDOWLIST *p, *q; + WINDOWLIST *p, *q; #if NO_LEAKS - _nc_free_tparm(); + _nc_free_tparm(); #endif + if (SP != 0) { while (_nc_windows != 0) { - /* Delete only windows that're not a parent */ - for (p = _nc_windows; p != 0; p = p->next) { - bool found = FALSE; - - for (q = _nc_windows; q != 0; q = q->next) { - if ((p != q) - && (q->win->_flags & _SUBWIN) - && (p->win == q->win->_parent)) { - found = TRUE; - break; - } - } - - if (!found) { - delwin(p->win); - break; - } + /* Delete only windows that're not a parent */ + for (p = _nc_windows; p != 0; p = p->next) { + bool found = FALSE; + + for (q = _nc_windows; q != 0; q = q->next) { + if ((p != q) + && (q->win->_flags & _SUBWIN) + && (p->win == q->win->_parent)) { + found = TRUE; + break; + } } + + if (!found) { + delwin(p->win); + break; + } + } } - if (SP != 0) { - free_tries (SP->_keytry); - free_tries (SP->_key_ok); - free_slk(SP->_slk); - FreeIfNeeded(SP->_color_pairs); - FreeIfNeeded(SP->_color_table); - /* it won't free buffer anyway */ -/* _nc_set_buffer(SP->_ofp, FALSE);*/ + free_tries(SP->_keytry); + free_tries(SP->_key_ok); + free_slk(SP->_slk); + FreeIfNeeded(SP->_color_pairs); + FreeIfNeeded(SP->_color_table); #if !BROKEN_LINKER - FreeAndNull(SP); + FreeAndNull(SP); #endif - } - - if (cur_term != 0) { - _nc_free_termtype(&(cur_term->type)); - free(cur_term); - } + } + if (cur_term != 0) { + _nc_free_termtype(&(cur_term->type)); + free(cur_term); + } #ifdef TRACE - (void) _nc_trace_buf(-1, 0); + (void) _nc_trace_buf(-1, 0); #endif #if HAVE_LIBDBMALLOC - malloc_dump(malloc_errfd); + malloc_dump(malloc_errfd); #elif HAVE_LIBDMALLOC #elif HAVE_PURIFY - purify_all_inuse(); + purify_all_inuse(); #endif } -void _nc_free_and_exit(int code) +void +_nc_free_and_exit(int code) { - _nc_freeall(); - exit(code); + _nc_freeall(); + exit(code); } + #else -void _nc_freeall(void) { } +void +_nc_freeall(void) +{ +} #endif diff --git a/lib/libcurses/base/lib_mouse.c b/lib/libcurses/base/lib_mouse.c index afc52ef37e9..b0263f20cdb 100644 --- a/lib/libcurses/base/lib_mouse.c +++ b/lib/libcurses/base/lib_mouse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_mouse.c,v 1.4 1999/08/15 11:40:55 millert Exp $ */ +/* $OpenBSD: lib_mouse.c,v 1.5 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999 Free Software Foundation, Inc. * @@ -87,7 +87,7 @@ #endif #endif -MODULE_ID("$From: lib_mouse.c,v 1.44 1999/07/24 21:10:48 tom Exp $") +MODULE_ID("$From: lib_mouse.c,v 1.45 1999/10/22 21:39:02 tom Exp $") #define MY_TRACE TRACE_ICALLS|TRACE_IEVENT @@ -533,7 +533,7 @@ static void mouse_activate(bool on) #endif } } - (void) fflush(SP->_ofp); + _nc_flush(); } /************************************************************************** diff --git a/lib/libcurses/base/lib_newwin.c b/lib/libcurses/base/lib_newwin.c index db0df629fff..66f2facd537 100644 --- a/lib/libcurses/base/lib_newwin.c +++ b/lib/libcurses/base/lib_newwin.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_newwin.c,v 1.1 1999/01/18 19:09:54 millert Exp $ */ +/* $OpenBSD: lib_newwin.c,v 1.2 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -44,7 +44,7 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_newwin.c,v 1.20 1998/05/23 23:21:32 Alexander.V.Lukyanov Exp $") +MODULE_ID("$From: lib_newwin.c,v 1.22 1999/11/25 13:48:24 juergen Exp $") void _nc_freewin(WINDOW *win) { @@ -61,8 +61,8 @@ int i; free(p); if (! (win->_flags & _SUBWIN)) { - for (i = 0; i <= win->_maxy && win->_line[i].text; i++) - free(win->_line[i].text); + for (i = 0; i <= win->_maxy; i++) + FreeIfNeeded(win->_line[i].text); } free(win->_line); free(win); diff --git a/lib/libcurses/base/lib_nl.c b/lib/libcurses/base/lib_nl.c index 2b4fe387462..9895d1d6f8a 100644 --- a/lib/libcurses/base/lib_nl.c +++ b/lib/libcurses/base/lib_nl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_nl.c,v 1.1 1999/01/18 19:09:54 millert Exp $ */ +/* $OpenBSD: lib_nl.c,v 1.2 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -45,7 +45,7 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_nl.c,v 1.3 1998/10/14 15:14:08 Alexander.V.Lukyanov Exp $") +MODULE_ID("$From: lib_nl.c,v 1.4 1999/10/22 22:31:51 tom Exp $") #ifdef __EMX__ #include <io.h> @@ -59,8 +59,8 @@ int nl(void) SP->_nl = TRUE; #ifdef __EMX__ - fflush(SP->_ofp); - _fsetmode(SP->_ofp, "t"); + _nc_flush(); + _fsetmode(NC_OUTPUT, "t"); #endif returnCode(OK); @@ -73,8 +73,8 @@ int nonl(void) SP->_nl = FALSE; #ifdef __EMX__ - fflush(SP->_ofp); - _fsetmode(SP->_ofp, "b"); + _nc_flush(); + _fsetmode(NC_OUTPUT, "b"); #endif returnCode(OK); diff --git a/lib/libcurses/base/lib_set_term.c b/lib/libcurses/base/lib_set_term.c index d05dcffb450..ab67435081b 100644 --- a/lib/libcurses/base/lib_set_term.c +++ b/lib/libcurses/base/lib_set_term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_set_term.c,v 1.4 1999/08/15 11:40:55 millert Exp $ */ +/* $OpenBSD: lib_set_term.c,v 1.5 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -44,7 +44,7 @@ #include <term.h> /* cur_term */ -MODULE_ID("$From: lib_set_term.c,v 1.46 1999/07/24 20:05:49 tom Exp $") +MODULE_ID("$From: lib_set_term.c,v 1.47 1999/11/14 00:14:39 tom Exp $") SCREEN * set_term(SCREEN *screenp) { @@ -168,6 +168,10 @@ size_t i; #ifdef NCURSES_NO_PADDING SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0; #endif +#ifdef NCURSES_EXT_FUNCS + SP->_default_fg = COLOR_WHITE; + SP->_default_bg = COLOR_BLACK; +#endif SP->_maxclick = DEFAULT_MAXCLICK; SP->_mouse_event = no_mouse_event; diff --git a/lib/libcurses/base/lib_slk.c b/lib/libcurses/base/lib_slk.c index 76ba38d65dd..c0cc60ba85b 100644 --- a/lib/libcurses/base/lib_slk.c +++ b/lib/libcurses/base/lib_slk.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_slk.c,v 1.2 1999/03/11 21:03:55 millert Exp $ */ +/* $OpenBSD: lib_slk.c,v 1.3 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -43,13 +43,13 @@ #include <ctype.h> #include <term.h> /* num_labels, label_*, plab_norm */ -MODULE_ID("$From: lib_slk.c,v 1.16 1999/03/03 23:44:22 juergen Exp $") +MODULE_ID("$From: lib_slk.c,v 1.17 1999/10/30 23:00:16 tom Exp $") /* * We'd like to move these into the screen context structure, but cannot, * because slk_init() is called before initscr()/newterm(). */ -int _nc_slk_format; /* one more than format specified in slk_init() */ +int _nc_slk_format = 0; /* one more than format specified in slk_init() */ /* * Paint the info line for the PC style SLK emulation. diff --git a/lib/libcurses/base/safe_sprintf.c b/lib/libcurses/base/safe_sprintf.c index a5dd7c4a8e1..d344b79463e 100644 --- a/lib/libcurses/base/safe_sprintf.c +++ b/lib/libcurses/base/safe_sprintf.c @@ -1,7 +1,7 @@ -/* $OpenBSD: safe_sprintf.c,v 1.2 1999/03/02 06:23:27 millert Exp $ */ +/* $OpenBSD: safe_sprintf.c,v 1.3 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -35,7 +35,7 @@ #include <curses.priv.h> #include <ctype.h> -MODULE_ID("$From: safe_sprintf.c,v 1.10 1999/02/27 19:56:37 tom Exp $") +MODULE_ID("$From: safe_sprintf.c,v 1.11 1999/09/11 18:03:27 tom Exp $") #if USE_SAFE_SPRINTF @@ -114,7 +114,6 @@ _nc_printf_length(const char *fmt, va_list ap) case 'Z': /* FALLTHRU */ case 'h': /* FALLTHRU */ case 'l': /* FALLTHRU */ - case 'L': /* FALLTHRU */ done = FALSE; type = *fmt; break; @@ -136,10 +135,7 @@ _nc_printf_length(const char *fmt, va_list ap) case 'E': /* FALLTHRU */ case 'g': /* FALLTHRU */ case 'G': /* FALLTHRU */ - if (type == 'L') - VA_FLOAT(long double); - else - VA_FLOAT(double); + VA_FLOAT(double); used = 'f'; break; case 'c': diff --git a/lib/libcurses/base/version.c b/lib/libcurses/base/version.c new file mode 100644 index 00000000000..a8f78015cec --- /dev/null +++ b/lib/libcurses/base/version.c @@ -0,0 +1,48 @@ +/**************************************************************************** + * Copyright (c) 1999 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 * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Thomas E. Dickey <dickey@clark.net> 1999 * + ****************************************************************************/ + +#include <curses.priv.h> + +MODULE_ID("$From: version.c,v 1.1 1999/10/23 13:28:49 tom Exp $") + +const char * +curses_version(void) +{ + static char my_version[80]; + + T((T_CALLED("curses_version()"))); + sprintf(my_version, "ncurses %d.%d.%d", + NCURSES_VERSION_MAJOR, + NCURSES_VERSION_MINOR, + NCURSES_VERSION_PATCH); + returnPtr(my_version); +} diff --git a/lib/libcurses/tinfo/comp_error.c b/lib/libcurses/tinfo/comp_error.c index 2a5b115c7ad..38580200f4d 100644 --- a/lib/libcurses/tinfo/comp_error.c +++ b/lib/libcurses/tinfo/comp_error.c @@ -1,7 +1,7 @@ -/* $OpenBSD: comp_error.c,v 1.1 1999/01/18 19:10:13 millert Exp $ */ +/* $OpenBSD: comp_error.c,v 1.2 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -43,11 +43,11 @@ #include <tic.h> -MODULE_ID("$From: comp_error.c,v 1.16 1998/08/01 23:39:51 tom Exp $") +MODULE_ID("$From: comp_error.c,v 1.17 1999/10/30 23:00:16 tom Exp $") -bool _nc_suppress_warnings; -int _nc_curr_line; /* current line # in input */ -int _nc_curr_col; /* current column # in input */ +bool _nc_suppress_warnings = FALSE; +int _nc_curr_line = 0; /* current line # in input */ +int _nc_curr_col = 0; /* current column # in input */ static const char *sourcename; static char termtype[MAX_NAME_SIZE+1]; diff --git a/lib/libcurses/tinfo/comp_parse.c b/lib/libcurses/tinfo/comp_parse.c index b5cb6716e83..253febbafc2 100644 --- a/lib/libcurses/tinfo/comp_parse.c +++ b/lib/libcurses/tinfo/comp_parse.c @@ -1,7 +1,7 @@ -/* $OpenBSD: comp_parse.c,v 1.3 1999/03/02 06:23:28 millert Exp $ */ +/* $OpenBSD: comp_parse.c,v 1.4 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -56,7 +56,7 @@ #include <tic.h> #include <term_entry.h> -MODULE_ID("$From: comp_parse.c,v 1.34 1999/02/27 22:13:02 tom Exp $") +MODULE_ID("$From: comp_parse.c,v 1.36 1999/10/31 00:56:12 tom Exp $") static void sanity_check(TERMTYPE *); void (*_nc_check_termtype)(TERMTYPE *) = sanity_check; @@ -82,7 +82,7 @@ void (*_nc_check_termtype)(TERMTYPE *) = sanity_check; * _nc_head _nc_tail */ -ENTRY *_nc_head, *_nc_tail; +ENTRY *_nc_head = 0, *_nc_tail = 0; static void enqueue(ENTRY *ep) /* add an entry to the in-core list */ @@ -100,12 +100,12 @@ static void enqueue(ENTRY *ep) newp->last->next = newp; } -void _nc_free_entries(ENTRY *head) +void _nc_free_entries(ENTRY *headp) /* free the allocated storage consumed by list entries */ { ENTRY *ep, *next; - for (ep = head; ep; ep = next) + for (ep = headp; ep; ep = next) { /* * This conditional lets us disconnect storage from the list. diff --git a/lib/libcurses/tinfo/comp_scan.c b/lib/libcurses/tinfo/comp_scan.c index 0c9012c835d..fa5f1e327d1 100644 --- a/lib/libcurses/tinfo/comp_scan.c +++ b/lib/libcurses/tinfo/comp_scan.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -49,7 +49,7 @@ #include <ctype.h> #include <tic.h> -MODULE_ID("$From: comp_scan.c,v 1.34 1998/11/01 00:56:39 tom Exp $") +MODULE_ID("$From: comp_scan.c,v 1.35 1999/10/30 23:00:16 tom Exp $") /* * Maximum length of string capability we'll accept before raising an error. @@ -59,11 +59,11 @@ MODULE_ID("$From: comp_scan.c,v 1.34 1998/11/01 00:56:39 tom Exp $") #define iswhite(ch) (ch == ' ' || ch == '\t') -int _nc_syntax; /* termcap or terminfo? */ -long _nc_curr_file_pos; /* file offset of current line */ -long _nc_comment_start; /* start of comment range before name */ -long _nc_comment_end; /* end of comment range before name */ -long _nc_start_line; /* start line of current entry */ +int _nc_syntax = 0; /* termcap or terminfo? */ +long _nc_curr_file_pos = 0; /* file offset of current line */ +long _nc_comment_start = 0; /* start of comment range before name */ +long _nc_comment_end = 0; /* end of comment range before name */ +long _nc_start_line = 0; /* start line of current entry */ /***************************************************************************** * diff --git a/lib/libcurses/tinfo/init_keytry.c b/lib/libcurses/tinfo/init_keytry.c index 312b15d4d0b..7ec2b909412 100644 --- a/lib/libcurses/tinfo/init_keytry.c +++ b/lib/libcurses/tinfo/init_keytry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_keytry.c,v 1.1 1999/02/24 06:31:10 millert Exp $ */ +/* $OpenBSD: init_keytry.c,v 1.2 1999/11/28 17:49:53 millert Exp $ */ /**************************************************************************** * Copyright (c) 1999 Free Software Foundation, Inc. * @@ -34,7 +34,7 @@ /* cursor_visible,cursor_normal,cursor_invisible */ #include <tic.h> /* struct tinfo_fkeys */ -MODULE_ID("$From: init_keytry.c,v 1.1 1999/02/18 22:39:11 tom Exp $") +MODULE_ID("$From: init_keytry.c,v 1.2 1999/09/11 17:32:57 Jeffrey.Honig Exp $") /* ** _nc_init_keytry() @@ -43,12 +43,23 @@ MODULE_ID("$From: init_keytry.c,v 1.1 1999/02/18 22:39:11 tom Exp $") ** */ +#ifdef BROKEN_LINKER +#undef _nc_tinfo_fkeys +#endif + /* LINT_PREPRO #if 0*/ #include <init_keytry.h> /* LINT_PREPRO #endif*/ +#ifdef BROKEN_LINKER +struct tinfo_fkeys *_nc_tinfo_fkeysf(void) +{ + return _nc_tinfo_fkeys; +} +#endif + void _nc_init_keytry(void) { size_t n; diff --git a/lib/libcurses/tinfo/lib_acs.c b/lib/libcurses/tinfo/lib_acs.c index f0ae29c1742..a9b142b9b64 100644 --- a/lib/libcurses/tinfo/lib_acs.c +++ b/lib/libcurses/tinfo/lib_acs.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_acs.c,v 1.2 1999/02/24 06:31:11 millert Exp $ */ +/* $OpenBSD: lib_acs.c,v 1.3 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -38,9 +38,9 @@ #include <curses.priv.h> #include <term.h> /* ena_acs, acs_chars */ -MODULE_ID("$From: lib_acs.c,v 1.15 1999/02/18 11:31:43 tom Exp $") +MODULE_ID("$From: lib_acs.c,v 1.16 1999/10/30 23:00:16 tom Exp $") -chtype acs_map[ACS_LEN]; +chtype acs_map[ACS_LEN] = { 0 }; void _nc_init_acs(void) { diff --git a/lib/libcurses/tinfo/lib_cur_term.c b/lib/libcurses/tinfo/lib_cur_term.c index a7618f95a05..22bdcaa77df 100644 --- a/lib/libcurses/tinfo/lib_cur_term.c +++ b/lib/libcurses/tinfo/lib_cur_term.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_cur_term.c,v 1.3 1999/08/15 11:40:55 millert Exp $ */ +/* $OpenBSD: lib_cur_term.c,v 1.4 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -42,9 +42,9 @@ #include <term_entry.h> /* TTY, cur_term */ #include <termcap.h> /* ospeed */ -MODULE_ID("$From: lib_cur_term.c,v 1.8 1999/07/24 20:08:19 tom Exp $") +MODULE_ID("$From: lib_cur_term.c,v 1.9 1999/10/30 23:00:16 tom Exp $") -TERMINAL *cur_term; +TERMINAL *cur_term = 0; TERMINAL *set_curterm(TERMINAL *termp) { diff --git a/lib/libcurses/tinfo/lib_napms.c b/lib/libcurses/tinfo/lib_napms.c index f78b5149f19..39da90f4a97 100644 --- a/lib/libcurses/tinfo/lib_napms.c +++ b/lib/libcurses/tinfo/lib_napms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_napms.c,v 1.2 1999/06/06 15:55:17 millert Exp $ */ +/* $OpenBSD: lib_napms.c,v 1.3 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -60,7 +60,7 @@ #endif #endif -MODULE_ID("$From: lib_napms.c,v 1.5 1999/06/06 00:42:47 R.Lindsay.Todd Exp $") +MODULE_ID("$From: lib_napms.c,v 1.6 1999/10/21 23:01:41 tom Exp $") int napms(int ms) { @@ -73,8 +73,6 @@ int napms(int ms) ts.tv_nsec = (ms % 1000) * 1000000; nanosleep(&ts, NULL); } -#elif HAVE_USLEEP - usleep(1000*(unsigned)ms); #elif USE_FUNC_POLL { struct pollfd fds[1]; diff --git a/lib/libcurses/tinfo/lib_options.c b/lib/libcurses/tinfo/lib_options.c index ed74b5d0269..5420fa1964f 100644 --- a/lib/libcurses/tinfo/lib_options.c +++ b/lib/libcurses/tinfo/lib_options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_options.c,v 1.3 1999/07/04 12:43:16 millert Exp $ */ +/* $OpenBSD: lib_options.c,v 1.4 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -46,7 +46,7 @@ #include <term.h> /* keypad_xmit, keypad_local, meta_on, meta_off */ /* cursor_visible,cursor_normal,cursor_invisible */ -MODULE_ID("$From: lib_options.c,v 1.35 1999/07/04 00:18:28 tom Exp $") +MODULE_ID("$From: lib_options.c,v 1.36 1999/10/22 21:38:57 tom Exp $") int idlok(WINDOW *win, bool flag) { @@ -195,7 +195,7 @@ int cursor = SP->_cursor; break; } SP->_cursor = vis; - (void) fflush(SP->_ofp); + _nc_flush(); returnCode(cursor==-1 ? 1 : cursor); } @@ -246,13 +246,13 @@ int _nc_keypad(bool flag) { TPUTS_TRACE("keypad_xmit"); putp(keypad_xmit); - (void) fflush(SP->_ofp); + _nc_flush(); } else if (! flag && keypad_local) { TPUTS_TRACE("keypad_local"); putp(keypad_local); - (void) fflush(SP->_ofp); + _nc_flush(); } if (flag && !SP->_tried) { diff --git a/lib/libcurses/tinfo/lib_setup.c b/lib/libcurses/tinfo/lib_setup.c index 1facd522cba..36fd188c42d 100644 --- a/lib/libcurses/tinfo/lib_setup.c +++ b/lib/libcurses/tinfo/lib_setup.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_setup.c,v 1.6 1999/08/22 17:42:37 millert Exp $ */ +/* $OpenBSD: lib_setup.c,v 1.7 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -51,7 +51,7 @@ #include <term.h> /* lines, columns, cur_term */ -MODULE_ID("$From: lib_setup.c,v 1.55 1999/08/21 23:06:08 tom Exp $") +MODULE_ID("$From: lib_setup.c,v 1.56 1999/10/30 23:00:16 tom Exp $") /**************************************************************************** * @@ -102,7 +102,7 @@ void use_env(bool f) _use_env = f; } -int LINES, COLS, TABSIZE; +int LINES = 0, COLS = 0, TABSIZE = 0; static void _nc_get_screensize(int *linep, int *colp) /* Obtain lines/columns values from the environment and/or terminfo entry */ @@ -282,7 +282,7 @@ static int grab_entry(const char *const tn, TERMTYPE *const tp) } #endif -char ttytype[NAMESIZE]; +char ttytype[NAMESIZE] = ""; /* * setupterm(termname, Filedes, errret) diff --git a/lib/libcurses/tinfo/lib_termcap.c b/lib/libcurses/tinfo/lib_termcap.c index e7e76cd5b5c..2ead2fded90 100644 --- a/lib/libcurses/tinfo/lib_termcap.c +++ b/lib/libcurses/tinfo/lib_termcap.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_termcap.c,v 1.2 1999/03/02 06:23:29 millert Exp $ */ +/* $OpenBSD: lib_termcap.c,v 1.3 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -41,15 +41,15 @@ #define __INTERNAL_CAPS_VISIBLE #include <term_entry.h> -MODULE_ID("$From: lib_termcap.c,v 1.28 1999/02/27 22:12:58 tom Exp $") +MODULE_ID("$From: lib_termcap.c,v 1.30 1999/10/30 23:00:16 tom Exp $") /* some of the code in here was contributed by: Magnus Bengtsson, d6mbeng@dtek.chalmers.se */ -char *UP; -char *BC; +char *UP = 0; +char *BC = 0; /*************************************************************************** * @@ -164,7 +164,7 @@ int i; * ***************************************************************************/ -char *tgetstr(NCURSES_CONST char *id, char **area GCC_UNUSED) +char *tgetstr(NCURSES_CONST char *id, char **area) { int i; @@ -177,6 +177,12 @@ int i; if (!strncmp(id, capname, 2)) { T(("found match : %s", _nc_visbuf(tp->Strings[i]))); /* setupterm forces cancelled strings to null */ + if (area != 0 + && *area != 0 + && VALID_STRING(tp->Strings[i])) { + (void) strcpy(*area, tp->Strings[i]); + *area += strlen(*area) + 1; + } returnPtr(tp->Strings[i]); } } diff --git a/lib/libcurses/tinfo/lib_tputs.c b/lib/libcurses/tinfo/lib_tputs.c index 19a1339033b..e6955723c0b 100644 --- a/lib/libcurses/tinfo/lib_tputs.c +++ b/lib/libcurses/tinfo/lib_tputs.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_tputs.c,v 1.2 1999/03/02 06:23:29 millert Exp $ */ +/* $OpenBSD: lib_tputs.c,v 1.3 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -48,14 +48,12 @@ #include <termcap.h> /* ospeed */ #include <tic.h> -MODULE_ID("$From: lib_tputs.c,v 1.39 1999/02/25 10:44:29 tom Exp $") +MODULE_ID("$From: lib_tputs.c,v 1.42 1999/10/30 23:00:16 tom Exp $") -#define OUTPUT ((SP != 0) ? SP->_ofp : stdout) +char PC = 0; /* used by termcap library */ +speed_t ospeed = 0; /* used by termcap library */ -char PC; /* used by termcap library */ -speed_t ospeed; /* used by termcap library */ - -int _nc_nulls_sent; /* used by 'tack' program */ +int _nc_nulls_sent = 0; /* used by 'tack' program */ static int (*my_outch)(int c) = _nc_outch; @@ -72,7 +70,7 @@ int delay_output(int ms) for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--) my_outch(PC); if (my_outch == _nc_outch) - (void) fflush(OUTPUT); + _nc_flush(); } returnCode(OK); @@ -84,7 +82,17 @@ int _nc_outch(int ch) _nc_outchars++; #endif /* TRACE */ - putc(ch, OUTPUT); + if (SP != 0 + && SP->_cleanup) { + char tmp = ch; + /* + * POSIX says write() is safe in a signal handler, but the + * buffered I/O is not. + */ + write(fileno(NC_OUTPUT), &tmp, 1); + } else { + putc(ch, NC_OUTPUT); + } return OK; } diff --git a/lib/libcurses/tinfo/lib_ttyflags.c b/lib/libcurses/tinfo/lib_ttyflags.c index 269c28ea088..9a4825e8384 100644 --- a/lib/libcurses/tinfo/lib_ttyflags.c +++ b/lib/libcurses/tinfo/lib_ttyflags.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_ttyflags.c,v 1.2 1999/08/15 11:40:55 millert Exp $ */ +/* $OpenBSD: lib_ttyflags.c,v 1.3 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -40,7 +40,7 @@ #include <curses.priv.h> #include <term.h> /* cur_term */ -MODULE_ID("$From: lib_ttyflags.c,v 1.2 1999/07/24 22:36:12 tom Exp $") +MODULE_ID("$From: lib_ttyflags.c,v 1.3 1999/10/22 21:38:55 tom Exp $") #undef tabs @@ -135,7 +135,7 @@ int reset_shell_mode(void) if (SP) { _nc_keypad(FALSE); - fflush(SP->_ofp); + _nc_flush(); NC_BUFFERED(FALSE); } returnCode(_nc_set_tty_mode(&cur_term->Ottyb)); diff --git a/lib/libcurses/tinfo/make_keys.c b/lib/libcurses/tinfo/make_keys.c index afc60725e3a..d10b1a7e87f 100644 --- a/lib/libcurses/tinfo/make_keys.c +++ b/lib/libcurses/tinfo/make_keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: make_keys.c,v 1.3 1999/03/02 06:23:29 millert Exp $ */ +/* $OpenBSD: make_keys.c,v 1.4 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -39,7 +39,7 @@ */ #include <curses.priv.h> -MODULE_ID("$From: make_keys.c,v 1.6 1999/02/22 16:55:20 tom Exp $") +MODULE_ID("$From: make_keys.c,v 1.7 1999/09/11 17:32:57 Jeffrey.Honig Exp $") #include <names.c> @@ -105,6 +105,9 @@ int main(int argc, char *argv[]) "", "/* This file was generated by MAKE_KEYS */", "", + "#ifdef BROKEN_LINKER", + "static", + "#endif", "struct tinfo_fkeys _nc_tinfo_fkeys[] = {", 0 }; diff --git a/lib/libcurses/tinfo/parse_entry.c b/lib/libcurses/tinfo/parse_entry.c index e75680138d9..08a2a859fba 100644 --- a/lib/libcurses/tinfo/parse_entry.c +++ b/lib/libcurses/tinfo/parse_entry.c @@ -1,7 +1,7 @@ -/* $OpenBSD: parse_entry.c,v 1.2 1999/03/02 06:23:29 millert Exp $ */ +/* $OpenBSD: parse_entry.c,v 1.3 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1999 Free Software Foundation, Inc. * + * Copyright (c) 1999,1999 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 * @@ -50,7 +50,7 @@ #define __INTERNAL_CAPS_VISIBLE #include <term_entry.h> -MODULE_ID("$From: parse_entry.c,v 1.39 1999/03/01 02:28:51 tom Exp $") +MODULE_ID("$From: parse_entry.c,v 1.40 1999/10/30 23:00:16 tom Exp $") #ifdef LINT static short const parametrized[] = { 0 }; @@ -58,7 +58,7 @@ static short const parametrized[] = { 0 }; #include <parametrized.h> #endif -struct token _nc_curr_token; +struct token _nc_curr_token = { 0, 0, 0 }; static void postprocess_termcap(TERMTYPE *, bool); static void postprocess_terminfo(TERMTYPE *); diff --git a/lib/libcurses/trace/lib_trace.c b/lib/libcurses/trace/lib_trace.c index 11124a0167c..fbdf5abf455 100644 --- a/lib/libcurses/trace/lib_trace.c +++ b/lib/libcurses/trace/lib_trace.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_trace.c,v 1.1 1999/01/18 19:10:23 millert Exp $ */ +/* $OpenBSD: lib_trace.c,v 1.2 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -40,7 +40,7 @@ #include <curses.priv.h> #include <tic.h> -MODULE_ID("$From: lib_trace.c,v 1.30 1998/10/03 23:41:42 tom Exp $") +MODULE_ID("$From: lib_trace.c,v 1.31 1999/10/30 23:00:15 tom Exp $") #include <ctype.h> #if HAVE_FCNTL_H @@ -51,7 +51,7 @@ unsigned _nc_tracing = 0; /* always define this */ #ifdef TRACE const char *_nc_tputs_trace = ""; -long _nc_outchars; +long _nc_outchars = 0; static FILE * tracefp; /* default to writing to stderr */ #endif diff --git a/lib/libcurses/tty/hashmap.c b/lib/libcurses/tty/hashmap.c index 25ea2478a84..a2442f97c1a 100644 --- a/lib/libcurses/tty/hashmap.c +++ b/lib/libcurses/tty/hashmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hashmap.c,v 1.4 1999/03/18 16:46:58 millert Exp $ */ +/* $OpenBSD: hashmap.c,v 1.5 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -72,7 +72,7 @@ AUTHOR #include <curses.priv.h> #include <term.h> /* for back_color_erase */ -MODULE_ID("$From: hashmap.c,v 1.33 1999/03/18 02:09:45 Alexander.V.Lukyanov Exp $") +MODULE_ID("$From: hashmap.c,v 1.34 1999/11/28 00:10:57 tom Exp $") #ifdef HASHDEBUG @@ -288,7 +288,9 @@ void _nc_hash_map(void) if (!hashtab) { if (oldhash) + { FreeAndNull(oldhash); + } lines_alloc = 0; return; } diff --git a/lib/libcurses/tty/lib_mvcur.c b/lib/libcurses/tty/lib_mvcur.c index 29e9f89d266..b3179275d1f 100644 --- a/lib/libcurses/tty/lib_mvcur.c +++ b/lib/libcurses/tty/lib_mvcur.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_mvcur.c,v 1.3 1999/06/27 08:14:21 millert Exp $ */ +/* $OpenBSD: lib_mvcur.c,v 1.4 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -155,7 +155,7 @@ #include <term.h> #include <ctype.h> -MODULE_ID("$From: lib_mvcur.c,v 1.57 1999/06/26 22:16:04 tom Exp $") +MODULE_ID("$From: lib_mvcur.c,v 1.60 1999/10/03 01:08:27 Alexander.V.Lukyanov Exp $") #define STRLEN(s) (s != 0) ? strlen(s) : 0 @@ -248,10 +248,10 @@ int _nc_msec_cost(const char *const cap, int affcnt) { if (isdigit(*cp)) number = number * 10 + (*cp - '0'); - else if (*cp == '.') - number += (*++cp - 10) / 10.0; else if (*cp == '*') number *= affcnt; + else if (*cp == '.' && (*++cp != '>') && isdigit(*cp)) + number += (*cp - '0') / 10.0; } cum_cost += number * 10; @@ -736,6 +736,7 @@ onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw) { char use[OPT_SIZE], *sp; int tactic = 0, newcost, usecost = INFINITY; + int t5_cr_cost; #if defined(MAIN) || defined(NCURSES_TEST) struct timeval before, after; @@ -819,13 +820,14 @@ onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw) * tactic #5: use left margin for wrap to right-hand side, * unless strange wrap behavior indicated by xenl might hose us. */ + t5_cr_cost = (xold>0 ? SP->_cr_cost : 0); if (auto_left_margin && !eat_newline_glitch && yold > 0 && cursor_left && ((newcost=relative_move(NULL, yold-1, screen_columns-1, ynew, xnew, ovw)) != INFINITY) - && SP->_cr_cost + SP->_cub1_cost + newcost + newcost < usecost) + && t5_cr_cost + SP->_cub1_cost + newcost < usecost) { tactic = 5; - usecost = SP->_cr_cost + SP->_cub1_cost + newcost; + usecost = t5_cr_cost + SP->_cub1_cost + newcost; } /* diff --git a/lib/libcurses/tty/lib_tstp.c b/lib/libcurses/tty/lib_tstp.c index b3c181521ae..aab402f0223 100644 --- a/lib/libcurses/tty/lib_tstp.c +++ b/lib/libcurses/tty/lib_tstp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_tstp.c,v 1.4 1999/08/15 11:40:56 millert Exp $ */ +/* $OpenBSD: lib_tstp.c,v 1.5 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999 Free Software Foundation, Inc. * @@ -50,7 +50,7 @@ #define _POSIX_SOURCE #endif -MODULE_ID("$From: lib_tstp.c,v 1.19 1999/07/24 22:47:20 tom Exp $") +MODULE_ID("$From: lib_tstp.c,v 1.20 1999/10/22 23:11:09 tom Exp $") #if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC) #define USE_SIGTSTP 1 @@ -201,13 +201,16 @@ static void tstp(int dummy GCC_UNUSED) static void cleanup(int sig) { + static int nested; + /* * Actually, doing any sort of I/O from within an signal handler is * "unsafe". But we'll _try_ to clean up the screen and terminal * settings on the way out. */ - if (sig == SIGINT - || sig == SIGQUIT) { + if (!nested++ + && (sig == SIGINT + || sig == SIGQUIT)) { #if HAVE_SIGACTION || HAVE_SIGVEC sigaction_t act; sigemptyset(&act.sa_mask); @@ -221,6 +224,11 @@ static void cleanup(int sig) SCREEN *scan = _nc_screen_chain; while(scan) { + if (SP != 0 + && SP->_ofp != 0 + && isatty(fileno(SP->_ofp))) { + SP->_cleanup = TRUE; + } set_term(scan); endwin(); if (SP) diff --git a/lib/libcurses/tty/lib_twait.c b/lib/libcurses/tty/lib_twait.c index 5a7cffeae2b..0d330245f48 100644 --- a/lib/libcurses/tty/lib_twait.c +++ b/lib/libcurses/tty/lib_twait.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_twait.c,v 1.1 1999/01/18 19:10:27 millert Exp $ */ +/* $OpenBSD: lib_twait.c,v 1.2 1999/11/28 17:49:54 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -42,6 +42,10 @@ ** comments, none of the original code remains - T.Dickey). */ +#ifdef __BEOS__ +#include <OS.h> +#endif + #include <curses.priv.h> #if USE_FUNC_POLL @@ -59,28 +63,32 @@ # endif #endif -#ifdef __BEOS__ -/* BeOS select() only works on sockets. Use the tty hack instead */ -#include <socket.h> -#define select check_select -#endif - -MODULE_ID("$From: lib_twait.c,v 1.32 1998/06/06 22:44:14 tom Exp $") +MODULE_ID("$From: lib_twait.c,v 1.34 1999/10/16 21:25:10 tom Exp $") -static int _nc_gettime(void) +static long _nc_gettime(bool first) { - int res; + long res; #if HAVE_GETTIMEOFDAY # define PRECISE_GETTIME 1 - struct timeval t; - gettimeofday(&t, (struct timezone *)0); - res = t.tv_sec*1000 + t.tv_usec/1000; + static struct timeval t0; + struct timeval t1; + gettimeofday(&t1, (struct timezone *)0); + if (first) { + t0 = t1; + } + res = (t1.tv_sec - t0.tv_sec) * 1000 + + (t1.tv_usec - t0.tv_usec) / 1000; #else # define PRECISE_GETTIME 0 - res = time(0)*1000; + static time_t t0; + time_t t1 = time((time_t*)0); + if (first) { + t0 = t1; + } + res = (t1 - t0) * 1000; #endif - T(("time: %d msec", res)); + T(("%s time: %ld msec", first ? "get" : "elapsed", res)); return res; } @@ -106,18 +114,19 @@ int result; #if USE_FUNC_POLL struct pollfd fds[2]; +#elif defined(__BEOS__) #elif HAVE_SELECT static fd_set set; #endif -int starttime, returntime; +long starttime, returntime; T(("start twait: %d milliseconds, mode: %d", milliseconds, mode)); #if PRECISE_GETTIME retry: #endif - starttime = _nc_gettime(); + starttime = _nc_gettime(TRUE); count = 0; @@ -135,6 +144,40 @@ retry: } result = poll(fds, count, milliseconds); +#elif defined(__BEOS__) + /* + * BeOS's select() is declared in socket.h, so the configure script does + * not see it. That's just as well, since that function works only for + * sockets. This (using snooze and ioctl) was distilled from Be's patch + * for ncurses which uses a separate thread to simulate select(). + * + * FIXME: the return values from the ioctl aren't very clear if we get + * interrupted. + */ + result = 0; + if (mode & 1) { + bigtime_t d; + bigtime_t useconds = milliseconds * 1000; + int n, howmany; + + if (useconds == 0) /* we're here to go _through_ the loop */ + useconds = 1; + + for (d = 0; d < useconds; d += 5000) { + n = 0; + howmany = ioctl(0, 'ichr', &n); + if (howmany >= 0 && n > 0) { + result = 1; + break; + } + if (useconds > 1) + snooze(5000); + milliseconds -= 5; + } + } else if (milliseconds > 0) { + snooze(milliseconds * 1000); + milliseconds = 0; + } #elif HAVE_SELECT /* * select() modifies the fd_set arguments; do this in the @@ -162,10 +205,10 @@ retry: } #endif - returntime = _nc_gettime(); + returntime = _nc_gettime(FALSE); if (milliseconds >= 0) - milliseconds -= returntime-starttime; + milliseconds -= (returntime - starttime); #if PRECISE_GETTIME /* @@ -205,6 +248,8 @@ retry: count++; } } +#elif defined(__BEOS__) + result = 1; /* redundant, but simple */ #elif HAVE_SELECT if ((mode & 2) && (fd = SP->_mouse_fd) >= 0 diff --git a/lib/libcurses/tty/lib_vidattr.c b/lib/libcurses/tty/lib_vidattr.c index 9db4ee5aec9..8e836442f0f 100644 --- a/lib/libcurses/tty/lib_vidattr.c +++ b/lib/libcurses/tty/lib_vidattr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_vidattr.c,v 1.2 1999/06/14 02:29:16 millert Exp $ */ +/* $OpenBSD: lib_vidattr.c,v 1.3 1999/11/28 17:49:55 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -66,7 +66,7 @@ #include <curses.priv.h> #include <term.h> -MODULE_ID("$From: lib_vidattr.c,v 1.23 1999/06/12 21:20:41 tom Exp $") +MODULE_ID("$From: lib_vidattr.c,v 1.24 1999/11/14 02:53:43 tom Exp $") #define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc) @@ -78,10 +78,11 @@ MODULE_ID("$From: lib_vidattr.c,v 1.23 1999/06/12 21:20:41 tom Exp $") /* if there is no current screen, assume we *can* do color */ #define SetColorsIf(why,old_attr) \ - if ((!SP || SP->_coloron) && (why)) { \ + if (can_color && (1)) { \ int old_pair = PAIR_NUMBER(old_attr); \ T(("old pair = %d -- new pair = %d", old_pair, pair)); \ if ((pair != old_pair) \ + || (fix_pair0 && (pair == 0)) \ || (reverse ^ ((old_attr & A_REVERSE) != 0))) { \ _nc_do_color(pair, reverse, outc); \ } \ @@ -94,6 +95,12 @@ attr_t turn_on, turn_off; int pair; bool reverse = FALSE; bool used_ncv = FALSE; +bool can_color = (SP == 0 || SP->_coloron); +#ifdef NCURSES_EXT_FUNCS +bool fix_pair0 = (SP != 0 && SP->_coloron && !SP->_default_color); +#else +#define fix_pair0 FALSE +#endif T((T_CALLED("vidputs(%s)"), _traceattr(newmode))); @@ -163,6 +170,7 @@ bool used_ncv = FALSE; } if (previous_attr) { doPut(exit_attribute_mode); + if (fix_pair0) _nc_do_color(0, FALSE, _nc_outch); previous_attr &= ~A_COLOR; } @@ -199,6 +207,7 @@ bool used_ncv = FALSE; if (turn_off && exit_attribute_mode) { doPut(exit_attribute_mode); + if (fix_pair0) _nc_do_color(0, FALSE, _nc_outch); turn_on |= (newmode & (chtype)(~A_COLOR)); previous_attr &= ~A_COLOR; } diff --git a/lib/libcurses/tty/tty_update.c b/lib/libcurses/tty/tty_update.c index 6389748139b..2df0aa2f81d 100644 --- a/lib/libcurses/tty/tty_update.c +++ b/lib/libcurses/tty/tty_update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_update.c,v 1.3 1999/03/02 06:23:30 millert Exp $ */ +/* $OpenBSD: tty_update.c,v 1.4 1999/11/28 17:49:55 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -44,6 +44,10 @@ * *-----------------------------------------------------------------*/ +#ifdef __BEOS__ +#include <OS.h> +#endif + #include <curses.priv.h> #if defined(TRACE) && HAVE_SYS_TIMES_H && HAVE_TIMES @@ -69,15 +73,9 @@ #endif #endif -#ifdef __BEOS__ -/* BeOS select() only works on sockets. Use the tty hack instead */ -#include <socket.h> -#define select check_select -#endif - #include <term.h> -MODULE_ID("$From: tty_update.c,v 1.111 1999/02/27 20:07:56 tom Exp $") +MODULE_ID("$From: tty_update.c,v 1.122 1999/11/28 03:07:38 tom Exp $") /* * This define controls the line-breakout optimization. Every once in a @@ -99,10 +97,10 @@ MODULE_ID("$From: tty_update.c,v 1.111 1999/02/27 20:07:56 tom Exp $") static inline chtype ClrBlank ( WINDOW *win ); static int ClrBottom(int total); -static int InsStr( chtype *line, int count ); static void ClearScreen( chtype blank ); static void ClrUpdate( void ); static void DelChar( int count ); +static void InsStr( chtype *line, int count ); static void TransformLine( int const lineno ); #ifdef POSITION_DEBUG @@ -112,29 +110,40 @@ static void TransformLine( int const lineno ); * ****************************************************************************/ -void position_check(int expected_y, int expected_x, char *legend) +static void position_check(int expected_y, int expected_x, char *legend) /* check to see if the real cursor position matches the virtual */ { - static char buf[9]; + char buf[20]; int y, x; - if (_nc_tracing) + if (!_nc_tracing || (expected_y < 0 && expected_x < 0)) return; memset(buf, '\0', sizeof(buf)); - (void) write(1, "\033[6n", 4); /* only works on ANSI-compatibles */ - (void) read(0, (void *)buf, 8); + putp("\033[6n"); /* only works on ANSI-compatibles */ + _nc_flush(); + (void) read(0, buf, sizeof(buf)-1); _tracef("probe returned %s", _nc_visbuf(buf)); /* try to interpret as a position report */ - if (sscanf(buf, "\033[%d;%dR", &y, &x) != 2) + if (sscanf(buf, "\033[%d;%dR", &y, &x) != 2) { _tracef("position probe failed in %s", legend); - else if (y - 1 != expected_y || x - 1 != expected_x) - _tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s", - y-1, x-1, expected_y, expected_x, legend); - else - _tracef("position matches OK in %s", legend); + } else { + if (expected_x < 0) + expected_x = x - 1; + if (expected_y < 0) + expected_y = y - 1; + if (y - 1 != expected_y || x - 1 != expected_x) { + beep(); + _tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s", + y-1, x-1, expected_y, expected_x, legend); + } else { + _tracef("position matches OK in %s", legend); + } + } } +#else +#define position_check(expected_y, expected_x, legend) /* nothing */ #endif /* POSITION_DEBUG */ /**************************************************************************** @@ -150,9 +159,7 @@ static inline void GoTo(int const row, int const col) TR(TRACE_MOVE, ("GoTo(%d, %d) from (%d, %d)", row, col, SP->_cursrow, SP->_curscol)); -#ifdef POSITION_DEBUG position_check(SP->_cursrow, SP->_curscol, "GoTo"); -#endif /* POSITION_DEBUG */ /* * Force restore even if msgr is on when we're in an alternate @@ -170,6 +177,7 @@ static inline void GoTo(int const row, int const col) mvcur(SP->_cursrow, SP->_curscol, row, col); SP->_cursrow = row; SP->_curscol = col; + position_check(SP->_cursrow, SP->_curscol, "GoTo2"); } static inline void PutAttrChar(chtype ch) @@ -181,10 +189,14 @@ static inline void PutAttrChar(chtype ch) _tracechtype(ch), SP->_cursrow, SP->_curscol)); UpdateAttrs(ch); - putc((int)TextOf(ch), SP->_ofp); + if (SP->_cleanup) { + _nc_outch((int)TextOf(ch)); + } else { + putc((int)TextOf(ch), SP->_ofp); /* macro's fastest... */ #ifdef TRACE - _nc_outchars++; + _nc_outchars++; #endif /* TRACE */ + } SP->_curscol++; if (char_padding) { TPUTS_TRACE("char_padding"); @@ -214,6 +226,21 @@ static bool check_pending(void) { have_pending = TRUE; } +#elif defined(__BEOS__) + /* + * BeOS's select() is declared in socket.h, so the configure script does + * not see it. That's just as well, since that function works only for + * sockets. This (using snooze and ioctl) was distilled from Be's patch + * for ncurses which uses a separate thread to simulate select(). + * + * FIXME: the return values from the ioctl aren't very clear if we get + * interrupted. + */ + int n = 0; + int howmany = ioctl(0, 'ichr', &n); + if (howmany >= 0 && n > 0) { + have_pending = TRUE; + } #elif HAVE_SELECT fd_set fdset; struct timeval ktimeout; @@ -231,7 +258,7 @@ static bool check_pending(void) } if (have_pending) { SP->_fifohold = 5; - fflush(SP->_ofp); + _nc_flush(); } return FALSE; } @@ -263,6 +290,8 @@ static void PutCharLR(chtype const ch) putp(exit_am_mode); PutAttrChar(ch); + SP->_curscol--; + position_check(SP->_cursrow, SP->_curscol, "exit_am_mode"); TPUTS_TRACE("enter_am_mode"); putp(enter_am_mode); @@ -309,6 +338,7 @@ static void wrap_cursor(void) { SP->_curscol--; } + position_check(SP->_cursrow, SP->_curscol, "wrap_cursor"); } static inline void PutChar(chtype const ch) @@ -322,9 +352,7 @@ static inline void PutChar(chtype const ch) if (SP->_curscol >= screen_columns) wrap_cursor(); -#ifdef POSITION_DEBUG position_check(SP->_cursrow, SP->_curscol, "PutChar"); -#endif /* POSITION_DEBUG */ } /* @@ -755,7 +783,7 @@ struct tms before, after; */ UpdateAttrs(A_NORMAL); - fflush(SP->_ofp); + _nc_flush(); curscr->_attrs = newscr->_attrs; /* curscr->_bkgd = newscr->_bkgd; */ @@ -844,7 +872,11 @@ bool needclear = FALSE; { UpdateAttrs(blank); TPUTS_TRACE("clr_eol"); - if (SP->_el_cost > (screen_columns - SP->_curscol)) + if (SP->_el_cost > (screen_columns - SP->_curscol) +#ifdef NCURSES_EXT_FUNCS + || (SP->_coloron && !SP->_default_color && !back_color_erase) +#endif + ) { int count = (screen_columns - SP->_curscol); while (count-- > 0) @@ -865,13 +897,30 @@ static void ClrToEOS(chtype blank) { int row, col; - UpdateAttrs(blank); - TPUTS_TRACE("clr_eos"); row = SP->_cursrow; - tputs(clr_eos, screen_lines-row, _nc_outch); + col = SP->_curscol; + +#ifdef NCURSES_EXT_FUNCS + if (SP->_coloron && !SP->_default_color && !back_color_erase) { + int i, j, k = col; + for (i = row; i < screen_lines; i++) { + GoTo(i, k); + UpdateAttrs(blank); + for (j = k; j < screen_columns; j++) + PutChar(blank); + k = 0; + } + GoTo(row, col); + } else +#endif + { + UpdateAttrs(blank); + TPUTS_TRACE("clr_eos"); + tputs(clr_eos, screen_lines-row, _nc_outch); + } - for (col = SP->_curscol; col < screen_columns; col++) - curscr->_line[row].text[col] = blank; + while (col < screen_columns) + curscr->_line[row].text[col++] = blank; for (row++; row < screen_lines; row++) { @@ -903,13 +952,14 @@ chtype blank = newscr->_line[total-1].text[last-1]; /* lower right char */ if ((tstLine == 0) || (last > (int)lenLine)) { tstLine = typeRealloc(chtype, last, tstLine); + if (tstLine != 0) { + lenLine = last; + for (col = 0; col < last; col++) + tstLine[col] = blank; + } } if (tstLine != 0) { - lenLine = last; - for (col = 0; col < last; col++) - tstLine[col] = blank; - for (row = total-1; row >= 0; row--) { if (memcmp(tstLine, newscr->_line[row].text, length)) break; @@ -930,8 +980,9 @@ chtype blank = newscr->_line[total-1].text[last-1]; /* lower right char */ } } #if NO_LEAKS - if (tstLine != 0) + if (tstLine != 0) { FreeAndNull(tstLine); + } #endif return total; } @@ -1206,37 +1257,53 @@ bool attrchanged = FALSE; static void ClearScreen(chtype blank) { int i, j; + bool fast_clear = (clear_screen || clr_eos || clr_eol); T(("ClearScreen() called")); - if (clear_screen) { - UpdateAttrs(blank); - TPUTS_TRACE("clear_screen"); - putp(clear_screen); - SP->_cursrow = SP->_curscol = 0; -#ifdef POSITION_DEBUG - position_check(SP->_cursrow, SP->_curscol, "ClearScreen"); -#endif /* POSITION_DEBUG */ - } else if (clr_eos) { - SP->_cursrow = SP->_curscol = -1; - GoTo(0,0); +#ifdef NCURSES_EXT_FUNCS + if (SP->_coloron + && !SP->_default_color) { + _nc_do_color(0, FALSE, _nc_outch); + if (!back_color_erase) { + fast_clear = FALSE; + } + } +#endif - UpdateAttrs(blank); - TPUTS_TRACE("clr_eos"); - putp(clr_eos); - } else if (clr_eol) { - SP->_cursrow = SP->_curscol = -1; + if (fast_clear) { + if (clear_screen) { + UpdateAttrs(blank); + TPUTS_TRACE("clear_screen"); + putp(clear_screen); + SP->_cursrow = SP->_curscol = 0; + position_check(SP->_cursrow, SP->_curscol, "ClearScreen"); + } else if (clr_eos) { + SP->_cursrow = SP->_curscol = -1; + GoTo(0,0); + UpdateAttrs(blank); + TPUTS_TRACE("clr_eos"); + putp(clr_eos); + } else if (clr_eol) { + SP->_cursrow = SP->_curscol = -1; + + for (i = 0; i < screen_lines; i++) { + GoTo(i, 0); + UpdateAttrs(blank); + TPUTS_TRACE("clr_eol"); + putp(clr_eol); + } + GoTo(0,0); + } + } else { for (i = 0; i < screen_lines; i++) { GoTo(i, 0); UpdateAttrs(blank); - TPUTS_TRACE("clr_eol"); - putp(clr_eol); + for (j = 0; j < screen_columns; j++) + PutChar(blank); } GoTo(0,0); - } else { - T(("cannot clear screen")); - return; } for (i = 0; i < screen_lines; i++) { @@ -1254,7 +1321,7 @@ static void ClearScreen(chtype blank) ** */ -static int InsStr(chtype *line, int count) +static void InsStr(chtype *line, int count) { T(("InsStr(%p,%d) called", line, count)); @@ -1269,7 +1336,6 @@ static int InsStr(chtype *line, int count) line++; count--; } - return(OK); } else if (enter_insert_mode && exit_insert_mode) { TPUTS_TRACE("enter_insert_mode"); putp(enter_insert_mode); @@ -1285,7 +1351,6 @@ static int InsStr(chtype *line, int count) } TPUTS_TRACE("exit_insert_mode"); putp(exit_insert_mode); - return(OK); } else { while (count) { TPUTS_TRACE("insert_character"); @@ -1299,8 +1364,8 @@ static int InsStr(chtype *line, int count) line++; count--; } - return(OK); } + position_check(SP->_cursrow, SP->_curscol, "InsStr"); } /* @@ -1334,14 +1399,8 @@ static void DelChar(int count) void _nc_outstr(const char *str) { - FILE *ofp = SP ? SP->_ofp : stdout; - - (void) fputs(str, ofp); - (void) fflush(ofp); - -#ifdef TRACE - _nc_outchars += strlen(str); -#endif /* TRACE */ + (void) putp(str); + _nc_flush(); } /* @@ -1379,7 +1438,7 @@ void _nc_outstr(const char *str) /* Try to scroll up assuming given csr (miny, maxy). Returns ERR on failure */ static int scroll_csr_forward(int n, int top, int bot, int miny, int maxy, chtype blank) { - int i; + int i, j; if (n == 1 && scroll_forward && top == miny && bot == maxy) { @@ -1432,6 +1491,15 @@ static int scroll_csr_forward(int n, int top, int bot, int miny, int maxy, chtyp else return ERR; +#ifdef NCURSES_EXT_FUNCS + if (SP->_coloron && !SP->_default_color && !back_color_erase) { + for (i = 0; i < n; i++) { + GoTo(bot-i, 0); + for (j = 0; j < screen_columns; j++) + PutChar(blank); + } + } +#endif return OK; } @@ -1439,7 +1507,7 @@ static int scroll_csr_forward(int n, int top, int bot, int miny, int maxy, chtyp /* n > 0 */ static int scroll_csr_backward(int n, int top, int bot, int miny, int maxy, chtype blank) { - int i; + int i, j; if (n == 1 && scroll_reverse && top == miny && bot == maxy) { @@ -1492,6 +1560,15 @@ static int scroll_csr_backward(int n, int top, int bot, int miny, int maxy, chty else return ERR; +#ifdef NCURSES_EXT_FUNCS + if (SP->_coloron && !SP->_default_color && !back_color_erase) { + for (i = 0; i < n; i++) { + GoTo(top+i, 0); + for (j = 0; j < screen_columns; j++) + PutChar(blank); + } + } +#endif return OK; } @@ -1720,6 +1797,14 @@ void _nc_screen_init() void _nc_screen_wrap() { UpdateAttrs(A_NORMAL); +#ifdef NCURSES_EXT_FUNCS + if (SP->_coloron + && !SP->_default_color) { + SP->_default_color = TRUE; + _nc_do_color(0, FALSE, _nc_outch); + SP->_default_color = FALSE; + } +#endif } #if USE_XMC_SUPPORT diff --git a/lib/libpanel/p_above.c b/lib/libpanel/p_above.c index 4c090d0fdbb..c8941a6c89c 100644 --- a/lib/libpanel/p_above.c +++ b/lib/libpanel/p_above.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_above.c,v 1.2 1998/07/24 17:08:05 millert Exp $ */ +/* $OpenBSD: p_above.c,v 1.3 1999/11/28 17:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -37,7 +37,7 @@ */ #include "panel.priv.h" -MODULE_ID("$From: p_above.c,v 1.2 1998/02/11 12:14:01 tom Exp $") +MODULE_ID("$From: p_above.c,v 1.3 1999/09/18 11:03:28 juergen Exp $") PANEL* panel_above(const PANEL *pan) @@ -46,7 +46,7 @@ panel_above(const PANEL *pan) { /* if top and bottom are equal, we have no or only the pseudo panel; if not, we return the panel above the pseudo panel */ - return(_nc_bottom_panel==_nc_top_panel ? (PANEL*)0 : _nc_bottom_panel->above); + return(EMPTY_STACK() ? (PANEL*)0 : _nc_bottom_panel->above); } else return(pan->above); diff --git a/lib/libpanel/p_below.c b/lib/libpanel/p_below.c index 02287a88565..33bad48323f 100644 --- a/lib/libpanel/p_below.c +++ b/lib/libpanel/p_below.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_below.c,v 1.2 1998/07/24 17:08:06 millert Exp $ */ +/* $OpenBSD: p_below.c,v 1.3 1999/11/28 17:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -37,7 +37,7 @@ */ #include "panel.priv.h" -MODULE_ID("$From: p_below.c,v 1.2 1998/02/11 12:14:01 tom Exp $") +MODULE_ID("$From: p_below.c,v 1.3 1999/09/18 11:03:33 juergen Exp $") PANEL* panel_below(const PANEL *pan) @@ -45,11 +45,11 @@ panel_below(const PANEL *pan) if(!pan) { /* if top and bottom are equal, we have no or only the pseudo panel */ - return(_nc_top_panel==_nc_bottom_panel ? (PANEL*)0 : _nc_top_panel); + return(EMPTY_STACK() ? (PANEL*)0 : _nc_top_panel); } else { /* we must not return the pseudo panel */ - return(pan->below==_nc_bottom_panel ? (PANEL*) 0 : pan->below); + return(Is_Pseudo(pan->below) ? (PANEL*) 0 : pan->below); } } diff --git a/lib/libpanel/p_bottom.c b/lib/libpanel/p_bottom.c index c7490d6f836..e7918017846 100644 --- a/lib/libpanel/p_bottom.c +++ b/lib/libpanel/p_bottom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_bottom.c,v 1.2 1998/07/24 17:08:07 millert Exp $ */ +/* $OpenBSD: p_bottom.c,v 1.3 1999/11/28 17:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -38,18 +38,35 @@ */ #include "panel.priv.h" -MODULE_ID("$From: p_bottom.c,v 1.2 1998/02/11 12:14:01 tom Exp $") +MODULE_ID("$From: p_bottom.c,v 1.7 1999/11/25 13:49:26 juergen Exp $") int bottom_panel(PANEL *pan) { - if(!pan) - return(ERR); - if(pan == _nc_bottom_panel) - return(OK); - dBug(("--> bottom_panel %s", USER_PTR(pan->user))); - if(_nc_panel_is_linked(pan)) - (void)hide_panel(pan); - _nc_panel_link_bottom(pan); - return(OK); + int err = OK; + + if (pan) { + + if(!Is_Bottom(pan)) { + + dBug(("--> bottom_panel %s", USER_PTR(pan->user))); + + HIDE_PANEL(pan,err,FALSE); + assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel); + + dStack("<lb%d>",1,pan); + + pan->below = _nc_bottom_panel; + pan->above = _nc_bottom_panel->above; + if (pan->above) + pan->above->below = pan; + _nc_bottom_panel->above = pan; + + dStack("<lb%d>",9,pan); + } + } + else + err = ERR; + + return(err); } diff --git a/lib/libpanel/p_delete.c b/lib/libpanel/p_delete.c index a9af2bc28db..9cfebc7f231 100644 --- a/lib/libpanel/p_delete.c +++ b/lib/libpanel/p_delete.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_delete.c,v 1.2 1998/07/24 17:08:08 millert Exp $ */ +/* $OpenBSD: p_delete.c,v 1.3 1999/11/28 17:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -38,18 +38,19 @@ */ #include "panel.priv.h" -MODULE_ID("$From: p_delete.c,v 1.2 1998/02/11 12:14:01 tom Exp $") +MODULE_ID("$From: p_delete.c,v 1.4 1999/11/25 13:49:26 juergen Exp $") int del_panel(PANEL *pan) { + int err = OK; if(pan) { dBug(("--> del_panel %s", USER_PTR(pan->user))); - if(_nc_panel_is_linked(pan)) - (void)hide_panel(pan); + HIDE_PANEL(pan,err,FALSE); free((void *)pan); - return(OK); } - return(ERR); + else + err = ERR; + return(err); } diff --git a/lib/libpanel/p_hidden.c b/lib/libpanel/p_hidden.c index f1368f0810b..ff47a80d10b 100644 --- a/lib/libpanel/p_hidden.c +++ b/lib/libpanel/p_hidden.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_hidden.c,v 1.2 1998/07/24 17:08:09 millert Exp $ */ +/* $OpenBSD: p_hidden.c,v 1.3 1999/11/28 17:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -38,12 +38,12 @@ */ #include "panel.priv.h" -MODULE_ID("$From: p_hidden.c,v 1.2 1998/02/11 12:14:01 tom Exp $") +MODULE_ID("$From: p_hidden.c,v 1.4 1999/11/22 18:02:41 juergen Exp $") int panel_hidden(const PANEL *pan) { if(!pan) return(ERR); - return(_nc_panel_is_linked(pan) ? TRUE : FALSE); + return(IS_LINKED(pan) ? FALSE : TRUE); } diff --git a/lib/libpanel/p_hide.c b/lib/libpanel/p_hide.c index 9ba369d1b15..d3cd6cab7cb 100644 --- a/lib/libpanel/p_hide.c +++ b/lib/libpanel/p_hide.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_hide.c,v 1.2 1998/07/24 17:08:11 millert Exp $ */ +/* $OpenBSD: p_hide.c,v 1.3 1999/11/28 17:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -38,64 +38,22 @@ */ #include "panel.priv.h" -MODULE_ID("$From: p_hide.c,v 1.2 1998/02/11 12:14:01 tom Exp $") - -/*+------------------------------------------------------------------------- - __panel_unlink(pan) - unlink panel from stack ---------------------------------------------------------------------------*/ -static void -__panel_unlink(PANEL *pan) -{ - PANEL *prev; - PANEL *next; - -#ifdef TRACE - dStack("<u%d>",1,pan); - if(!_nc_panel_is_linked(pan)) - return; -#endif - - _nc_override(pan,P_TOUCH); - _nc_free_obscure(pan); - - prev = pan->below; - next = pan->above; - - if(prev) - { /* if non-zero, we will not update the list head */ - prev->above = next; - if(next) - next->below = prev; - } - else if(next) - next->below = prev; - if(pan == _nc_bottom_panel) - _nc_bottom_panel = next; - if(pan == _nc_top_panel) - _nc_top_panel = prev; - - _nc_calculate_obscure(); - - pan->above = (PANEL *)0; - pan->below = (PANEL *)0; - dStack("<u%d>",9,pan); -} +MODULE_ID("$From: p_hide.c,v 1.5 1999/11/25 13:49:26 juergen Exp $") int hide_panel(register PANEL *pan) { + int err = OK; + if(!pan) return(ERR); dBug(("--> hide_panel %s", USER_PTR(pan->user))); + dStack("<u%d>",1,pan); + + HIDE_PANEL(pan,err,TRUE); - if(!_nc_panel_is_linked(pan)) - { - pan->above = (PANEL *)0; - pan->below = (PANEL *)0; - return(ERR); - } + dStack("<u%d>",9,pan); - __panel_unlink(pan); - return(OK); + return(err); } diff --git a/lib/libpanel/p_move.c b/lib/libpanel/p_move.c index 2a6b228af3f..552e2164f98 100644 --- a/lib/libpanel/p_move.c +++ b/lib/libpanel/p_move.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_move.c,v 1.2 1998/07/24 17:08:12 millert Exp $ */ +/* $OpenBSD: p_move.c,v 1.3 1999/11/28 17:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -38,24 +38,19 @@ */ #include "panel.priv.h" -MODULE_ID("$From: p_move.c,v 1.2 1998/02/11 12:14:01 tom Exp $") +MODULE_ID("$From: p_move.c,v 1.5 1999/11/25 13:49:26 juergen Exp $") int move_panel(PANEL *pan, int starty, int startx) { - WINDOW *win; - if(!pan) return(ERR); - if(_nc_panel_is_linked(pan)) - _nc_override(pan,P_TOUCH); - win = pan->win; - if(mvwin(win,starty,startx)) + + if (IS_LINKED(pan)) + PANEL_UPDATE(pan,(PANEL*)0, TRUE); + + if (mvwin(pan->win,starty,startx)) return(ERR); - getbegyx(win, pan->wstarty, pan->wstartx); - pan->wendy = pan->wstarty + getmaxy(win); - pan->wendx = pan->wstartx + getmaxx(win); - if(_nc_panel_is_linked(pan)) - _nc_calculate_obscure(); + return(OK); } diff --git a/lib/libpanel/p_new.c b/lib/libpanel/p_new.c index 765b9c8f3a1..b9bd9262562 100644 --- a/lib/libpanel/p_new.c +++ b/lib/libpanel/p_new.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_new.c,v 1.2 1998/07/24 17:08:13 millert Exp $ */ +/* $OpenBSD: p_new.c,v 1.3 1999/11/28 17:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -38,7 +38,12 @@ */ #include "panel.priv.h" -MODULE_ID("$From: p_new.c,v 1.2 1998/02/11 12:14:01 tom Exp $") +MODULE_ID("$From: p_new.c,v 1.5 1999/11/22 18:02:41 juergen Exp $") + +#ifdef TRACE +static char* stdscr_id; +static char* new_id; +#endif /*+------------------------------------------------------------------------- Get root (i.e. stdscr's) panel. @@ -56,18 +61,16 @@ root_panel(void) PANEL* pan = _nc_stdscr_pseudo_panel; WINDOW* win = stdscr; pan->win = win; - getbegyx(win, pan->wstarty, pan->wstartx); - pan->wendy = pan->wstarty + getmaxy(win); - pan->wendx = pan->wstartx + getmaxx(win); pan->below = (PANEL*)0; pan->above = (PANEL*)0; - pan->obscure = (PANELCONS*)0; #ifdef TRACE - pan->user = "stdscr"; + if (!stdscr_id) + stdscr_id = strdup("stdscr"); + pan->user = stdscr_id; #else pan->user = (void*)0; #endif - _nc_panel_link_bottom(pan); + _nc_bottom_panel = _nc_top_panel = pan; } } return _nc_stdscr_pseudo_panel; @@ -78,7 +81,11 @@ new_panel(WINDOW *win) { PANEL *pan = (PANEL*)0; - (void)root_panel(); + if (!win) + return(pan); + + if (!_nc_stdscr_pseudo_panel) + (void)root_panel(); assert(_nc_stdscr_pseudo_panel); if (!(win->_flags & _ISPAD) && (pan = (PANEL*)malloc(sizeof(PANEL)))) @@ -86,15 +93,13 @@ new_panel(WINDOW *win) pan->win = win; pan->above = (PANEL *)0; pan->below = (PANEL *)0; - getbegyx(win, pan->wstarty, pan->wstartx); - pan->wendy = pan->wstarty + getmaxy(win); - pan->wendx = pan->wstartx + getmaxx(win); #ifdef TRACE - pan->user = "new"; + if (!new_id) + new_id = strdup("new"); + pan->user = new_id; #else pan->user = (char *)0; #endif - pan->obscure = (PANELCONS *)0; (void)show_panel(pan); } return(pan); diff --git a/lib/libpanel/p_replace.c b/lib/libpanel/p_replace.c index 2d074c33d3f..bf2506e019f 100644 --- a/lib/libpanel/p_replace.c +++ b/lib/libpanel/p_replace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_replace.c,v 1.2 1998/07/24 17:08:14 millert Exp $ */ +/* $OpenBSD: p_replace.c,v 1.3 1999/11/28 17:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -38,17 +38,18 @@ */ #include "panel.priv.h" -MODULE_ID("$From: p_replace.c,v 1.2 1998/02/11 12:14:01 tom Exp $") +MODULE_ID("$From: p_replace.c,v 1.5 1999/11/25 13:49:26 juergen Exp $") int replace_panel(PANEL *pan, WINDOW *win) { if(!pan) return(ERR); - if(_nc_panel_is_linked(pan)) - _nc_override(pan,P_TOUCH); + + if (IS_LINKED(pan)) + PANEL_UPDATE(pan,(PANEL*)0, TRUE); + pan->win = win; - if(_nc_panel_is_linked(pan)) - _nc_calculate_obscure(); + return(OK); } diff --git a/lib/libpanel/p_show.c b/lib/libpanel/p_show.c index e67ce71800c..fb97cb12ab0 100644 --- a/lib/libpanel/p_show.c +++ b/lib/libpanel/p_show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_show.c,v 1.2 1998/07/24 17:08:15 millert Exp $ */ +/* $OpenBSD: p_show.c,v 1.3 1999/11/28 17:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -38,41 +38,32 @@ */ #include "panel.priv.h" -MODULE_ID("$From: p_show.c,v 1.2 1998/02/11 12:14:01 tom Exp $") - -static void -panel_link_top(PANEL *pan) -{ -#ifdef TRACE - dStack("<lt%d>",1,pan); - if(_nc_panel_is_linked(pan)) - return; -#endif - - pan->above = (PANEL *)0; - pan->below = (PANEL *)0; - if(_nc_top_panel) - { - _nc_top_panel->above = pan; - pan->below = _nc_top_panel; - } - _nc_top_panel = pan; - if(!_nc_bottom_panel) - _nc_bottom_panel = pan; - _nc_calculate_obscure(); - dStack("<lt%d>",9,pan); -} +MODULE_ID("$From: p_show.c,v 1.7 1999/11/25 13:49:26 juergen Exp $") int show_panel(PANEL *pan) -{ +{ + int err = OK; + if(!pan) return(ERR); - if(pan == _nc_top_panel) + + if (Is_Top(pan)) return(OK); + dBug(("--> show_panel %s", USER_PTR(pan->user))); - if(_nc_panel_is_linked(pan)) - (void)hide_panel(pan); - panel_link_top(pan); + + HIDE_PANEL(pan,err,FALSE); + + dStack("<lt%d>",1,pan); + assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel); + + _nc_top_panel->above = pan; + pan->below = _nc_top_panel; + pan->above = (PANEL *)0; + _nc_top_panel = pan; + + dStack("<lt%d>",9,pan); + return(OK); } diff --git a/lib/libpanel/p_update.c b/lib/libpanel/p_update.c index 4e0d66f5917..2b65a59602b 100644 --- a/lib/libpanel/p_update.c +++ b/lib/libpanel/p_update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_update.c,v 1.2 1998/07/24 17:08:17 millert Exp $ */ +/* $OpenBSD: p_update.c,v 1.3 1999/11/28 17:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -38,7 +38,7 @@ */ #include "panel.priv.h" -MODULE_ID("$From: p_update.c,v 1.2 1998/02/11 12:14:01 tom Exp $") +MODULE_ID("$From: p_update.c,v 1.5 1999/11/25 13:49:26 juergen Exp $") void update_panels(void) @@ -47,17 +47,16 @@ update_panels(void) dBug(("--> update_panels")); pan = _nc_bottom_panel; - while(pan) + while(pan && pan->above) { - _nc_override(pan,P_UPDATE); + PANEL_UPDATE(pan,pan->above, FALSE); pan = pan->above; } pan = _nc_bottom_panel; while (pan) { - if (is_wintouched(pan->win)) - Wnoutrefresh(pan); + Wnoutrefresh(pan); pan = pan->above; } } diff --git a/lib/libpanel/panel.c b/lib/libpanel/panel.c index 158212b916c..3971878c63c 100644 --- a/lib/libpanel/panel.c +++ b/lib/libpanel/panel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: panel.c,v 1.6 1998/11/19 01:14:21 millert Exp $ */ +/* $OpenBSD: panel.c,v 1.7 1999/11/28 17:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -36,7 +36,7 @@ /* panel.c -- implementation of panels library, some core routines */ #include "panel.priv.h" -MODULE_ID("$From: panel.c,v 1.16 1998/09/19 21:26:31 Todd.Miller Exp $") +MODULE_ID("$From: panel.c,v 1.18 1999/09/29 15:22:32 juergen Exp $") #ifdef TRACE #ifndef TRACE_TXT @@ -64,7 +64,7 @@ _nc_dPanel(const char *text, const PANEL *pan) text, USER_PTR(pan->user), (pan->below) ? USER_PTR(pan->below->user) : "--", (pan->above) ? USER_PTR(pan->above->user) : "--", - pan->wstarty, pan->wstartx); + PSTARTY(pan), PSTARTX(pan)); } #endif @@ -130,181 +130,9 @@ _nc_Touchline(const PANEL *pan, int start, int count) } #endif -/*+------------------------------------------------------------------------- - __panels_overlapped(pan1,pan2) - check panel overlapped ---------------------------------------------------------------------------*/ -static INLINE bool -__panels_overlapped(register const PANEL *pan1, register const PANEL *pan2) -{ - if(!pan1 || !pan2) - return(FALSE); - - dBug(("__panels_overlapped %s %s", USER_PTR(pan1->user), USER_PTR(pan2->user))); - /* pan1 intersects with pan2 ? */ - if( (((pan1->wstarty >= pan2->wstarty) && (pan1->wstarty < pan2->wendy)) || - ((pan2->wstarty >= pan1->wstarty) && (pan2->wstarty < pan1->wendy))) && - (((pan1->wstartx >= pan2->wstartx) && (pan1->wstartx < pan2->wendx)) || - ((pan2->wstartx >= pan1->wstartx) && (pan2->wstartx < pan1->wendx))) - ) return(TRUE); - else { - dBug((" no")); - return(FALSE); - } -} - -/*+------------------------------------------------------------------------- - _nc_free_obscure(pan) ---------------------------------------------------------------------------*/ -void -_nc_free_obscure(PANEL *pan) -{ - PANELCONS *tobs = pan->obscure; /* "this" one */ - PANELCONS *nobs; /* "next" one */ - - while(tobs) - { - nobs = tobs->above; - free((char *)tobs); - tobs = nobs; - } - pan->obscure = (PANELCONS *)0; -} - -/*+------------------------------------------------------------------------- - __override(pan,show) ---------------------------------------------------------------------------*/ -void -_nc_override(const PANEL *pan, int show) -{ - int y; - PANEL *pan2; - PANELCONS *tobs = pan->obscure; /* "this" one */ - - dBug(("_nc_override %s,%d", USER_PTR(pan->user),show)); - - switch (show) - { - case P_TOUCH: - Touchpan(pan); - /* The following while loop will now mark all panel window lines - * obscured by use or obscuring us as touched, so they will be - * updated. - */ - break; - case P_UPDATE: - while(tobs && (tobs->pan != pan)) - tobs = tobs->above; - /* The next loop will now only go through the panels obscuring pan; - * it updates all the lines in the obscuring panels in sync. with - * the lines touched in pan itself. This is called in update_panels() - * in a loop from the bottom_panel to the top_panel, resulting in - * the desired update effect. - */ - break; - default: - return; - } - - while(tobs) - { - if((pan2 = tobs->pan) != pan) { - dBug(("test obs pan=%s pan2=%s", USER_PTR(pan->user), USER_PTR(pan2->user))); - for(y = pan->wstarty; y < pan->wendy; y++) { - if( (y >= pan2->wstarty) && (y < pan2->wendy) && - ((is_linetouched(pan->win,y - pan->wstarty) == TRUE)) ) - Touchline(pan2,y - pan2->wstarty,1); - } - } - tobs = tobs->above; - } -} - -/*+------------------------------------------------------------------------- - __calculate_obscure() ---------------------------------------------------------------------------*/ -void -_nc_calculate_obscure(void) -{ - PANEL *pan; - PANEL *pan2; - PANELCONS *tobs; /* "this" one */ - PANELCONS *lobs = (PANELCONS *)0; /* last one */ - - pan = _nc_bottom_panel; - while(pan) - { - if(pan->obscure) - _nc_free_obscure(pan); - dBug(("--> __calculate_obscure %s", USER_PTR(pan->user))); - lobs = (PANELCONS *)0; /* last one */ - pan2 = _nc_bottom_panel; - /* This loop builds a list of panels obsured by pan or obscuring - pan; pan itself is in the list; all panels before pan are - obscured by pan, all panels after pan are obscuring pan. */ - while(pan2) - { - if(__panels_overlapped(pan,pan2)) - { - if(!(tobs = (PANELCONS *)malloc(sizeof(PANELCONS)))) - return; - tobs->pan = pan2; - dPanel("obscured",pan2); - tobs->above = (PANELCONS *)0; - if(lobs) - lobs->above = tobs; - else - pan->obscure = tobs; - lobs = tobs; - } - pan2 = pan2->above; - } - _nc_override(pan,P_TOUCH); - pan = pan->above; - } -} - -/*+------------------------------------------------------------------------- - _nc_panel_is_linked(pan) - check to see if panel is in the stack ---------------------------------------------------------------------------*/ -bool -_nc_panel_is_linked(const PANEL *pan) -{ - /* This works! The only case where it would fail is, when the list has - only one element. But this could only be the pseudo panel at the bottom */ - return ( ((pan->above!=(PANEL *)0) || - (pan->below!=(PANEL *)0) || - (pan==_nc_bottom_panel)) ? TRUE : FALSE ); -} - - -/*+------------------------------------------------------------------------- - __panel_link_bottom(pan) - link panel into stack at bottom ---------------------------------------------------------------------------*/ -void -_nc_panel_link_bottom(PANEL *pan) -{ -#ifdef TRACE - dStack("<lb%d>",1,pan); - if(_nc_panel_is_linked(pan)) - return; +#ifndef TRACE +# ifndef __GNUC__ + /* Some C compilers need something defined in a source file */ + static char GCC_UNUSED dummy; +# endif #endif - - pan->above = (PANEL *)0; - pan->below = (PANEL *)0; - if(_nc_bottom_panel) - { /* the stdscr pseudo panel always stays real bottom; - so we insert after bottom panel*/ - pan->below = _nc_bottom_panel; - pan->above = _nc_bottom_panel->above; - if (pan->above) - pan->above->below = pan; - _nc_bottom_panel->above = pan; - } - else - _nc_bottom_panel = pan; - if(!_nc_top_panel) - _nc_top_panel = pan; - assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel); - _nc_calculate_obscure(); - dStack("<lb%d>",9,pan); -} diff --git a/lib/libpanel/panel.h b/lib/libpanel/panel.h index dd04bf696f3..93a620f0023 100644 --- a/lib/libpanel/panel.h +++ b/lib/libpanel/panel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: panel.h,v 1.4 1998/07/24 17:08:23 millert Exp $ */ +/* $OpenBSD: panel.h,v 1.5 1999/11/28 17:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -42,37 +42,31 @@ typedef struct panel { - WINDOW *win; - int wstarty; - int wendy; - int wstartx; - int wendx; - struct panel *below; - struct panel *above; - NCURSES_CONST void *user; - struct panelcons *obscure; -} -PANEL; + WINDOW *win; + struct panel *below; + struct panel *above; + NCURSES_CONST void *user; +} PANEL; #if defined(__cplusplus) extern "C" { #endif -extern WINDOW *panel_window(const PANEL *); -extern void update_panels(void); -extern int hide_panel(PANEL *); -extern int show_panel(PANEL *); -extern int del_panel(PANEL *); -extern int top_panel(PANEL *); -extern int bottom_panel(PANEL *); -extern PANEL *new_panel(WINDOW *); -extern PANEL *panel_above(const PANEL *); -extern PANEL *panel_below(const PANEL *); -extern int set_panel_userptr(PANEL *, NCURSES_CONST void *); +extern WINDOW* panel_window(const PANEL *); +extern void update_panels(void); +extern int hide_panel(PANEL *); +extern int show_panel(PANEL *); +extern int del_panel(PANEL *); +extern int top_panel(PANEL *); +extern int bottom_panel(PANEL *); +extern PANEL* new_panel(WINDOW *); +extern PANEL* panel_above(const PANEL *); +extern PANEL* panel_below(const PANEL *); +extern int set_panel_userptr(PANEL *, NCURSES_CONST void *); extern NCURSES_CONST void* panel_userptr(const PANEL *); -extern int move_panel(PANEL *, int, int); -extern int replace_panel(PANEL *,WINDOW *); -extern int panel_hidden(const PANEL *); +extern int move_panel(PANEL *, int, int); +extern int replace_panel(PANEL *,WINDOW *); +extern int panel_hidden(const PANEL *); #if defined(__cplusplus) } diff --git a/lib/libpanel/panel.priv.h b/lib/libpanel/panel.priv.h index a8d8d182867..3e1f3f45cca 100644 --- a/lib/libpanel/panel.priv.h +++ b/lib/libpanel/panel.priv.h @@ -1,5 +1,5 @@ -/* $OpenBSD: panel.priv.h,v 1.3 1998/07/24 17:08:24 millert Exp $ */ -/* $From: panel.priv.h,v 1.8 1997/10/21 10:19:37 juergen Exp $ */ +/* $OpenBSD: panel.priv.h,v 1.4 1999/11/28 17:49:19 millert Exp $ */ +/* $From: panel.priv.h,v 1.12 1999/11/25 13:49:26 juergen Exp $ */ #ifndef _PANEL_PRIV_H #define _PANEL_PRIV_H @@ -29,20 +29,12 @@ # define INLINE #endif -typedef struct panelcons -{ - struct panelcons *above; - struct panel *pan; -} PANELCONS; - #ifdef USE_RCS_IDS # define MODULE_ID(id) static const char Ident[] = id; #else # define MODULE_ID(id) /*nothing*/ #endif -#define P_TOUCH (0) -#define P_UPDATE (1) #ifdef TRACE extern const char *_nc_my_visbuf(const void *); @@ -77,10 +69,109 @@ typedef struct panelcons #define _nc_top_panel _nc_panelhook()->top_panel #define _nc_bottom_panel _nc_panelhook()->bottom_panel -extern void _nc_panel_link_bottom(PANEL*); -extern bool _nc_panel_is_linked(const PANEL*); -extern void _nc_calculate_obscure(void); -extern void _nc_free_obscure(PANEL*); -extern void _nc_override(const PANEL*,int); +#define EMPTY_STACK() (_nc_top_panel==_nc_bottom_panel) +#define Is_Bottom(p) (((p)!=(PANEL*)0) && !EMPTY_STACK() && (_nc_bottom_panel->above==(p))) +#define Is_Top(p) (((p)!=(PANEL*)0) && !EMPTY_STACK() && (_nc_top_panel==(p))) +#define Is_Pseudo(p) ((p) && ((p)==_nc_bottom_panel)) + +/* borrowed from curses.priv.h */ +#define CHANGED_RANGE(line,start,end) \ + if (line->firstchar == _NOCHANGE \ + || line->firstchar > (start)) \ + line->firstchar = start; \ + if (line->lastchar == _NOCHANGE \ + || line->lastchar < (end)) \ + line->lastchar = end + +/*+------------------------------------------------------------------------- + IS_LINKED(pan) - check to see if panel is in the stack +--------------------------------------------------------------------------*/ +/* This works! The only case where it would fail is, when the list has + only one element. But this could only be the pseudo panel at the bottom */ +#define IS_LINKED(p) (((p)->above || (p)->below ||((p)==_nc_bottom_panel)) ? TRUE : FALSE) + +#define PSTARTX(pan) ((pan)->win->_begx) +#define PENDX(pan) ((pan)->win->_begx + getmaxx((pan)->win) - 1) +#define PSTARTY(pan) ((pan)->win->_begy) +#define PENDY(pan) ((pan)->win->_begy + getmaxy((pan)->win) - 1) + +/*+------------------------------------------------------------------------- + PANELS_OVERLAPPED(pan1,pan2) - check panel overlapped +---------------------------------------------------------------------------*/ +#define PANELS_OVERLAPPED(pan1,pan2) \ +(( !(pan1) || !(pan2) || \ + PSTARTY(pan1) > PENDY(pan2) || PENDY(pan1) < PSTARTY(pan2) ||\ + PSTARTX(pan1) > PENDX(pan2) || PENDX(pan1) < PSTARTX(pan2) ) \ + ? FALSE : TRUE) + + +/*+------------------------------------------------------------------------- + Compute the intersection rectangle of two overlapping rectangles +---------------------------------------------------------------------------*/ +#define COMPUTE_INTERSECTION(pan1,pan2,ix1,ix2,iy1,iy2)\ + ix1 = (PSTARTX(pan1) < PSTARTX(pan2)) ? PSTARTX(pan2) : PSTARTX(pan1);\ + ix2 = (PENDX(pan1) < PENDX(pan2)) ? PENDX(pan1) : PENDX(pan2);\ + iy1 = (PSTARTY(pan1) < PSTARTY(pan2)) ? PSTARTY(pan2) : PSTARTY(pan1);\ + iy2 = (PENDY(pan1) < PENDY(pan2)) ? PENDY(pan1) : PENDY(pan2);\ + assert((ix1<=ix2) && (iy1<=iy2));\ + + +/*+------------------------------------------------------------------------- + Walk through the panel stack starting at the given location and + check for intersections; overlapping panels are "touched", so they + are incrementally overwriting cells that should be hidden. + If the "touch" flag is set, the panel gets touched before it is + updated. +---------------------------------------------------------------------------*/ +#define PANEL_UPDATE(pan,panstart,touch)\ +{ int y;\ + PANEL* pan2 = ((panstart) ? (panstart) : _nc_bottom_panel);\ + if (touch)\ + Touchpan(pan);\ + while(pan2) {\ + if ((pan2 != pan) && PANELS_OVERLAPPED(pan,pan2)) {\ + int ix1,ix2,iy1,iy2;\ + COMPUTE_INTERSECTION(pan,pan2,ix1,ix2,iy1,iy2);\ + for(y = iy1; y <= iy2; y++) {\ + if (is_linetouched(pan->win,y - PSTARTY(pan))) {\ + struct ldat* line = &(pan2->win->_line[y - PSTARTY(pan2)]);\ + CHANGED_RANGE(line,ix1-PSTARTX(pan2),ix2-PSTARTX(pan2));\ + }\ + }\ + }\ + pan2 = pan2->above;\ + }\ +} + +/*+------------------------------------------------------------------------- + Remove panel from stack. +---------------------------------------------------------------------------*/ +#define PANEL_UNLINK(pan,err) \ +{ err = ERR;\ + if (pan) {\ + if (IS_LINKED(pan)) {\ + if ((pan)->below)\ + (pan)->below->above = (pan)->above;\ + if ((pan)->above)\ + (pan)->above->below = (pan)->below;\ + if ((pan) == _nc_bottom_panel) \ + _nc_bottom_panel = (pan)->above;\ + if ((pan) == _nc_top_panel) \ + _nc_top_panel = (pan)->below;\ + err = OK;\ + }\ + (pan)->above = (pan)->below = (PANEL*)0;\ + }\ +} + +#define HIDE_PANEL(pan,err,err_if_unlinked)\ + if (IS_LINKED(pan)) {\ + PANEL_UPDATE(pan,(PANEL*)0,TRUE);\ + PANEL_UNLINK(pan,err);\ + } \ + else {\ + if (err_if_unlinked)\ + err = ERR;\ + } #endif /* _PANEL_PRIV_H */ diff --git a/lib/libpanel/shlib_version b/lib/libpanel/shlib_version index 893819d18ff..c8860078e50 100644 --- a/lib/libpanel/shlib_version +++ b/lib/libpanel/shlib_version @@ -1,2 +1,2 @@ major=1 -minor=1 +minor=2 |