diff options
Diffstat (limited to 'contrib/ncurses/ncurses/base')
48 files changed, 1332 insertions, 551 deletions
diff --git a/contrib/ncurses/ncurses/base/MKkeyname.awk b/contrib/ncurses/ncurses/base/MKkeyname.awk index c06773350cc6..5aab9369857c 100644 --- a/contrib/ncurses/ncurses/base/MKkeyname.awk +++ b/contrib/ncurses/ncurses/base/MKkeyname.awk @@ -1,6 +1,6 @@ -# $Id: MKkeyname.awk,v 1.18 2000/12/10 02:25:23 tom Exp $ +# $Id: MKkeyname.awk,v 1.21 2002/02/23 22:36:33 tom Exp $ ############################################################################## -# Copyright (c) 1999,2000 Free Software Foundation, Inc. # +# Copyright (c) 1999-2001,2002 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"), # @@ -29,10 +29,7 @@ BEGIN { print "/* generated by MKkeyname.awk */" print "" - print "#include <ncurses_cfg.h>" - print "#include <stdlib.h>" - print "#include <string.h>" - print "#include <curses.h>" + print "#include <curses.priv.h>" print "#include <tic.h>" print "" print "const struct kn _nc_key_names[] = {" @@ -47,28 +44,47 @@ END { print "" print "NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)" print "{" + print "static char **table;" print "int i;" - print "static char name[20];" + print "char name[20];" print "char *p;" print "" print "\tfor (i = 0; _nc_key_names[i].name != 0; i++)" print "\t\tif (_nc_key_names[i].code == c)" print "\t\t\treturn (NCURSES_CONST char *)_nc_key_names[i].name;" print "\tif (c >= 256) return \"UNKNOWN KEY\";" - print "\tp = name;" - print "\tif (c >= 128) {" - print "\t\tstrcpy(p, \"M-\");" - print "\t\tp += 2;" - print "\t\tc -= 128;" + print "" + print "\tif (table == 0)" + print "\t\ttable = typeCalloc(char *, 256);" + print "\tif (table == 0)" + print "\t\treturn keyname(256);" + print "" + print "\tif (table[c] == 0) {" + print "\t\tp = name;" + print "\t\tif (c >= 128) {" + print "\t\t\tstrcpy(p, \"M-\");" + print "\t\t\tp += 2;" + print "\t\t\tc -= 128;" + print "\t\t}" + print "\t\tif (c < 0)" + print "\t\t\tsprintf(p, \"%d\", c);" + print "\t\telse if (c < 32)" + print "\t\t\tsprintf(p, \"^%c\", c + '@');" + print "\t\telse if (c == 127)" + print "\t\t\tstrcpy(p, \"^?\");" + print "\t\telse" + print "\t\t\tsprintf(p, \"%c\", c);" + print "\t\ttable[c] = strdup(name);" print "\t}" - print "\tif (c < 0)" - print "\t\tsprintf(p, \"%d\", c);" - print "\telse if (c < 32)" - print "\t\tsprintf(p, \"^%c\", c + '@');" - print "\telse if (c == 127)" - print "\t\tstrcpy(p, \"^?\");" - print "\telse" - print "\t\tsprintf(p, \"%c\", c);" - print "\treturn (NCURSES_CONST char *)name;" + print "\treturn (NCURSES_CONST char *)table[c];" + print "}" + print "" + print "#if USE_WIDEC_SUPPORT" + print "NCURSES_EXPORT(NCURSES_CONST char *) key_name (wchar_t c)" + print "{" + print "\tchar *result = keyname((int)c);" + print "\tif (!strncmp(result, \"M-\", 2)) result = \"UNKNOWN KEY\";" + print "\treturn result;" print "}" + print "#endif" } diff --git a/contrib/ncurses/ncurses/base/MKlib_gen.sh b/contrib/ncurses/ncurses/base/MKlib_gen.sh index 4de2a5a466bf..e172feb3baaf 100755 --- a/contrib/ncurses/ncurses/base/MKlib_gen.sh +++ b/contrib/ncurses/ncurses/base/MKlib_gen.sh @@ -2,7 +2,35 @@ # # MKlib_gen.sh -- generate sources from curses.h macro definitions # -# ($Id: MKlib_gen.sh,v 1.13 2000/12/10 00:30:25 tom Exp $) +# ($Id: MKlib_gen.sh,v 1.18 2002/04/30 00:37:55 tom Exp $) +# +############################################################################## +# Copyright (c) 1998-2001,2002 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. # +############################################################################## # # The XSI Curses standard requires all curses entry points to exist as # functions, even though many definitions would normally be shadowed @@ -28,21 +56,30 @@ preprocessor="$1 -I../include" AWK="$2" -ED1=sed1$$.sed -ED2=sed2$$.sed -ED3=sed3$$.sed -AW1=awk1$$.awk -TMP=gen$$.c -trap "rm -f $ED1 $ED2 $ED3 $AW1 $TMP" 0 1 2 5 15 - -(cat <<EOF -#include <ncurses_cfg.h> -#include <curses.h> +USE="$3" -DECLARATIONS +PID=$$ +ED1=sed1_${PID}.sed +ED2=sed2_${PID}.sed +ED3=sed3_${PID}.sed +ED4=sed4_${PID}.sed +AW1=awk1_${PID}.awk +AW2=awk2_${PID}.awk +TMP=gen__${PID}.c +trap "rm -f $ED1 $ED2 $ED3 $ED4 $AW1 $AW2 $TMP" 0 1 2 5 15 -EOF -cat >$ED1 <<EOF1 +ALL=$USE +if test "$USE" = implemented ; then + CALL="call_" + cat >$ED1 <<EOF1 +/^extern.*implemented/{ + h + s/^.*implemented:\([^ *]*\).*/P_#if_USE_\1_SUPPORT/p + g + s/^extern \([^;]*\);.*/\1/p + g + s/^.*implemented:\([^ *]*\).*/P_#endif/p +} /^extern.*generated/{ h s/^.*generated:\([^ *]*\).*/P_#if_USE_\1_SUPPORT/p @@ -52,6 +89,19 @@ cat >$ED1 <<EOF1 s/^.*generated:\([^ *]*\).*/P_#endif/p } EOF1 +else + CALL="" + cat >$ED1 <<EOF1 +/^extern.*${ALL}/{ + h + s/^.*${ALL}:\([^ *]*\).*/P_#if_USE_\1_SUPPORT/p + g + s/^extern \([^;]*\);.*/\1/p + g + s/^.*${ALL}:\([^ *]*\).*/P_#endif/p +} +EOF1 +fi cat >$ED2 <<EOF2 /^P_/b nc @@ -74,6 +124,7 @@ cat >$ED2 <<EOF2 s/*/ * /g s/%/ , /g s/)/ z)/ + s/\.\.\. z)/...)/ :nc /(/s// ( / s/)/ )/ @@ -88,6 +139,7 @@ cat >$ED3 <<EOF3 s/ */ /g s/ */ /g s/ ,/,/g + s/( /(/g s/ )/)/g s/ gen_/ / s/^M_/#undef / @@ -95,34 +147,74 @@ cat >$ED3 <<EOF3 :done EOF3 +if test "$USE" = generated ; then +cat >$ED4 <<EOF + s/^\(.*\) \(.*\) (\(.*\))\$/NCURSES_EXPORT(\1) \2 (\3)/ +EOF +else +cat >$ED4 <<EOF +/^\(.*\) \(.*\) (\(.*\))\$/ { + h + s/^\(.*\) \(.*\) (\(.*\))\$/extern \1 call_\2 (\3);/ + p + g + s/^\(.*\) \(.*\) (\(.*\))\$/\1 call_\2 (\3)/ + } +EOF +fi + cat >$AW1 <<\EOF1 BEGIN { skip=0; } - /^P_#if/ { +/^P_#if/ { print "\n" print $0 skip=0; - } - /^P_#endif/ { +} +/^P_#endif/ { print $0 skip=1; - } - $0 !~ /^P_/ { +} +$0 !~ /^P_/ { if (skip) print "\n" skip=1; - if ( $1 == "chtype" ) { + first=$1 + for (i = 1; i <= NF; i++) { + if ( $i != "NCURSES_CONST" ) { + first = i; + break; + } + } + second = first + 1; + if ( $first == "chtype" ) { returnType = "Char"; + } else if ( $first == "SCREEN" ) { + returnType = "SP"; + } else if ( $first == "WINDOW" ) { + returnType = "Win"; + } else if ( $second == "*" ) { + returnType = "Ptr"; } else { returnType = "Code"; } - print "M_" $2 + myfunc = second; + for (i = second; i <= NF; i++) { + if ($i != "*") { + myfunc = i; + break; + } + } + if (using == "generated") { + print "M_" $myfunc + } print $0; print "{"; argcount = 1; - if (NF == 5 && $4 == "void") + check = NF - 1; + if ($check == "void") argcount = 0; if (argcount != 0) { for (i = 1; i <= NF; i++) @@ -133,8 +225,19 @@ BEGIN { # suppress trace-code for functions that we cannot do properly here, # since they return data. dotrace = 1; - if ($2 == "innstr") + if ($myfunc ~ /innstr/) + dotrace = 0; + if ($myfunc ~ /innwstr/) + dotrace = 0; + + # workaround functions that we do not parse properly + if ($myfunc ~ /ripoffline/) { dotrace = 0; + argcount = 2; + } + if ($myfunc ~ /wunctrl/) { + dotrace = 0; + } call = "%%T((T_CALLED(\"" args = "" @@ -142,7 +245,7 @@ BEGIN { num = 0; pointer = 0; argtype = "" - for (i = 1; i <= NF; i++) { + for (i = myfunc; i <= NF; i++) { ch = $i; if ( ch == "*" ) pointer = 1; @@ -181,7 +284,7 @@ BEGIN { } if (ch == ",") args = args comma "a" ++num; - else if (argcount != 0) + else if ( argcount != 0 && $check != "..." ) args = args comma "z" call = call ch if (pointer == 0 && argcount != 0 && argtype != "" ) @@ -209,11 +312,17 @@ BEGIN { else call = "%%return "; - call = call $2 "("; - for (i = 1; i < argcount; i++) - call = call "a" i ", "; - if (argcount != 0) + call = call $myfunc "("; + for (i = 1; i < argcount; i++) { + if (i != 1) + call = call ", "; + call = call "a" i; + } + if ( argcount != 0 && $check != "..." ) { + if (argcount != 1) + call = call ", "; call = call "z"; + } if (!match($0, "^void")) call = call ") "; if (dotrace) @@ -226,38 +335,54 @@ BEGIN { } EOF1 -sed -n -f $ED1 \ -| sed -e 's/NCURSES_EXPORT(\(.*\)) \(.*\) (\(.*\))/\1 \2(\3)/' \ -| sed -f $ED2 \ -| $AWK -f $AW1 ) \ -| sed \ - -e '/^\([a-z_][a-z_]*\) /s//\1 gen_/' >$TMP - $preprocessor $TMP 2>/dev/null \ -| $AWK ' +cat >$AW2 <<EOF1 BEGIN { - print "/*" - print " * DO NOT EDIT THIS FILE BY HAND!" - print " * It is generated by MKlib_gen.sh." - print " *" - print " * This is a file of trivial functions generated from macro" - print " * definitions in curses.h to satisfy the XSI Curses requirement" - print " * that every macro also exist as a callable function." - print " *" - print " * It will never be linked unless you call one of the entry" - print " * points with its normal macro definition disabled. In that" - print " * case, if you have no shared libraries, it will indirectly" - print " * pull most of the rest of the library into your link image." - print " */" - print "#include <curses.priv.h>" - print "" + print "/*" + print " * DO NOT EDIT THIS FILE BY HAND!" + printf " * It is generated by $0 %s.\n", "$USE" + if ( "$USE" == "generated" ) { + print " *" + print " * This is a file of trivial functions generated from macro" + print " * definitions in curses.h to satisfy the XSI Curses requirement" + print " * that every macro also exist as a callable function." + print " *" + print " * It will never be linked unless you call one of the entry" + print " * points with its normal macro definition disabled. In that" + print " * case, if you have no shared libraries, it will indirectly" + print " * pull most of the rest of the library into your link image." + } + print " */" + print "#include <curses.priv.h>" + print "" } /^DECLARATIONS/ {start = 1; next;} - {if (start) print $0;} -' \ + {if (start) print \$0;} +END { + if ( "$USE" != "generated" ) { + print "int main(void) { return 0; }" + } + } +EOF1 + +cat >$TMP <<EOF +#include <ncurses_cfg.h> +#include <curses.h> + +DECLARATIONS + +EOF + +sed -n -f $ED1 \ +| sed -e 's/NCURSES_EXPORT(\(.*\)) \(.*\) (\(.*\))/\1 \2(\3)/' \ +| sed -f $ED2 \ +| $AWK -f $AW1 using=$USE \ +| sed -e 's/^\([a-z_][a-z_]*[ *]*\)/\1 gen_/' -e 's/ / /g' >>$TMP + +$preprocessor $TMP 2>/dev/null \ +| sed -e 's/ / /g' -e 's/^ //' \ +| $AWK -f $AW2 \ | sed -f $ED3 \ | sed \ -e 's/^.*T_CALLED.*returnCode( \([a-z].*) \));/ return \1;/' \ -e 's/^.*T_CALLED.*returnCode( \((wmove.*) \));/ return \1;/' \ -| sed \ - -e 's/^\(.*\) \(.*\) (\(.*\))$/NCURSES_EXPORT(\1) \2 (\3)/' - +| sed -f $ED4 diff --git a/contrib/ncurses/ncurses/base/MKunctrl.awk b/contrib/ncurses/ncurses/base/MKunctrl.awk index d9d5da59433f..d8a6587e2c69 100644 --- a/contrib/ncurses/ncurses/base/MKunctrl.awk +++ b/contrib/ncurses/ncurses/base/MKunctrl.awk @@ -1,6 +1,6 @@ -# $Id: MKunctrl.awk,v 1.8 2000/12/10 02:25:37 tom Exp $ +# $Id: MKunctrl.awk,v 1.9 2001/06/02 23:59:20 skimo Exp $ ############################################################################## -# Copyright (c) 1998,2000 Free Software Foundation, Inc. # +# Copyright (c) 1998,2000,2001 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"), # @@ -64,6 +64,6 @@ END { } print "};" print "" - print "\treturn (NCURSES_CONST char *)table[TextOf(ch)];" + print "\treturn (NCURSES_CONST char *)table[ChCharOf(ch)];" print "}" } diff --git a/contrib/ncurses/ncurses/base/lib_addch.c b/contrib/ncurses/ncurses/base/lib_addch.c index 799fbf61523c..423a45e6abe4 100644 --- a/contrib/ncurses/ncurses/base/lib_addch.c +++ b/contrib/ncurses/ncurses/base/lib_addch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2001,2002 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 * @@ -26,11 +26,6 @@ * authorization. * ****************************************************************************/ -/**************************************************************************** - * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * - * and: Eric S. Raymond <esr@snark.thyrsus.com> * - ****************************************************************************/ - /* ** lib_addch.c ** @@ -41,7 +36,7 @@ #include <curses.priv.h> #include <ctype.h> -MODULE_ID("$Id: lib_addch.c,v 1.47 2000/12/10 02:43:26 tom Exp $") +MODULE_ID("$Id: lib_addch.c,v 1.64 2002/05/11 18:16:43 tom Exp $") /* * Ugly microtweaking alert. Everything from here to end of module is @@ -54,41 +49,35 @@ MODULE_ID("$Id: lib_addch.c,v 1.47 2000/12/10 02:43:26 tom Exp $") */ /* Return bit mask for clearing color pair number if given ch has color */ -#define COLOR_MASK(ch) (~(chtype)((ch)&A_COLOR?A_COLOR:0)) +#define COLOR_MASK(ch) (~(attr_t)((ch)&A_COLOR?A_COLOR:0)) -static inline chtype -render_char(WINDOW *win, chtype ch) +static inline NCURSES_CH_T +render_char(WINDOW *win, NCURSES_CH_T ch) /* compute a rendition of the given char correct for the current context */ { - chtype a = win->_attrs; + attr_t a = win->_attrs; - if (ch == ' ') { - /* color in attrs has precedence over bkgd */ - ch = a | (win->_bkgd & COLOR_MASK(a)); + if (ISBLANK(ch) && AttrOf(ch) == A_NORMAL) { + /* color in attrs has precedence over bkgrnd */ + ch = win->_nc_bkgd; + SetAttr(ch, a | (AttrOf(win->_nc_bkgd) & COLOR_MASK(a))); } else { - /* color in attrs has precedence over bkgd */ - a |= (win->_bkgd & A_ATTRIBUTES) & COLOR_MASK(a); + /* color in attrs has precedence over bkgrnd */ + a |= (AttrOf(win->_nc_bkgd) & A_ATTRIBUTES) & COLOR_MASK(a); /* color in ch has precedence */ - ch |= (a & COLOR_MASK(ch)); + AddAttr(ch, (a & COLOR_MASK(AttrOf(ch)))); } - TR(TRACE_VIRTPUT, ("bkg = %lx, attrs = %lx -> ch = %lx", win->_bkgd, - win->_attrs, ch)); + TR(TRACE_VIRTPUT, ("bkg = %s, attrs = %s -> ch = %s", + _tracech_t2(1, CHREF(win->_nc_bkgd)), + _traceattr(win->_attrs), + _tracech_t2(3, CHREF(ch)))); return (ch); } -NCURSES_EXPORT(chtype) -_nc_background -(WINDOW *win) -/* make render_char() visible while still allowing us to inline it below */ -{ - return (win->_bkgd); -} - -NCURSES_EXPORT(chtype) -_nc_render -(WINDOW *win, chtype ch) +NCURSES_EXPORT(NCURSES_CH_T) +_nc_render(WINDOW *win, NCURSES_CH_T ch) /* make render_char() visible while still allowing us to inline it below */ { return render_char(win, ch); @@ -111,7 +100,7 @@ _nc_render #endif static inline int -waddch_literal(WINDOW *win, chtype ch) +waddch_literal(WINDOW *win, NCURSES_CH_T ch) { int x; struct ldat *line; @@ -140,8 +129,12 @@ waddch_literal(WINDOW *win, chtype ch) CHANGED_CELL(line, x); line->text[x++] = ch; + if_WIDEC({ + if (wcwidth(CharOf(ch)) > 1) + AddAttr(line->text[x++], WA_NAC); + }); - TR(TRACE_VIRTPUT, ("(%d, %d) = %s", win->_cury, x, _tracechtype(ch))); + TR(TRACE_VIRTPUT, ("(%d, %d) = %s", win->_cury, x, _tracech_t(CHREF(ch)))); if (x > win->_maxx) { /* * The _WRAPPED flag is useful only for telling an application that @@ -169,15 +162,15 @@ waddch_literal(WINDOW *win, chtype ch) } static inline int -waddch_nosync(WINDOW *win, const chtype ch) +waddch_nosync(WINDOW *win, const NCURSES_CH_T ch) /* the workhorse function -- add a character to the given window */ { int x, y; chtype t = 0; const char *s = 0; - if ((ch & A_ALTCHARSET) - || ((t = TextOf(ch)) > 127) + if ((AttrOf(ch) & A_ALTCHARSET) + || ((t = CharOf(ch)) > 127) || ((s = unctrl(t))[1] == 0)) return waddch_literal(win, ch); @@ -194,7 +187,8 @@ waddch_nosync(WINDOW *win, const chtype ch) */ if ((!win->_scroll && (y == win->_regbottom)) || (x <= win->_maxx)) { - chtype blank = (' ' | AttrOf(ch)); + NCURSES_CH_T blank = NewChar2(BLANK_TEXT, BLANK_ATTR); + AddAttr(blank, AttrOf(ch)); while (win->_curx < x) { if (waddch_literal(win, blank) == ERR) return (ERR); @@ -236,9 +230,12 @@ waddch_nosync(WINDOW *win, const chtype ch) win->_flags &= ~_WRAPPED; break; default: - while (*s) - if (waddch_literal(win, (*s++) | AttrOf(ch)) == ERR) + while (*s) { + NCURSES_CH_T sch; + SetChar(sch, *s++, AttrOf(ch)); + if (waddch_literal(win, sch) == ERR) return ERR; + } return (OK); } @@ -249,8 +246,7 @@ waddch_nosync(WINDOW *win, const chtype ch) } NCURSES_EXPORT(int) -_nc_waddch_nosync -(WINDOW *win, const chtype c) +_nc_waddch_nosync(WINDOW *win, const NCURSES_CH_T c) /* export copy of waddch_nosync() so the string-put functions can use it */ { return (waddch_nosync(win, c)); @@ -265,15 +261,16 @@ _nc_waddch_nosync /* These are actual entry points */ NCURSES_EXPORT(int) -waddch -(WINDOW *win, const chtype ch) +waddch(WINDOW *win, const chtype ch) { int code = ERR; + NCURSES_CH_T wch; + SetChar2(wch, ch); TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("waddch(%p, %s)"), win, _tracechtype(ch))); - if (win && (waddch_nosync(win, ch) != ERR)) { + if (win && (waddch_nosync(win, wch) != ERR)) { _nc_synchook(win); code = OK; } @@ -283,15 +280,53 @@ waddch } NCURSES_EXPORT(int) -wechochar -(WINDOW *win, const chtype ch) +wechochar(WINDOW *win, const chtype ch) { int code = ERR; + NCURSES_CH_T wch; + SetChar2(wch, ch); TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"), win, _tracechtype(ch))); - if (win && (waddch_nosync(win, ch) != ERR)) { + if (win && (waddch_nosync(win, wch) != ERR)) { + bool save_immed = win->_immed; + win->_immed = TRUE; + _nc_synchook(win); + win->_immed = save_immed; + code = OK; + } + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); +} + +#if USE_WIDEC_SUPPORT +NCURSES_EXPORT(int) +wadd_wch(WINDOW *win, const cchar_t * wch) +{ + int code = ERR; + + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wadd_wch(%p, %s)"), win, + _tracech_t(wch))); + + if (win && (waddch_nosync(win, *wch) != ERR)) { + _nc_synchook(win); + code = OK; + } + + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); +} + +NCURSES_EXPORT(int) +wecho_wchar(WINDOW *win, const cchar_t * wch) +{ + int code = ERR; + + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wecho_wchar(%p, %s)"), win, + _tracech_t(wch))); + + if (win && (waddch_nosync(win, *wch) != ERR)) { bool save_immed = win->_immed; win->_immed = TRUE; _nc_synchook(win); @@ -301,3 +336,4 @@ wechochar TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); return (code); } +#endif /* USE_WIDEC_SUPPORT */ diff --git a/contrib/ncurses/ncurses/base/lib_addstr.c b/contrib/ncurses/ncurses/base/lib_addstr.c index 60bf944a44ed..343555a39aff 100644 --- a/contrib/ncurses/ncurses/base/lib_addstr.c +++ b/contrib/ncurses/ncurses/base/lib_addstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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,27 +40,69 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_addstr.c,v 1.19 2000/12/10 01:24:50 tom Exp $") +MODULE_ID("$Id: lib_addstr.c,v 1.31 2001/12/19 01:05:52 tom Exp $") + +#if USE_WIDEC_SUPPORT +#define CONV_DATA mbstate_t state; wchar_t cached; int clen = 0 +#define CONV_INIT memset (&state, '\0', sizeof (state)); cached = (wchar_t)WEOF +#define NEXT_CHAR(s,ch, n) \ + { \ + int len, i = 0; \ + memset(&ch, 0, sizeof(cchar_t)); \ + if (cached != (wchar_t) WEOF) { \ + ch.chars[i++] = cached; \ + cached = (wchar_t) WEOF; \ + n -= clen; \ + s += clen; \ + } \ + for (; i < CCHARW_MAX && n > 0; ++i) { \ + if ((len = mbrtowc(&ch.chars[i], s, n, &state)) < 0) { \ + code = ERR; \ + break; \ + } \ + if (i == 0 || wcwidth(ch.chars[i]) == 0) { \ + n -= len; \ + s += len; \ + } else { \ + cached = ch.chars[i]; \ + clen = len; \ + ch.chars[i] = L'\0'; \ + break; \ + } \ + } \ + if (code == ERR) \ + break; \ + } +#else +#define CONV_DATA +#define CONV_INIT +#define NEXT_CHAR(s,ch, n) \ + ch = *s++; \ + --n +#endif NCURSES_EXPORT(int) -waddnstr -(WINDOW *win, const char *const astr, int n) +waddnstr(WINDOW *win, const char *const astr, int n) { unsigned const char *str = (unsigned const char *) astr; int code = ERR; + CONV_DATA; T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbuf(astr), n)); if (win && (str != 0)) { TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs))); - TR(TRACE_VIRTPUT, ("str is not null")); code = OK; if (n < 0) n = (int) strlen(astr); - while ((n-- > 0) && (*str != '\0')) { + TR(TRACE_VIRTPUT, ("str is not null, length = %d", n)); + CONV_INIT; + while ((n > 0) && (*str != '\0')) { + NCURSES_CH_T ch; TR(TRACE_VIRTPUT, ("*str = %#x", *str)); - if (_nc_waddch_nosync(win, (chtype) * str++) == ERR) { + NEXT_CHAR(str, ch, n); + if (_nc_waddch_nosync(win, ch) == ERR) { code = ERR; break; } @@ -72,8 +114,7 @@ waddnstr } NCURSES_EXPORT(int) -waddchnstr -(WINDOW *win, const chtype * const astr, int n) +waddchnstr(WINDOW *win, const chtype * const astr, int n) { NCURSES_SIZE_T y = win->_cury; NCURSES_SIZE_T x = win->_curx; @@ -97,9 +138,116 @@ waddchnstr returnCode(code); line = &(win->_line[y]); +#if USE_WIDEC_SUPPORT + { + int i; + for (i = 0; i < n; ++i) + SetChar(line->text[i + x], ChCharOf(astr[i]), ChAttrOf(astr[i])); + } +#else memcpy(line->text + x, astr, n * sizeof(*astr)); +#endif CHANGED_RANGE(line, x, x + n - 1); _nc_synchook(win); returnCode(code); } + +#if USE_WIDEC_SUPPORT + +int +_nc_wchstrlen(const cchar_t * s) +{ + int result = 0; + while (CharOf(s[result]) != L'\0') { + result++; + } + return result; +} + +NCURSES_EXPORT(int) +wadd_wchnstr(WINDOW *win, const cchar_t * const astr, int n) +{ + NCURSES_SIZE_T y = win->_cury; + NCURSES_SIZE_T x = win->_curx; + int code = OK; + struct ldat *line; + int i, start, end; + + T((T_CALLED("wadd_wchnstr(%p,%s,%d)"), win, _nc_viscbuf(astr, n), n)); + + if (!win) + returnCode(ERR); + + if (n < 0) { + n = _nc_wchstrlen(astr); + } + if (n > win->_maxx - x + 1) + n = win->_maxx - x + 1; + if (n == 0) + returnCode(code); + + line = &(win->_line[y]); + start = x; + end = x + n - 1; + if (isnac(line->text[x])) { + line->text[x - 1] = win->_nc_bkgd; + --start; + } + for (i = 0; i < n && x <= win->_maxx; ++i) { + line->text[x++] = astr[i]; + if (wcwidth(CharOf(astr[i])) > 1) { + if (x <= win->_maxx) + AddAttr(line->text[x++], WA_NAC); + else + line->text[x - 1] = win->_nc_bkgd; + } + } + if (x <= win->_maxx && isnac(line->text[x])) { + line->text[x] = win->_nc_bkgd; + ++end; + } + CHANGED_RANGE(line, start, end); + + _nc_synchook(win); + returnCode(code); +} + +NCURSES_EXPORT(int) +waddnwstr(WINDOW *win, const wchar_t * str, int n) +{ + int code = ERR; + int i; + + T((T_CALLED("waddnwstr(%p,%s,%d)"), win, _nc_viswbuf(str), n)); + + if (win && (str != 0)) { + TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs))); + code = OK; + if (n < 0) + n = (int) wcslen(str); + + TR(TRACE_VIRTPUT, ("str is not null, length = %d", n)); + while ((n-- > 0) && (*str != L('\0'))) { + NCURSES_CH_T ch; + TR(TRACE_VIRTPUT, ("*str[0] = %#lx", *str)); + SetChar(ch, *str++, A_NORMAL); + i = 1; + while (i < CCHARW_MAX && n > 0 && (*str != L('\0')) + && wcwidth(*str) == 0) { + TR(TRACE_VIRTPUT, ("*str[%d] = %#lx", i, *str)); + ch.chars[i++] = *str++; + --n; + } + if (_nc_waddch_nosync(win, ch) == ERR) { + code = ERR; + break; + } + } + _nc_synchook(win); + } + TR(TRACE_VIRTPUT, ("waddnwstr returns %d", code)); + returnCode(code); +} + +#endif diff --git a/contrib/ncurses/ncurses/base/lib_bkgd.c b/contrib/ncurses/ncurses/base/lib_bkgd.c index 071924c56f1e..a3d7c306e29d 100644 --- a/contrib/ncurses/ncurses/base/lib_bkgd.c +++ b/contrib/ncurses/ncurses/base/lib_bkgd.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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 * @@ -33,51 +33,93 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_bkgd.c,v 1.14 2000/12/10 02:43:26 tom Exp $") +MODULE_ID("$Id: lib_bkgd.c,v 1.26 2001/12/19 01:36:58 tom Exp $") +/* + * Set the window's background information. + */ +#if USE_WIDEC_SUPPORT NCURSES_EXPORT(void) -wbkgdset(WINDOW *win, chtype ch) +#else +static inline void +#endif +wbkgrndset(WINDOW *win, const ARG_CH_T ch) { - T((T_CALLED("wbkgdset(%p,%s)"), win, _tracechtype(ch))); + T((T_CALLED("wbkgdset(%p,%s)"), win, _tracech_t(ch))); if (win) { - chtype off = AttrOf(win->_bkgd); - chtype on = AttrOf(ch); + attr_t off = AttrOf(win->_nc_bkgd); + attr_t on = AttrOf(CHDEREF(ch)); toggle_attr_off(win->_attrs, off); toggle_attr_on(win->_attrs, on); - if (TextOf(ch) == 0) - ch |= BLANK; - win->_bkgd = ch; + if (CharOf(CHDEREF(ch)) == L('\0')) + SetChar(win->_nc_bkgd, BLANK_TEXT, AttrOf(CHDEREF(ch))); + else + win->_nc_bkgd = CHDEREF(ch); +#if USE_WIDEC_SUPPORT + /* + * If we're compiled for wide-character support, _bkgrnd is the + * preferred location for the background information since it stores + * more than _bkgd. Update _bkgd each time we modify _bkgrnd, so the + * macro getbkgd() will work. + */ + { + cchar_t wch; + int tmp; + + wgetbkgrnd(win, &wch); + tmp = wctob(CharOf(wch)); + + win->_bkgd = ((tmp == EOF) ? ' ' : (chtype) tmp) | AttrOf(wch); + } +#endif } returnVoid; } +NCURSES_EXPORT(void) +wbkgdset(WINDOW *win, chtype ch) +{ + NCURSES_CH_T wch; + SetChar2(wch, ch); + wbkgrndset(win, CHREF(wch)); +} + +/* + * Set the window's background information and apply it to each cell. + */ +#if USE_WIDEC_SUPPORT NCURSES_EXPORT(int) -wbkgd(WINDOW *win, const chtype ch) +#else +static inline int +#undef wbkgrnd +#endif +wbkgrnd(WINDOW *win, const ARG_CH_T ch) { int code = ERR; int x, y; - chtype new_bkgd = ch; + NCURSES_CH_T new_bkgd = CHDEREF(ch); - T((T_CALLED("wbkgd(%p,%s)"), win, _tracechtype(new_bkgd))); + T((T_CALLED("wbkgd(%p,%s)"), win, _tracech_t(ch))); if (win) { - chtype old_bkgd = getbkgd(win); + NCURSES_CH_T old_bkgrnd; + wgetbkgrnd(win, &old_bkgrnd); - wbkgdset(win, new_bkgd); - wattrset(win, AttrOf(win->_bkgd)); + wbkgrndset(win, CHREF(new_bkgd)); + wattrset(win, AttrOf(win->_nc_bkgd)); for (y = 0; y <= win->_maxy; y++) { for (x = 0; x <= win->_maxx; x++) { - if (win->_line[y].text[x] == old_bkgd) - win->_line[y].text[x] = win->_bkgd; - else - win->_line[y].text[x] = - _nc_render(win, (A_ALTCHARSET & - AttrOf(win->_line[y].text[x])) - | TextOf(win->_line[y].text[x])); + if (CharEq(win->_line[y].text[x], old_bkgrnd)) + win->_line[y].text[x] = win->_nc_bkgd; + else { + NCURSES_CH_T wch = win->_line[y].text[x]; + RemAttr(wch, ~A_ALTCHARSET); + win->_line[y].text[x] = _nc_render(win, wch); + } } } touchwin(win); @@ -86,3 +128,11 @@ wbkgd(WINDOW *win, const chtype ch) } returnCode(code); } + +NCURSES_EXPORT(int) +wbkgd(WINDOW *win, const chtype ch) +{ + NCURSES_CH_T wch; + SetChar2(wch, ch); + return wbkgrnd(win, CHREF(wch)); +} diff --git a/contrib/ncurses/ncurses/base/lib_box.c b/contrib/ncurses/ncurses/base/lib_box.c index d018fd89b09a..7181edb3ed34 100644 --- a/contrib/ncurses/ncurses/base/lib_box.c +++ b/contrib/ncurses/ncurses/base/lib_box.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001,2002 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,16 +40,18 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_box.c,v 1.13 2000/12/10 02:43:26 tom Exp $") +MODULE_ID("$Id: lib_box.c,v 1.18 2002/02/23 20:40:06 tom Exp $") NCURSES_EXPORT(int) -wborder -(WINDOW *win, - chtype ls, chtype rs, chtype ts, chtype bs, - chtype tl, chtype tr, chtype bl, chtype br) +wborder(WINDOW *win, + chtype ls, chtype rs, + chtype ts, chtype bs, + chtype tl, chtype tr, + chtype bl, chtype br) { NCURSES_SIZE_T i; NCURSES_SIZE_T endx, endy; + chtype wls, wrs, wts, wbs, wtl, wtr, wbl, wbr; T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"), win, @@ -65,55 +67,47 @@ wborder if (!win) returnCode(ERR); - if (ls == 0) - ls = ACS_VLINE; - if (rs == 0) - rs = ACS_VLINE; - if (ts == 0) - ts = ACS_HLINE; - if (bs == 0) - bs = ACS_HLINE; - if (tl == 0) - tl = ACS_ULCORNER; - if (tr == 0) - tr = ACS_URCORNER; - if (bl == 0) - bl = ACS_LLCORNER; - if (br == 0) - br = ACS_LRCORNER; +#define RENDER_WITH_DEFAULT(ch,def) w ## ch = (ch == 0) ? def : ch - ls = _nc_render(win, ls); - rs = _nc_render(win, rs); - ts = _nc_render(win, ts); - bs = _nc_render(win, bs); - tl = _nc_render(win, tl); - tr = _nc_render(win, tr); - bl = _nc_render(win, bl); - br = _nc_render(win, br); + RENDER_WITH_DEFAULT(ls, ACS_VLINE); + RENDER_WITH_DEFAULT(rs, ACS_VLINE); + RENDER_WITH_DEFAULT(ts, ACS_HLINE); + RENDER_WITH_DEFAULT(bs, ACS_HLINE); + RENDER_WITH_DEFAULT(tl, ACS_ULCORNER); + RENDER_WITH_DEFAULT(tr, ACS_URCORNER); + RENDER_WITH_DEFAULT(bl, ACS_LLCORNER); + RENDER_WITH_DEFAULT(br, ACS_LRCORNER); - T(("using %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx", - ls, rs, ts, bs, tl, tr, bl, br)); + T(("using %s, %s, %s, %s, %s, %s, %s, %s", + _tracechtype2(1, wls), + _tracechtype2(2, wrs), + _tracechtype2(3, wts), + _tracechtype2(4, wbs), + _tracechtype2(5, wtl), + _tracechtype2(6, wtr), + _tracechtype2(7, wbl), + _tracechtype2(8, wbr))); endx = win->_maxx; endy = win->_maxy; for (i = 0; i <= endx; i++) { - win->_line[0].text[i] = ts; - win->_line[endy].text[i] = bs; + SetChar(win->_line[0].text[i], ChCharOf(wts), ChAttrOf(wts)); + SetChar(win->_line[endy].text[i], ChCharOf(wbs), ChAttrOf(wbs)); } win->_line[endy].firstchar = win->_line[0].firstchar = 0; win->_line[endy].lastchar = win->_line[0].lastchar = endx; for (i = 0; i <= endy; i++) { - win->_line[i].text[0] = ls; - win->_line[i].text[endx] = rs; + SetChar(win->_line[i].text[0], ChCharOf(wls), ChAttrOf(wls)); + SetChar(win->_line[i].text[endx], ChCharOf(wrs), ChAttrOf(wrs)); win->_line[i].firstchar = 0; win->_line[i].lastchar = endx; } - win->_line[0].text[0] = tl; - win->_line[0].text[endx] = tr; - win->_line[endy].text[0] = bl; - win->_line[endy].text[endx] = br; + SetChar(win->_line[0].text[0], ChCharOf(wtl), ChAttrOf(wtl)); + SetChar(win->_line[0].text[endx], ChCharOf(wtr), ChAttrOf(wtr)); + SetChar(win->_line[endy].text[0], ChCharOf(wbl), ChAttrOf(wbl)); + SetChar(win->_line[endy].text[endx], ChCharOf(wbr), ChAttrOf(wbr)); _nc_synchook(win); returnCode(OK); diff --git a/contrib/ncurses/ncurses/base/lib_chgat.c b/contrib/ncurses/ncurses/base/lib_chgat.c index 66c6a09b63f9..54e66ed1ffae 100644 --- a/contrib/ncurses/ncurses/base/lib_chgat.c +++ b/contrib/ncurses/ncurses/base/lib_chgat.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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> -MODULE_ID("$Id: lib_chgat.c,v 1.4 2000/12/10 02:43:26 tom Exp $") +MODULE_ID("$Id: lib_chgat.c,v 1.5 2001/06/03 00:05:02 skimo Exp $") NCURSES_EXPORT(int) wchgat @@ -54,8 +54,7 @@ wchgat toggle_attr_on(attr, COLOR_PAIR(color)); for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++) - win->_line[win->_cury].text[i] - = TextOf(win->_line[win->_cury].text[i]) | attr; + SetAttr(win->_line[win->_cury].text[i], attr); returnCode(OK); } else diff --git a/contrib/ncurses/ncurses/base/lib_clrbot.c b/contrib/ncurses/ncurses/base/lib_clrbot.c index 805e7c29093d..bc12960e48f0 100644 --- a/contrib/ncurses/ncurses/base/lib_clrbot.c +++ b/contrib/ncurses/ncurses/base/lib_clrbot.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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> -MODULE_ID("$Id: lib_clrbot.c,v 1.17 2000/12/10 02:43:26 tom Exp $") +MODULE_ID("$Id: lib_clrbot.c,v 1.19 2001/12/19 01:05:59 tom Exp $") NCURSES_EXPORT(int) wclrtobot(WINDOW *win) @@ -52,15 +52,15 @@ wclrtobot(WINDOW *win) if (win) { NCURSES_SIZE_T y; NCURSES_SIZE_T startx = win->_curx; - chtype blank = _nc_background(win); + NCURSES_CH_T blank = win->_nc_bkgd; T(("clearing from y = %d to y = %d with maxx = %d", win->_cury, win->_maxy, win->_maxx)); for (y = win->_cury; y <= win->_maxy; y++) { struct ldat *line = &(win->_line[y]); - chtype *ptr = &(line->text[startx]); - chtype *end = &(line->text[win->_maxx]); + NCURSES_CH_T *ptr = &(line->text[startx]); + NCURSES_CH_T *end = &(line->text[win->_maxx]); CHANGED_TO_EOL(line, startx, win->_maxx); diff --git a/contrib/ncurses/ncurses/base/lib_clreol.c b/contrib/ncurses/ncurses/base/lib_clreol.c index fa0afe4ec502..c46ebd93a332 100644 --- a/contrib/ncurses/ncurses/base/lib_clreol.c +++ b/contrib/ncurses/ncurses/base/lib_clreol.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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> -MODULE_ID("$Id: lib_clreol.c,v 1.19 2000/12/10 02:43:26 tom Exp $") +MODULE_ID("$Id: lib_clreol.c,v 1.21 2001/12/19 01:06:04 tom Exp $") NCURSES_EXPORT(int) wclrtoeol(WINDOW *win) @@ -50,8 +50,8 @@ wclrtoeol(WINDOW *win) T((T_CALLED("wclrtoeol(%p)"), win)); if (win) { - chtype blank; - chtype *ptr, *end; + NCURSES_CH_T blank; + NCURSES_CH_T *ptr, *end; struct ldat *line; NCURSES_SIZE_T y = win->_cury; NCURSES_SIZE_T x = win->_curx; @@ -74,7 +74,7 @@ wclrtoeol(WINDOW *win) || x > win->_maxx) returnCode(ERR); - blank = _nc_background(win); + blank = win->_nc_bkgd; line = &win->_line[y]; CHANGED_TO_EOL(line, x, win->_maxx); diff --git a/contrib/ncurses/ncurses/base/lib_color.c b/contrib/ncurses/ncurses/base/lib_color.c index 1fa573271ab9..42d301d5e9ad 100644 --- a/contrib/ncurses/ncurses/base/lib_color.c +++ b/contrib/ncurses/ncurses/base/lib_color.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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,17 +41,15 @@ #include <term.h> #include <tic.h> -MODULE_ID("$Id: lib_color.c,v 1.55 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_color.c,v 1.58 2001/09/01 21:42:59 tom Exp $") /* * These should be screen structure members. They need to be globals for * historical reasons. So we assign them in start_color() and also in * set_term()'s screen-switching logic. */ -NCURSES_EXPORT_VAR(int) -COLOR_PAIRS = 0; -NCURSES_EXPORT_VAR(int) -COLORS = 0; +NCURSES_EXPORT_VAR(int) COLOR_PAIRS = 0; +NCURSES_EXPORT_VAR(int) COLORS = 0; /* * Given a RGB range of 0..1000, we'll normally set the individual values @@ -92,8 +90,8 @@ static const color_t hls_palette[] = * These are called from _nc_do_color(), which in turn is called from * vidattr - so we have to assume that SP may be null. */ - static int - default_fg(void) +static int +default_fg(void) { return (SP != 0) ? SP->_default_fg : COLOR_WHITE; } @@ -113,8 +111,8 @@ default_bg(void) * to maintain compatibility with a pre-ANSI scheme. The same scheme is * also used in the FreeBSD syscons. */ - static int - toggled_colors(int c) +static int +toggled_colors(int c) { if (c < 16) { static const int table[] = @@ -259,8 +257,7 @@ rgb2hls(short r, short g, short b, short *h, short *l, short *s) * values. */ NCURSES_EXPORT(int) -init_pair -(short pair, short f, short b) +init_pair(short pair, short f, short b) { unsigned result; @@ -302,10 +299,10 @@ init_pair struct ldat *ptr = &(curscr->_line[y]); bool changed = FALSE; for (x = 0; x <= curscr->_maxx; x++) { - if ((ptr->text[x] & A_COLOR) == z) { + if ((AttrOf(ptr->text[x]) & A_COLOR) == z) { /* Set the old cell to zero to ensure it will be updated on the next doupdate() */ - ptr->text[x] = 0; + SetChar(ptr->text[x], 0, 0); CHANGED_CELL(ptr, x); changed = TRUE; } @@ -339,8 +336,7 @@ init_pair } NCURSES_EXPORT(int) -init_color -(short color, short r, short g, short b) +init_color(short color, short r, short g, short b) { T((T_CALLED("init_color(%d,%d,%d,%d)"), color, r, g, b)); @@ -390,8 +386,7 @@ has_colors(void) } NCURSES_EXPORT(int) -color_content -(short color, short *r, short *g, short *b) +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) @@ -407,8 +402,7 @@ color_content } NCURSES_EXPORT(int) -pair_content -(short pair, short *f, short *b) +pair_content(short pair, short *f, short *b) { T((T_CALLED("pair_content(%d,%p,%p)"), pair, f, b)); @@ -423,8 +417,7 @@ pair_content } NCURSES_EXPORT(void) -_nc_do_color -(int old_pair, int pair, bool reverse, int (*outc) (int)) +_nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int)) { NCURSES_COLOR_T fg = C_MASK, bg = C_MASK; NCURSES_COLOR_T old_fg, old_bg; diff --git a/contrib/ncurses/ncurses/base/lib_delch.c b/contrib/ncurses/ncurses/base/lib_delch.c index 918e22534f0d..0c30f2d93c1b 100644 --- a/contrib/ncurses/ncurses/base/lib_delch.c +++ b/contrib/ncurses/ncurses/base/lib_delch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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> -MODULE_ID("$Id: lib_delch.c,v 1.10 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_delch.c,v 1.12 2001/12/19 01:06:09 tom Exp $") NCURSES_EXPORT(int) wdelch(WINDOW *win) @@ -50,11 +50,11 @@ wdelch(WINDOW *win) T((T_CALLED("wdelch(%p)"), win)); if (win) { - chtype blank = _nc_background(win); + NCURSES_CH_T blank = win->_nc_bkgd; struct ldat *line = &(win->_line[win->_cury]); - chtype *end = &(line->text[win->_maxx]); - chtype *temp2 = &(line->text[win->_curx + 1]); - chtype *temp1 = temp2 - 1; + NCURSES_CH_T *end = &(line->text[win->_maxx]); + NCURSES_CH_T *temp2 = &(line->text[win->_curx + 1]); + NCURSES_CH_T *temp1 = temp2 - 1; CHANGED_TO_EOL(line, win->_curx, win->_maxx); while (temp1 < end) diff --git a/contrib/ncurses/ncurses/base/lib_delwin.c b/contrib/ncurses/ncurses/base/lib_delwin.c index 7c5686952319..89d8e7c32ece 100644 --- a/contrib/ncurses/ncurses/base/lib_delwin.c +++ b/contrib/ncurses/ncurses/base/lib_delwin.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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> -MODULE_ID("$Id: lib_delwin.c,v 1.12 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_delwin.c,v 1.13 2001/08/26 00:40:20 tom Exp $") static bool cannot_delete(WINDOW *win) @@ -49,10 +49,10 @@ cannot_delete(WINDOW *win) bool result = TRUE; for (p = _nc_windows; p != 0; p = p->next) { - if (p->win == win) { + if (&(p->win) == win) { result = FALSE; - } else if ((p->win->_flags & _SUBWIN) != 0 - && p->win->_parent == win) { + } else if ((p->win._flags & _SUBWIN) != 0 + && p->win._parent == win) { result = TRUE; break; } diff --git a/contrib/ncurses/ncurses/base/lib_erase.c b/contrib/ncurses/ncurses/base/lib_erase.c index 87673b7a81f4..5e397312ffe3 100644 --- a/contrib/ncurses/ncurses/base/lib_erase.c +++ b/contrib/ncurses/ncurses/base/lib_erase.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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,20 +40,20 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_erase.c,v 1.13 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_erase.c,v 1.15 2001/12/19 01:06:13 tom Exp $") NCURSES_EXPORT(int) werase(WINDOW *win) { int code = ERR; int y; - chtype blank; - chtype *sp, *end, *start; + NCURSES_CH_T blank; + NCURSES_CH_T *sp, *end, *start; T((T_CALLED("werase(%p)"), win)); if (win) { - blank = _nc_background(win); + blank = win->_nc_bkgd; for (y = 0; y <= win->_maxy; y++) { start = win->_line[y].text; end = &start[win->_maxx]; diff --git a/contrib/ncurses/ncurses/base/lib_freeall.c b/contrib/ncurses/ncurses/base/lib_freeall.c index bbd8c0ed7cb2..2063c6fa593e 100644 --- a/contrib/ncurses/ncurses/base/lib_freeall.c +++ b/contrib/ncurses/ncurses/base/lib_freeall.c @@ -39,7 +39,7 @@ extern int malloc_errfd; /* FIXME */ #endif -MODULE_ID("$Id: lib_freeall.c,v 1.18 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_freeall.c,v 1.19 2001/09/15 21:32:48 tom Exp $") static void free_slk(SLK * p) @@ -85,15 +85,15 @@ _nc_freeall(void) for (q = _nc_windows; q != 0; q = q->next) { if ((p != q) - && (q->win->_flags & _SUBWIN) - && (p->win == q->win->_parent)) { + && (q->win._flags & _SUBWIN) + && (&(p->win) == q->win._parent)) { found = TRUE; break; } } if (!found) { - delwin(p->win); + delwin(&(p->win)); break; } } @@ -104,6 +104,9 @@ _nc_freeall(void) free_slk(SP->_slk); FreeIfNeeded(SP->_color_pairs); FreeIfNeeded(SP->_color_table); + FreeIfNeeded(SP->oldhash); + FreeIfNeeded(SP->newhash); + FreeIfNeeded(SP->hashtab); #if !BROKEN_LINKER FreeAndNull(SP); #endif diff --git a/contrib/ncurses/ncurses/base/lib_getch.c b/contrib/ncurses/ncurses/base/lib_getch.c index 9deafec57a43..f4ecbdafe2ae 100644 --- a/contrib/ncurses/ncurses/base/lib_getch.c +++ b/contrib/ncurses/ncurses/base/lib_getch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2001,2002 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,15 +40,15 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_getch.c,v 1.54 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_getch.c,v 1.60 2002/03/17 00:46:01 tom Exp $") #include <fifo_defs.h> NCURSES_EXPORT_VAR(int) ESCDELAY = 1000; /* max interval betw. chars in funkeys, in millisecs */ - static inline int - fifo_peek(void) +static inline int +fifo_peek(void) { int ch = SP->_fifo[peek]; TR(TRACE_IEVENT, ("peeking at %d", peek)); @@ -62,7 +62,7 @@ fifo_pull(void) { int ch; ch = SP->_fifo[head]; - TR(TRACE_IEVENT, ("pulling %d from %d", ch, head)); + TR(TRACE_IEVENT, ("pulling %s from %d", _tracechar(ch), head)); if (peek == head) { h_inc(); @@ -102,7 +102,7 @@ fifo_push(void) { unsigned char c2 = 0; n = read(SP->_ifd, &c2, 1); - ch = CharOf(c2); + ch = c2; } #ifdef HIDE_EINTR @@ -130,7 +130,7 @@ fifo_push(void) if (head == -1) head = peek = tail; t_inc(); - TR(TRACE_IEVENT, ("pushed %#x at %d", ch, tail)); + TR(TRACE_IEVENT, ("pushed %s at %d", _tracechar(ch), tail)); #ifdef TRACE if (_nc_tracing & TRACE_IEVENT) _nc_fifo_dump(); @@ -141,26 +141,25 @@ fifo_push(void) static inline void fifo_clear(void) { - int i; - for (i = 0; i < FIFO_SIZE; i++) - SP->_fifo[i] = 0; + memset(SP->_fifo, 0, sizeof(SP->_fifo)); head = -1; tail = peek = 0; } -static int kgetch(WINDOW *); +static int kgetch(void); #define wgetch_should_refresh(win) (\ (is_wintouched(win) || (win->_flags & _HASMOVED)) \ && !(win->_flags & _ISPAD)) NCURSES_EXPORT(int) -wgetch(WINDOW *win) +_nc_wgetch(WINDOW *win, unsigned long *result, int use_meta) { int ch; T((T_CALLED("wgetch(%p)"), win)); + *result = 0; if (!win) returnCode(ERR); @@ -168,9 +167,8 @@ wgetch(WINDOW *win) if (wgetch_should_refresh(win)) wrefresh(win); - ch = fifo_pull(); - T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch))); - returnCode(ch); + *result = fifo_pull(); + returnCode(OK); } /* @@ -190,9 +188,13 @@ wgetch(WINDOW *win) for (sp = buf + strlen(buf); sp > buf; sp--) ungetch(sp[-1]); - returnCode(fifo_pull()); + *result = fifo_pull(); + returnCode(OK); } + if (win->_use_keypad != SP->_keypad_on) + _nc_keypad(win->_use_keypad); + if (wgetch_should_refresh(win)) wrefresh(win); @@ -228,12 +230,14 @@ wgetch(WINDOW *win) int runcount = 0; do { - ch = kgetch(win); + ch = kgetch(); if (ch == KEY_MOUSE) { ++runcount; if (SP->_mouse_inline(SP)) break; } + if (SP->_maxclick < 0) + break; } while (ch == KEY_MOUSE && (_nc_timed_wait(3, SP->_maxclick, (int *) 0) @@ -255,13 +259,11 @@ wgetch(WINDOW *win) _nc_update_screensize(); /* resizeterm can push KEY_RESIZE */ if (cooked_key_in_fifo()) { - ch = fifo_pull(); - T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch))); - returnCode(ch); + *result = fifo_pull(); + returnCode(OK); } } #endif - T(("wgetch returning ERR")); returnCode(ERR); } @@ -300,13 +302,27 @@ wgetch(WINDOW *win) * that display only 7-bit characters. Note that 'ch' may be a * function key at this point, so we mustn't strip _those_. */ - if ((ch < KEY_MIN) && (ch & 0x80)) - if (!SP->_use_meta) + if (!use_meta) + if ((ch < KEY_MIN) && (ch & 0x80)) ch &= 0x7f; - T(("wgetch returning : %#x = %s", ch, _trace_key(ch))); + T(("wgetch returning : %s", _tracechar(ch))); + + *result = ch; + returnCode(ch >= KEY_MIN ? KEY_CODE_YES : OK); +} + +NCURSES_EXPORT(int) +wgetch(WINDOW *win) +{ + int code; + unsigned long value; - returnCode(ch); + T((T_CALLED("wgetch(%p)"), win)); + code = _nc_wgetch(win, &value, SP->_use_meta); + if (code != ERR) + code = value; + returnCode(code); } /* @@ -319,19 +335,19 @@ wgetch(WINDOW *win) ** sequence is received by the time the alarm goes off, pass through ** the sequence gotten so far. ** -** This function must be called when there is no cooked keys in queue. +** This function must be called when there are no cooked keys in queue. ** (that is head==-1 || peek==head) ** */ static int -kgetch(WINDOW *win GCC_UNUSED) +kgetch(void) { struct tries *ptr; int ch = 0; int timeleft = ESCDELAY; - TR(TRACE_IEVENT, ("kgetch(%p) called", win)); + TR(TRACE_IEVENT, ("kgetch() called")); ptr = SP->_keytry; @@ -350,19 +366,16 @@ kgetch(WINDOW *win GCC_UNUSED) return ch; } - TR(TRACE_IEVENT, ("ch: %s", _trace_key((unsigned char) ch))); + TR(TRACE_IEVENT, ("ch: %s", _tracechar((unsigned char) ch))); while ((ptr != NULL) && (ptr->ch != (unsigned char) ch)) ptr = ptr->sibling; -#ifdef TRACE + if (ptr == NULL) { TR(TRACE_IEVENT, ("ptr is null")); - } else - TR(TRACE_IEVENT, ("ptr=%p, ch=%d, value=%d", - ptr, ptr->ch, ptr->value)); -#endif /* TRACE */ - - if (ptr == NULL) break; + } + TR(TRACE_IEVENT, ("ptr=%p, ch=%d, value=%d", + ptr, ptr->ch, ptr->value)); if (ptr->value != 0) { /* sequence terminated */ TR(TRACE_IEVENT, ("end of sequence")); diff --git a/contrib/ncurses/ncurses/base/lib_hline.c b/contrib/ncurses/ncurses/base/lib_hline.c index 72d1ddba90fd..2cb6cc5ce6fd 100644 --- a/contrib/ncurses/ncurses/base/lib_hline.c +++ b/contrib/ncurses/ncurses/base/lib_hline.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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> -MODULE_ID("$Id: lib_hline.c,v 1.8 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_hline.c,v 1.10 2001/06/03 00:39:24 skimo Exp $") NCURSES_EXPORT(int) whline(WINDOW *win, chtype ch, int n) @@ -53,6 +53,7 @@ whline(WINDOW *win, chtype ch, int n) if (win) { struct ldat *line = &(win->_line[win->_cury]); + NCURSES_CH_T wch; start = win->_curx; end = start + n - 1; @@ -62,11 +63,13 @@ whline(WINDOW *win, chtype ch, int n) CHANGED_RANGE(line, start, end); if (ch == 0) - ch = ACS_HLINE; - ch = _nc_render(win, ch); + SetChar(wch, ChCharOf(ACS_HLINE), ChAttrOf(ACS_HLINE)); + else + SetChar(wch, ChCharOf(ch), ChAttrOf(ch)); + wch = _nc_render(win, wch); while (end >= start) { - line->text[end] = ch; + line->text[end] = wch; end--; } diff --git a/contrib/ncurses/ncurses/base/lib_inchstr.c b/contrib/ncurses/ncurses/base/lib_inchstr.c index 31625bbf4cdf..6ff01687826e 100644 --- a/contrib/ncurses/ncurses/base/lib_inchstr.c +++ b/contrib/ncurses/ncurses/base/lib_inchstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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> -MODULE_ID("$Id: lib_inchstr.c,v 1.9 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_inchstr.c,v 1.10 2001/06/02 23:37:58 skimo Exp $") NCURSES_EXPORT(int) winchnstr(WINDOW *win, chtype * str, int n) @@ -54,7 +54,9 @@ winchnstr(WINDOW *win, chtype * str, int n) if (win) { for (; (n < 0 || (i < n)) && (win->_curx + i <= win->_maxx); i++) - str[i] = win->_line[win->_cury].text[win->_curx + i]; + str[i] = + CharOf(win->_line[win->_cury].text[win->_curx + i]) | + AttrOf(win->_line[win->_cury].text[win->_curx + i]); } str[i] = (chtype) 0; diff --git a/contrib/ncurses/ncurses/base/lib_initscr.c b/contrib/ncurses/ncurses/base/lib_initscr.c index b6e34ef91a26..832da742f47b 100644 --- a/contrib/ncurses/ncurses/base/lib_initscr.c +++ b/contrib/ncurses/ncurses/base/lib_initscr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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 <sys/termio.h> /* needed for ISC */ #endif -MODULE_ID("$Id: lib_initscr.c,v 1.28 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_initscr.c,v 1.29 2001/08/26 01:05:05 tom Exp $") NCURSES_EXPORT(WINDOW *) initscr(void) @@ -53,6 +53,12 @@ initscr(void) static bool initialized = FALSE; NCURSES_CONST char *name; int value; +#ifdef TRACE + int t = _nc_getenv_num("NCURSES_TRACE"); + + if (t >= 0) + trace(t); +#endif T((T_CALLED("initscr()"))); /* Portable applications must not call initscr() more than once */ diff --git a/contrib/ncurses/ncurses/base/lib_insch.c b/contrib/ncurses/ncurses/base/lib_insch.c index 8d495f5bc4e8..c3671e5d235b 100644 --- a/contrib/ncurses/ncurses/base/lib_insch.c +++ b/contrib/ncurses/ncurses/base/lib_insch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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> -MODULE_ID("$Id: lib_insch.c,v 1.12 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_insch.c,v 1.15 2001/06/09 23:47:38 skimo Exp $") NCURSES_EXPORT(int) winsch(WINDOW *win, chtype c) @@ -51,15 +51,17 @@ winsch(WINDOW *win, chtype c) if (win) { struct ldat *line = &(win->_line[win->_cury]); - chtype *end = &(line->text[win->_curx]); - chtype *temp1 = &(line->text[win->_maxx]); - chtype *temp2 = temp1 - 1; + NCURSES_CH_T *end = &(line->text[win->_curx]); + NCURSES_CH_T *temp1 = &(line->text[win->_maxx]); + NCURSES_CH_T *temp2 = temp1 - 1; + NCURSES_CH_T wch; + SetChar2(wch, c); CHANGED_TO_EOL(line, win->_curx, win->_maxx); while (temp1 > end) *temp1-- = *temp2--; - *temp1 = _nc_render(win, c); + *temp1 = _nc_render(win, wch); code = OK; } returnCode(code); diff --git a/contrib/ncurses/ncurses/base/lib_insdel.c b/contrib/ncurses/ncurses/base/lib_insdel.c index 1a23a86b1e4c..432bcace9e6a 100644 --- a/contrib/ncurses/ncurses/base/lib_insdel.c +++ b/contrib/ncurses/ncurses/base/lib_insdel.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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,7 +42,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_insdel.c,v 1.10 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_insdel.c,v 1.11 2001/12/19 01:10:49 tom Exp $") NCURSES_EXPORT(int) winsdelln(WINDOW *win, int n) @@ -54,7 +54,7 @@ winsdelln(WINDOW *win, int n) if (win) { if (n != 0) { _nc_scroll_window(win, -n, win->_cury, win->_maxy, - _nc_background(win)); + win->_nc_bkgd); _nc_synchook(win); } code = OK; diff --git a/contrib/ncurses/ncurses/base/lib_insstr.c b/contrib/ncurses/ncurses/base/lib_insstr.c index f4c215d7103d..a16ab13e4d88 100644 --- a/contrib/ncurses/ncurses/base/lib_insstr.c +++ b/contrib/ncurses/ncurses/base/lib_insstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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 <ctype.h> -MODULE_ID("$Id: lib_insstr.c,v 1.17 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_insstr.c,v 1.19 2001/06/09 23:43:02 skimo Exp $") NCURSES_EXPORT(int) winsnstr(WINDOW *win, const char *s, int n) @@ -58,9 +58,11 @@ winsnstr(WINDOW *win, const char *s, int n) oy = win->_cury; ox = win->_curx; for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) { - if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b') - _nc_waddch_nosync(win, (chtype) (*cp)); - else if (is7bits(*cp) && iscntrl(*cp)) { + if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b') { + NCURSES_CH_T wch; + SetChar2(wch, *cp); + _nc_waddch_nosync(win, wch); + } else if (is7bits(*cp) && iscntrl(*cp)) { winsch(win, ' ' + (chtype) (*cp)); winsch(win, (chtype) '^'); win->_curx += 2; diff --git a/contrib/ncurses/ncurses/base/lib_instr.c b/contrib/ncurses/ncurses/base/lib_instr.c index 588f6c47d2b8..3eaf9892b45b 100644 --- a/contrib/ncurses/ncurses/base/lib_instr.c +++ b/contrib/ncurses/ncurses/base/lib_instr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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> -MODULE_ID("$Id: lib_instr.c,v 1.10 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_instr.c,v 1.11 2001/06/02 23:42:06 skimo Exp $") NCURSES_EXPORT(int) winnstr(WINDOW *win, char *str, int n) @@ -59,7 +59,7 @@ winnstr(WINDOW *win, char *str, int n) n = win->_maxx - win->_curx + 1; for (; i < n;) { - str[i++] = TextOf(win->_line[row].text[col]); + str[i++] = CharOf(win->_line[row].text[col]); if (++col > win->_maxx) { col = 0; if (++row > win->_maxy) diff --git a/contrib/ncurses/ncurses/base/lib_mouse.c b/contrib/ncurses/ncurses/base/lib_mouse.c index 01d3057f03ab..69af58d5fe24 100644 --- a/contrib/ncurses/ncurses/base/lib_mouse.c +++ b/contrib/ncurses/ncurses/base/lib_mouse.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2002 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 * @@ -84,7 +84,7 @@ #endif #endif -MODULE_ID("$Id: lib_mouse.c,v 1.57 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_mouse.c,v 1.58 2002/01/12 22:38:07 tom Exp $") #define MY_TRACE TRACE_ICALLS|TRACE_IEVENT @@ -655,7 +655,7 @@ _nc_mouse_parse(int runcount) /* first pass; merge press/release pairs */ do { merge = FALSE; - for (ep = runp; next = NEXT(ep), next != eventp; ep = next) { + for (ep = runp; (next = NEXT(ep)) != eventp; ep = next) { if (ep->x == next->x && ep->y == next->y && (ep->bstate & (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED)) && (!(ep->bstate & BUTTON1_PRESSED) @@ -720,7 +720,7 @@ _nc_mouse_parse(int runcount) MEVENT *follower; merge = FALSE; - for (ep = runp; next = NEXT(ep), next != eventp; ep = next) + for (ep = runp; (next = NEXT(ep)) != eventp; ep = next) if (ep->id != INVALID_EVENT) { if (next->id != INVALID_EVENT) continue; diff --git a/contrib/ncurses/ncurses/base/lib_mvwin.c b/contrib/ncurses/ncurses/base/lib_mvwin.c index 28b78f86842c..63d54ccda574 100644 --- a/contrib/ncurses/ncurses/base/lib_mvwin.c +++ b/contrib/ncurses/ncurses/base/lib_mvwin.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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> -MODULE_ID("$Id: lib_mvwin.c,v 1.9 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_mvwin.c,v 1.12 2001/12/19 01:06:22 tom Exp $") NCURSES_EXPORT(int) mvwin(WINDOW *win, int by, int bx) @@ -69,7 +69,8 @@ mvwin(WINDOW *win, int by, int bx) /* now we have the clone, so relocate win */ werase(win); /* Erase the original place */ - wbkgd(win, parent->_bkgd); /* fill with parents background */ + /* fill with parents background */ + wbkgrnd(win, CHREF(parent->_nc_bkgd)); wsyncup(win); /* Tell the parent(s) */ err = mvderwin(win, diff --git a/contrib/ncurses/ncurses/base/lib_newterm.c b/contrib/ncurses/ncurses/base/lib_newterm.c index 02f6ff5b449a..d95c4a9575c8 100644 --- a/contrib/ncurses/ncurses/base/lib_newterm.c +++ b/contrib/ncurses/ncurses/base/lib_newterm.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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 * @@ -47,7 +47,7 @@ #include <term.h> /* clear_screen, cup & friends, cur_term */ #include <tic.h> -MODULE_ID("$Id: lib_newterm.c,v 1.50 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_newterm.c,v 1.52 2001/08/04 16:47:48 tom Exp $") #ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */ #define ONLCR 0 @@ -89,7 +89,9 @@ static int filter_mode = FALSE; NCURSES_EXPORT(void) filter(void) { + T((T_CALLED("filter"))); filter_mode = TRUE; + returnVoid; } NCURSES_EXPORT(SCREEN *) @@ -110,7 +112,7 @@ newterm /* this loads the capability entry, then sets LINES and COLS */ if (setupterm(name, fileno(ofp), &errret) == ERR) - return 0; + returnSP(0); /* implement filter mode */ if (filter_mode) { @@ -140,7 +142,7 @@ newterm if (slk_format) { if (ERR == _nc_ripoffline(-SLK_LINES(slk_format), _nc_slk_initialize)) - return 0; + returnSP(0); } /* this actually allocates the screen structure, and saves the * original terminal settings. @@ -149,7 +151,7 @@ newterm _nc_set_screen(0); if (_nc_setupscreen(LINES, COLS, ofp) == ERR) { _nc_set_screen(current); - return 0; + returnSP(0); } /* if the terminal type has real soft labels, set those up */ @@ -192,26 +194,6 @@ newterm SP->_use_rmso = SGR0_TEST(exit_standout_mode); SP->_use_rmul = SGR0_TEST(exit_underline_mode); -#if USE_WIDEC_SUPPORT - /* - * XFree86 xterm can be configured to support UTF-8 based on environment - * variable settings. - */ - { - char *s; - s = getenv("LC_ALL"); - if (s == NULL || *s == '\0') { - s = getenv("LC_CTYPE"); - if (s == NULL || *s == '\0') { - s = getenv("LANG"); - } - } - if (s != NULL && *s != '\0' && strstr(s, "UTF-8") != NULL) { - SP->_outch = _nc_utf8_outch; - } - } -#endif - /* compute movement costs so we can do better move optimization */ _nc_mvcur_init(); @@ -223,6 +205,5 @@ newterm _nc_signal_handler(TRUE); - T((T_RETURN("%p"), SP)); - return (SP); + returnSP(SP); } diff --git a/contrib/ncurses/ncurses/base/lib_newwin.c b/contrib/ncurses/ncurses/base/lib_newwin.c index 08921f256f02..3cd8238b1e2e 100644 --- a/contrib/ncurses/ncurses/base/lib_newwin.c +++ b/contrib/ncurses/ncurses/base/lib_newwin.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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> -MODULE_ID("$Id: lib_newwin.c,v 1.27 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_newwin.c,v 1.33 2001/12/19 01:06:30 tom Exp $") NCURSES_EXPORT(int) _nc_freewin(WINDOW *win) @@ -51,19 +51,18 @@ _nc_freewin(WINDOW *win) if (win != 0) { for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) { - if (p->win == win) { + if (&(p->win) == win) { if (q == 0) _nc_windows = p->next; else q->next = p->next; - free(p); if (!(win->_flags & _SUBWIN)) { for (i = 0; i <= win->_maxy; i++) FreeIfNeeded(win->_line[i].text); } free(win->_line); - free(win); + free(p); if (win == curscr) curscr = 0; @@ -82,11 +81,10 @@ _nc_freewin(WINDOW *win) } NCURSES_EXPORT(WINDOW *) -newwin -(int num_lines, int num_columns, int begy, int begx) +newwin(int num_lines, int num_columns, int begy, int begx) { WINDOW *win; - chtype *ptr; + NCURSES_CH_T *ptr; int i; T((T_CALLED("newwin(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx)); @@ -106,24 +104,22 @@ newwin returnWin(0); for (i = 0; i < num_lines; i++) { - win->_line[i].text = typeCalloc(chtype, (unsigned) num_columns); + win->_line[i].text = typeCalloc(NCURSES_CH_T, (unsigned) num_columns); if (win->_line[i].text == 0) { (void) _nc_freewin(win); returnWin(0); } - for (ptr = win->_line[i].text; ptr < win->_line[i].text + - num_columns;) - *ptr++ = ' '; + for (ptr = win->_line[i].text; + ptr < win->_line[i].text + num_columns; + ptr++) + SetChar(*ptr, BLANK_TEXT, BLANK_ATTR); } - T(("newwin: returned window is %p", win)); - returnWin(win); } NCURSES_EXPORT(WINDOW *) -derwin -(WINDOW *orig, int num_lines, int num_columns, int begy, int begx) +derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx) { WINDOW *win; int i; @@ -133,7 +129,7 @@ derwin begy, begx)); /* - ** make sure window fits inside the original one + * make sure window fits inside the original one */ if (begy < 0 || begx < 0 || orig == 0 || num_lines < 0 || num_columns < 0) returnWin(0); @@ -157,21 +153,18 @@ derwin win->_pary = begy; win->_parx = begx; win->_attrs = orig->_attrs; - win->_bkgd = orig->_bkgd; + win->_nc_bkgd = orig->_nc_bkgd; for (i = 0; i < num_lines; i++) win->_line[i].text = &orig->_line[begy++].text[begx]; win->_parent = orig; - T(("derwin: returned window is %p", win)); - returnWin(win); } NCURSES_EXPORT(WINDOW *) -subwin -(WINDOW *w, int l, int c, int y, int x) +subwin(WINDOW *w, int l, int c, int y, int x) { T((T_CALLED("subwin(%p, %d, %d, %d, %d)"), w, l, c, y, x)); T(("parent has begy = %d, begx = %d", w->_begy, w->_begx)); @@ -187,8 +180,7 @@ dimension_limit(int value) } NCURSES_EXPORT(WINDOW *) -_nc_makenew -(int num_lines, int num_columns, int begy, int begx, int flags) +_nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags) { int i; WINDOWLIST *wp; @@ -203,8 +195,7 @@ _nc_makenew if ((wp = typeCalloc(WINDOWLIST, 1)) == 0) return 0; - if ((win = typeCalloc(WINDOW, 1)) == 0) - return 0; + win = &(wp->win); if ((win->_line = typeCalloc(struct ldat, ((unsigned) num_lines))) == 0) { free(win); @@ -221,7 +212,7 @@ _nc_makenew win->_flags = flags; win->_attrs = A_NORMAL; - win->_bkgd = BLANK; + SetChar(win->_nc_bkgd, BLANK_TEXT, BLANK_ATTR); win->_clear = is_pad ? FALSE : (num_lines == screen_lines && num_columns == screen_columns); @@ -284,7 +275,6 @@ _nc_makenew } wp->next = _nc_windows; - wp->win = win; _nc_windows = wp; T((T_CREATE("window %p"), win)); diff --git a/contrib/ncurses/ncurses/base/lib_overlay.c b/contrib/ncurses/ncurses/base/lib_overlay.c index 592e7add9239..010e6d18c861 100644 --- a/contrib/ncurses/ncurses/base/lib_overlay.c +++ b/contrib/ncurses/ncurses/base/lib_overlay.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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> -MODULE_ID("$Id: lib_overlay.c,v 1.14 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_overlay.c,v 1.20 2001/12/19 01:06:37 tom Exp $") static int overlap(const WINDOW *const s, WINDOW *const d, int const flag) @@ -109,8 +109,8 @@ copywin { int sx, sy, dx, dy; bool touched; - chtype bk = AttrOf(dst->_bkgd); - chtype mask = ~(chtype) ((bk & A_COLOR) ? A_COLOR : 0); + attr_t bk = AttrOf(dst->_nc_bkgd); + attr_t mask = ~(attr_t) ((bk & A_COLOR) ? A_COLOR : 0); T((T_CALLED("copywin(%p, %p, %d, %d, %d, %d, %d, %d, %d)"), src, dst, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, over)); @@ -137,14 +137,15 @@ copywin touched = FALSE; for (dx = dmincol, sx = smincol; dx <= dmaxcol; sx++, dx++) { if (over) { - if ((TextOf(src->_line[sy].text[sx]) != ' ') && - (dst->_line[dy].text[dx] != src->_line[sy].text[sx])) { - dst->_line[dy].text[dx] = - (src->_line[sy].text[sx] & mask) | bk; + if ((CharOf(src->_line[sy].text[sx]) != L(' ')) && + (!CharEq(dst->_line[dy].text[dx], src->_line[sy].text[sx]))) { + dst->_line[dy].text[dx] = src->_line[sy].text[sx]; + SetAttr(dst->_line[dy].text[dx], + (AttrOf(src->_line[sy].text[sx]) & mask) | bk); touched = TRUE; } } else { - if (dst->_line[dy].text[dx] != src->_line[sy].text[sx]) { + if (!CharEq(dst->_line[dy].text[dx], src->_line[sy].text[sx])) { dst->_line[dy].text[dx] = src->_line[sy].text[sx]; touched = TRUE; } diff --git a/contrib/ncurses/ncurses/base/lib_pad.c b/contrib/ncurses/ncurses/base/lib_pad.c index 8a9dae8ab745..556fb19e6993 100644 --- a/contrib/ncurses/ncurses/base/lib_pad.c +++ b/contrib/ncurses/ncurses/base/lib_pad.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2001,2002 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,13 +40,13 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_pad.c,v 1.32 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_pad.c,v 1.36 2002/05/18 21:28:44 Kriang.Lerdsuwanakij Exp $") NCURSES_EXPORT(WINDOW *) newpad(int l, int c) { WINDOW *win; - chtype *ptr; + NCURSES_CH_T *ptr; int i; T((T_CALLED("newpad(%d, %d)"), l, c)); @@ -59,12 +59,12 @@ newpad(int l, int c) for (i = 0; i < l; i++) { if_USE_SCROLL_HINTS(win->_line[i].oldindex = _NEWINDEX); - if ((win->_line[i].text = typeCalloc(chtype, ((size_t) c))) == 0) { + if ((win->_line[i].text = typeCalloc(NCURSES_CH_T, ((size_t) c))) == 0) { (void) _nc_freewin(win); returnWin(0); } - for (ptr = win->_line[i].text; ptr < win->_line[i].text + c;) - *ptr++ = ' '; + for (ptr = win->_line[i].text; ptr < win->_line[i].text + c; ptr++) + SetChar(*ptr, BLANK_TEXT, BLANK_ATTR); } returnWin(win); @@ -193,9 +193,23 @@ pnoutrefresh i++, m++) { register struct ldat *nline = &newscr->_line[m]; register struct ldat *oline = &win->_line[i]; + NCURSES_CH_T ch; + + /* + * Special case for leftmost character of the displayed area. + * Only half of a double-width character may be visible. + */ + ch = oline->text[pmincol]; + if_WIDEC(isnac(ch)) { + SetChar(ch, L(' '), AttrOf(oline->text[pmincol - 1])); + } + if (!CharEq(ch, nline->text[smincol])) { + nline->text[smincol] = ch; + CHANGED_CELL(nline, smincol); + } - for (j = pmincol, n = smincol; j <= pmaxcol; j++, n++) { - if (oline->text[j] != nline->text[n]) { + for (j = pmincol + 1, n = smincol + 1; j <= pmaxcol; j++, n++) { + if (!CharEq(oline->text[j], nline->text[n])) { nline->text[n] = oline->text[j]; CHANGED_CELL(nline, n); } diff --git a/contrib/ncurses/ncurses/base/lib_printw.c b/contrib/ncurses/ncurses/base/lib_printw.c index f6b7036fe367..f821a96ba7f0 100644 --- a/contrib/ncurses/ncurses/base/lib_printw.c +++ b/contrib/ncurses/ncurses/base/lib_printw.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -39,7 +39,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_printw.c,v 1.9 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_printw.c,v 1.12 2001/10/20 20:33:46 tom Exp $") NCURSES_EXPORT(int) printw(NCURSES_CONST char *fmt,...) @@ -47,13 +47,18 @@ printw(NCURSES_CONST char *fmt,...) va_list argp; int code; - T(("printw(%s,...) called", _nc_visbuf(fmt))); +#ifdef TRACE + va_start(argp, fmt); + T((T_CALLED("printw(%s%s)"), + _nc_visbuf(fmt), _nc_varargs(fmt, argp))); + va_end(argp); +#endif va_start(argp, fmt); code = vwprintw(stdscr, fmt, argp); va_end(argp); - return code; + returnCode(code); } NCURSES_EXPORT(int) @@ -62,56 +67,76 @@ wprintw(WINDOW *win, NCURSES_CONST char *fmt,...) va_list argp; int code; - T(("wprintw(%p,%s,...) called", win, _nc_visbuf(fmt))); +#ifdef TRACE + va_start(argp, fmt); + T((T_CALLED("wprintw(%p,%s%s)"), + win, _nc_visbuf(fmt), _nc_varargs(fmt, argp))); + va_end(argp); +#endif va_start(argp, fmt); code = vwprintw(win, fmt, argp); va_end(argp); - return code; + returnCode(code); } NCURSES_EXPORT(int) mvprintw(int y, int x, NCURSES_CONST char *fmt,...) { va_list argp; - int code = move(y, x); + int code; - if (code != ERR) { +#ifdef TRACE + va_start(argp, fmt); + T((T_CALLED("mvprintw(%d,%d,%s%s)"), + y, x, _nc_visbuf(fmt), _nc_varargs(fmt, argp))); + va_end(argp); +#endif + + if ((code = move(y, x)) != ERR) { va_start(argp, fmt); code = vwprintw(stdscr, fmt, argp); va_end(argp); } - return code; + returnCode(code); } NCURSES_EXPORT(int) -mvwprintw -(WINDOW *win, int y, int x, NCURSES_CONST char *fmt,...) +mvwprintw(WINDOW *win, int y, int x, NCURSES_CONST char *fmt,...) { va_list argp; - int code = wmove(win, y, x); + int code; + +#ifdef TRACE + va_start(argp, fmt); + T((T_CALLED("mvwprintw(%d,%d,%p,%s%s)"), + y, x, win, _nc_visbuf(fmt), _nc_varargs(fmt, argp))); + va_end(argp); +#endif - if (code != ERR) { + if ((code = wmove(win, y, x)) != ERR) { va_start(argp, fmt); code = vwprintw(win, fmt, argp); va_end(argp); } - return code; + returnCode(code); } NCURSES_EXPORT(int) -vwprintw -(WINDOW *win, NCURSES_CONST char *fmt, va_list argp) +vwprintw(WINDOW *win, NCURSES_CONST char *fmt, va_list argp) { - char *buf = _nc_printf_string(fmt, argp); + char *buf; int code = ERR; - if (buf != 0) { + T((T_CALLED("wprintw(%p,%s,%p)"), + win, _nc_visbuf(fmt), argp)); + + if ((buf = _nc_printf_string(fmt, argp)) != 0) { code = waddstr(win, buf); #if USE_SAFE_SPRINTF free(buf); #endif } - return code; + returnCode(code); } diff --git a/contrib/ncurses/ncurses/base/lib_redrawln.c b/contrib/ncurses/ncurses/base/lib_redrawln.c index dd0a51e6ae5a..91a03711de7c 100644 --- a/contrib/ncurses/ncurses/base/lib_redrawln.c +++ b/contrib/ncurses/ncurses/base/lib_redrawln.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -39,14 +39,14 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_redrawln.c,v 1.9 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_redrawln.c,v 1.10 2001/09/29 17:41:31 tom Exp $") NCURSES_EXPORT(int) wredrawln(WINDOW *win, int beg, int num) { int i; int end; - size_t len = (win->_maxx + 1) * sizeof(chtype); + size_t len = (win->_maxx + 1); T((T_CALLED("wredrawln(%p,%d,%d)"), win, beg, num)); @@ -57,9 +57,15 @@ wredrawln(WINDOW *win, int beg, int num) returnCode(ERR); end = beg + num; + if (end > curscr->_maxy + 1) + end = curscr->_maxy + 1; if (end > win->_maxy + 1) end = win->_maxy + 1; + if (len > (size_t) (curscr->_maxx + 1)) + len = (size_t) (curscr->_maxx + 1); + len *= sizeof(curscr->_line[0].text[0]); + for (i = beg; i < end; i++) { memset(curscr->_line[i + win->_begy].text + win->_begx, 0, len); _nc_make_oldhash(i + win->_begy); diff --git a/contrib/ncurses/ncurses/base/lib_refresh.c b/contrib/ncurses/ncurses/base/lib_refresh.c index bd03ce712f95..42c1f496c10a 100644 --- a/contrib/ncurses/ncurses/base/lib_refresh.c +++ b/contrib/ncurses/ncurses/base/lib_refresh.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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> -MODULE_ID("$Id: lib_refresh.c,v 1.28 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_refresh.c,v 1.31 2001/12/19 01:06:41 tom Exp $") NCURSES_EXPORT(int) wrefresh(WINDOW *win) @@ -96,7 +96,7 @@ wnoutrefresh(WINDOW *win) begx = win->_begx; begy = win->_begy; - newscr->_bkgd = win->_bkgd; + newscr->_nc_bkgd = win->_nc_bkgd; newscr->_attrs = win->_attrs; /* merge in change information from all subwindows of this window */ @@ -148,7 +148,7 @@ wnoutrefresh(WINDOW *win) last = limit_x; for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) { - if (oline->text[j] != nline->text[n]) { + if (!CharEq(oline->text[j], nline->text[n])) { nline->text[n] = oline->text[j]; CHANGED_CELL(nline, n); } diff --git a/contrib/ncurses/ncurses/base/lib_scanw.c b/contrib/ncurses/ncurses/base/lib_scanw.c index 3e1c9d0a36c0..b8a5a227a1a9 100644 --- a/contrib/ncurses/ncurses/base/lib_scanw.c +++ b/contrib/ncurses/ncurses/base/lib_scanw.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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,15 +40,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_scanw.c,v 1.10 2000/12/10 02:43:27 tom Exp $") - -#if !HAVE_VSSCANF -#if defined(__QNX__) -extern int vsscanf(const char *str, const char *format, __va_list __arg); -#else -extern int vsscanf(const char *str, const char *format,...); -#endif -#endif +MODULE_ID("$Id: lib_scanw.c,v 1.11 2001/06/30 23:39:41 tom Exp $") NCURSES_EXPORT(int) vwscanw(WINDOW *win, NCURSES_CONST char *fmt, va_list argp) diff --git a/contrib/ncurses/ncurses/base/lib_screen.c b/contrib/ncurses/ncurses/base/lib_screen.c index 5e674b35cb2f..3b2d9296a59a 100644 --- a/contrib/ncurses/ncurses/base/lib_screen.c +++ b/contrib/ncurses/ncurses/base/lib_screen.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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 * @@ -37,7 +37,7 @@ #include <time.h> #include <term.h> /* exit_ca_mode, non_rev_rmcup */ -MODULE_ID("$Id: lib_screen.c,v 1.17 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_screen.c,v 1.19 2001/12/19 00:55:28 tom Exp $") static time_t dumptime; @@ -71,7 +71,7 @@ getwin(FILE * filep) nwin->_flags = tmp._flags & ~(_SUBWIN | _ISPAD); nwin->_attrs = tmp._attrs; - nwin->_bkgd = tmp._bkgd; + nwin->_nc_bkgd = tmp._nc_bkgd; nwin->_clear = tmp._clear; nwin->_scroll = tmp._scroll; diff --git a/contrib/ncurses/ncurses/base/lib_scroll.c b/contrib/ncurses/ncurses/base/lib_scroll.c index dcde0fc3f7e4..39c62d0850e5 100644 --- a/contrib/ncurses/ncurses/base/lib_scroll.c +++ b/contrib/ncurses/ncurses/base/lib_scroll.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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 * @@ -27,7 +27,8 @@ ****************************************************************************/ /**************************************************************************** - * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * + * Author: Thomas E. Dickey 1996-2001 * + * and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ @@ -42,18 +43,26 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_scroll.c,v 1.20 2000/12/10 02:54:03 tom Exp $") +MODULE_ID("$Id: lib_scroll.c,v 1.23 2001/12/19 01:06:55 tom Exp $") NCURSES_EXPORT(void) -_nc_scroll_window -(WINDOW *win, int const n, NCURSES_SIZE_T const top, - NCURSES_SIZE_T const bottom, chtype blank) +_nc_scroll_window(WINDOW *win, int const n, NCURSES_SIZE_T const top, + NCURSES_SIZE_T const bottom, NCURSES_CH_T blank) { - int line, j; - size_t to_copy = (size_t) (sizeof(chtype) * (win->_maxx + 1)); + int limit; + int line; + int j; + size_t to_copy = (size_t) (sizeof(NCURSES_CH_T) * (win->_maxx + 1)); TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %d, %d)", win, n, top, bottom)); + if (top < 0 + || bottom < top + || bottom > win->_maxy) { + TR(TRACE_MOVE, ("nothing to scroll")); + return; + } + /* * This used to do a line-text pointer-shuffle instead of text copies. * That (a) doesn't work when the window is derived and doesn't have @@ -67,15 +76,26 @@ _nc_scroll_window /* shift n lines downwards */ if (n < 0) { - for (line = bottom; line >= top - n; line--) { - memcpy(win->_line[line].text, - win->_line[line + n].text, - to_copy); - if_USE_SCROLL_HINTS( - win->_line[line].oldindex = - win->_line[line + n].oldindex); + limit = top - n; + if (limit > win->_maxy) + limit = win->_maxy; + for (line = bottom; line >= limit; line--) { + if (line + n >= 0) { + TR(TRACE_MOVE, ("...copying %d to %d", line + n, line)); + memcpy(win->_line[line].text, + win->_line[line + n].text, + to_copy); + if_USE_SCROLL_HINTS(win->_line[line].oldindex = + win->_line[line + n].oldindex); + } else { + TR(TRACE_MOVE, ("...filling %d", line)); + for (j = 0; j <= win->_maxx; j++) + win->_line[line].text[j] = blank; + if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX); + } } - for (line = top; line < top - n; line++) { + for (line = top; line < limit; line++) { + TR(TRACE_MOVE, ("...filling %d", line)); for (j = 0; j <= win->_maxx; j++) win->_line[line].text[j] = blank; if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX); @@ -84,14 +104,26 @@ _nc_scroll_window /* shift n lines upwards */ if (n > 0) { - for (line = top; line <= bottom - n; line++) { - memcpy(win->_line[line].text, - win->_line[line + n].text, - to_copy); - if_USE_SCROLL_HINTS(win->_line[line].oldindex = - win->_line[line + n].oldindex); + limit = bottom - n; + if (limit < 0) + limit = 0; + for (line = top; line <= limit; line++) { + if (line + n <= win->_maxy) { + TR(TRACE_MOVE, ("...copying %d to %d", line + n, line)); + memcpy(win->_line[line].text, + win->_line[line + n].text, + to_copy); + if_USE_SCROLL_HINTS(win->_line[line].oldindex = + win->_line[line + n].oldindex); + } else { + TR(TRACE_MOVE, ("...filling %d", line)); + for (j = 0; j <= win->_maxx; j++) + win->_line[line].text[j] = blank; + if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX); + } } - for (line = bottom; line > bottom - n; line--) { + for (line = bottom; line > limit; line--) { + TR(TRACE_MOVE, ("...filling %d", line)); for (j = 0; j <= win->_maxx; j++) win->_line[line].text[j] = blank; if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX); @@ -105,17 +137,15 @@ wscrl(WINDOW *win, int n) { T((T_CALLED("wscrl(%p,%d)"), win, n)); - if (!win || !win->_scroll) + if (!win || !win->_scroll) { + TR(TRACE_MOVE, ("...scrollok is false")); returnCode(ERR); + } if (n == 0) returnCode(OK); - if ((n > (win->_regbottom - win->_regtop)) || - (-n > (win->_regbottom - win->_regtop))) - returnCode(ERR); - - _nc_scroll_window(win, n, win->_regtop, win->_regbottom, _nc_background(win)); + _nc_scroll_window(win, n, win->_regtop, win->_regbottom, win->_nc_bkgd); _nc_synchook(win); returnCode(OK); diff --git a/contrib/ncurses/ncurses/base/lib_set_term.c b/contrib/ncurses/ncurses/base/lib_set_term.c index e2afbecdb42d..03bb5bfaaac2 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,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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 <term.h> /* cur_term */ #include <tic.h> -MODULE_ID("$Id: lib_set_term.c,v 1.61 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_set_term.c,v 1.64 2002/02/10 00:21:10 tom Exp $") NCURSES_EXPORT(SCREEN *) set_term(SCREEN * screenp) @@ -268,8 +268,13 @@ _nc_setupscreen */ if (getenv("COLORFGBG") != 0) { char *p = getenv("COLORFGBG"); + TR(TRACE_CHARPUT | TRACE_MOVE, ("decoding COLORFGBG %s", p)); p = extract_fgbg(p, &(SP->_default_fg)); p = extract_fgbg(p, &(SP->_default_bg)); + if (*p) /* assume rxvt was compiled with xpm support */ + p = extract_fgbg(p, &(SP->_default_bg)); + TR(TRACE_CHARPUT | TRACE_MOVE, ("decoded fg=%d, bg=%d", + SP->_default_fg, SP->_default_bg)); } #endif #endif /* NCURSES_EXT_FUNCS */ @@ -319,6 +324,9 @@ _nc_setupscreen acs_chars = 0; #endif } +#if USE_WIDEC_SUPPORT + _nc_init_wacs(); +#endif _nc_init_acs(); memcpy(SP->_acs_map, acs_map, sizeof(chtype) * ACS_LEN); @@ -347,6 +355,9 @@ _nc_setupscreen newscr->_clear = TRUE; curscr->_clear = FALSE; + def_shell_mode(); + def_prog_mode(); + for (i = 0, rsp = rippedoff; rsp->line && (i < N_RIPS); rsp++, i++) { if (rsp->hook) { WINDOW *w; @@ -382,9 +393,6 @@ _nc_setupscreen return ERR; SP->_stdscr = stdscr; - def_shell_mode(); - def_prog_mode(); - return OK; } diff --git a/contrib/ncurses/ncurses/base/lib_slkclear.c b/contrib/ncurses/ncurses/base/lib_slkclear.c index 47e52456c204..03e6721cbb29 100644 --- a/contrib/ncurses/ncurses/base/lib_slkclear.c +++ b/contrib/ncurses/ncurses/base/lib_slkclear.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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,7 +38,7 @@ */ #include <curses.priv.h> -MODULE_ID("$Id: lib_slkclear.c,v 1.6 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_slkclear.c,v 1.8 2001/12/19 01:07:01 tom Exp $") NCURSES_EXPORT(int) slk_clear(void) @@ -50,7 +50,7 @@ slk_clear(void) 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->_bkgd = stdscr->_bkgd; + SP->_slk->win->_nc_bkgd = stdscr->_nc_bkgd; SP->_slk->win->_attrs = stdscr->_attrs; if (SP->_slk->win == stdscr) { returnCode(OK); diff --git a/contrib/ncurses/ncurses/base/lib_slkset.c b/contrib/ncurses/ncurses/base/lib_slkset.c index c3fb1a12cd16..d15002f17dba 100644 --- a/contrib/ncurses/ncurses/base/lib_slkset.c +++ b/contrib/ncurses/ncurses/base/lib_slkset.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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,7 +38,7 @@ #include <curses.priv.h> #include <ctype.h> -MODULE_ID("$Id: lib_slkset.c,v 1.6 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_slkset.c,v 1.7 2001/06/02 22:50:29 skimo Exp $") NCURSES_EXPORT(int) slk_set(int i, const char *astr, int format) @@ -55,10 +55,10 @@ slk_set(int i, const char *astr, int format) if (str == NULL) str = ""; - while (isspace(CharOf(*str))) + while (isspace(UChar(*str))) str++; /* skip over leading spaces */ p = str; - while (isprint(CharOf(*p))) + while (isprint(UChar(*p))) p++; /* The first non-print stops */ --i; /* Adjust numbering of labels */ diff --git a/contrib/ncurses/ncurses/base/lib_ungetch.c b/contrib/ncurses/ncurses/base/lib_ungetch.c index d28d3de8bff8..ba057c043901 100644 --- a/contrib/ncurses/ncurses/base/lib_ungetch.c +++ b/contrib/ncurses/ncurses/base/lib_ungetch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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> -MODULE_ID("$Id: lib_ungetch.c,v 1.4 2000/12/10 02:43:27 tom Exp $") +MODULE_ID("$Id: lib_ungetch.c,v 1.7 2001/12/29 23:01:09 tom Exp $") #include <fifo_defs.h> @@ -51,15 +51,17 @@ _nc_fifo_dump(void) int i; T(("head = %d, tail = %d, peek = %d", head, tail, peek)); for (i = 0; i < 10; i++) - T(("char %d = %s", i, _trace_key(SP->_fifo[i]))); + T(("char %d = %s", i, _tracechar(SP->_fifo[i]))); } #endif /* TRACE */ NCURSES_EXPORT(int) ungetch(int ch) { + T((T_CALLED("ungetch(%d)"), ch)); + if (tail == -1) - return ERR; + returnCode(ERR); if (head == -1) { head = 0; t_inc() @@ -73,5 +75,5 @@ ungetch(int ch) if (_nc_tracing & TRACE_IEVENT) _nc_fifo_dump(); #endif - return OK; + returnCode(OK); } diff --git a/contrib/ncurses/ncurses/base/lib_vline.c b/contrib/ncurses/ncurses/base/lib_vline.c index 0174baabbb88..c19570b66265 100644 --- a/contrib/ncurses/ncurses/base/lib_vline.c +++ b/contrib/ncurses/ncurses/base/lib_vline.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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> -MODULE_ID("$Id: lib_vline.c,v 1.7 2000/12/10 02:43:28 tom Exp $") +MODULE_ID("$Id: lib_vline.c,v 1.9 2001/06/03 00:39:24 skimo Exp $") NCURSES_EXPORT(int) wvline(WINDOW *win, chtype ch, int n) @@ -52,6 +52,7 @@ wvline(WINDOW *win, chtype ch, int n) T((T_CALLED("wvline(%p,%s,%d)"), win, _tracechtype(ch), n)); if (win) { + NCURSES_CH_T wch; row = win->_cury; col = win->_curx; end = row + n - 1; @@ -59,12 +60,14 @@ wvline(WINDOW *win, chtype ch, int n) end = win->_maxy; if (ch == 0) - ch = ACS_VLINE; - ch = _nc_render(win, ch); + SetChar(wch, ChCharOf(ACS_VLINE), ChAttrOf(ACS_VLINE)); + else + SetChar(wch, ChCharOf(ch), ChAttrOf(ch)); + wch = _nc_render(win, wch); while (end >= row) { struct ldat *line = &(win->_line[end]); - line->text[col] = ch; + line->text[col] = wch; CHANGED_CELL(line, col); end--; } diff --git a/contrib/ncurses/ncurses/base/lib_winch.c b/contrib/ncurses/ncurses/base/lib_winch.c index 236b11a6d7c7..18da9c594945 100644 --- a/contrib/ncurses/ncurses/base/lib_winch.c +++ b/contrib/ncurses/ncurses/base/lib_winch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -39,14 +39,15 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_winch.c,v 1.4 2000/12/10 02:43:28 tom Exp $") +MODULE_ID("$Id: lib_winch.c,v 1.5 2001/06/02 23:42:08 skimo Exp $") NCURSES_EXPORT(chtype) winch(WINDOW *win) { T((T_CALLED("winch(%p)"), win)); if (win != 0) { - returnChar(win->_line[win->_cury].text[win->_curx]); + returnChar(CharOf(win->_line[win->_cury].text[win->_curx]) | + AttrOf(win->_line[win->_cury].text[win->_curx])); } else { returnChar(0); } diff --git a/contrib/ncurses/ncurses/base/lib_window.c b/contrib/ncurses/ncurses/base/lib_window.c index 9cef79c71650..943f6e004312 100644 --- a/contrib/ncurses/ncurses/base/lib_window.c +++ b/contrib/ncurses/ncurses/base/lib_window.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -39,7 +39,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_window.c,v 1.15 2000/12/10 02:43:28 tom Exp $") +MODULE_ID("$Id: lib_window.c,v 1.18 2001/12/19 01:07:15 tom Exp $") NCURSES_EXPORT(void) _nc_synchook(WINDOW *win) @@ -98,7 +98,8 @@ wsyncup(WINDOW *win) { WINDOW *wp; - if (win && win->_parent) + T((T_CALLED("wsyncup(%p)"), win)); + if (win && win->_parent) { for (wp = win; wp->_parent; wp = wp->_parent) { int y; WINDOW *pp = wp->_parent; @@ -118,6 +119,8 @@ wsyncup(WINDOW *win) } } } + } + returnVoid; } NCURSES_EXPORT(void) @@ -125,6 +128,8 @@ wsyncdown(WINDOW *win) /* mark changed every cell in win that is changed in any of its ancestors */ /* Rewritten by J. Pfeifer, 1-Apr-96 (don't even think that...) */ { + T((T_CALLED("wsyncdown(%p)"), win)); + if (win && win->_parent) { WINDOW *pp = win->_parent; int y; @@ -153,6 +158,7 @@ wsyncdown(WINDOW *win) } } } + returnVoid; } NCURSES_EXPORT(void) @@ -160,9 +166,12 @@ wcursyncup(WINDOW *win) /* sync the cursor in all derived windows to its value in the base window */ { WINDOW *wp; + + T((T_CALLED("wcursyncup(%p)"), win)); for (wp = win; wp && wp->_parent; wp = wp->_parent) { wmove(wp->_parent, wp->_pary + wp->_cury, wp->_parx + wp->_curx); } + returnVoid; } NCURSES_EXPORT(WINDOW *) @@ -177,7 +186,7 @@ dupwin(WINDOW *win) if ((win == NULL) || ((nwin = newwin(win->_maxy + 1, win->_maxx + 1, win->_begy, - win->_begx)) == NULL)) + win->_begx)) == NULL)) returnWin(0); nwin->_curx = win->_curx; @@ -194,7 +203,7 @@ dupwin(WINDOW *win) */ nwin->_attrs = win->_attrs; - nwin->_bkgd = win->_bkgd; + nwin->_nc_bkgd = win->_nc_bkgd; nwin->_clear = win->_clear; nwin->_scroll = win->_scroll; diff --git a/contrib/ncurses/ncurses/base/resizeterm.c b/contrib/ncurses/ncurses/base/resizeterm.c index 303aa5e5be49..f454b20c8437 100644 --- a/contrib/ncurses/ncurses/base/resizeterm.c +++ b/contrib/ncurses/ncurses/base/resizeterm.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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,39 +41,34 @@ #include <curses.priv.h> #include <term.h> -MODULE_ID("$Id: resizeterm.c,v 1.9 2000/12/10 02:43:28 tom Exp $") +MODULE_ID("$Id: resizeterm.c,v 1.13 2002/02/02 19:26:27 tom Exp $") + +NCURSES_EXPORT(bool) +is_term_resized(int ToLines, int ToCols) +{ + return (ToLines != screen_lines + || ToCols != screen_columns); +} /* - * This function reallocates NCURSES window structures. It is invoked in - * response to a SIGWINCH interrupt. Other user-defined windows may also need - * to be reallocated. - * - * Because this performs memory allocation, it should not (in general) be - * invoked directly from the signal handler. + * This function reallocates NCURSES window structures, with no side-effects + * such as ungetch(). */ NCURSES_EXPORT(int) -resizeterm(int ToLines, int ToCols) +resize_term(int ToLines, int ToCols) { int stolen = screen_lines - SP->_lines_avail; int bottom = screen_lines + SP->_topstolen - stolen; - T((T_CALLED("resizeterm(%d,%d) old(%d,%d)"), + T((T_CALLED("resize_term(%d,%d) old(%d,%d)"), ToLines, ToCols, screen_lines, screen_columns)); - SP->_sig_winch = FALSE; - - if (ToLines != screen_lines - || ToCols != screen_columns) { + if (is_term_resized(ToLines, ToCols)) { WINDOWLIST *wp; -#if USE_SIGWINCH - ungetch(KEY_RESIZE); /* so application can know this */ - clearok(curscr, TRUE); /* screen contents are unknown */ -#endif - for (wp = _nc_windows; wp != 0; wp = wp->next) { - WINDOW *win = wp->win; + WINDOW *win = &(wp->win); int myLines = win->_maxy + 1; int myCols = win->_maxx + 1; @@ -122,3 +117,35 @@ resizeterm(int ToLines, int ToCols) returnCode(OK); } + +/* + * This function reallocates NCURSES window structures. It is invoked in + * response to a SIGWINCH interrupt. Other user-defined windows may also need + * to be reallocated. + * + * Because this performs memory allocation, it should not (in general) be + * invoked directly from the signal handler. + */ +NCURSES_EXPORT(int) +resizeterm(int ToLines, int ToCols) +{ + int result = OK; + + SP->_sig_winch = FALSE; + + T((T_CALLED("resizeterm(%d,%d) old(%d,%d)"), + ToLines, ToCols, + screen_lines, screen_columns)); + + if (is_term_resized(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); + } + + returnCode(result); +} diff --git a/contrib/ncurses/ncurses/base/safe_sprintf.c b/contrib/ncurses/ncurses/base/safe_sprintf.c index e534776f4790..cb48365f7f51 100644 --- a/contrib/ncurses/ncurses/base/safe_sprintf.c +++ b/contrib/ncurses/ncurses/base/safe_sprintf.c @@ -33,7 +33,7 @@ #include <curses.priv.h> #include <ctype.h> -MODULE_ID("$Id: safe_sprintf.c,v 1.13 2000/12/10 02:43:28 tom Exp $") +MODULE_ID("$Id: safe_sprintf.c,v 1.14 2001/07/08 00:58:34 tom Exp $") #if USE_SAFE_SPRINTF @@ -84,7 +84,7 @@ _nc_printf_length(const char *fmt, va_list ap) while (*++fmt != '\0' && len >= 0 && !done) { format[f++] = *fmt; - if (isdigit(*fmt)) { + if (isdigit(UChar(*fmt))) { int num = *fmt - '0'; if (state == Flags && num != 0) state = Width; @@ -108,7 +108,7 @@ _nc_printf_length(const char *fmt, va_list ap) } sprintf(&format[--f], "%d", ival); f = strlen(format); - } else if (isalpha(*fmt)) { + } else if (isalpha(UChar(*fmt))) { done = TRUE; switch (*fmt) { case 'Z': /* FALLTHRU */ diff --git a/contrib/ncurses/ncurses/base/sigaction.c b/contrib/ncurses/ncurses/base/sigaction.c index 8819638bef88..8ba8629a4f50 100644 --- a/contrib/ncurses/ncurses/base/sigaction.c +++ b/contrib/ncurses/ncurses/base/sigaction.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2001,2002 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 * @@ -33,7 +33,6 @@ #include <curses.priv.h> -#include <signal.h> #include <SigAction.h> /* This file provides sigaction() emulation using sigvec() */ @@ -41,7 +40,7 @@ #if !HAVE_SIGACTION && HAVE_SIGVEC -MODULE_ID("$Id: sigaction.c,v 1.11 2000/12/10 02:43:28 tom Exp $") +MODULE_ID("$Id: sigaction.c,v 1.13 2002/05/18 19:56:26 tom Exp $") NCURSES_EXPORT(int) sigaction diff --git a/contrib/ncurses/ncurses/base/tries.c b/contrib/ncurses/ncurses/base/tries.c index 04f8b919f5a6..fe7d93ed5e10 100644 --- a/contrib/ncurses/ncurses/base/tries.c +++ b/contrib/ncurses/ncurses/base/tries.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -39,7 +39,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: tries.c,v 1.14 2000/12/10 02:43:28 tom Exp $") +MODULE_ID("$Id: tries.c,v 1.15 2001/12/16 00:50:40 tom Exp $") /* * Expand a keycode into the string that it corresponds to, returning null if @@ -73,7 +73,7 @@ _nc_expand_try *((unsigned char *) (result + len)) = 128; #ifdef TRACE if (len == 0) - _tracef("expand_key %s %s", _trace_key(code), _nc_visbuf(result)); + _tracef("expand_key %s %s", _tracechar(code), _nc_visbuf(result)); #endif } return result; diff --git a/contrib/ncurses/ncurses/base/vsscanf.c b/contrib/ncurses/ncurses/base/vsscanf.c index 70d0517a6f0e..65794b76623b 100644 --- a/contrib/ncurses/ncurses/base/vsscanf.c +++ b/contrib/ncurses/ncurses/base/vsscanf.c @@ -1,3 +1,35 @@ +/**************************************************************************** + * Copyright (c) 1998,2000,2001,2002 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. * + ****************************************************************************/ + +/**************************************************************************** + * State-machine fallback written by Thomas E. Dickey 2002 * + ****************************************************************************/ + /* * This function is needed to support vwscanw */ @@ -6,14 +38,132 @@ #if !HAVE_VSSCANF -MODULE_ID("$Id: vsscanf.c,v 1.12 2000/12/10 02:43:28 tom Exp $") +MODULE_ID("$Id: vsscanf.c,v 1.15 2002/02/03 00:49:45 tom Exp $") + +#if !(HAVE_VFSCANF || HAVE__DOSCAN) + +#include <ctype.h> + +#define L_SQUARE '[' +#define R_SQUARE ']' + +typedef enum { + cUnknown + ,cError /* anything that isn't ANSI */ + ,cAssigned + ,cChar + ,cInt + ,cFloat + ,cDouble + ,cPointer + ,cLong + ,cShort + ,cRange + ,cString +} ChunkType; + +typedef enum { + oUnknown + ,oShort + ,oLong +} OtherType; + +typedef enum { + sUnknown + ,sPercent /* last was '%' beginning a format */ + ,sNormal /* ...somewhere in the middle */ + ,sLeft /* last was left square bracket beginning a range */ + ,sRange /* ...somewhere in the middle */ + ,sFinal /* last finished a format */ +} ScanState; + +static ChunkType +final_ch(int ch, OtherType other) +{ + ChunkType result = cUnknown; + + switch (ch) { + case 'c': + if (other == oUnknown) + result = cChar; + else + result = cError; + break; + case 'd': + case 'i': + case 'X': + case 'x': + switch (other) { + case oUnknown: + result = cInt; + break; + case oShort: + result = cShort; + break; + case oLong: + result = cLong; + break; + } + break; + case 'E': + case 'e': + case 'f': + case 'g': + switch (other) { + case oUnknown: + result = cFloat; + break; + case oShort: + result = cError; + break; + case oLong: + result = cDouble; + break; + } + break; + case 'n': + if (other == oUnknown) + result = cAssigned; + else + result = cError; + break; + case 'p': + if (other == oUnknown) + result = cPointer; + else + result = cError; + break; + case 's': + if (other == oUnknown) + result = cString; + else + result = cError; + break; + } + return result; +} + +static OtherType +other_ch(int ch) +{ + OtherType result = oUnknown; + switch (ch) { + case 'h': + result = oShort; + break; + case 'l': + result = oLong; + break; + } + return result; +} +#endif -#if defined(_IOREAD) && defined(_NFILE) /*VARARGS2*/ NCURSES_EXPORT(int) -vsscanf -(const char *str, const char *format, va_list ap) +vsscanf(const char *str, const char *format, va_list ap) { +#if HAVE_VFSCANF || HAVE__DOSCAN /* * This code should work on anything descended from AT&T SVr1. */ @@ -29,22 +179,171 @@ vsscanf #else return (_doscan(&strbuf, format, ap)); #endif -} #else -/*VARARGS2*/ -NCURSES_EXPORT(int) -vsscanf -(const char *str, const char *format, va_list ap) -{ + static int can_convert = -1; + + int assigned = 0; + int consumed = 0; + + T((T_CALLED("vsscanf(%s,%s,...)"), + _nc_visbuf2(1, str), + _nc_visbuf2(2, format))); + /* - * You don't have a native vsscanf(3), and you don't have System-V - * compatible stdio internals. You're probably using a BSD - * older than 4.4 or a really old Linux. You lose. Upgrade - * to a current C library to win. + * This relies on having a working "%n" format conversion. Check if it + * works. Only very old C libraries do not support it. + * + * FIXME: move this check into the configure script. */ - return -1; /* not implemented */ -} + if (can_convert < 0) { + int check1; + int check2; + if (sscanf("123", "%d%n", &check1, &check2) > 0 + && check1 == 123 + && check2 == 3) { + can_convert = 1; + } else { + can_convert = 0; + } + } + + if (can_convert) { + size_t len_fmt = strlen(format) + 32; + char *my_fmt = malloc(len_fmt); + ChunkType other, chunk, check; + ScanState state; + unsigned n; + int eaten; + void *pointer; + + if (my_fmt != 0) { + /* + * Split the original format into chunks, adding a "%n" to the end + * of each (except of course if it used %n), and use that + * information to decide where to start scanning the next chunk. + * + * FIXME: does %n count bytes or characters? If the latter, this + * will require further work for multibyte strings. + */ + while (*format != '\0') { + /* find a chunk */ + state = sUnknown; + chunk = cUnknown; + other = cUnknown; + pointer = 0; + for (n = 0; format[n] != 0 && state != sFinal; ++n) { + my_fmt[n] = format[n]; + switch (state) { + case sUnknown: + if (format[n] == '%') + state = sPercent; + break; + case sPercent: + if (format[n] == '%') { + state = sUnknown; + } else if (format[n] == L_SQUARE) { + state = sLeft; + } else { + state = sNormal; + --n; + } + break; + case sLeft: + state = sRange; + if (format[n] == '^') { + ++n; + my_fmt[n] = format[n]; + } + break; + case sRange: + if (format[n] == R_SQUARE) { + state = sFinal; + chunk = cRange; + } + break; + case sNormal: + if (format[n] == '*') { + state = sUnknown; + } else { + if ((check = final_ch(format[n], other)) != cUnknown) { + state = sFinal; + chunk = check; + } else if ((check = other_ch(format[n])) != oUnknown) { + other = check; + } else if (isalpha(format[n])) { + state = sFinal; + chunk = cError; + } + } + break; + case sFinal: + break; + } + } + my_fmt[n] = '\0'; + format += n; + + if (chunk == cUnknown + || chunk == cError) { + if (assigned == 0) + assigned = EOF; + break; + } + + /* add %n, if the format was not that */ + if (chunk != cAssigned) { + strcat(my_fmt, "%n"); + } + + switch (chunk) { + case cAssigned: + strcat(my_fmt, "%n"); + pointer = &eaten; + break; + case cInt: + pointer = va_arg(ap, int *); + break; + case cShort: + pointer = va_arg(ap, short *); + break; + case cFloat: + pointer = va_arg(ap, float *); + break; + case cDouble: + pointer = va_arg(ap, double *); + break; + case cLong: + pointer = va_arg(ap, long *); + break; + case cPointer: + pointer = va_arg(ap, void *); + break; + case cChar: + case cRange: + case cString: + pointer = va_arg(ap, char *); + break; + case cError: + case cUnknown: + break; + } + /* do the conversion */ + T(("...converting chunk #%d type %d(%s,%s)", + assigned + 1, chunk, + _nc_visbuf2(1, str + consumed), + _nc_visbuf2(2, my_fmt))); + if (sscanf(str + consumed, my_fmt, pointer, &eaten) > 0) + consumed += eaten; + else + break; + ++assigned; + } + free(my_fmt); + } + } + returnCode(assigned); #endif +} #else extern NCURSES_EXPORT(void) diff --git a/contrib/ncurses/ncurses/base/wresize.c b/contrib/ncurses/ncurses/base/wresize.c index 4889ee098f02..fa97a2bee52b 100644 --- a/contrib/ncurses/ncurses/base/wresize.c +++ b/contrib/ncurses/ncurses/base/wresize.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2001,2002 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: wresize.c,v 1.18 2000/12/10 02:43:28 tom Exp $") +MODULE_ID("$Id: wresize.c,v 1.21 2002/05/11 19:36:29 tom Exp $") /* * Reallocate a curses WINDOW struct to either shrink or grow to the specified @@ -42,7 +42,7 @@ MODULE_ID("$Id: wresize.c,v 1.18 2000/12/10 02:43:28 tom Exp $") #define DOALLOC(p,t,n) typeRealloc(t, n, p) #define ld_ALLOC(p,n) DOALLOC(p,struct ldat,n) -#define c_ALLOC(p,n) DOALLOC(p,chtype,n) +#define c_ALLOC(p,n) DOALLOC(p,NCURSES_CH_T,n) NCURSES_EXPORT(int) wresize(WINDOW *win, int ToLines, int ToCols) @@ -50,7 +50,7 @@ wresize(WINDOW *win, int ToLines, int ToCols) register int row; int size_x, size_y; struct ldat *pline; - chtype blank; + NCURSES_CH_T blank; #ifdef TRACE T((T_CALLED("wresize(%p,%d,%d)"), win, ToLines, ToCols)); @@ -117,9 +117,9 @@ wresize(WINDOW *win, int ToLines, int ToCols) /* * Adjust the width of the columns: */ - blank = _nc_background(win); + blank = win->_nc_bkgd; for (row = 0; row <= ToLines; row++) { - chtype *s = win->_line[row].text; + NCURSES_CH_T *s = win->_line[row].text; int begin = (s == 0) ? 0 : size_x + 1; int end = ToCols; @@ -130,7 +130,7 @@ wresize(WINDOW *win, int ToLines, int ToCols) win->_line[row].text = s = c_ALLOC(s, ToCols + 1); if (win->_line[row].text == 0) returnCode(ERR); - } else if (s == 0) { + } else { win->_line[row].text = s = &pline[win->_pary + row].text[win->_parx]; } @@ -138,14 +138,15 @@ wresize(WINDOW *win, int ToLines, int ToCols) if (end >= begin) { /* growing */ if (win->_line[row].firstchar < begin) win->_line[row].firstchar = begin; - win->_line[row].lastchar = ToCols; - do { - s[end] = blank; - } while (--end >= begin); + if (!(win->_flags & _SUBWIN)) { + do { + s[end] = blank; + } while (--end >= begin); + } } else { /* shrinking */ win->_line[row].firstchar = 0; - win->_line[row].lastchar = ToCols; } + win->_line[row].lastchar = ToCols; } } |