diff options
Diffstat (limited to 'contrib/ncurses/ncurses/base')
-rwxr-xr-x | contrib/ncurses/ncurses/base/MKlib_gen.sh | 5 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/MKunctrl.awk | 80 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_addch.c | 29 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_getch.c | 22 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_insch.c | 24 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_newterm.c | 6 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_newwin.c | 6 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_set_term.c | 26 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_slk.c | 23 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_slkclear.c | 33 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_slkinit.c | 11 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/resizeterm.c | 128 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/use_window.c | 8 |
13 files changed, 283 insertions, 118 deletions
diff --git a/contrib/ncurses/ncurses/base/MKlib_gen.sh b/contrib/ncurses/ncurses/base/MKlib_gen.sh index b5b07140b55f..09857834e7e0 100755 --- a/contrib/ncurses/ncurses/base/MKlib_gen.sh +++ b/contrib/ncurses/ncurses/base/MKlib_gen.sh @@ -2,10 +2,10 @@ # # MKlib_gen.sh -- generate sources from curses.h macro definitions # -# ($Id: MKlib_gen.sh,v 1.29 2007/08/18 13:17:14 tom Exp $) +# ($Id: MKlib_gen.sh,v 1.30 2008/01/05 23:21:10 tom Exp $) # ############################################################################## -# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. # +# Copyright (c) 1998-2007,2008 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"), # @@ -422,4 +422,5 @@ $preprocessor $TMP 2>/dev/null \ | sed \ -e 's/^.*T_CALLED.*returnCode( \([a-z].*) \));/ return \1;/' \ -e 's/^.*T_CALLED.*returnCode( \((wmove.*) \));/ return \1;/' \ + -e 's/gen_//' \ | sed -f $ED4 diff --git a/contrib/ncurses/ncurses/base/MKunctrl.awk b/contrib/ncurses/ncurses/base/MKunctrl.awk index 5d187a8cfb7e..1ba511d72323 100644 --- a/contrib/ncurses/ncurses/base/MKunctrl.awk +++ b/contrib/ncurses/ncurses/base/MKunctrl.awk @@ -1,6 +1,6 @@ -# $Id: MKunctrl.awk,v 1.14 2007/07/28 21:13:21 tom Exp $ +# $Id: MKunctrl.awk,v 1.21 2008/02/03 20:24:30 tom Exp $ ############################################################################## -# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. # +# Copyright (c) 1998-2007,2008 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"), # @@ -27,13 +27,20 @@ # authorization. # ############################################################################## # -# Author: Thomas E. Dickey <dickey@clark.net> 1997 +# Author: Thomas E. Dickey (1997-on) # BEGIN { print "/* generated by MKunctrl.awk */" print "" print "#include <curses.priv.h>" + print "#include <ctype.h>" + print "" + print "#if USE_WIDEC_SUPPORT" + print "#if HAVE_WCTYPE_H" + print "#include <wctype.h>" + print "#endif" + print "#endif" print "" print "#undef unctrl" print "" @@ -69,6 +76,12 @@ END { } else if (ch >= 128 && ch < 160) { part = sprintf("~\\%03o", ch - 64); offset = offset + 3; + } else if (ch == 255) { + part = "~?"; + offset = offset + 3; + } else if (ch >= 160) { + part = sprintf("M-\\%03o", ch - 128); + offset = offset + 4; } else { gap = gap " " part = sprintf("\\%03o", ch); @@ -88,14 +101,13 @@ END { blob = blob "\""; print "" - print "#if NCURSES_EXT_FUNCS" if (bigstrings) { - blob = blob "\n#if NCURSES_EXT_FUNCS" + blob = blob "\n/* printable values in 128-255 range */" printf "static const short unctrl_c1[] = {" } else { printf "static const char* const unctrl_c1[] = {" } - for ( ch = 128; ch < 160; ch++ ) { + for ( ch = 128; ch < 256; ch++ ) { gap = "," if ((ch % 8) == 0) { if (ch != 128) @@ -111,7 +123,7 @@ END { if (((ch + 1) % 8) != 0) gap = gap " " } else { - if (ch >= 128 && ch < 160) { + if (ch >= 128) { printf "\"\\%03o\"", ch gap = gap " " } @@ -123,8 +135,7 @@ END { } } print "};" - print "#endif /* NCURSES_EXT_FUNCS */" - blob = blob "\"\n#endif /* NCURSES_EXT_FUNCS */\n" + blob = blob "\"\n" print "" if (bigstrings) { @@ -134,22 +145,41 @@ END { } else { stringname = "unctrl" } - print "\tint check = ChCharOf(ch);" - print "\tconst char *result;" - print "" - print "\tif (check >= 0 && check < (int)SIZEOF(unctrl_table)) {" - print "#if NCURSES_EXT_FUNCS" - print "\t\tif ((SP != 0)" - print "\t\t && (SP->_legacy_coding > 1)" - print "\t\t && (check >= 128)" - print "\t\t && (check < 160))" + print "\tint check = ChCharOf(ch);" + print "\tconst char *result;" + print "" + print "\tif (check >= 0 && check < (int)SIZEOF(unctrl_table)) {" + print "#if NCURSES_EXT_FUNCS" + print "\t\tif ((SP != 0)" + print "\t\t && (SP->_legacy_coding > 1)" + print "\t\t && (check >= 128)" + print "\t\t && (check < 160))" + printf "\t\t\tresult = %s_c1[check - 128];\n", stringname; + print "\t\telse" + print "#if USE_WIDEC_SUPPORT" + print "\t\tif ((check >= 160)" + print "\t\t && (check < 256)" + print "\t\t && ((SP != 0)" + print "\t\t && ((SP->_legacy_coding > 0)" + print "\t\t || (SP->_legacy_coding == 0" + print "\t\t && (isprint(check) || iswprint(check))))))" + printf "\t\t\tresult = %s_c1[check - 128];\n", stringname; + print "\t\telse" + print "#else" + print "\t\tif ((check >= 160)" + print "\t\t && (check < 256)" + print "\t\t && ((SP != 0)" + print "\t\t && ((SP->_legacy_coding > 0)" + print "\t\t || (SP->_legacy_coding == 0" + print "\t\t && isprint(check)))))" printf "\t\t\tresult = %s_c1[check - 128];\n", stringname; - print "\t\telse" - print "#endif /* NCURSES_EXT_FUNCS */" + print "\t\telse" + print "#endif /* USE_WIDEC_SUPPORT */" + print "#endif /* NCURSES_EXT_FUNCS */" printf "\t\t\tresult = %s_table[check];\n", stringname; - print "\t} else {" - print "\t\tresult = 0;" - print "\t}" - print "\treturn (NCURSES_CONST char *)result;" - print "}" + print "\t} else {" + print "\t\tresult = 0;" + print "\t}" + print "\treturn (NCURSES_CONST char *)result;" + print "}" } diff --git a/contrib/ncurses/ncurses/base/lib_addch.c b/contrib/ncurses/ncurses/base/lib_addch.c index 9d73edfde5de..1ef6cc5803d3 100644 --- a/contrib/ncurses/ncurses/base/lib_addch.c +++ b/contrib/ncurses/ncurses/base/lib_addch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2008 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,7 +36,7 @@ #include <curses.priv.h> #include <ctype.h> -MODULE_ID("$Id: lib_addch.c,v 1.104 2006/10/14 20:31:19 tom Exp $") +MODULE_ID("$Id: lib_addch.c,v 1.108 2008/02/03 18:50:27 tom Exp $") static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT); @@ -219,17 +219,15 @@ _nc_build_wch(WINDOW *win, ARG_CH_T ch) attr_t attrs = AttrOf(CHDEREF(ch)); SetChar(CHDEREF(ch), result, attrs); WINDOW_EXT(win, addch_used) = 0; - } else { - if (len == -1) { - /* - * An error occurred. We could either discard everything, - * or assume that the error was in the previous input. - * Try the latter. - */ - TR(TRACE_VIRTPUT, ("Alert! mbrtowc returns error")); - buffer[0] = CharOf(CHDEREF(ch)); - WINDOW_EXT(win, addch_used) = 1; - } + } else if (len == -1) { + /* + * An error occurred. We could either discard everything, + * or assume that the error was in the previous input. + * Try the latter. + */ + TR(TRACE_VIRTPUT, ("Alert! mbrtowc returns error")); + /* handle this with unctrl() */ + WINDOW_EXT(win, addch_used) = 0; } return len; } @@ -264,13 +262,16 @@ waddch_literal(WINDOW *win, NCURSES_CH_T ch) if (WINDOW_EXT(win, addch_used) != 0 || !Charable(ch)) { int len = _nc_build_wch(win, CHREF(ch)); - if (len > 0) { + if (len >= -1) { + /* handle EILSEQ */ if (is8bits(CharOf(ch))) { const char *s = unctrl((chtype) CharOf(ch)); if (s[1] != 0) { return waddstr(win, s); } } + if (len == -1) + return waddch(win, ' '); } else { return OK; } diff --git a/contrib/ncurses/ncurses/base/lib_getch.c b/contrib/ncurses/ncurses/base/lib_getch.c index 64566ccc7629..11e8052a668c 100644 --- a/contrib/ncurses/ncurses/base/lib_getch.c +++ b/contrib/ncurses/ncurses/base/lib_getch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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,7 +41,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_getch.c,v 1.80 2007/09/29 20:39:34 tom Exp $") +MODULE_ID("$Id: lib_getch.c,v 1.82 2008/01/19 21:07:30 tom Exp $") #include <fifo_defs.h> @@ -56,6 +56,24 @@ NCURSES_EXPORT_VAR(int) ESCDELAY = 1000; /* max interval betw. chars in funkeys, in millisecs */ #endif +#if NCURSES_EXT_FUNCS +NCURSES_EXPORT(int) +set_escdelay(int value) +{ + int code = OK; +#if USE_REENTRANT + if (SP) { + SP->_ESCDELAY = value; + } else { + code = ERR; + } +#else + ESCDELAY = value; +#endif + return code; +} +#endif + #ifdef NCURSES_WGETCH_EVENTS #define TWAIT_MASK 7 #else diff --git a/contrib/ncurses/ncurses/base/lib_insch.c b/contrib/ncurses/ncurses/base/lib_insch.c index b8a856df3a82..9166ea5240e7 100644 --- a/contrib/ncurses/ncurses/base/lib_insch.c +++ b/contrib/ncurses/ncurses/base/lib_insch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. * + * Copyright (c) 1998-2005,2008 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,7 +43,7 @@ #include <curses.priv.h> #include <ctype.h> -MODULE_ID("$Id: lib_insch.c,v 1.24 2005/02/26 19:27:28 tom Exp $") +MODULE_ID("$Id: lib_insch.c,v 1.25 2008/02/03 00:14:37 tom Exp $") /* * Insert the given character, updating the current location to simplify @@ -95,7 +95,8 @@ _nc_insert_ch(WINDOW *win, chtype ch) } else if (is8bits(ChCharOf(ch)) && iscntrl(ChCharOf(ch))) { s = unctrl(ChCharOf(ch)); while (*s != '\0') { - if ((code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s))) != OK) + code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s)); + if (code != OK) break; ++s; } @@ -107,8 +108,23 @@ _nc_insert_ch(WINDOW *win, chtype ch) */ SetChar2(wch, ch); wch = _nc_render(win, wch); - if (_nc_build_wch(win, &wch) >= 0) + count = _nc_build_wch(win, &wch); + if (count > 0) { code = wins_wch(win, &wch); + } else if (count == -1) { + /* handle EILSEQ */ + if (is8bits(ch)) { + s = unctrl(ChCharOf(ch)); + while (*s != '\0') { + code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s)); + if (code != OK) + break; + ++s; + } + } else { + code = ERR; + } + } } #endif break; diff --git a/contrib/ncurses/ncurses/base/lib_newterm.c b/contrib/ncurses/ncurses/base/lib_newterm.c index 05cd9b8a5b00..f52562cec106 100644 --- a/contrib/ncurses/ncurses/base/lib_newterm.c +++ b/contrib/ncurses/ncurses/base/lib_newterm.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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,7 +48,7 @@ #include <term.h> /* clear_screen, cup & friends, cur_term */ #include <tic.h> -MODULE_ID("$Id: lib_newterm.c,v 1.67 2007/04/21 20:47:32 tom Exp $") +MODULE_ID("$Id: lib_newterm.c,v 1.68 2008/01/12 20:24:40 tom Exp $") #ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */ #define ONLCR 0 @@ -123,7 +123,7 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp) { int value; int errret; - int slk_format = _nc_slk_format; + int slk_format = _nc_globals.slk_format; SCREEN *current; SCREEN *result = 0; diff --git a/contrib/ncurses/ncurses/base/lib_newwin.c b/contrib/ncurses/ncurses/base/lib_newwin.c index b0f4603ae7ab..21ba95f34ed6 100644 --- a/contrib/ncurses/ncurses/base/lib_newwin.c +++ b/contrib/ncurses/ncurses/base/lib_newwin.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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,7 +41,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_newwin.c,v 1.42 2007/12/22 23:20:18 tom Exp $") +MODULE_ID("$Id: lib_newwin.c,v 1.44 2008/01/13 00:28:13 tom Exp $") static WINDOW * remove_window_from_screen(WINDOW *win) @@ -234,7 +234,7 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags) { pthread_mutexattr_t recattr; memset(&recattr, 0, sizeof(recattr)); - pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_NORMAL); pthread_mutex_init(&(wp->mutex_use_window), &recattr); } #endif diff --git a/contrib/ncurses/ncurses/base/lib_set_term.c b/contrib/ncurses/ncurses/base/lib_set_term.c index 2b1387ad7a02..e44850c6a15a 100644 --- a/contrib/ncurses/ncurses/base/lib_set_term.c +++ b/contrib/ncurses/ncurses/base/lib_set_term.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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 * @@ -44,7 +44,7 @@ #include <term.h> /* cur_term */ #include <tic.h> -MODULE_ID("$Id: lib_set_term.c,v 1.100 2007/09/08 21:23:43 tom Exp $") +MODULE_ID("$Id: lib_set_term.c,v 1.103 2008/02/03 20:31:08 tom Exp $") NCURSES_EXPORT(SCREEN *) set_term(SCREEN *screenp) @@ -221,9 +221,6 @@ extract_fgbg(char *src, int *result) } #endif -#define ripoff_sp _nc_prescreen.rsp -#define ripoff_stack _nc_prescreen.rippedoff - /* OS-independent screen initializations */ NCURSES_EXPORT(int) _nc_setupscreen(int slines GCC_UNUSED, @@ -232,6 +229,7 @@ _nc_setupscreen(int slines GCC_UNUSED, bool filtered, int slk_format) { + char *env; int bottom_stolen = 0; bool support_cookies = USE_XMC_SUPPORT; ripoff_t *rop; @@ -504,13 +502,12 @@ _nc_setupscreen(int slines GCC_UNUSED, _nc_init_wacs(); SP->_screen_acs_fix = (_nc_unicode_locale() && _nc_locale_breaks_acs()); - { - char *env = _nc_get_locale(); - SP->_legacy_coding = ((env == 0) - || !strcmp(env, "C") - || !strcmp(env, "POSIX")); - } #endif + env = _nc_get_locale(); + SP->_legacy_coding = ((env == 0) + || !strcmp(env, "C") + || !strcmp(env, "POSIX")); + T(("legacy-coding %d", SP->_legacy_coding)); _nc_idcok = TRUE; _nc_idlok = FALSE; @@ -568,10 +565,12 @@ _nc_setupscreen(int slines GCC_UNUSED, ? SP->_lines_avail - count : 0), 0); - if (w) + if (w) { + rop->win = w; rop->hook(w, scolumns); - else + } else { returnCode(ERR); + } if (rop->line < 0) bottom_stolen += count; else @@ -622,6 +621,7 @@ _nc_ripoffline(int line, int (*init) (WINDOW *, int)) NCURSES_EXPORT(int) ripoffline(int line, int (*init) (WINDOW *, int)) { + START_TRACE(); T((T_CALLED("ripoffline(%d,%p)"), line, init)); if (line == 0) diff --git a/contrib/ncurses/ncurses/base/lib_slk.c b/contrib/ncurses/ncurses/base/lib_slk.c index 5609e3b59024..27b21b08d718 100644 --- a/contrib/ncurses/ncurses/base/lib_slk.c +++ b/contrib/ncurses/ncurses/base/lib_slk.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. * + * Copyright (c) 1998-2005,2008 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 * @@ -45,7 +45,7 @@ #include <ctype.h> #include <term.h> /* num_labels, label_*, plab_norm */ -MODULE_ID("$Id: lib_slk.c,v 1.30 2005/01/08 21:56:36 tom Exp $") +MODULE_ID("$Id: lib_slk.c,v 1.31 2008/01/12 20:21:00 tom Exp $") /* * We'd like to move these into the screen context structure, but cannot, @@ -56,7 +56,6 @@ _nc_slk_format = 0; /* one more than format specified in slk_init() */ /* * Paint the info line for the PC style SLK emulation. - * */ static void slk_paint_info(WINDOW *win) @@ -119,12 +118,12 @@ _nc_slk_initialize(WINDOW *stwin, int cols) SP->_slk->maxlab = ((num_labels > 0) ? num_labels - : MAX_SKEY(_nc_slk_format)); + : MAX_SKEY(_nc_globals.slk_format)); SP->_slk->maxlen = ((num_labels > 0) ? label_width * label_height - : MAX_SKEY_LEN(_nc_slk_format)); - SP->_slk->labcnt = ((SP->_slk->maxlab < MAX_SKEY(_nc_slk_format)) - ? MAX_SKEY(_nc_slk_format) + : MAX_SKEY_LEN(_nc_globals.slk_format)); + SP->_slk->labcnt = ((SP->_slk->maxlab < MAX_SKEY(_nc_globals.slk_format)) + ? MAX_SKEY(_nc_globals.slk_format) : SP->_slk->maxlab); if (SP->_slk->maxlen <= 0 @@ -148,7 +147,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols) memset(SP->_slk->ent[i].form_text, ' ', max_length); SP->_slk->ent[i].visible = (i < SP->_slk->maxlab); } - if (_nc_slk_format >= 3) { /* PC style */ + if (_nc_globals.slk_format >= 3) { /* PC style */ int gap = (cols - 3 * (3 + 4 * max_length)) / 2; if (gap < 1) @@ -161,7 +160,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols) } slk_paint_info(stwin); } else { - if (_nc_slk_format == 2) { /* 4-4 */ + if (_nc_globals.slk_format == 2) { /* 4-4 */ int gap = cols - (SP->_slk->maxlab * max_length) - 6; if (gap < 1) @@ -172,7 +171,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols) x += (i == 3) ? gap : 1; } } else { - if (_nc_slk_format == 1) { /* 1 -> 3-2-3 */ + if (_nc_globals.slk_format == 1) { /* 1 -> 3-2-3 */ int gap = (cols - (SP->_slk->maxlab * max_length) - 5) / 2; @@ -196,8 +195,8 @@ _nc_slk_initialize(WINDOW *stwin, int cols) * per default no SLK keys and may call slk_init again to * define a new layout. (juergen 03-Mar-1999) */ - SP->slk_format = _nc_slk_format; - _nc_slk_format = 0; + SP->slk_format = _nc_globals.slk_format; + _nc_globals.slk_format = 0; returnCode(res); } diff --git a/contrib/ncurses/ncurses/base/lib_slkclear.c b/contrib/ncurses/ncurses/base/lib_slkclear.c index 99edcd538ec5..946ceeaf0e0d 100644 --- a/contrib/ncurses/ncurses/base/lib_slkclear.c +++ b/contrib/ncurses/ncurses/base/lib_slkclear.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2007 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,6 +29,8 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * + * and: Juergen Pfeifer 1996-1999 * + * and: Thomas E. Dickey 1996-on * ****************************************************************************/ /* @@ -38,24 +40,27 @@ */ #include <curses.priv.h> -MODULE_ID("$Id: lib_slkclear.c,v 1.9 2006/05/27 19:21:19 tom Exp $") +MODULE_ID("$Id: lib_slkclear.c,v 1.10 2007/12/29 17:51:47 tom Exp $") NCURSES_EXPORT(int) slk_clear(void) { + int rc = ERR; + T((T_CALLED("slk_clear()"))); - if (SP == NULL || SP->_slk == NULL) - returnCode(ERR); - SP->_slk->hidden = TRUE; - /* For simulated SLK's it's looks much more natural to - inherit those attributes from the standard screen */ - SP->_slk->win->_nc_bkgd = stdscr->_nc_bkgd; - WINDOW_ATTRS(SP->_slk->win) = WINDOW_ATTRS(stdscr); - if (SP->_slk->win == stdscr) { - returnCode(OK); - } else { - werase(SP->_slk->win); - returnCode(wrefresh(SP->_slk->win)); + if (SP != NULL && SP->_slk != NULL) { + SP->_slk->hidden = TRUE; + /* For simulated SLK's it looks much more natural to + inherit those attributes from the standard screen */ + SP->_slk->win->_nc_bkgd = stdscr->_nc_bkgd; + WINDOW_ATTRS(SP->_slk->win) = WINDOW_ATTRS(stdscr); + if (SP->_slk->win == stdscr) { + rc = OK; + } else { + werase(SP->_slk->win); + rc = wrefresh(SP->_slk->win); + } } + returnCode(rc); } diff --git a/contrib/ncurses/ncurses/base/lib_slkinit.c b/contrib/ncurses/ncurses/base/lib_slkinit.c index 20c0baa59646..c440109b34e6 100644 --- a/contrib/ncurses/ncurses/base/lib_slkinit.c +++ b/contrib/ncurses/ncurses/base/lib_slkinit.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2000,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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,6 +29,7 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * + * and: Thomas E. Dickey 1996-on * ****************************************************************************/ /* @@ -38,7 +39,7 @@ */ #include <curses.priv.h> -MODULE_ID("$Id: lib_slkinit.c,v 1.6 2007/05/12 18:14:21 tom Exp $") +MODULE_ID("$Id: lib_slkinit.c,v 1.7 2008/01/12 20:23:39 tom Exp $") NCURSES_EXPORT(int) slk_init(int format) @@ -46,9 +47,9 @@ slk_init(int format) int code = ERR; T((T_CALLED("slk_init(%d)"), format)); - if (format >= 0 && format <= 3 && !_nc_slk_format) { - _nc_slk_format = 1 + format; - code = _nc_ripoffline(-SLK_LINES(_nc_slk_format), _nc_slk_initialize); + if (format >= 0 && format <= 3 && !_nc_globals.slk_format) { + _nc_globals.slk_format = 1 + format; + code = _nc_ripoffline(-SLK_LINES(_nc_globals.slk_format), _nc_slk_initialize); } returnCode(code); } diff --git a/contrib/ncurses/ncurses/base/resizeterm.c b/contrib/ncurses/ncurses/base/resizeterm.c index 8bea743a3d22..eb2dd737f94c 100644 --- a/contrib/ncurses/ncurses/base/resizeterm.c +++ b/contrib/ncurses/ncurses/base/resizeterm.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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,7 +41,7 @@ #include <curses.priv.h> #include <term.h> -MODULE_ID("$Id: resizeterm.c,v 1.24 2007/12/22 23:20:31 tom Exp $") +MODULE_ID("$Id: resizeterm.c,v 1.30 2008/01/12 22:26:56 tom Exp $") #define stolen_lines (screen_lines - SP->_lines_avail) @@ -81,6 +81,10 @@ show_window_sizes(const char *name) } #endif +/* + * Return true if the given dimensions do not match the internal terminal + * structure's size. + */ NCURSES_EXPORT(bool) is_term_resized(int ToLines, int ToCols) { @@ -92,6 +96,48 @@ is_term_resized(int ToLines, int ToCols) } /* + */ +static ripoff_t * +ripped_window(WINDOW *win) +{ + ripoff_t *result = 0; + ripoff_t *rop; + + if (win != 0) { + for (rop = ripoff_stack; (rop - ripoff_stack) < N_RIPS; rop++) { + if (rop->win == win && rop->line != 0) { + result = rop; + break; + } + } + } + return result; +} + +/* + * Returns the number of lines from the bottom for the beginning of a ripped + * off window. + */ +static int +ripped_bottom(WINDOW *win) +{ + int result = 0; + ripoff_t *rop; + + if (win != 0) { + for (rop = ripoff_stack; (rop - ripoff_stack) < N_RIPS; rop++) { + if (rop->line < 0) { + result -= rop->line; + if (rop->win == win) { + break; + } + } + } + } + return result; +} + +/* * Return the number of levels of child-windows under the current window. */ static int @@ -141,33 +187,45 @@ adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen EXTRA_DCLS) int bottom = CurLines + SP->_topstolen - stolen; int myLines = win->_maxy + 1; int myCols = win->_maxx + 1; + ripoff_t *rop = ripped_window(win); - T((T_CALLED("adjust_window(%p,%d,%d) currently %ldx%ld at %ld,%ld"), + T((T_CALLED("adjust_window(%p,%d,%d)%s depth %d/%d currently %ldx%ld at %ld,%ld"), win, ToLines, ToCols, + (rop != 0) ? " (rip)" : "", + parent_depth(win), + child_depth(win), (long) getmaxy(win), (long) getmaxx(win), - (long) getbegy(win), (long) getbegx(win))); - - if (win->_begy >= bottom) { + (long) getbegy(win) + win->_yoffset, (long) getbegx(win))); + + if (rop != 0 && rop->line < 0) { + /* + * If it is a ripped-off window at the bottom of the screen, simply + * move it to the same relative position. + */ + win->_begy = ToLines - ripped_bottom(win) - 0 - win->_yoffset; + } else if (win->_begy >= bottom) { + /* + * If it is below the bottom of the new screen, move up by the same + * amount that the screen shrank. + */ win->_begy += (ToLines - CurLines); } else { - if (myLines == CurLines - stolen - && ToLines != CurLines) + if (myLines == (CurLines - stolen) + && ToLines != CurLines) { myLines = ToLines - stolen; - else if (myLines == CurLines - && ToLines != CurLines) + } else if (myLines == CurLines + && ToLines != CurLines) { myLines = ToLines; + } } - if (myLines > ToLines) + if (myLines > ToLines) { myLines = ToLines; + } if (myCols > ToCols) myCols = ToCols; - if (myLines == CurLines - && ToLines != CurLines) - myLines = ToLines; - if (myCols == CurCols && ToCols != CurCols) myCols = ToCols; @@ -347,13 +405,49 @@ resizeterm(int ToLines, int ToCols) SP->_sig_winch = FALSE; if (is_term_resized(ToLines, ToCols)) { +#if USE_SIGWINCH + ripoff_t *rop; + bool slk_visible = (SP != 0 + && SP->_slk != 0 + && !(SP->_slk->hidden)); + + if (slk_visible) { + slk_clear(); + } +#endif + result = resize_term(ToLines, ToCols); #if USE_SIGWINCH ungetch(KEY_RESIZE); /* so application can know this */ clearok(curscr, TRUE); /* screen contents are unknown */ -#endif - result = resize_term(ToLines, ToCols); + /* ripped-off lines are a special case: if we did not lengthen + * them, we haven't moved them either. repaint them, too. + * + * for the rest - stdscr and other windows - the client has to + * decide which to repaint, since without panels, ncurses does + * not know which are really on top. + */ + for (rop = ripoff_stack; (rop - ripoff_stack) < N_RIPS; rop++) { + if (rop->win != stdscr + && rop->win != 0 + && rop->line < 0) { + + if (rop->hook != _nc_slk_initialize) { + touchwin(rop->win); + wnoutrefresh(rop->win); + } + } + } + + /* soft-keys are a special case: we _know_ how to repaint them */ + if (slk_visible) { + slk_restore(); + slk_touch(); + + slk_refresh(); + } +#endif } } diff --git a/contrib/ncurses/ncurses/base/use_window.c b/contrib/ncurses/ncurses/base/use_window.c index 8792cb47c37e..4c9b1375f288 100644 --- a/contrib/ncurses/ncurses/base/use_window.c +++ b/contrib/ncurses/ncurses/base/use_window.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2007 Free Software Foundation, Inc. * + * Copyright (c) 2007,2008 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 * @@ -32,7 +32,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: use_window.c,v 1.2 2007/10/20 19:57:55 tom Exp $") +MODULE_ID("$Id: use_window.c,v 1.3 2008/01/13 00:36:22 tom Exp $") #ifdef USE_PTHREADS NCURSES_EXPORT(void) @@ -43,7 +43,7 @@ _nc_lock_window(WINDOW *win) _nc_lock_global(windowlist); for (p = _nc_windows; p != 0; p = p->next) { if (&(p->win) == win) { - pthread_mutex_lock(&(p->mutex_use_window)); + _nc_mutex_lock(&(p->mutex_use_window)); break; } } @@ -58,7 +58,7 @@ _nc_unlock_window(WINDOW *win) _nc_lock_global(windowlist); for (p = _nc_windows; p != 0; p = p->next) { if (&(p->win) == win) { - pthread_mutex_unlock(&(p->mutex_use_window)); + _nc_mutex_unlock(&(p->mutex_use_window)); break; } } |