aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/ncurses')
-rw-r--r--contrib/ncurses/ncurses/Makefile.in125
-rw-r--r--contrib/ncurses/ncurses/README29
-rw-r--r--contrib/ncurses/ncurses/README.IZ95
-rw-r--r--contrib/ncurses/ncurses/SigAction.h14
-rw-r--r--contrib/ncurses/ncurses/base/MKkeyname.awk115
-rwxr-xr-xcontrib/ncurses/ncurses/base/MKlib_gen.sh75
-rw-r--r--contrib/ncurses/ncurses/base/MKunctrl.awk44
-rw-r--r--contrib/ncurses/ncurses/base/README30
-rw-r--r--contrib/ncurses/ncurses/base/define_key.c23
-rw-r--r--contrib/ncurses/ncurses/base/key_defined.c76
-rw-r--r--contrib/ncurses/ncurses/base/keybound.c15
-rw-r--r--contrib/ncurses/ncurses/base/keyok.c37
-rw-r--r--contrib/ncurses/ncurses/base/legacy_coding.c48
-rw-r--r--contrib/ncurses/ncurses/base/lib_addch.c408
-rw-r--r--contrib/ncurses/ncurses/base/lib_addstr.c165
-rw-r--r--contrib/ncurses/ncurses/base/lib_beep.c9
-rw-r--r--contrib/ncurses/ncurses/base/lib_bkgd.c46
-rw-r--r--contrib/ncurses/ncurses/base/lib_box.c38
-rw-r--r--contrib/ncurses/ncurses/base/lib_chgat.c18
-rw-r--r--contrib/ncurses/ncurses/base/lib_clrbot.c8
-rw-r--r--contrib/ncurses/ncurses/base/lib_color.c364
-rw-r--r--contrib/ncurses/ncurses/base/lib_colorset.c15
-rw-r--r--contrib/ncurses/ncurses/base/lib_dft_fgbg.c22
-rw-r--r--contrib/ncurses/ncurses/base/lib_erase.c21
-rw-r--r--contrib/ncurses/ncurses/base/lib_freeall.c87
-rw-r--r--contrib/ncurses/ncurses/base/lib_getch.c253
-rw-r--r--contrib/ncurses/ncurses/base/lib_getstr.c41
-rw-r--r--contrib/ncurses/ncurses/base/lib_hline.c8
-rw-r--r--contrib/ncurses/ncurses/base/lib_initscr.c36
-rw-r--r--contrib/ncurses/ncurses/base/lib_insch.c99
-rw-r--r--contrib/ncurses/ncurses/base/lib_insdel.c6
-rw-r--r--contrib/ncurses/ncurses/base/lib_insnstr.c68
-rw-r--r--contrib/ncurses/ncurses/base/lib_instr.c48
-rw-r--r--contrib/ncurses/ncurses/base/lib_mouse.c1014
-rw-r--r--contrib/ncurses/ncurses/base/lib_move.c9
-rw-r--r--contrib/ncurses/ncurses/base/lib_mvwin.c10
-rw-r--r--contrib/ncurses/ncurses/base/lib_newterm.c211
-rw-r--r--contrib/ncurses/ncurses/base/lib_newwin.c54
-rw-r--r--contrib/ncurses/ncurses/base/lib_overlay.c78
-rw-r--r--contrib/ncurses/ncurses/base/lib_pad.c39
-rw-r--r--contrib/ncurses/ncurses/base/lib_printw.c20
-rw-r--r--contrib/ncurses/ncurses/base/lib_redrawln.c13
-rw-r--r--contrib/ncurses/ncurses/base/lib_refresh.c15
-rw-r--r--contrib/ncurses/ncurses/base/lib_restart.c59
-rw-r--r--contrib/ncurses/ncurses/base/lib_screen.c141
-rw-r--r--contrib/ncurses/ncurses/base/lib_scroll.c92
-rw-r--r--contrib/ncurses/ncurses/base/lib_set_term.c300
-rw-r--r--contrib/ncurses/ncurses/base/lib_slk.c138
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkatr_set.c20
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkatrof.c15
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkatron.c15
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkatrset.c10
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkattr.c12
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkclear.c6
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkcolor.c14
-rw-r--r--contrib/ncurses/ncurses/base/lib_slklab.c6
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkrefr.c20
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkset.c99
-rw-r--r--contrib/ncurses/ncurses/base/lib_ungetch.c8
-rw-r--r--contrib/ncurses/ncurses/base/lib_vline.c8
-rw-r--r--contrib/ncurses/ncurses/base/lib_wattroff.c19
-rw-r--r--contrib/ncurses/ncurses/base/lib_wattron.c21
-rw-r--r--contrib/ncurses/ncurses/base/lib_window.c108
-rw-r--r--contrib/ncurses/ncurses/base/resizeterm.c249
-rw-r--r--contrib/ncurses/ncurses/base/safe_sprintf.c84
-rw-r--r--contrib/ncurses/ncurses/base/sigaction.c64
-rw-r--r--contrib/ncurses/ncurses/base/tries.c25
-rw-r--r--contrib/ncurses/ncurses/base/version.c11
-rw-r--r--contrib/ncurses/ncurses/base/vsscanf.c19
-rw-r--r--contrib/ncurses/ncurses/base/wresize.c187
-rw-r--r--contrib/ncurses/ncurses/curses.priv.h905
-rw-r--r--contrib/ncurses/ncurses/llib-lncurses553
-rw-r--r--contrib/ncurses/ncurses/llib-lncursesw767
-rw-r--r--contrib/ncurses/ncurses/modules40
-rw-r--r--contrib/ncurses/ncurses/tinfo/MKcaptab.awk29
-rwxr-xr-xcontrib/ncurses/ncurses/tinfo/MKfallback.sh31
-rwxr-xr-xcontrib/ncurses/ncurses/tinfo/MKkeys_list.sh8
-rw-r--r--contrib/ncurses/ncurses/tinfo/MKnames.awk29
-rw-r--r--contrib/ncurses/ncurses/tinfo/README30
-rw-r--r--contrib/ncurses/ncurses/tinfo/access.c77
-rw-r--r--contrib/ncurses/ncurses/tinfo/add_tries.c6
-rw-r--r--contrib/ncurses/ncurses/tinfo/alloc_entry.c103
-rw-r--r--contrib/ncurses/ncurses/tinfo/alloc_ttype.c48
-rw-r--r--contrib/ncurses/ncurses/tinfo/captoinfo.c51
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_error.c32
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_expand.c16
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_hash.c22
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_parse.c167
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_scan.c526
-rw-r--r--contrib/ncurses/ncurses/tinfo/db_iterator.c227
-rw-r--r--contrib/ncurses/ncurses/tinfo/doalloc.c4
-rw-r--r--contrib/ncurses/ncurses/tinfo/free_ttype.c16
-rw-r--r--contrib/ncurses/ncurses/tinfo/hashed_db.c260
-rw-r--r--contrib/ncurses/ncurses/tinfo/home_terminfo.c15
-rw-r--r--contrib/ncurses/ncurses/tinfo/init_keytry.c50
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_acs.c185
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_cur_term.c10
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_data.c20
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_has_cap.c5
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_kernel.c8
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_napms.c19
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_options.c121
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_print.c9
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_raw.c226
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_setup.c411
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_termcap.c210
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_termname.c16
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_tgoto.c23
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_ti.c10
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_tparm.c477
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_tputs.c21
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_ttyflags.c94
-rw-r--r--contrib/ncurses/ncurses/tinfo/make_keys.c10
-rw-r--r--contrib/ncurses/ncurses/tinfo/name_match.c17
-rw-r--r--contrib/ncurses/ncurses/tinfo/parse_entry.c74
-rw-r--r--contrib/ncurses/ncurses/tinfo/read_entry.c455
-rw-r--r--contrib/ncurses/ncurses/tinfo/read_termcap.c91
-rw-r--r--contrib/ncurses/ncurses/tinfo/setbuf.c58
-rw-r--r--contrib/ncurses/ncurses/tinfo/strings.c23
-rw-r--r--contrib/ncurses/ncurses/tinfo/trim_sgr0.c328
-rw-r--r--contrib/ncurses/ncurses/tinfo/write_entry.c372
-rw-r--r--contrib/ncurses/ncurses/trace/README30
-rw-r--r--contrib/ncurses/ncurses/trace/lib_trace.c98
-rw-r--r--contrib/ncurses/ncurses/trace/lib_traceatr.c139
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracebits.c6
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracechr.c36
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracedmp.c41
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracemse.c42
-rw-r--r--contrib/ncurses/ncurses/trace/trace_buf.c71
-rw-r--r--contrib/ncurses/ncurses/trace/varargs.c64
-rw-r--r--contrib/ncurses/ncurses/trace/visbuf.c227
-rwxr-xr-xcontrib/ncurses/ncurses/tty/MKexpanded.sh6
-rw-r--r--contrib/ncurses/ncurses/tty/hashmap.c18
-rw-r--r--contrib/ncurses/ncurses/tty/lib_mvcur.c253
-rw-r--r--contrib/ncurses/ncurses/tty/lib_tstp.c12
-rw-r--r--contrib/ncurses/ncurses/tty/lib_twait.c213
-rw-r--r--contrib/ncurses/ncurses/tty/lib_vidattr.c72
-rw-r--r--contrib/ncurses/ncurses/tty/tty_display.h11
-rw-r--r--contrib/ncurses/ncurses/tty/tty_update.c639
-rw-r--r--contrib/ncurses/ncurses/widechar/charable.c80
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_add_wch.c113
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_box_set.c4
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_cchar.c56
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_get_wch.c50
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_get_wstr.c76
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_in_wch.c12
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_in_wchnstr.c20
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_ins_wch.c95
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_inwstr.c36
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_pecho_wchar.c57
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_slk_wset.c72
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_unget_wch.c49
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_vid_attr.c252
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_wacs.c43
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_wunctrl.c13
155 files changed, 11083 insertions, 4927 deletions
diff --git a/contrib/ncurses/ncurses/Makefile.in b/contrib/ncurses/ncurses/Makefile.in
index 9b9a39eb173c..ce35c0340195 100644
--- a/contrib/ncurses/ncurses/Makefile.in
+++ b/contrib/ncurses/ncurses/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.83 2002/04/20 22:02:39 tom Exp $
+# $Id: Makefile.in,v 1.101 2006/10/14 19:08:11 tom Exp $
##############################################################################
-# Copyright (c) 1998,1999,2000,2001,2002 Free Software Foundation, Inc. #
+# Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@@ -27,7 +27,7 @@
# authorization. #
##############################################################################
#
-# Author: Thomas E. Dickey 1996-2001
+# Author: Thomas E. Dickey 1996-on
#
# Makefile for ncurses source code.
#
@@ -48,11 +48,12 @@
SHELL = /bin/sh
THIS = Makefile
-x = @PROG_EXT@
-
CF_MFLAGS = @cf_cv_makeflags@
@SET_MAKE@
+x = @EXEEXT@
+o = .@OBJEXT@
+
MODEL = @DFT_LWR_MODEL@
DESTDIR = @DESTDIR@
top_srcdir = @top_srcdir@
@@ -65,10 +66,15 @@ includedir = @includedir@
datadir = @datadir@
LIBTOOL = @LIBTOOL@
+LIBTOOL_CLEAN = @LIB_CLEAN@
+LIBTOOL_COMPILE = @LIB_COMPILE@
+LIBTOOL_LINK = @LIB_LINK@
+LIBTOOL_INSTALL = @LIB_INSTALL@
+LIBTOOL_UNINSTALL = @LIB_UNINSTALL@
INSTALL = @INSTALL@
INSTALL_LIB = @INSTALL@ @INSTALL_LIB@
-INSTALL_PROG = @INSTALL_PROG@
+INSTALL_PROG = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
AR = @AR@
@@ -82,15 +88,21 @@ CPP = @CPP@
CFLAGS = @CFLAGS@
INCDIR = $(srcdir)/../include
-CPPFLAGS = -I../ncurses -I$(srcdir) @CPPFLAGS@ \
- -DHAVE_CONFIG_H
+CPPFLAGS = -DHAVE_CONFIG_H -I../ncurses -I$(srcdir) @CPPFLAGS@
CCFLAGS = $(CPPFLAGS) $(CFLAGS)
-HOSTCC = @BUILD_CC@
-HOSTCCFLAGS = @BUILD_CFLAGS@ $(CPPFLAGS)
-HOSTLDFLAGS = @BUILD_LDFLAGS@
-HOSTLIBS = @BUILD_LIBS@
+BUILD_CPPFLAGS = -I../include @BUILD_CPPFLAGS@
+BUILD_CC = @BUILD_CC@
+BUILD_CCFLAGS = -DHAVE_CONFIG_H -I../ncurses -I$(srcdir) -I$(INCDIR) $(BUILD_CPPFLAGS) @BUILD_CFLAGS@
+BUILD_LDFLAGS = @BUILD_LDFLAGS@
+BUILD_LIBS = @BUILD_LIBS@
+
+# The executables built in this directory are used for generating source that
+# is compiled into the build, or are test-programs that are not installed.
+
+BUILD_EXEEXT = @BUILD_EXEEXT@
+x = @PROG_EXT@
CFLAGS_LIBTOOL = $(CCFLAGS)
CFLAGS_NORMAL = $(CCFLAGS)
@@ -114,7 +126,7 @@ NCURSES_MINOR = @NCURSES_MINOR@
REL_VERSION = @cf_cv_rel_version@
ABI_VERSION = @cf_cv_abi_version@
-RANLIB = @RANLIB@
+RANLIB = @LIB_PREP@
IMPORT_LIB = @IMPORT_LIB@
SHARED_LIB = @SHARED_LIB@
@@ -129,22 +141,22 @@ FALLBACK_LIST = @FALLBACK_LIST@
TERMINFO_CAPS = $(top_srcdir)/include/@TERMINFO_CAPS@
AUTO_SRC = \
- ../include/nomacros.h \
- codes.c \
- comp_captab.c \
- expanded.c \
- fallback.c \
+ ./codes.c \
+ ./comp_captab.c \
+ ./expanded.c \
+ ./fallback.c \
+ ./lib_gen.c \
+ ./lib_keyname.c \
+ ./link_test.c \
+ ./names.c \
+ ./unctrl.c \
init_keytry.h \
keys.list \
- lib_gen.c \
- lib_keyname.c \
- link_test.c \
- names.c \
- unctrl.c
+ names-stamp
TEST_DEPS = ../lib/@LIB_PREFIX@ncurses@DFT_DEP_SUFFIX@
TEST_ARGS = -L../lib -lncurses@DFT_ARG_SUFFIX@
-TEST_LDFLAGS = @LD_MODEL@ $(TEST_ARGS) @LIBS@ @EXTRA_LIBS@ @LOCAL_LDFLAGS@ @LDFLAGS@
+TEST_LDFLAGS = @LD_MODEL@ $(TEST_ARGS) @LIBS@ @LOCAL_LDFLAGS@ @LDFLAGS@
TEST_PROGS = \
captoinfo$x \
@@ -171,58 +183,61 @@ $(DESTDIR)$(libdir) :
../lib : ; mkdir $@
-fallback.c : $(tinfo)/MKfallback.sh
+./fallback.c : $(tinfo)/MKfallback.sh
sh $(tinfo)/MKfallback.sh @TERMINFO@ @TERMINFO_SRC@ $(FALLBACK_LIST) >$@
-lib_gen.c : $(base)/MKlib_gen.sh ../include/curses.h
+./lib_gen.c : $(base)/MKlib_gen.sh ../include/curses.h
sh $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" generated <../include/curses.h >$@
-../include/nomacros.h : $(base)/MKlib_gen.sh ../include/curses.h
- sh $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" generated <../include/curses.h | \
- fgrep undef >$@
-
-init_keytry.h: make_keys$x keys.list
- ./make_keys keys.list > $@
+init_keytry.h: make_keys$(BUILD_EXEEXT) keys.list
+ ./make_keys$(BUILD_EXEEXT) keys.list > $@
keys.list : $(tinfo)/MKkeys_list.sh
AWK=$(AWK) sh $(tinfo)/MKkeys_list.sh $(TERMINFO_CAPS) | sort >$@
-make_keys$x : \
+make_keys$(BUILD_EXEEXT) : \
$(tinfo)/make_keys.c \
- names.c
- $(HOSTCC) -o $@ $(HOSTCCFLAGS) $(tinfo)/make_keys.c $(HOSTLDFLAGS) $(HOSTLIBS)
+ names-stamp
+ $(BUILD_CC) -o $@ $(BUILD_CCFLAGS) $(tinfo)/make_keys.c $(BUILD_LDFLAGS) $(BUILD_LIBS)
-make_hash$x : \
+make_hash$(BUILD_EXEEXT) : \
$(tinfo)/comp_hash.c \
../include/hashsize.h
- $(HOSTCC) -o $@ $(HOSTCCFLAGS) -DMAIN_PROGRAM $(tinfo)/comp_hash.c $(HOSTLDFLAGS) $(HOSTLIBS)
+ $(BUILD_CC) -o $@ $(BUILD_CCFLAGS) -DMAIN_PROGRAM $(tinfo)/comp_hash.c $(BUILD_LDFLAGS) $(BUILD_LIBS)
-expanded.c : $(serial)/MKexpanded.sh
+./expanded.c : $(serial)/MKexpanded.sh
sh $(serial)/MKexpanded.sh "$(CPP)" $(CPPFLAGS) > $@
-comp_captab.c: \
- make_hash$x \
+./comp_captab.c: \
+ make_hash$(BUILD_EXEEXT) \
../include/hashsize.h \
$(tinfo)/MKcaptab.awk
sh $(tinfo)/MKcaptab.awk $(AWK) $(srcdir)/../include/@TERMINFO_CAPS@ > $@
-lib_keyname.c: keys.list $(base)/MKkeyname.awk
+./lib_keyname.c: keys.list $(base)/MKkeyname.awk
$(AWK) -f $(base)/MKkeyname.awk keys.list > $@
-names.c codes.c: $(tinfo)/MKnames.awk
+names-stamp: $(tinfo)/MKnames.awk
$(AWK) -f $(tinfo)/MKnames.awk $(srcdir)/../include/@TERMINFO_CAPS@
cat namehdr boolnames boolfnames numnames numfnames strnames strfnames nameftr >names.c
cat namehdr boolcodes numcodes strcodes codeftr >codes.c
-rm -f namehdr nameftr codeftr boolnames boolfnames boolcodes numnames numfnames numcodes strnames strfnames strcodes
+ @echo >$@
+
+./names.c: names-stamp
+ @echo made $@
+
+./codes.c: names-stamp
+ @echo made $@
-unctrl.c: $(base)/MKunctrl.awk
+./unctrl.c: $(base)/MKunctrl.awk
echo | $(AWK) -f $(base)/MKunctrl.awk >$@
tags:
- ctags *.[ch]
+ ctags *.[ch] */*.[ch]
@MAKE_UPPER_TAGS@TAGS:
-@MAKE_UPPER_TAGS@ etags *.[ch]
+@MAKE_UPPER_TAGS@ etags *.[ch] */*.[ch]
mostlyclean ::
-rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace
@@ -230,8 +245,8 @@ mostlyclean ::
clean :: mostlyclean
-rm -f $(AUTO_SRC)
- -rm -f make_keys$x
- -rm -f make_hash$x
+ -rm -f make_keys$(BUILD_EXEEXT)
+ -rm -f make_hash$(BUILD_EXEEXT)
-rm -rf .libs
distclean :: clean
@@ -248,7 +263,7 @@ realclean :: distclean
# These rules build test-programs for the modules that have test-drivers
test_progs : $(TEST_PROGS)
-link_test.c : $(base)/MKlib_gen.sh ../include/curses.h
+./link_test.c : $(base)/MKlib_gen.sh ../include/curses.h
sh $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" implemented <../include/curses.h >$@
captoinfo$x : $(tinfo)/captoinfo.c $(TEST_DEPS)
@@ -261,15 +276,15 @@ hashmap$x : $(serial)/hashmap.c $(TEST_DEPS)
@ECHO_LINK@ $(CC) -o $@ $(CFLAGS_DEFAULT) -DHASHDEBUG $(serial)/hashmap.c $(TEST_LDFLAGS)
lib_mvcur$x : $(serial)/lib_mvcur.c $(TEST_DEPS) \
- ../@DFT_OBJ_SUBDIR@/dump_entry.o
- @ECHO_LINK@ $(CC) -o $@ $(CFLAGS_DEFAULT) -DNCURSES_TEST -I$(serial)/../../progs $(serial)/lib_mvcur.c ../@DFT_OBJ_SUBDIR@/dump_entry.o $(TEST_LDFLAGS)
+ ../@DFT_OBJ_SUBDIR@/dump_entry$o
+ @ECHO_LINK@ $(CC) -o $@ $(CFLAGS_DEFAULT) -DNCURSES_TEST -I$(serial)/../../progs $(serial)/lib_mvcur.c ../@DFT_OBJ_SUBDIR@/dump_entry$o $(TEST_LDFLAGS)
-link_test$x : link_test.c $(TEST_DEPS) \
- ../@DFT_OBJ_SUBDIR@/link_test.o
- @ECHO_LINK@ $(CC) -o $@ $(CFLAGS_DEFAULT) ../@DFT_OBJ_SUBDIR@/link_test.o $(TEST_LDFLAGS)
+link_test$x : ./link_test.c $(TEST_DEPS) \
+ ../@DFT_OBJ_SUBDIR@/link_test$o
+ @ECHO_LINK@ $(CC) -o $@ $(CFLAGS_DEFAULT) ../@DFT_OBJ_SUBDIR@/link_test$o $(TEST_LDFLAGS)
-../@DFT_OBJ_SUBDIR@/dump_entry.o:
- cd ../progs && $(MAKE) ../@DFT_OBJ_SUBDIR@/dump_entry.o
+../@DFT_OBJ_SUBDIR@/dump_entry$o:
+ cd ../progs && $(MAKE) ../@DFT_OBJ_SUBDIR@/dump_entry$o
###############################################################################
# The remainder of this file is automatically generated during configuration
diff --git a/contrib/ncurses/ncurses/README b/contrib/ncurses/ncurses/README
index 20c94d3c2895..120aa5b82c1d 100644
--- a/contrib/ncurses/ncurses/README
+++ b/contrib/ncurses/ncurses/README
@@ -1,2 +1,31 @@
+-------------------------------------------------------------------------------
+-- Copyright (c) 1998-2000,2006 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. --
+-------------------------------------------------------------------------------
+-- $Id: README,v 1.9 2006/04/22 22:19:37 tom Exp $
+-------------------------------------------------------------------------------
For discussion of the package internals, see hackguide.html in the doc/html
directory.
diff --git a/contrib/ncurses/ncurses/README.IZ b/contrib/ncurses/ncurses/README.IZ
new file mode 100644
index 000000000000..78206cdfd712
--- /dev/null
+++ b/contrib/ncurses/ncurses/README.IZ
@@ -0,0 +1,95 @@
+-------------------------------------------------------------------------------
+-- Copyright (c) 2002,2006 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. --
+-------------------------------------------------------------------------------
+-- $Id: README.IZ,v 1.2 2006/04/22 23:13:05 tom Exp $
+---------------------------------------------------------------------
+
+Here is the patch. I did no testing whatsoever with event watching
+requests present (I need some applications which exersize this before
+this, probably lynx ;-), but the code looks working "the normal way".
+
+I had no way to test that the poll() branch compiles/works...
+
+Here is the API:
+
+*) two new functions wgetch_events() wgetstrn_event() are introduced,
+ which allow an event-watch specification given as the last argument;
+
+*) if the last argument is NULL, they behave as wgetch() and
+ wgetstrn() (TESTED!);
+
+*) the event specification is a pointer to _nc_eventlist, which
+ contains bookkeeping elements (count and the summary of results),
+ and an array of pointers to _nc_event;
+
+*) each _nc_event is a typed union, with two types supported "as
+ shipped": _NC_EVENT_TIMEOUT_MSEC, _NC_EVENT_FILE. For
+ _NC_EVENT_FILE the fields are fd, flag, and the output field.
+
+*) The only supported flag "as shipped" is _NC_EVENT_FILE_READABLE.
+ If the file was found readable, the return field is set to this,
+ otherwise to 0;
+
+*) If these functions return KEY_EVENT, this means that the return
+ fields in both the _nc_eventlist and _nc_event structures make
+ sense. The field result_flags of _nc_eventlist may have a
+ combination of bits _NC_EVENT_TIMEOUT_MSEC and _NC_EVENT_FILE_READABLE
+ set;
+
+*) The timeout_msec field of _NC_EVENT_TIMEOUT_MSEC _nc_event's is
+ updated on return, even if the return is not KEY_EVENT. However,
+ the change in the value represents only the amount of time spent in
+ waiting for events, not the amount of time spent bookkeeping;
+
+*) the return KEY_EVENT of wgetstrn_event() means that the output
+ string includes the user input typed so far, but the user did not have
+ a chance to press ENTER (or whatever). This call should be
+ repeated (with "shifted" pointer to a buffer, of course) to
+ complete the input;
+
+*) The presence of this extension can be checked via inspecting
+ #ifdef NCURSES_EVENT_VERSION. This symbol is not defined on BeOS,
+ since there is no support for this on BeOS.
+
+Known issues: calls interrupted by KEY_EVENT reset the ESCDELAY
+timer. This is not entirely new, since other synthetic events behave
+the same (see "if (ch >= KEY_MIN)" branch of kgetch()). However,
+KEY_EVENT may be generated in a continuous stream (say, when
+downloading a file), thus this may be more important than with other
+synthetic keys. An additional field in window structure which keeps
+timestamp of the first raw key in the queue may be needed to
+circumvent this.
+
+Another possible issue: KEY_EVENT has a preference over a user input,
+so a stream of KEY_EVENT's can make input hard. Maybe use
+result_flags as in input parameter too, which specifies whether the
+user input should have higher precedence?
+
+Also: I took an opportunity to document kgetch() better.
+
+Enjoy,
+Ilya
diff --git a/contrib/ncurses/ncurses/SigAction.h b/contrib/ncurses/ncurses/SigAction.h
index 53d12bfd42bc..5dfde643f6a1 100644
--- a/contrib/ncurses/ncurses/SigAction.h
+++ b/contrib/ncurses/ncurses/SigAction.h
@@ -32,7 +32,7 @@
****************************************************************************/
/*
- * $Id: SigAction.h,v 1.6 2000/12/10 02:36:10 tom Exp $
+ * $Id: SigAction.h,v 1.8 2005/08/06 20:05:32 tom Exp $
*
* This file exists to handle non-POSIX systems which don't have <unistd.h>,
* and usually no sigaction() nor <termios.h>
@@ -59,10 +59,6 @@ typedef struct sigaction sigaction_t;
#if HAVE_SIGVEC
-#if HAVE_LIBC_H
-#include <libc.h>
-#endif
-
#undef SIG_BLOCK
#define SIG_BLOCK 00
@@ -105,12 +101,8 @@ typedef unsigned long sigset_t;
#undef sigaddset
#define sigaddset _nc_sigaddset
-extern NCURSES_EXPORT(int) sigaction (int sig, sigaction_t * sigact, sigaction_t * osigact);
-extern NCURSES_EXPORT(int) sigprocmask (int how, sigset_t *mask, sigset_t *omask);
-extern NCURSES_EXPORT(int) sigemptyset (sigset_t *mask);
-extern NCURSES_EXPORT(int) sigsuspend (sigset_t *mask);
-extern NCURSES_EXPORT(int) sigdelset (sigset_t *mask, int sig);
-extern NCURSES_EXPORT(int) sigaddset (sigset_t *mask, int sig);
+/* tty/lib_tstp.c is the only user */
+#include <base/sigaction.c>
#endif /* HAVE_SIGVEC */
#endif /* HAVE_SIGACTION */
diff --git a/contrib/ncurses/ncurses/base/MKkeyname.awk b/contrib/ncurses/ncurses/base/MKkeyname.awk
index b8cd5da256a2..11dcfe5c2375 100644
--- a/contrib/ncurses/ncurses/base/MKkeyname.awk
+++ b/contrib/ncurses/ncurses/base/MKkeyname.awk
@@ -1,6 +1,6 @@
-# $Id: MKkeyname.awk,v 1.22 2002/05/25 22:25:06 tom Exp $
+# $Id: MKkeyname.awk,v 1.30 2006/05/20 17:35:30 tom Exp $
##############################################################################
-# Copyright (c) 1999-2001,2002 Free Software Foundation, Inc. #
+# Copyright (c) 1999-2005,2006 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"), #
@@ -31,6 +31,7 @@ BEGIN {
print ""
print "#include <curses.priv.h>"
print "#include <tic.h>"
+ print "#include <term_entry.h>"
print ""
print "const struct kn _nc_key_names[] = {"
}
@@ -42,49 +43,93 @@ BEGIN {
END {
printf "\t{ 0, 0 }};\n"
print ""
+ print "#define SIZEOF_TABLE 256"
+ print "static char **keyname_table;"
+ print ""
print "NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)"
print "{"
- print "static char **table;"
- print "int i;"
- print "char name[20];"
- print "char *p;"
- print ""
- print "\tif (c == -1) return \"-1\";"
+ print " int i;"
+ print " char name[20];"
+ print " char *p;"
+ print " NCURSES_CONST char *result = 0;"
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 < 0 || c >= 256) return \"UNKNOWN KEY\";"
+ print " if (c == -1) {"
+ print " result = \"-1\";"
+ print " } else {"
+ print " for (i = 0; _nc_key_names[i].name != 0; i++) {"
+ print " if (_nc_key_names[i].code == c) {"
+ print " result = (NCURSES_CONST char *)_nc_key_names[i].name;"
+ print " break;"
+ print " }"
+ print " }"
print ""
- print "\tif (table == 0)"
- print "\t\ttable = typeCalloc(char *, 256);"
- print "\tif (table == 0)"
- print "\t\treturn keyname(256);"
+ print " if (result == 0 && (c >= 0 && c < SIZEOF_TABLE)) {"
+ print " if (keyname_table == 0)"
+ print " keyname_table = typeCalloc(char *, SIZEOF_TABLE);"
+ print " if (keyname_table != 0) {"
+ print " if (keyname_table[c] == 0) {"
+ print " int cc = c;"
+ print " p = name;"
+ print " if (cc >= 128) {"
+ print " strcpy(p, \"M-\");"
+ print " p += 2;"
+ print " cc -= 128;"
+ print " }"
+ print " if (cc < 32)"
+ print " sprintf(p, \"^%c\", cc + '@');"
+ print " else if (cc == 127)"
+ print " strcpy(p, \"^?\");"
+ print " else"
+ print " sprintf(p, \"%c\", cc);"
+ print " keyname_table[c] = strdup(name);"
+ print " }"
+ print " result = keyname_table[c];"
+ print " }"
+ print "#if NCURSES_EXT_FUNCS && NCURSES_XNAMES"
+ print " } else if (result == 0 && cur_term != 0) {"
+ print " int j, k;"
+ print " char * bound;"
+ print " TERMTYPE *tp = &(cur_term->type);"
+ print " int save_trace = _nc_tracing;"
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 < 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 "\treturn (NCURSES_CONST char *)table[c];"
+ print " _nc_tracing = 0; /* prevent recursion via keybound() */"
+ print " for (j = 0; (bound = keybound(c, j)) != 0; ++j) {"
+ print " for(k = STRCOUNT; k < NUM_STRINGS(tp); k++) {"
+ print " if (tp->Strings[k] != 0 && !strcmp(bound, tp->Strings[k])) {"
+ print " result = ExtStrname(tp, k, strnames);"
+ print " break;"
+ print " }"
+ print " }"
+ print " free(bound);"
+ print " if (result != 0)"
+ print " break;"
+ print " }"
+ print " _nc_tracing = save_trace;"
+ print "#endif"
+ print " }"
+ print " }"
+ print " return result;"
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 " NCURSES_CONST char *result = keyname((int)c);"
+ print " if (!strncmp(result, \"M-\", 2)) result = 0;"
+ print " return result;"
print "}"
print "#endif"
+ print ""
+ print "#if NO_LEAKS"
+ print "void _nc_keyname_leaks(void)"
+ print "{"
+ print " int j;"
+ print " if (keyname_table != 0) {"
+ print " for (j = 0; j < SIZEOF_TABLE; ++j) {"
+ print " FreeIfNeeded(keyname_table[j]);"
+ print " }"
+ print " FreeAndNull(keyname_table);"
+ print " }"
+ print "}"
+ print "#endif /* NO_LEAKS */"
}
diff --git a/contrib/ncurses/ncurses/base/MKlib_gen.sh b/contrib/ncurses/ncurses/base/MKlib_gen.sh
index e172feb3baaf..30c44fff6f83 100755
--- a/contrib/ncurses/ncurses/base/MKlib_gen.sh
+++ b/contrib/ncurses/ncurses/base/MKlib_gen.sh
@@ -2,10 +2,10 @@
#
# MKlib_gen.sh -- generate sources from curses.h macro definitions
#
-# ($Id: MKlib_gen.sh,v 1.18 2002/04/30 00:37:55 tom Exp $)
+# ($Id: MKlib_gen.sh,v 1.27 2006/07/01 21:25:39 tom Exp $)
#
##############################################################################
-# Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. #
+# Copyright (c) 1998-2005,2006 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"), #
@@ -39,14 +39,14 @@
#
# This script accepts a file of prototypes on standard input. It discards
# any that don't have a `generated' comment attached. It then parses each
-# prototype (relying on the fact that none of the macros take function
+# prototype (relying on the fact that none of the macros take function
# pointer or array arguments) and generates C source from it.
#
# Here is what the pipeline stages are doing:
#
# 1. sed: extract prototypes of generated functions
# 2. sed: decorate prototypes with generated arguments a1. a2,...z
-# 3. awk: generate the calls with args matching the formals
+# 3. awk: generate the calls with args matching the formals
# 4. sed: prefix function names in prototypes so the preprocessor won't expand
# them.
# 5. cpp: macro-expand the file so the macro calls turn into C calls
@@ -54,6 +54,14 @@
# 7. sed: squeeze spaces, strip off gen_ prefix, create needed #undef
#
+# keep the editing independent of locale:
+if test "${LANGUAGE+set}" = set; then LANGUAGE=C; export LANGUAGE; fi
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+if test "${LC_COLLATE+set}" = set; then LC_COLLATE=C; export LC_COLLATE; fi
+
preprocessor="$1 -I../include"
AWK="$2"
USE="$3"
@@ -74,19 +82,19 @@ if test "$USE" = implemented ; then
cat >$ED1 <<EOF1
/^extern.*implemented/{
h
- s/^.*implemented:\([^ *]*\).*/P_#if_USE_\1_SUPPORT/p
+ s/^.*implemented:\([^ *]*\).*/P_POUNDCif_USE_\1_SUPPORT/p
g
s/^extern \([^;]*\);.*/\1/p
g
- s/^.*implemented:\([^ *]*\).*/P_#endif/p
+ s/^.*implemented:\([^ *]*\).*/P_POUNDCendif/p
}
/^extern.*generated/{
h
- s/^.*generated:\([^ *]*\).*/P_#if_USE_\1_SUPPORT/p
+ s/^.*generated:\([^ *]*\).*/P_POUNDCif_USE_\1_SUPPORT/p
g
s/^extern \([^;]*\);.*/\1/p
g
- s/^.*generated:\([^ *]*\).*/P_#endif/p
+ s/^.*generated:\([^ *]*\).*/P_POUNDCendif/p
}
EOF1
else
@@ -94,11 +102,11 @@ else
cat >$ED1 <<EOF1
/^extern.*${ALL}/{
h
- s/^.*${ALL}:\([^ *]*\).*/P_#if_USE_\1_SUPPORT/p
+ s/^.*${ALL}:\([^ *]*\).*/P_POUNDCif_USE_\1_SUPPORT/p
g
s/^extern \([^;]*\);.*/\1/p
g
- s/^.*${ALL}:\([^ *]*\).*/P_#endif/p
+ s/^.*${ALL}:\([^ *]*\).*/P_POUNDCendif/p
}
EOF1
fi
@@ -126,13 +134,14 @@ cat >$ED2 <<EOF2
s/)/ z)/
s/\.\.\. z)/...)/
:nc
- /(/s// ( /
+ s/(/ ( /
s/)/ )/
EOF2
cat >$ED3 <<EOF3
/^P_/{
- s/^P_#if_/#if /
+ s/^P_POUNDCif_/#if /
+ s/^P_POUNDCendif/#endif/
s/^P_//
b done
}
@@ -143,7 +152,7 @@ cat >$ED3 <<EOF3
s/ )/)/g
s/ gen_/ /
s/^M_/#undef /
- /^%%/s// /
+ s/^[ ]*%[ ]*%[ ]*/ /
:done
EOF3
@@ -167,12 +176,12 @@ cat >$AW1 <<\EOF1
BEGIN {
skip=0;
}
-/^P_#if/ {
+/^P_POUNDCif/ {
print "\n"
print $0
skip=0;
}
-/^P_#endif/ {
+/^P_POUNDCendif/ {
print $0
skip=1;
}
@@ -195,6 +204,10 @@ $0 !~ /^P_/ {
returnType = "SP";
} else if ( $first == "WINDOW" ) {
returnType = "Win";
+ } else if ( $first == "attr_t" || $second == "attrset" || $second == "standout" || $second == "standend" || $second == "wattrset" || $second == "wstandout" || $second == "wstandend" ) {
+ returnType = "Attr";
+ } else if ( $first == "bool" || $first == "NCURSES_BOOL" ) {
+ returnType = "Bool";
} else if ( $second == "*" ) {
returnType = "Ptr";
} else {
@@ -244,13 +257,17 @@ $0 !~ /^P_/ {
comma = ""
num = 0;
pointer = 0;
+ va_list = 0;
+ varargs = 0;
argtype = ""
for (i = myfunc; i <= NF; i++) {
ch = $i;
if ( ch == "*" )
pointer = 1;
else if ( ch == "va_list" )
- pointer = 1;
+ va_list = 1;
+ else if ( ch == "..." )
+ varargs = 1;
else if ( ch == "char" )
argtype = "char";
else if ( ch == "int" )
@@ -263,7 +280,11 @@ $0 !~ /^P_/ {
argtype = "attr";
if ( ch == "," || ch == ")" ) {
- if (pointer) {
+ if (va_list) {
+ call = call "%s"
+ } else if (varargs) {
+ call = call "%s"
+ } else if (pointer) {
if ( argtype == "char" ) {
call = call "%s"
comma = comma "_nc_visbuf2(" num ","
@@ -282,10 +303,17 @@ $0 !~ /^P_/ {
comma = comma "(long)"
}
}
- if (ch == ",")
+ if (ch == ",") {
args = args comma "a" ++num;
- else if ( argcount != 0 && $check != "..." )
- args = args comma "z"
+ } else if ( argcount != 0 ) {
+ if ( va_list ) {
+ args = args comma "\"va_list\""
+ } else if ( varargs ) {
+ args = args comma "\"...\""
+ } else {
+ args = args comma "z"
+ }
+ }
call = call ch
if (pointer == 0 && argcount != 0 && argtype != "" )
args = args ")"
@@ -352,6 +380,7 @@ BEGIN {
print " * pull most of the rest of the library into your link image."
}
print " */"
+ print "#define NCURSES_ATTR_T int"
print "#include <curses.priv.h>"
print ""
}
@@ -366,6 +395,7 @@ EOF1
cat >$TMP <<EOF
#include <ncurses_cfg.h>
+#undef NCURSES_NOMACROS
#include <curses.h>
DECLARATIONS
@@ -379,7 +409,10 @@ sed -n -f $ED1 \
| sed -e 's/^\([a-z_][a-z_]*[ *]*\)/\1 gen_/' -e 's/ / /g' >>$TMP
$preprocessor $TMP 2>/dev/null \
-| sed -e 's/ / /g' -e 's/^ //' \
+| sed \
+ -e 's/ / /g' \
+ -e 's/^ //' \
+ -e 's/^_Bool/bool/' \
| $AWK -f $AW2 \
| sed -f $ED3 \
| sed \
diff --git a/contrib/ncurses/ncurses/base/MKunctrl.awk b/contrib/ncurses/ncurses/base/MKunctrl.awk
index d8a6587e2c69..e153fa8c95c4 100644
--- a/contrib/ncurses/ncurses/base/MKunctrl.awk
+++ b/contrib/ncurses/ncurses/base/MKunctrl.awk
@@ -1,6 +1,6 @@
-# $Id: MKunctrl.awk,v 1.9 2001/06/02 23:59:20 skimo Exp $
+# $Id: MKunctrl.awk,v 1.11 2005/12/17 22:48:37 tom Exp $
##############################################################################
-# Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. #
+# Copyright (c) 1998-2004,2005 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"), #
@@ -41,6 +41,7 @@ BEGIN {
END {
print "NCURSES_EXPORT(NCURSES_CONST char *) unctrl (register chtype ch)"
print "{"
+
printf "static const char* const table[] = {"
for ( ch = 0; ch < 256; ch++ ) {
gap = ","
@@ -63,7 +64,44 @@ END {
printf "%s", gap
}
print "};"
+
+ print ""
+ print "#if NCURSES_EXT_FUNCS"
+ printf "static const char* const table2[] = {"
+ for ( ch = 128; ch < 160; ch++ ) {
+ gap = ","
+ if ((ch % 8) == 0)
+ printf "\n "
+ if (ch >= 128 && ch < 160) {
+ printf "\"\\%03o\"", ch
+ gap = gap " "
+ }
+ if (ch == 255)
+ gap = "\n"
+ else if (((ch + 1) % 8) != 0)
+ gap = gap " "
+ printf "%s", gap
+ }
+ print "};"
+ print "#endif /* NCURSES_EXT_FUNCS */"
+
+ print ""
+ print "\tint check = ChCharOf(ch);"
+ print "\tconst char *result;"
print ""
- print "\treturn (NCURSES_CONST char *)table[ChCharOf(ch)];"
+ print "\tif (check >= 0 && check < (int)SIZEOF(table)) {"
+ print "#if NCURSES_EXT_FUNCS"
+ print "\t\tif ((SP != 0)"
+ print "\t\t && (SP->_legacy_coding > 1)"
+ print "\t\t && (check >= 128)"
+ print "\t\t && (check < 160))"
+ print "\t\t\tresult = table2[check - 128];"
+ print "\t\telse"
+ print "#endif /* NCURSES_EXT_FUNCS */"
+ print "\t\t\tresult = table[check];"
+ print "\t} else {"
+ print "\t\tresult = 0;"
+ print "\t}"
+ print "\treturn (NCURSES_CONST char *)result;"
print "}"
}
diff --git a/contrib/ncurses/ncurses/base/README b/contrib/ncurses/ncurses/base/README
index ffa16963e9e3..4677e42e6176 100644
--- a/contrib/ncurses/ncurses/base/README
+++ b/contrib/ncurses/ncurses/base/README
@@ -1,4 +1,32 @@
--- $Id: README,v 1.1 1998/11/14 22:58:22 tom Exp $
+-------------------------------------------------------------------------------
+-- Copyright (c) 1998,2006 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. --
+-------------------------------------------------------------------------------
+-- $Id: README,v 1.2 2006/04/22 22:19:37 tom Exp $
+-------------------------------------------------------------------------------
The functions in this directory are the generic (not device-specific) modules
of ncurses.
diff --git a/contrib/ncurses/ncurses/base/define_key.c b/contrib/ncurses/ncurses/base/define_key.c
index 7fc885f8d9b3..3b5299a338e4 100644
--- a/contrib/ncurses/ncurses/base/define_key.c
+++ b/contrib/ncurses/ncurses/base/define_key.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 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,30 +27,35 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ * Author: Thomas E. Dickey 1997-on *
****************************************************************************/
#include <curses.priv.h>
-MODULE_ID("$Id: define_key.c,v 1.6 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: define_key.c,v 1.10 2006/06/17 18:19:48 tom Exp $")
NCURSES_EXPORT(int)
-define_key
-(char *str, int keycode)
+define_key(const char *str, int keycode)
{
int code = ERR;
T((T_CALLED("define_key(%s,%d)"), _nc_visbuf(str), keycode));
- if (keycode > 0) {
+ if (SP == 0) {
+ code = ERR;
+ } else if (keycode > 0) {
if (str != 0) {
define_key(str, 0);
} else if (has_key(keycode)) {
- while (_nc_remove_key(&(SP->_keytry), keycode))
+ while (_nc_remove_key(&(SP->_keytry), (unsigned) keycode))
code = OK;
}
if (str != 0) {
- (void) _nc_add_to_try(&(SP->_keytry), str, keycode);
- code = OK;
+ if (key_defined(str) == 0) {
+ (void) _nc_add_to_try(&(SP->_keytry), str, (unsigned) keycode);
+ code = OK;
+ } else {
+ code = ERR;
+ }
}
} else {
while (_nc_remove_string(&(SP->_keytry), str))
diff --git a/contrib/ncurses/ncurses/base/key_defined.c b/contrib/ncurses/ncurses/base/key_defined.c
new file mode 100644
index 000000000000..dac188748770
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/key_defined.c
@@ -0,0 +1,76 @@
+/****************************************************************************
+ * Copyright (c) 2003 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey, 2003 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: key_defined.c,v 1.3 2003/05/17 23:12:27 tom Exp $")
+
+static int
+find_definition(struct tries *tree, const char *str)
+{
+ struct tries *ptr;
+ int result = 0;
+
+ if (str != 0 && *str != '\0') {
+ for (ptr = tree; ptr != 0; ptr = ptr->sibling) {
+ if (UChar(*str) == UChar(ptr->ch)) {
+ if (str[1] == '\0' && ptr->child != 0) {
+ result = -1;
+ } else if ((result = find_definition(ptr->child, str + 1)) == 0) {
+ result = ptr->value;
+ } else if (str[1] == '\0') {
+ result = -1;
+ }
+ }
+ if (result != 0)
+ break;
+ }
+ }
+ return (result);
+}
+
+/*
+ * Returns the keycode associated with the given string. If none is found,
+ * return 0. If the string is only a prefix to other strings, return -1.
+ */
+NCURSES_EXPORT(int)
+key_defined(const char *str)
+{
+ int code = ERR;
+
+ T((T_CALLED("key_defined(%s)"), _nc_visbuf(str)));
+ if (SP != 0 && str != 0) {
+ code = find_definition(SP->_keytry, str);
+ }
+
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/keybound.c b/contrib/ncurses/ncurses/base/keybound.c
index c8ca2856bb97..2995714ba936 100644
--- a/contrib/ncurses/ncurses/base/keybound.c
+++ b/contrib/ncurses/ncurses/base/keybound.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2005,2006 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,20 +27,25 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1999 *
+ * Author: Thomas E. Dickey 1999-on *
****************************************************************************/
#include <curses.priv.h>
-MODULE_ID("$Id: keybound.c,v 1.3 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: keybound.c,v 1.7 2006/06/17 18:19:24 tom Exp $")
/*
* Returns the count'th string definition which is associated with the
* given keycode. The result is malloc'd, must be freed by the caller.
*/
-
NCURSES_EXPORT(char *)
keybound(int code, int count)
{
- return _nc_expand_try(SP->_key_ok, code, &count, 0);
+ char *result = 0;
+
+ T((T_CALLED("keybound(%d,%d)"), code, count));
+ if (SP != 0 && code >= 0) {
+ result = _nc_expand_try(SP->_keytry, (unsigned) code, &count, 0);
+ }
+ returnPtr(result);
}
diff --git a/contrib/ncurses/ncurses/base/keyok.c b/contrib/ncurses/ncurses/base/keyok.c
index e3b4be297c17..4c9950600c33 100644
--- a/contrib/ncurses/ncurses/base/keyok.c
+++ b/contrib/ncurses/ncurses/base/keyok.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2006 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: keyok.c,v 1.5 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: keyok.c,v 1.6 2006/06/17 18:18:43 tom Exp $")
/*
* Enable (or disable) ncurses' interpretation of a keycode by adding (or
@@ -52,21 +52,24 @@ keyok(int c, bool flag)
char *s;
T((T_CALLED("keyok(%d,%d)"), c, flag));
- if (flag) {
- while ((s = _nc_expand_try(SP->_key_ok, c, &count, 0)) != 0
- && _nc_remove_key(&(SP->_key_ok), c)) {
- _nc_add_to_try(&(SP->_keytry), s, c);
- free(s);
- code = OK;
- count = 0;
- }
- } else {
- while ((s = _nc_expand_try(SP->_keytry, c, &count, 0)) != 0
- && _nc_remove_key(&(SP->_keytry), c)) {
- _nc_add_to_try(&(SP->_key_ok), s, c);
- free(s);
- code = OK;
- count = 0;
+ if (c >= 0) {
+ unsigned ch = (unsigned) c;
+ if (flag) {
+ while ((s = _nc_expand_try(SP->_key_ok, ch, &count, 0)) != 0
+ && _nc_remove_key(&(SP->_key_ok), ch)) {
+ _nc_add_to_try(&(SP->_keytry), s, ch);
+ free(s);
+ code = OK;
+ count = 0;
+ }
+ } else {
+ while ((s = _nc_expand_try(SP->_keytry, ch, &count, 0)) != 0
+ && _nc_remove_key(&(SP->_keytry), ch)) {
+ _nc_add_to_try(&(SP->_key_ok), s, ch);
+ free(s);
+ code = OK;
+ count = 0;
+ }
}
}
returnCode(code);
diff --git a/contrib/ncurses/ncurses/base/legacy_coding.c b/contrib/ncurses/ncurses/base/legacy_coding.c
new file mode 100644
index 000000000000..1c2f160a605d
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/legacy_coding.c
@@ -0,0 +1,48 @@
+/****************************************************************************
+ * Copyright (c) 2005 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: legacy_coding.c,v 1.2 2005/12/17 23:38:17 tom Exp $")
+
+NCURSES_EXPORT(int)
+use_legacy_coding(int level)
+{
+ int result = ERR;
+
+ T((T_CALLED("use_legacy_coding(%d)"), level));
+ if (level >= 0 && level <= 2 && SP != 0) {
+ result = SP->_legacy_coding;
+ SP->_legacy_coding = level;
+ }
+ returnCode(result);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_addch.c b/contrib/ncurses/ncurses/base/lib_addch.c
index 423a45e6abe4..9d73edfde5de 100644
--- a/contrib/ncurses/ncurses/base/lib_addch.c
+++ b/contrib/ncurses/ncurses/base/lib_addch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -36,7 +36,9 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_addch.c,v 1.64 2002/05/11 18:16:43 tom Exp $")
+MODULE_ID("$Id: lib_addch.c,v 1.104 2006/10/14 20:31:19 tom Exp $")
+
+static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
/*
* Ugly microtweaking alert. Everything from here to end of module is
@@ -49,29 +51,50 @@ MODULE_ID("$Id: lib_addch.c,v 1.64 2002/05/11 18:16:43 tom Exp $")
*/
/* Return bit mask for clearing color pair number if given ch has color */
-#define COLOR_MASK(ch) (~(attr_t)((ch)&A_COLOR?A_COLOR:0))
+#define COLOR_MASK(ch) (~(attr_t)((ch) & A_COLOR ? A_COLOR : 0))
-static inline NCURSES_CH_T
+static NCURSES_INLINE NCURSES_CH_T
render_char(WINDOW *win, NCURSES_CH_T ch)
/* compute a rendition of the given char correct for the current context */
{
- attr_t a = win->_attrs;
+ attr_t a = WINDOW_ATTRS(win);
+ int pair = GetPair(ch);
- if (ISBLANK(ch) && AttrOf(ch) == A_NORMAL) {
- /* color in attrs has precedence over bkgrnd */
+ if (ISBLANK(ch)
+ && AttrOf(ch) == A_NORMAL
+ && pair == 0) {
+ /* color/pair in attrs has precedence over bkgrnd */
ch = win->_nc_bkgd;
- SetAttr(ch, a | (AttrOf(win->_nc_bkgd) & COLOR_MASK(a)));
+ SetAttr(ch, a | AttrOf(win->_nc_bkgd));
+ if ((pair = GET_WINDOW_PAIR(win)) == 0)
+ pair = GetPair(win->_nc_bkgd);
+ SetPair(ch, pair);
} else {
/* color in attrs has precedence over bkgrnd */
- a |= (AttrOf(win->_nc_bkgd) & A_ATTRIBUTES) & COLOR_MASK(a);
+ a |= AttrOf(win->_nc_bkgd) & COLOR_MASK(a);
/* color in ch has precedence */
+ if (pair == 0) {
+ if ((pair = GET_WINDOW_PAIR(win)) == 0)
+ pair = GetPair(win->_nc_bkgd);
+ }
+#if 0
+ if (pair > 255) {
+ NCURSES_CH_T fixme = ch;
+ SetPair(fixme, pair);
+ }
+#endif
AddAttr(ch, (a & COLOR_MASK(AttrOf(ch))));
+ SetPair(ch, pair);
}
- TR(TRACE_VIRTPUT, ("bkg = %s, attrs = %s -> ch = %s",
- _tracech_t2(1, CHREF(win->_nc_bkgd)),
- _traceattr(win->_attrs),
- _tracech_t2(3, CHREF(ch))));
+ TR(TRACE_VIRTPUT,
+ ("render_char bkg %s (%d), attrs %s (%d) -> ch %s (%d)",
+ _tracech_t2(1, CHREF(win->_nc_bkgd)),
+ GetPair(win->_nc_bkgd),
+ _traceattr(WINDOW_ATTRS(win)),
+ GET_WINDOW_PAIR(win),
+ _tracech_t2(3, CHREF(ch)),
+ GetPair(ch)));
return (ch);
}
@@ -99,81 +122,300 @@ _nc_render(WINDOW *win, NCURSES_CH_T ch)
#define CHECK_POSITION(win, x, y) /* nothing */
#endif
-static inline int
+static bool
+newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T * ypos)
+{
+ bool result = FALSE;
+
+ if (*ypos >= win->_regtop && *ypos == win->_regbottom) {
+ *ypos = win->_regbottom;
+ result = TRUE;
+ } else {
+ *ypos += 1;
+ }
+ return result;
+}
+
+/*
+ * The _WRAPPED flag is useful only for telling an application that we've just
+ * wrapped the cursor. We don't do anything with this flag except set it when
+ * wrapping, and clear it whenever we move the cursor. If we try to wrap at
+ * the lower-right corner of a window, we cannot move the cursor (since that
+ * wouldn't be legal). So we return an error (which is what SVr4 does).
+ * Unlike SVr4, we can successfully add a character to the lower-right corner
+ * (Solaris 2.6 does this also, however).
+ */
+static int
+wrap_to_next_line(WINDOW *win)
+{
+ win->_flags |= _WRAPPED;
+ if (newline_forces_scroll(win, &(win->_cury))) {
+ win->_curx = win->_maxx;
+ if (!win->_scroll)
+ return (ERR);
+ scroll(win);
+ }
+ win->_curx = 0;
+ return (OK);
+}
+
+#if USE_WIDEC_SUPPORT
+static int waddch_literal(WINDOW *, NCURSES_CH_T);
+/*
+ * Fill the given number of cells with blanks using the current background
+ * rendition. This saves/restores the current x-position.
+ */
+static void
+fill_cells(WINDOW *win, int count)
+{
+ NCURSES_CH_T blank = blankchar;
+ int save_x = win->_curx;
+ int save_y = win->_cury;
+
+ while (count-- > 0) {
+ if (waddch_literal(win, blank) == ERR)
+ break;
+ }
+ win->_curx = save_x;
+ win->_cury = save_y;
+}
+#endif
+
+/*
+ * Build up the bytes for a multibyte character, returning the length when
+ * complete (a positive number), -1 for error and -2 for incomplete.
+ */
+#if USE_WIDEC_SUPPORT
+NCURSES_EXPORT(int)
+_nc_build_wch(WINDOW *win, ARG_CH_T ch)
+{
+ char *buffer = WINDOW_EXT(win, addch_work);
+ int len;
+ int x = win->_curx;
+ int y = win->_cury;
+ mbstate_t state;
+ wchar_t result;
+
+ if ((WINDOW_EXT(win, addch_used) != 0) &&
+ (WINDOW_EXT(win, addch_x) != x ||
+ WINDOW_EXT(win, addch_y) != y)) {
+ /* discard the incomplete multibyte character */
+ WINDOW_EXT(win, addch_used) = 0;
+ TR(TRACE_VIRTPUT,
+ ("Alert discarded multibyte on move (%d,%d) -> (%d,%d)",
+ WINDOW_EXT(win, addch_y), WINDOW_EXT(win, addch_x),
+ y, x));
+ }
+ WINDOW_EXT(win, addch_x) = x;
+ WINDOW_EXT(win, addch_y) = y;
+
+ init_mb(state);
+ buffer[WINDOW_EXT(win, addch_used)] = CharOf(CHDEREF(ch));
+ WINDOW_EXT(win, addch_used) += 1;
+ buffer[WINDOW_EXT(win, addch_used)] = '\0';
+ if ((len = mbrtowc(&result,
+ buffer,
+ WINDOW_EXT(win, addch_used), &state)) > 0) {
+ attr_t attrs = AttrOf(CHDEREF(ch));
+ SetChar(CHDEREF(ch), result, attrs);
+ WINDOW_EXT(win, addch_used) = 0;
+ } else {
+ if (len == -1) {
+ /*
+ * An error occurred. We could either discard everything,
+ * or assume that the error was in the previous input.
+ * Try the latter.
+ */
+ TR(TRACE_VIRTPUT, ("Alert! mbrtowc returns error"));
+ buffer[0] = CharOf(CHDEREF(ch));
+ WINDOW_EXT(win, addch_used) = 1;
+ }
+ }
+ return len;
+}
+#endif /* USE_WIDEC_SUPPORT */
+
+static
+#if !USE_WIDEC_SUPPORT /* cannot be inline if it is recursive */
+NCURSES_INLINE
+#endif
+int
waddch_literal(WINDOW *win, NCURSES_CH_T ch)
{
int x;
+ int y;
struct ldat *line;
x = win->_curx;
+ y = win->_cury;
- CHECK_POSITION(win, x, win->_cury);
-
- /*
- * If we're trying to add a character at the lower-right corner more
- * than once, fail. (Moving the cursor will clear the flag).
- */
-#if 0 /* Solaris 2.6 allows updating the corner more than once */
- if (win->_flags & _WRAPPED) {
- if (x >= win->_maxx)
- return (ERR);
- win->_flags &= ~_WRAPPED;
- }
-#endif
+ CHECK_POSITION(win, x, y);
ch = render_char(win, ch);
- TR(TRACE_VIRTPUT, ("win attr = %s", _traceattr(win->_attrs)));
- line = win->_line + win->_cury;
+ line = win->_line + y;
CHANGED_CELL(line, x);
- line->text[x++] = ch;
+ /*
+ * Build up multibyte characters until we have a wide-character.
+ */
if_WIDEC({
- if (wcwidth(CharOf(ch)) > 1)
- AddAttr(line->text[x++], WA_NAC);
+ if (WINDOW_EXT(win, addch_used) != 0 || !Charable(ch)) {
+ int len = _nc_build_wch(win, CHREF(ch));
+
+ if (len > 0) {
+ if (is8bits(CharOf(ch))) {
+ const char *s = unctrl((chtype) CharOf(ch));
+ if (s[1] != 0) {
+ return waddstr(win, s);
+ }
+ }
+ } else {
+ return OK;
+ }
+ }
});
- 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
- * we've just wrapped the cursor. We don't do anything with this flag
- * except set it when wrapping, and clear it whenever we move the
- * cursor. If we try to wrap at the lower-right corner of a window, we
- * cannot move the cursor (since that wouldn't be legal). So we return
- * an error (which is what SVr4 does). Unlike SVr4, we can
- * successfully add a character to the lower-right corner (Solaris 2.6
- * does this also, however).
- */
- win->_flags |= _WRAPPED;
- if (++win->_cury > win->_regbottom) {
- win->_cury = win->_regbottom;
- win->_curx = win->_maxx;
- if (!win->_scroll)
- return (ERR);
- scroll(win);
+ /*
+ * Non-spacing characters are added to the current cell.
+ *
+ * Spacing characters that are wider than one column require some display
+ * adjustments.
+ */
+ if_WIDEC({
+ int len = wcwidth(CharOf(ch));
+ int i;
+ int j;
+
+ if (len == 0) { /* non-spacing */
+ if ((x > 0 && y >= 0)
+ || ((y = win->_cury - 1) >= 0 &&
+ (x = win->_maxx) > 0)) {
+ wchar_t *chars = (win->_line[y].text[x - 1].chars);
+ for (i = 0; i < CCHARW_MAX; ++i) {
+ if (chars[i] == 0) {
+ TR(TRACE_VIRTPUT,
+ ("added non-spacing %d: %x",
+ x, (int) CharOf(ch)));
+ chars[i] = CharOf(ch);
+ break;
+ }
+ }
+ }
+ goto testwrapping;
+ } else if (len > 1) { /* multi-column characters */
+ /*
+ * Check if the character will fit on the current line. If it does
+ * not fit, fill in the remainder of the line with blanks. and
+ * move to the next line.
+ */
+ if (len > win->_maxx + 1) {
+ TR(TRACE_VIRTPUT, ("character will not fit"));
+ return ERR;
+ } else if (x + len > win->_maxx + 1) {
+ int count = win->_maxx + 1 - x;
+ TR(TRACE_VIRTPUT, ("fill %d remaining cells", count));
+ fill_cells(win, count);
+ if (wrap_to_next_line(win) == ERR)
+ return ERR;
+ x = win->_curx;
+ y = win->_cury;
+ }
+ /*
+ * Check for cells which are orphaned by adding this character, set
+ * those to blanks.
+ *
+ * FIXME: this actually could fill j-i cells, more complicated to
+ * setup though.
+ */
+ for (i = 0; i < len; ++i) {
+ if (isWidecBase(win->_line[y].text[x + i])) {
+ break;
+ } else if (isWidecExt(win->_line[y].text[x + i])) {
+ for (j = i; x + j <= win->_maxx; ++j) {
+ if (!isWidecExt(win->_line[y].text[x + j])) {
+ TR(TRACE_VIRTPUT, ("fill %d orphan cells", j));
+ fill_cells(win, j);
+ break;
+ }
+ }
+ break;
+ }
+ }
+ /*
+ * Finally, add the cells for this character.
+ */
+ for (i = 0; i < len; ++i) {
+ NCURSES_CH_T value = ch;
+ SetWidecExt(value, i);
+ TR(TRACE_VIRTPUT, ("multicolumn %d:%d (%d,%d)",
+ i + 1, len,
+ win->_begy + y, win->_begx + x));
+ line->text[x] = value;
+ CHANGED_CELL(line, x);
+ ++x;
+ }
+ goto testwrapping;
}
- win->_curx = 0;
- return (OK);
+ });
+
+ /*
+ * Single-column characters.
+ */
+ line->text[x++] = ch;
+ /*
+ * This label is used only for wide-characters.
+ */
+ if_WIDEC(
+ testwrapping:
+ );
+
+ TR(TRACE_VIRTPUT, ("cell (%ld, %ld..%d) = %s",
+ (long) win->_cury, (long) win->_curx, x - 1,
+ _tracech_t(CHREF(ch))));
+
+ if (x > win->_maxx) {
+ return wrap_to_next_line(win);
}
win->_curx = x;
return OK;
}
-static inline int
+static NCURSES_INLINE int
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;
+ NCURSES_SIZE_T x, y;
+ chtype t = CharOf(ch);
+ const char *s = unctrl(t);
+ /*
+ * If we are using the alternate character set, forget about locale.
+ * Otherwise, if unctrl() returns a single-character or the locale
+ * claims the code is printable, treat it that way.
+ */
if ((AttrOf(ch) & A_ALTCHARSET)
- || ((t = CharOf(ch)) > 127)
- || ((s = unctrl(t))[1] == 0))
+ || (
+#if USE_WIDEC_SUPPORT
+ (SP != 0 && SP->_legacy_coding) &&
+#endif
+ s[1] == 0
+ )
+ || (
+ isprint(t)
+#if USE_WIDEC_SUPPORT
+ || ((SP == 0 || !SP->_legacy_coding) &&
+ (WINDOW_EXT(win, addch_used)
+ || !_nc_is_charable(CharOf(ch))))
+#endif
+ ))
return waddch_literal(win, ch);
+ /*
+ * Handle carriage control and other codes that are not printable, or are
+ * known to expand to more than one character according to unctrl().
+ */
x = win->_curx;
y = win->_cury;
@@ -187,7 +429,7 @@ waddch_nosync(WINDOW *win, const NCURSES_CH_T ch)
*/
if ((!win->_scroll && (y == win->_regbottom))
|| (x <= win->_maxx)) {
- NCURSES_CH_T blank = NewChar2(BLANK_TEXT, BLANK_ATTR);
+ NCURSES_CH_T blank = blankchar;
AddAttr(blank, AttrOf(ch));
while (win->_curx < x) {
if (waddch_literal(win, blank) == ERR)
@@ -197,9 +439,8 @@ waddch_nosync(WINDOW *win, const NCURSES_CH_T ch)
} else {
wclrtoeol(win);
win->_flags |= _WRAPPED;
- if (++y > win->_regbottom) {
+ if (newline_forces_scroll(win, &y)) {
x = win->_maxx;
- y--;
if (win->_scroll) {
scroll(win);
x = 0;
@@ -211,8 +452,7 @@ waddch_nosync(WINDOW *win, const NCURSES_CH_T ch)
break;
case '\n':
wclrtoeol(win);
- if (++y > win->_regbottom) {
- y--;
+ if (newline_forces_scroll(win, &y)) {
if (win->_scroll)
scroll(win);
else
@@ -253,7 +493,7 @@ _nc_waddch_nosync(WINDOW *win, const NCURSES_CH_T c)
}
/*
- * The versions below call _nc_synhook(). We wanted to avoid this in the
+ * The versions below call _nc_synchook(). We wanted to avoid this in the
* version exported for string puts; they'll call _nc_synchook once at end
* of run.
*/
@@ -299,41 +539,3 @@ wechochar(WINDOW *win, const chtype ch)
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);
- win->_immed = save_immed;
- code = OK;
- }
- 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 343555a39aff..b7a0b40ef948 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,10 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * *
+ * Rewritten 2001-2004 to support wide-characters by *
+ * Sven Verdoolaege *
+ * Thomas Dickey *
****************************************************************************/
/*
@@ -40,68 +44,28 @@
#include <curses.priv.h>
-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
+MODULE_ID("$Id: lib_addstr.c,v 1.46 2006/05/27 19:22:19 tom Exp $")
NCURSES_EXPORT(int)
-waddnstr(WINDOW *win, const char *const astr, int n)
+waddnstr(WINDOW *win, const char *astr, int n)
{
- unsigned const char *str = (unsigned const char *) astr;
+ const char *str = astr;
int code = ERR;
- CONV_DATA;
- T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbuf(astr), n));
+ T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbufn(astr, n), n));
if (win && (str != 0)) {
- TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs)));
+ TR(TRACE_VIRTPUT | TRACE_ATTRS,
+ ("... current %s", _traceattr(WINDOW_ATTRS(win))));
code = OK;
if (n < 0)
n = (int) strlen(astr);
TR(TRACE_VIRTPUT, ("str is not null, length = %d", n));
- CONV_INIT;
- while ((n > 0) && (*str != '\0')) {
+ while ((n-- > 0) && (*str != '\0')) {
NCURSES_CH_T ch;
- TR(TRACE_VIRTPUT, ("*str = %#x", *str));
- NEXT_CHAR(str, ch, n);
+ TR(TRACE_VIRTPUT, ("*str = %#o", UChar(*str)));
+ SetChar(ch, UChar(*str++), A_NORMAL);
if (_nc_waddch_nosync(win, ch) == ERR) {
code = ERR;
break;
@@ -114,11 +78,12 @@ waddnstr(WINDOW *win, const char *const astr, int n)
}
NCURSES_EXPORT(int)
-waddchnstr(WINDOW *win, const chtype * const astr, int n)
+waddchnstr(WINDOW *win, const chtype *astr, int n)
{
NCURSES_SIZE_T y = win->_cury;
NCURSES_SIZE_T x = win->_curx;
int code = OK;
+ int i;
struct ldat *line;
T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n));
@@ -138,15 +103,9 @@ waddchnstr(WINDOW *win, const chtype * const astr, int n)
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]));
+ for (i = 0; i < n && ChCharOf(astr[i]) != '\0'; ++i) {
+ SetChar2(line->text[i + x], astr[i]);
}
-#else
- memcpy(line->text + x, astr, n * sizeof(*astr));
-#endif
CHANGED_RANGE(line, x, x + n - 1);
_nc_synchook(win);
@@ -155,8 +114,8 @@ waddchnstr(WINDOW *win, const chtype * const astr, int n)
#if USE_WIDEC_SUPPORT
-int
-_nc_wchstrlen(const cchar_t * s)
+NCURSES_EXPORT(int)
+_nc_wchstrlen(const cchar_t *s)
{
int result = 0;
while (CharOf(s[result]) != L'\0') {
@@ -166,13 +125,14 @@ _nc_wchstrlen(const cchar_t * s)
}
NCURSES_EXPORT(int)
-wadd_wchnstr(WINDOW *win, const cchar_t * const astr, int n)
+wadd_wchnstr(WINDOW *win, const cchar_t *astr, int n)
{
+ static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
NCURSES_SIZE_T y = win->_cury;
NCURSES_SIZE_T x = win->_curx;
int code = OK;
struct ldat *line;
- int i, start, end;
+ int i, j, start, len, end;
T((T_CALLED("wadd_wchnstr(%p,%s,%d)"), win, _nc_viscbuf(astr, n), n));
@@ -190,22 +150,58 @@ wadd_wchnstr(WINDOW *win, const cchar_t * const astr, int n)
line = &(win->_line[y]);
start = x;
end = x + n - 1;
- if (isnac(line->text[x])) {
- line->text[x - 1] = win->_nc_bkgd;
- --start;
+
+ /*
+ * Reset orphaned cells of multi-column characters that extend up to the
+ * new string's location to blanks.
+ */
+ if (x > 0 && isWidecExt(line->text[x])) {
+ for (i = 0; i <= x; ++i) {
+ if (!isWidecExt(line->text[x - i])) {
+ /* must be isWidecBase() */
+ start -= i;
+ while (i > 0) {
+ line->text[x - i--] = _nc_render(win, blank);
+ }
+ break;
+ }
+ }
}
- 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;
+
+ /*
+ * Copy the new string to the window.
+ */
+ for (i = 0; i < n && CharOf(astr[i]) != L'\0' && x <= win->_maxx; ++i) {
+ if (isWidecExt(astr[i]))
+ continue;
+
+ len = wcwidth(CharOf(astr[i]));
+
+ if (x + len - 1 <= win->_maxx) {
+ line->text[x] = _nc_render(win, astr[i]);
+ if (len > 1) {
+ for (j = 0; j < len; ++j) {
+ if (j != 0) {
+ line->text[x + j] = line->text[x];
+ }
+ SetWidecExt(line->text[x + j], j);
+ }
+ }
+ x += len;
+ end += len - 1;
+ } else {
+ break;
}
}
- if (x <= win->_maxx && isnac(line->text[x])) {
- line->text[x] = win->_nc_bkgd;
+
+ /*
+ * Set orphaned cells of multi-column characters which lie after the new
+ * string to blanks.
+ */
+ while (x <= win->_maxx && isWidecExt(line->text[x])) {
+ line->text[x] = _nc_render(win, blank);
++end;
+ ++x;
}
CHANGED_RANGE(line, start, end);
@@ -214,15 +210,15 @@ wadd_wchnstr(WINDOW *win, const cchar_t * const astr, int n)
}
NCURSES_EXPORT(int)
-waddnwstr(WINDOW *win, const wchar_t * str, int n)
+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));
+ T((T_CALLED("waddnwstr(%p,%s,%d)"), win, _nc_viswbufn(str, n), n));
if (win && (str != 0)) {
- TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs)));
+ TR(TRACE_VIRTPUT | TRACE_ATTRS,
+ ("... current %s", _traceattr(WINDOW_ATTRS(win))));
code = OK;
if (n < 0)
n = (int) wcslen(str);
@@ -230,16 +226,9 @@ waddnwstr(WINDOW *win, const wchar_t * str, int n)
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));
+ TR(TRACE_VIRTPUT, ("*str[0] = %#lx", (unsigned long) *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) {
+ if (wadd_wch(win, &ch) == ERR) {
code = ERR;
break;
}
diff --git a/contrib/ncurses/ncurses/base/lib_beep.c b/contrib/ncurses/ncurses/base/lib_beep.c
index c23d0a1d2ff1..b478f251a1bb 100644
--- a/contrib/ncurses/ncurses/base/lib_beep.c
+++ b/contrib/ncurses/ncurses/base/lib_beep.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -41,7 +42,7 @@
#include <curses.priv.h>
#include <term.h> /* beep, flash */
-MODULE_ID("$Id: lib_beep.c,v 1.9 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: lib_beep.c,v 1.10 2005/04/09 15:20:04 tom Exp $")
/*
* beep()
@@ -59,7 +60,9 @@ beep(void)
T((T_CALLED("beep()")));
/* FIXME: should make sure that we are not in altchar mode */
- if (bell) {
+ if (cur_term == 0) {
+ res = ERR;
+ } else if (bell) {
TPUTS_TRACE("bell");
res = putp(bell);
_nc_flush();
diff --git a/contrib/ncurses/ncurses/base/lib_bkgd.c b/contrib/ncurses/ncurses/base/lib_bkgd.c
index a3d7c306e29d..e6a0cb000b15 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,11 +29,14 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Juergen Pfeifer 1997 *
+ * and: Sven Verdoolaege 2000 *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_bkgd.c,v 1.26 2001/12/19 01:36:58 tom Exp $")
+MODULE_ID("$Id: lib_bkgd.c,v 1.35 2006/05/27 19:20:11 tom Exp $")
/*
* Set the window's background information.
@@ -41,7 +44,7 @@ MODULE_ID("$Id: lib_bkgd.c,v 1.26 2001/12/19 01:36:58 tom Exp $")
#if USE_WIDEC_SUPPORT
NCURSES_EXPORT(void)
#else
-static inline void
+static NCURSES_INLINE void
#endif
wbkgrndset(WINDOW *win, const ARG_CH_T ch)
{
@@ -51,13 +54,26 @@ wbkgrndset(WINDOW *win, const ARG_CH_T 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);
+ toggle_attr_off(WINDOW_ATTRS(win), off);
+ toggle_attr_on(WINDOW_ATTRS(win), on);
- if (CharOf(CHDEREF(ch)) == L('\0'))
+#if NCURSES_EXT_COLORS
+ {
+ int pair;
+
+ if ((pair = GetPair(win->_nc_bkgd)) != 0)
+ SET_WINDOW_PAIR(win, 0);
+ if ((pair = GetPair(CHDEREF(ch))) != 0)
+ SET_WINDOW_PAIR(win, pair);
+ }
+#endif
+
+ if (CharOf(CHDEREF(ch)) == L('\0')) {
SetChar(win->_nc_bkgd, BLANK_TEXT, AttrOf(CHDEREF(ch)));
- else
+ SetPair(win->_nc_bkgd, GetPair(CHDEREF(ch)));
+ } else {
win->_nc_bkgd = CHDEREF(ch);
+ }
#if USE_WIDEC_SUPPORT
/*
* If we're compiled for wide-character support, _bkgrnd is the
@@ -70,9 +86,11 @@ wbkgrndset(WINDOW *win, const ARG_CH_T ch)
int tmp;
wgetbkgrnd(win, &wch);
- tmp = wctob(CharOf(wch));
+ tmp = _nc_to_char((wint_t) CharOf(wch));
- win->_bkgd = ((tmp == EOF) ? ' ' : (chtype) tmp) | AttrOf(wch);
+ win->_bkgd = (((tmp == EOF) ? ' ' : (chtype) tmp)
+ | (AttrOf(wch) & ALL_BUT_COLOR)
+ | COLOR_PAIR(GET_WINDOW_PAIR(win)));
}
#endif
}
@@ -93,7 +111,7 @@ wbkgdset(WINDOW *win, chtype ch)
#if USE_WIDEC_SUPPORT
NCURSES_EXPORT(int)
#else
-static inline int
+static NCURSES_INLINE int
#undef wbkgrnd
#endif
wbkgrnd(WINDOW *win, const ARG_CH_T ch)
@@ -113,11 +131,11 @@ wbkgrnd(WINDOW *win, const ARG_CH_T ch)
for (y = 0; y <= win->_maxy; y++) {
for (x = 0; x <= win->_maxx; x++) {
- if (CharEq(win->_line[y].text[x], old_bkgrnd))
+ if (CharEq(win->_line[y].text[x], old_bkgrnd)) {
win->_line[y].text[x] = win->_nc_bkgd;
- else {
+ } else {
NCURSES_CH_T wch = win->_line[y].text[x];
- RemAttr(wch, ~A_ALTCHARSET);
+ RemAttr(wch, (~(A_ALTCHARSET | A_CHARTEXT)));
win->_line[y].text[x] = _nc_render(win, wch);
}
}
@@ -130,7 +148,7 @@ wbkgrnd(WINDOW *win, const ARG_CH_T ch)
}
NCURSES_EXPORT(int)
-wbkgd(WINDOW *win, const chtype ch)
+wbkgd(WINDOW *win, chtype ch)
{
NCURSES_CH_T wch;
SetChar2(wch, ch);
diff --git a/contrib/ncurses/ncurses/base/lib_box.c b/contrib/ncurses/ncurses/base/lib_box.c
index 7181edb3ed34..d6cfc6cfe09c 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,2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,8 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
+ * and: Sven Verdoolaege 2001 *
****************************************************************************/
/*
@@ -40,7 +42,21 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_box.c,v 1.18 2002/02/23 20:40:06 tom Exp $")
+MODULE_ID("$Id: lib_box.c,v 1.22 2005/11/26 15:39:42 tom Exp $")
+
+#if USE_WIDEC_SUPPORT
+static NCURSES_INLINE chtype
+_my_render(WINDOW *win, chtype ch)
+{
+ NCURSES_CH_T wch;
+ SetChar2(wch, ch);
+ wch = _nc_render(win, wch);
+ return CharOf(wch) | AttrOf(wch);
+}
+#define RENDER_WITH_DEFAULT(ch,def) w ## ch = _my_render(win, (ch == 0) ? def : ch)
+#else
+#define RENDER_WITH_DEFAULT(ch,def) w ## ch = _nc_render(win, (ch == 0) ? def : ch)
+#endif
NCURSES_EXPORT(int)
wborder(WINDOW *win,
@@ -67,8 +83,6 @@ wborder(WINDOW *win,
if (!win)
returnCode(ERR);
-#define RENDER_WITH_DEFAULT(ch,def) w ## ch = (ch == 0) ? def : ch
-
RENDER_WITH_DEFAULT(ls, ACS_VLINE);
RENDER_WITH_DEFAULT(rs, ACS_VLINE);
RENDER_WITH_DEFAULT(ts, ACS_HLINE);
@@ -92,22 +106,22 @@ wborder(WINDOW *win,
endy = win->_maxy;
for (i = 0; i <= endx; i++) {
- SetChar(win->_line[0].text[i], ChCharOf(wts), ChAttrOf(wts));
- SetChar(win->_line[endy].text[i], ChCharOf(wbs), ChAttrOf(wbs));
+ SetChar2(win->_line[0].text[i], wts);
+ SetChar2(win->_line[endy].text[i], 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++) {
- SetChar(win->_line[i].text[0], ChCharOf(wls), ChAttrOf(wls));
- SetChar(win->_line[i].text[endx], ChCharOf(wrs), ChAttrOf(wrs));
+ SetChar2(win->_line[i].text[0], wls);
+ SetChar2(win->_line[i].text[endx], wrs);
win->_line[i].firstchar = 0;
win->_line[i].lastchar = endx;
}
- 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));
+ SetChar2(win->_line[0].text[0], wtl);
+ SetChar2(win->_line[0].text[endx], wtr);
+ SetChar2(win->_line[endy].text[0], wbl);
+ SetChar2(win->_line[endy].text[endx], 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 54e66ed1ffae..89eefa7e82fe 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,8 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Sven Verdoolaege 2001 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
@@ -40,21 +42,25 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_chgat.c,v 1.5 2001/06/03 00:05:02 skimo Exp $")
+MODULE_ID("$Id: lib_chgat.c,v 1.7 2006/07/15 22:07:11 tom Exp $")
NCURSES_EXPORT(int)
-wchgat
-(WINDOW *win, int n, attr_t attr, short color, const void *opts GCC_UNUSED)
+wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts GCC_UNUSED)
{
int i;
T((T_CALLED("wchgat(%p,%d,%s,%d)"), win, n, _traceattr(attr), color));
if (win) {
+ struct ldat *line = &(win->_line[win->_cury]);
+
toggle_attr_on(attr, COLOR_PAIR(color));
- for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++)
- SetAttr(win->_line[win->_cury].text[i], attr);
+ for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++) {
+ SetAttr(line->text[i], attr);
+ SetPair(line->text[i], color);
+ CHANGED_CELL(line, i);
+ }
returnCode(OK);
} else
diff --git a/contrib/ncurses/ncurses/base/lib_clrbot.c b/contrib/ncurses/ncurses/base/lib_clrbot.c
index bc12960e48f0..df196e815f82 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2006 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.19 2001/12/19 01:05:59 tom Exp $")
+MODULE_ID("$Id: lib_clrbot.c,v 1.20 2006/10/14 20:43:31 tom Exp $")
NCURSES_EXPORT(int)
wclrtobot(WINDOW *win)
@@ -54,8 +54,8 @@ wclrtobot(WINDOW *win)
NCURSES_SIZE_T startx = win->_curx;
NCURSES_CH_T blank = win->_nc_bkgd;
- T(("clearing from y = %d to y = %d with maxx = %d",
- win->_cury, win->_maxy, win->_maxx));
+ T(("clearing from y = %ld to y = %ld with maxx = %ld",
+ (long) win->_cury, (long) win->_maxy, (long) win->_maxx));
for (y = win->_cury; y <= win->_maxy; y++) {
struct ldat *line = &(win->_line[y]);
diff --git a/contrib/ncurses/ncurses/base/lib_color.c b/contrib/ncurses/ncurses/base/lib_color.c
index 42d301d5e9ad..a90ca9d34308 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/* lib_color.c
@@ -41,7 +42,7 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$Id: lib_color.c,v 1.58 2001/09/01 21:42:59 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.80 2006/11/26 01:33:16 tom Exp $")
/*
* These should be screen structure members. They need to be globals for
@@ -51,6 +52,12 @@ MODULE_ID("$Id: lib_color.c,v 1.58 2001/09/01 21:42:59 tom Exp $")
NCURSES_EXPORT_VAR(int) COLOR_PAIRS = 0;
NCURSES_EXPORT_VAR(int) COLORS = 0;
+#define DATA(r,g,b) {r,g,b, 0,0,0, 0}
+
+#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
+
+#define OkColorHi(n) (((n) < COLORS) && ((n) < max_colors))
+
/*
* Given a RGB range of 0..1000, we'll normally set the individual values
* to about 2/3 of the maximum, leaving full-range for bold/bright colors.
@@ -61,27 +68,27 @@ NCURSES_EXPORT_VAR(int) COLORS = 0;
static const color_t cga_palette[] =
{
/* R G B */
- {RGB_OFF, RGB_OFF, RGB_OFF}, /* COLOR_BLACK */
- {RGB_ON, RGB_OFF, RGB_OFF}, /* COLOR_RED */
- {RGB_OFF, RGB_ON, RGB_OFF}, /* COLOR_GREEN */
- {RGB_ON, RGB_ON, RGB_OFF}, /* COLOR_YELLOW */
- {RGB_OFF, RGB_OFF, RGB_ON}, /* COLOR_BLUE */
- {RGB_ON, RGB_OFF, RGB_ON}, /* COLOR_MAGENTA */
- {RGB_OFF, RGB_ON, RGB_ON}, /* COLOR_CYAN */
- {RGB_ON, RGB_ON, RGB_ON}, /* COLOR_WHITE */
+ DATA(RGB_OFF, RGB_OFF, RGB_OFF), /* COLOR_BLACK */
+ DATA(RGB_ON, RGB_OFF, RGB_OFF), /* COLOR_RED */
+ DATA(RGB_OFF, RGB_ON, RGB_OFF), /* COLOR_GREEN */
+ DATA(RGB_ON, RGB_ON, RGB_OFF), /* COLOR_YELLOW */
+ DATA(RGB_OFF, RGB_OFF, RGB_ON), /* COLOR_BLUE */
+ DATA(RGB_ON, RGB_OFF, RGB_ON), /* COLOR_MAGENTA */
+ DATA(RGB_OFF, RGB_ON, RGB_ON), /* COLOR_CYAN */
+ DATA(RGB_ON, RGB_ON, RGB_ON), /* COLOR_WHITE */
};
static const color_t hls_palette[] =
{
- /* H L S */
- { 0, 0, 0}, /* COLOR_BLACK */
- { 120, 50, 100}, /* COLOR_RED */
- { 240, 50, 100}, /* COLOR_GREEN */
- { 180, 50, 100}, /* COLOR_YELLOW */
- { 330, 50, 100}, /* COLOR_BLUE */
- { 60, 50, 100}, /* COLOR_MAGENTA */
- { 300, 50, 100}, /* COLOR_CYAN */
- { 0, 50, 100}, /* COLOR_WHITE */
+ /* H L S */
+ DATA( 0, 0, 0), /* COLOR_BLACK */
+ DATA( 120, 50, 100), /* COLOR_RED */
+ DATA( 240, 50, 100), /* COLOR_GREEN */
+ DATA( 180, 50, 100), /* COLOR_YELLOW */
+ DATA( 330, 50, 100), /* COLOR_BLUE */
+ DATA( 60, 50, 100), /* COLOR_MAGENTA */
+ DATA( 300, 50, 100), /* COLOR_CYAN */
+ DATA( 0, 50, 100), /* COLOR_WHITE */
};
/* *INDENT-ON* */
@@ -128,10 +135,10 @@ set_background_color(int bg, int (*outc) (int))
{
if (set_a_background) {
TPUTS_TRACE("set_a_background");
- tputs(tparm(set_a_background, bg), 1, outc);
+ tputs(TPARM_1(set_a_background, bg), 1, outc);
} else {
TPUTS_TRACE("set_background");
- tputs(tparm(set_background, toggled_colors(bg)), 1, outc);
+ tputs(TPARM_1(set_background, toggled_colors(bg)), 1, outc);
}
}
@@ -140,56 +147,19 @@ set_foreground_color(int fg, int (*outc) (int))
{
if (set_a_foreground) {
TPUTS_TRACE("set_a_foreground");
- tputs(tparm(set_a_foreground, fg), 1, outc);
+ tputs(TPARM_1(set_a_foreground, fg), 1, outc);
} else {
TPUTS_TRACE("set_foreground");
- tputs(tparm(set_foreground, toggled_colors(fg)), 1, outc);
- }
-}
-
-static bool
-set_original_colors(void)
-{
- if (orig_pair != 0) {
- TPUTS_TRACE("orig_pair");
- putp(orig_pair);
- return TRUE;
- } else if (orig_colors != NULL) {
- TPUTS_TRACE("orig_colors");
- putp(orig_colors);
- return TRUE;
+ tputs(TPARM_1(set_foreground, toggled_colors(fg)), 1, outc);
}
- return FALSE;
}
-NCURSES_EXPORT(int)
-start_color(void)
+static void
+init_color_table(void)
{
- int n;
const color_t *tp;
+ int n;
- T((T_CALLED("start_color()")));
-
- if (set_original_colors() != TRUE) {
- set_foreground_color(default_fg(), _nc_outch);
- set_background_color(default_bg(), _nc_outch);
- }
-
- if (VALID_NUMERIC(max_pairs))
- COLOR_PAIRS = SP->_pair_count = max_pairs;
- else
- returnCode(ERR);
- if ((SP->_color_pairs = typeCalloc(unsigned short, max_pairs)) == 0)
- returnCode(ERR);
- SP->_color_pairs[0] = PAIR_OF(default_fg(), default_bg());
- if (VALID_NUMERIC(max_colors))
- COLORS = SP->_color_count = max_colors;
- else
- returnCode(ERR);
- SP->_coloron = 1;
-
- if ((SP->_color_table = typeMalloc(color_t, COLORS)) == 0)
- returnCode(ERR);
tp = (hue_lightness_saturation) ? hls_palette : cga_palette;
for (n = 0; n < COLORS; n++) {
if (n < 8) {
@@ -208,10 +178,91 @@ start_color(void)
}
}
}
+}
- T(("started color: COLORS = %d, COLOR_PAIRS = %d", COLORS, COLOR_PAIRS));
+/*
+ * Reset the color pair, e.g., to whatever color pair 0 is.
+ */
+static bool
+reset_color_pair(void)
+{
+ bool result = FALSE;
- returnCode(OK);
+ if (orig_pair != 0) {
+ TPUTS_TRACE("orig_pair");
+ putp(orig_pair);
+ result = TRUE;
+ }
+ return result;
+}
+
+/*
+ * Reset color pairs and definitions. Actually we do both more to accommodate
+ * badly-written terminal descriptions than for the relatively rare case where
+ * someone has changed the color definitions.
+ */
+bool
+_nc_reset_colors(void)
+{
+ int result = FALSE;
+
+ T((T_CALLED("_nc_reset_colors()")));
+ if (SP->_color_defs > 0)
+ SP->_color_defs = -(SP->_color_defs);
+
+ if (reset_color_pair())
+ result = TRUE;
+ if (orig_colors != 0) {
+ TPUTS_TRACE("orig_colors");
+ putp(orig_colors);
+ result = TRUE;
+ }
+ returnBool(result);
+}
+
+NCURSES_EXPORT(int)
+start_color(void)
+{
+ int result = ERR;
+
+ T((T_CALLED("start_color()")));
+
+ if (SP == 0) {
+ result = ERR;
+ } else if (SP->_coloron) {
+ result = OK;
+ } else {
+
+ if (reset_color_pair() != TRUE) {
+ set_foreground_color(default_fg(), _nc_outch);
+ set_background_color(default_bg(), _nc_outch);
+ }
+
+ if (max_pairs > 0 && max_colors > 0) {
+ COLOR_PAIRS = SP->_pair_count = max_pairs;
+ COLORS = SP->_color_count = max_colors;
+
+ if ((SP->_color_pairs = TYPE_CALLOC(colorpair_t,
+ max_pairs)) != 0) {
+ if ((SP->_color_table = TYPE_CALLOC(color_t,
+ max_colors)) != 0) {
+ SP->_color_pairs[0] = PAIR_OF(default_fg(), default_bg());
+ init_color_table();
+
+ T(("started color: COLORS = %d, COLOR_PAIRS = %d",
+ COLORS, COLOR_PAIRS));
+
+ SP->_coloron = 1;
+ result = OK;
+ } else if (SP->_color_pairs != 0) {
+ FreeAndNull(SP->_color_pairs);
+ }
+ }
+ } else {
+ result = OK;
+ }
+ }
+ returnCode(result);
}
/* This function was originally written by Daniel Weaver <danw@znyx.com> */
@@ -259,27 +310,27 @@ rgb2hls(short r, short g, short b, short *h, short *l, short *s)
NCURSES_EXPORT(int)
init_pair(short pair, short f, short b)
{
- unsigned result;
+ colorpair_t result;
T((T_CALLED("init_pair(%d,%d,%d)"), pair, f, b));
- if ((pair < 0) || (pair >= COLOR_PAIRS))
+ if ((pair < 0) || (pair >= COLOR_PAIRS) || SP == 0 || !SP->_coloron)
returnCode(ERR);
#if NCURSES_EXT_FUNCS
if (SP->_default_color) {
if (f < 0)
- f = C_MASK;
+ f = COLOR_DEFAULT;
if (b < 0)
- b = C_MASK;
- if (f >= COLORS && f != C_MASK)
+ b = COLOR_DEFAULT;
+ if (!OkColorHi(f) && !isDefaultColor(f))
returnCode(ERR);
- if (b >= COLORS && b != C_MASK)
+ if (!OkColorHi(b) && !isDefaultColor(b))
returnCode(ERR);
} else
#endif
{
- if ((f < 0) || (f >= COLORS)
- || (b < 0) || (b >= COLORS)
+ if ((f < 0) || !OkColorHi(f)
+ || (b < 0) || !OkColorHi(b)
|| (pair < 1))
returnCode(ERR);
}
@@ -293,13 +344,12 @@ init_pair(short pair, short f, short b)
if (SP->_color_pairs[pair] != 0
&& SP->_color_pairs[pair] != result) {
int y, x;
- attr_t z = COLOR_PAIR(pair);
for (y = 0; y <= curscr->_maxy; y++) {
struct ldat *ptr = &(curscr->_line[y]);
bool changed = FALSE;
for (x = 0; x <= curscr->_maxx; x++) {
- if ((AttrOf(ptr->text[x]) & A_COLOR) == z) {
+ if (GetPair(ptr->text[x]) == pair) {
/* Set the old cell to zero to ensure it will be
updated on the next doupdate() */
SetChar(ptr->text[x], 0, 0);
@@ -312,8 +362,8 @@ init_pair(short pair, short f, short b)
}
}
SP->_color_pairs[pair] = result;
- if ((int) (SP->_current_attr & A_COLOR) == COLOR_PAIR(pair))
- SP->_current_attr |= A_COLOR; /* force attribute update */
+ if (GET_SCREEN_PAIR(SP) == pair)
+ SET_SCREEN_PAIR(SP, (chtype) (~0)); /* force attribute update */
if (initialize_pair) {
const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette;
@@ -323,47 +373,53 @@ init_pair(short pair, short f, short b)
tp[f].red, tp[f].green, tp[f].blue,
tp[b].red, tp[b].green, tp[b].blue));
- if (initialize_pair) {
- TPUTS_TRACE("initialize_pair");
- putp(tparm(initialize_pair,
- pair,
- tp[f].red, tp[f].green, tp[f].blue,
- tp[b].red, tp[b].green, tp[b].blue));
- }
+ TPUTS_TRACE("initialize_pair");
+ putp(TPARM_7(initialize_pair,
+ pair,
+ tp[f].red, tp[f].green, tp[f].blue,
+ tp[b].red, tp[b].green, tp[b].blue));
}
returnCode(OK);
}
+#define okRGB(n) ((n) >= 0 && (n) <= 1000)
+
NCURSES_EXPORT(int)
init_color(short color, short r, short g, short b)
{
- T((T_CALLED("init_color(%d,%d,%d,%d)"), color, r, g, b));
+ int result = ERR;
- if (initialize_color == NULL)
- returnCode(ERR);
-
- if (color < 0 || color >= COLORS)
- returnCode(ERR);
- if (r < 0 || r > 1000 || g < 0 || g > 1000 || b < 0 || b > 1000)
- returnCode(ERR);
+ T((T_CALLED("init_color(%d,%d,%d,%d)"), color, r, g, b));
- if (hue_lightness_saturation)
- rgb2hls(r, g, b,
- &SP->_color_table[color].red,
- &SP->_color_table[color].green,
- &SP->_color_table[color].blue);
- else {
- SP->_color_table[color].red = r;
- SP->_color_table[color].green = g;
- SP->_color_table[color].blue = b;
- }
+ if (initialize_color != NULL
+ && SP != 0
+ && SP->_coloron
+ && (color >= 0 && OkColorHi(color))
+ && (okRGB(r) && okRGB(g) && okRGB(b))) {
+
+ SP->_color_table[color].init = 1;
+ SP->_color_table[color].r = r;
+ SP->_color_table[color].g = g;
+ SP->_color_table[color].b = b;
+
+ if (hue_lightness_saturation) {
+ rgb2hls(r, g, b,
+ &SP->_color_table[color].red,
+ &SP->_color_table[color].green,
+ &SP->_color_table[color].blue);
+ } else {
+ SP->_color_table[color].red = r;
+ SP->_color_table[color].green = g;
+ SP->_color_table[color].blue = b;
+ }
- if (initialize_color) {
TPUTS_TRACE("initialize_color");
- putp(tparm(initialize_color, color, r, g, b));
+ putp(TPARM_4(initialize_color, color, r, g, b));
+ SP->_color_defs = max(color + 1, SP->_color_defs);
+ result = OK;
}
- returnCode(OK);
+ returnCode(result);
}
NCURSES_EXPORT(bool)
@@ -388,38 +444,65 @@ has_colors(void)
NCURSES_EXPORT(int)
color_content(short color, short *r, short *g, short *b)
{
- T((T_CALLED("color_content(%d,%p,%p,%p)"), color, r, g, b));
- if (color < 0 || color >= COLORS)
- returnCode(ERR);
+ int result;
- if (r)
- *r = SP->_color_table[color].red;
- if (g)
- *g = SP->_color_table[color].green;
- if (b)
- *b = SP->_color_table[color].blue;
- returnCode(OK);
+ T((T_CALLED("color_content(%d,%p,%p,%p)"), color, r, g, b));
+ if (color < 0 || !OkColorHi(color) || SP == 0 || !SP->_coloron) {
+ result = ERR;
+ } else {
+ NCURSES_COLOR_T c_r = SP->_color_table[color].red;
+ NCURSES_COLOR_T c_g = SP->_color_table[color].green;
+ NCURSES_COLOR_T c_b = SP->_color_table[color].blue;
+
+ if (r)
+ *r = c_r;
+ if (g)
+ *g = c_g;
+ if (b)
+ *b = c_b;
+
+ T(("...color_content(%d,%d,%d,%d)", color, c_r, c_g, c_b));
+ result = OK;
+ }
+ returnCode(result);
}
NCURSES_EXPORT(int)
pair_content(short pair, short *f, short *b)
{
+ int result;
+
T((T_CALLED("pair_content(%d,%p,%p)"), pair, f, b));
- if ((pair < 0) || (pair >= COLOR_PAIRS))
- returnCode(ERR);
- if (f)
- *f = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK);
- if (b)
- *b = (SP->_color_pairs[pair] & C_MASK);
+ if ((pair < 0) || (pair >= COLOR_PAIRS) || SP == 0 || !SP->_coloron) {
+ result = ERR;
+ } else {
+ NCURSES_COLOR_T fg = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK);
+ NCURSES_COLOR_T bg = (SP->_color_pairs[pair] & C_MASK);
- returnCode(OK);
+#if NCURSES_EXT_FUNCS
+ if (fg == COLOR_DEFAULT)
+ fg = -1;
+ if (bg == COLOR_DEFAULT)
+ bg = -1;
+#endif
+
+ if (f)
+ *f = fg;
+ if (b)
+ *b = bg;
+
+ T(("...pair_content(%d,%d,%d)", pair, fg, bg));
+ result = OK;
+ }
+ returnCode(result);
}
NCURSES_EXPORT(void)
-_nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
+_nc_do_color(short old_pair, short pair, bool reverse, int (*outc) (int))
{
- NCURSES_COLOR_T fg = C_MASK, bg = C_MASK;
+ NCURSES_COLOR_T fg = COLOR_DEFAULT;
+ NCURSES_COLOR_T bg = COLOR_DEFAULT;
NCURSES_COLOR_T old_fg, old_bg;
if (pair < 0 || pair >= COLOR_PAIRS) {
@@ -427,41 +510,46 @@ _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
} else if (pair != 0) {
if (set_color_pair) {
TPUTS_TRACE("set_color_pair");
- tputs(tparm(set_color_pair, pair), 1, outc);
+ tputs(TPARM_1(set_color_pair, pair), 1, outc);
return;
} else if (SP != 0) {
- pair_content(pair, &fg, &bg);
+ pair_content((short) pair, &fg, &bg);
}
}
- if (old_pair >= 0 && SP != 0) {
- pair_content(old_pair, &old_fg, &old_bg);
- if ((fg == C_MASK && old_fg != C_MASK)
- || (bg == C_MASK && old_bg != C_MASK)) {
+ if (old_pair >= 0
+ && SP != 0
+ && pair_content(old_pair, &old_fg, &old_bg) != ERR) {
+ if ((isDefaultColor(fg) && !isDefaultColor(old_fg))
+ || (isDefaultColor(bg) && !isDefaultColor(old_bg))) {
#if NCURSES_EXT_FUNCS
/*
* A minor optimization - but extension. If "AX" is specified in
* the terminal description, treat it as screen's indicator of ECMA
* SGR 39 and SGR 49, and assume the two sequences are independent.
*/
- if (SP->_has_sgr_39_49 && old_bg == C_MASK && old_fg != C_MASK) {
+ if (SP->_has_sgr_39_49
+ && isDefaultColor(old_bg)
+ && !isDefaultColor(old_fg)) {
tputs("\033[39m", 1, outc);
- } else if (SP->_has_sgr_39_49 && old_fg == C_MASK && old_bg != C_MASK) {
+ } else if (SP->_has_sgr_39_49
+ && isDefaultColor(old_fg)
+ && !isDefaultColor(old_bg)) {
tputs("\033[49m", 1, outc);
} else
#endif
- set_original_colors();
+ reset_color_pair();
}
} else {
- set_original_colors();
+ reset_color_pair();
if (old_pair < 0)
return;
}
#if NCURSES_EXT_FUNCS
- if (fg == C_MASK)
+ if (isDefaultColor(fg))
fg = default_fg();
- if (bg == C_MASK)
+ if (isDefaultColor(bg))
bg = default_bg();
#endif
@@ -474,10 +562,10 @@ _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
TR(TRACE_ATTRS, ("setting colors: pair = %d, fg = %d, bg = %d", pair,
fg, bg));
- if (fg != C_MASK) {
+ if (!isDefaultColor(fg)) {
set_foreground_color(fg, outc);
}
- if (bg != C_MASK) {
+ if (!isDefaultColor(bg)) {
set_background_color(bg, outc);
}
}
diff --git a/contrib/ncurses/ncurses/base/lib_colorset.c b/contrib/ncurses/ncurses/base/lib_colorset.c
index b496c78c9e39..a973c5350c8f 100644
--- a/contrib/ncurses/ncurses/base/lib_colorset.c
+++ b/contrib/ncurses/ncurses/base/lib_colorset.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2005 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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1998 *
+ * Author: Juergen Pfeifer, 1998 *
+ * and: Thomas E. Dickey, 2005 *
****************************************************************************/
/*
@@ -40,19 +41,19 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_colorset.c,v 1.7 2000/12/10 01:24:50 tom Exp $")
+MODULE_ID("$Id: lib_colorset.c,v 1.11 2005/01/29 21:40:51 tom Exp $")
NCURSES_EXPORT(int)
-wcolor_set
-(WINDOW *win, short color_pair_number, void *opts)
+wcolor_set(WINDOW *win, short color_pair_number, void *opts)
{
T((T_CALLED("wcolor_set(%p,%d)"), win, color_pair_number));
if (win
&& !opts
&& (color_pair_number >= 0)
&& (color_pair_number < COLOR_PAIRS)) {
- TR(TRACE_ATTRS, ("... current %ld", (long) PAIR_NUMBER(win->_attrs)));
- toggle_attr_on(win->_attrs, COLOR_PAIR(color_pair_number));
+ TR(TRACE_ATTRS, ("... current %ld", (long) GET_WINDOW_PAIR(win)));
+ SET_WINDOW_PAIR(win, color_pair_number);
+ if_EXT_COLORS(win->_color = color_pair_number);
returnCode(OK);
} else
returnCode(ERR);
diff --git a/contrib/ncurses/ncurses/base/lib_dft_fgbg.c b/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
index 24705c9615e9..8953c148b09e 100644
--- a/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
+++ b/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 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,13 +27,13 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997,1999 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: lib_dft_fgbg.c,v 1.15 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_dft_fgbg.c,v 1.18 2005/11/26 20:03:38 tom Exp $")
/*
* Modify the behavior of color-pair 0 so that the library doesn't assume that
@@ -43,7 +43,7 @@ NCURSES_EXPORT(int)
use_default_colors(void)
{
T((T_CALLED("use_default_colors()")));
- returnCode(assume_default_colors(C_MASK, C_MASK));
+ returnCode(assume_default_colors(-1, -1));
}
/*
@@ -61,11 +61,15 @@ assume_default_colors(int fg, int bg)
if (initialize_pair) /* don't know how to handle this */
returnCode(ERR);
- SP->_default_color = (fg < 0 || fg == C_MASK) || (bg < 0 || bg == C_MASK);
+ SP->_default_color = isDefaultColor(fg) || isDefaultColor(bg);
SP->_has_sgr_39_49 = (tigetflag("AX") == TRUE);
- SP->_default_fg = (fg >= 0) ? (fg & C_MASK) : C_MASK;
- SP->_default_bg = (bg >= 0) ? (bg & C_MASK) : C_MASK;
- if (SP->_color_pairs != 0)
- init_pair(0, fg, bg);
+ SP->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : (fg & C_MASK);
+ SP->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : (bg & C_MASK);
+ if (SP->_color_pairs != 0) {
+ bool save = SP->_default_color;
+ SP->_default_color = TRUE;
+ init_pair(0, (short) fg, (short) bg);
+ SP->_default_color = save;
+ }
returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_erase.c b/contrib/ncurses/ncurses/base/lib_erase.c
index 5e397312ffe3..2566e8b39820 100644
--- a/contrib/ncurses/ncurses/base/lib_erase.c
+++ b/contrib/ncurses/ncurses/base/lib_erase.c
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -40,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_erase.c,v 1.15 2001/12/19 01:06:13 tom Exp $")
+MODULE_ID("$Id: lib_erase.c,v 1.16 2005/10/30 00:36:36 tom Exp $")
NCURSES_EXPORT(int)
werase(WINDOW *win)
@@ -58,6 +59,24 @@ werase(WINDOW *win)
start = win->_line[y].text;
end = &start[win->_maxx];
+ /*
+ * If this is a derived window, we have to handle the case where
+ * a multicolumn character extends into the window that we are
+ * erasing.
+ */
+ if_WIDEC({
+ if (isWidecExt(start[0])) {
+ int x = (win->_parent != 0) ? (win->_begx) : 0;
+ while (x-- > 0) {
+ if (isWidecBase(start[-1])) {
+ --start;
+ break;
+ }
+ --start;
+ }
+ }
+ });
+
for (sp = start; sp <= end; sp++)
*sp = blank;
diff --git a/contrib/ncurses/ncurses/base/lib_freeall.c b/contrib/ncurses/ncurses/base/lib_freeall.c
index 2063c6fa593e..27897a9f6a2a 100644
--- a/contrib/ncurses/ncurses/base/lib_freeall.c
+++ b/contrib/ncurses/ncurses/base/lib_freeall.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 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,11 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997 *
+ * Author: Thomas E. Dickey 1996,1997 *
****************************************************************************/
#include <curses.priv.h>
#include <term_entry.h>
+#include <tic.h>
#if HAVE_NC_FREEALL
@@ -39,31 +40,7 @@
extern int malloc_errfd; /* FIXME */
#endif
-MODULE_ID("$Id: lib_freeall.c,v 1.19 2001/09/15 21:32:48 tom Exp $")
-
-static void
-free_slk(SLK * p)
-{
- if (p != 0) {
- FreeIfNeeded(p->ent);
- FreeIfNeeded(p->buffer);
- free(p);
- }
-}
-
-static void
-free_tries(struct tries *p)
-{
- struct tries *q;
-
- while (p != 0) {
- q = p->sibling;
- if (p->child != 0)
- free_tries(p->child);
- free(p);
- p = q;
- }
-}
+MODULE_ID("$Id: lib_freeall.c,v 1.38 2006/12/02 22:36:43 tom Exp $")
/*
* Free all ncurses data. This is used for testing only (there's no practical
@@ -73,9 +50,15 @@ NCURSES_EXPORT(void)
_nc_freeall(void)
{
WINDOWLIST *p, *q;
+ char *s;
+ static va_list empty_va;
+ T((T_CALLED("_nc_freeall()")));
#if NO_LEAKS
_nc_free_tparm();
+ if (_nc_oldnums != 0) {
+ FreeAndNull(_nc_oldnums);
+ }
#endif
if (SP != 0) {
while (_nc_windows != 0) {
@@ -98,39 +81,57 @@ _nc_freeall(void)
}
}
}
-
- free_tries(SP->_keytry);
- free_tries(SP->_key_ok);
- 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
+ delscreen(SP);
}
+#if NO_LEAKS
+ _nc_tgetent_leaks();
+#endif
+ del_curterm(cur_term);
+ _nc_free_entries(_nc_head);
+ _nc_get_type(0);
+ _nc_first_name(0);
+#if USE_WIDEC_SUPPORT
+ FreeIfNeeded(_nc_wacs);
+#endif
+#if NO_LEAKS
+ _nc_alloc_entry_leaks();
+ _nc_captoinfo_leaks();
+ _nc_comp_scan_leaks();
+ _nc_keyname_leaks();
+ _nc_tic_expand(0, FALSE, 0);
+#endif
- if (cur_term != 0) {
- _nc_free_termtype(&(cur_term->type));
- free(cur_term);
- }
+ if ((s = _nc_home_terminfo()) != 0)
+ free(s);
+
+ (void) _nc_printf_string(0, empty_va);
#ifdef TRACE
(void) _nc_trace_buf(-1, 0);
#endif
+
#if HAVE_LIBDBMALLOC
malloc_dump(malloc_errfd);
#elif HAVE_LIBDMALLOC
+#elif HAVE_LIBMPATROL
+ __mp_summary();
#elif HAVE_PURIFY
purify_all_inuse();
#endif
+ returnVoid;
}
NCURSES_EXPORT(void)
_nc_free_and_exit(int code)
{
+ char *last_setbuf = (SP != 0) ? SP->_setbuf : 0;
+
_nc_freeall();
+#ifdef TRACE
+ trace(0); /* close trace file, freeing its setbuf */
+ free(_nc_varargs("?", 0));
+#endif
+ fclose(stdout);
+ FreeIfNeeded(last_setbuf);
exit(code);
}
diff --git a/contrib/ncurses/ncurses/base/lib_getch.c b/contrib/ncurses/ncurses/base/lib_getch.c
index af1be33a18d5..7891edf3b079 100644
--- a/contrib/ncurses/ncurses/base/lib_getch.c
+++ b/contrib/ncurses/ncurses/base/lib_getch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -40,14 +41,46 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_getch.c,v 1.61 2002/06/16 00:31:57 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.75 2006/03/04 20:06:09 tom Exp $")
#include <fifo_defs.h>
NCURSES_EXPORT_VAR(int)
ESCDELAY = 1000; /* max interval betw. chars in funkeys, in millisecs */
-static inline int
+#ifdef NCURSES_WGETCH_EVENTS
+#define TWAIT_MASK 7
+#else
+#define TWAIT_MASK 3
+#endif
+
+/*
+ * Check for mouse activity, returning nonzero if we find any.
+ */
+static int
+check_mouse_activity(int delay EVENTLIST_2nd(_nc_eventlist * evl))
+{
+ int rc;
+
+#if USE_SYSMOUSE
+ if ((SP->_mouse_type == M_SYSMOUSE)
+ && (SP->_sysmouse_head < SP->_sysmouse_tail)) {
+ return 2;
+ }
+#endif
+ rc = _nc_timed_wait(TWAIT_MASK, delay, (int *) 0 EVENTLIST_2nd(evl));
+#if USE_SYSMOUSE
+ if ((SP->_mouse_type == M_SYSMOUSE)
+ && (SP->_sysmouse_head < SP->_sysmouse_tail)
+ && (rc == 0)
+ && (errno == EINTR)) {
+ rc |= 2;
+ }
+#endif
+ return rc;
+}
+
+static NCURSES_INLINE int
fifo_peek(void)
{
int ch = SP->_fifo[peek];
@@ -57,7 +90,7 @@ fifo_peek(void)
return ch;
}
-static inline int
+static NCURSES_INLINE int
fifo_pull(void)
{
int ch;
@@ -77,12 +110,14 @@ fifo_pull(void)
return ch;
}
-static inline int
-fifo_push(void)
+static NCURSES_INLINE int
+fifo_push(EVENTLIST_0th(_nc_eventlist * evl))
{
int n;
- int ch;
+ int ch = 0;
+ int mask = 0;
+ (void) mask;
if (tail == -1)
return ERR;
@@ -91,15 +126,48 @@ fifo_push(void)
errno = 0;
#endif
-#if USE_GPM_SUPPORT || defined(USE_EMX_MOUSE)
- if ((SP->_mouse_fd >= 0)
- && (_nc_timed_wait(3, -1, (int *) 0) & 2)) {
+#ifdef NCURSES_WGETCH_EVENTS
+ if (evl
+#if USE_GPM_SUPPORT || USE_EMX_MOUSE || USE_SYSMOUSE
+ || (SP->_mouse_fd >= 0)
+#endif
+ ) {
+ mask = check_mouse_activity(-1 EVENTLIST_2nd(evl));
+ } else
+ mask = 0;
+
+ if (mask & 4) {
+ T(("fifo_push: ungetch KEY_EVENT"));
+ ungetch(KEY_EVENT);
+ return KEY_EVENT;
+ }
+#elif USE_GPM_SUPPORT || USE_EMX_MOUSE || USE_SYSMOUSE
+ if (SP->_mouse_fd >= 0) {
+ mask = check_mouse_activity(-1 EVENTLIST_2nd(evl));
+ }
+#endif
+
+#if USE_GPM_SUPPORT || USE_EMX_MOUSE
+ if ((SP->_mouse_fd >= 0) && (mask & 2)) {
SP->_mouse_event(SP);
ch = KEY_MOUSE;
n = 1;
} else
#endif
- {
+#if USE_SYSMOUSE
+ if ((SP->_mouse_type == M_SYSMOUSE)
+ && (SP->_sysmouse_head < SP->_sysmouse_tail)) {
+ SP->_mouse_event(SP);
+ ch = KEY_MOUSE;
+ n = 1;
+ } else if ((SP->_mouse_type == M_SYSMOUSE)
+ && (mask <= 0) && errno == EINTR) {
+ SP->_mouse_event(SP);
+ ch = KEY_MOUSE;
+ n = 1;
+ } else
+#endif
+ { /* Can block... */
unsigned char c2 = 0;
n = read(SP->_ifd, &c2, 1);
ch = c2;
@@ -138,7 +206,7 @@ fifo_push(void)
return ch;
}
-static inline void
+static NCURSES_INLINE void
fifo_clear(void)
{
memset(SP->_fifo, 0, sizeof(SP->_fifo));
@@ -146,21 +214,27 @@ fifo_clear(void)
tail = peek = 0;
}
-static int kgetch(void);
+static int kgetch(EVENTLIST_0th(_nc_eventlist * evl));
#define wgetch_should_refresh(win) (\
(is_wintouched(win) || (win->_flags & _HASMOVED)) \
&& !(win->_flags & _ISPAD))
NCURSES_EXPORT(int)
-_nc_wgetch(WINDOW *win, unsigned long *result, int use_meta)
+_nc_wgetch(WINDOW *win,
+ unsigned long *result,
+ int use_meta
+ EVENTLIST_2nd(_nc_eventlist * evl))
{
int ch;
+#ifdef NCURSES_WGETCH_EVENTS
+ long event_delay = -1;
+#endif
- T((T_CALLED("wgetch(%p)"), win));
+ T((T_CALLED("_nc_wgetch(%p)"), win));
*result = 0;
- if (!win)
+ if (win == 0 || SP == 0)
returnCode(ERR);
if (cooked_key_in_fifo()) {
@@ -170,24 +244,47 @@ _nc_wgetch(WINDOW *win, unsigned long *result, int use_meta)
*result = fifo_pull();
returnCode(OK);
}
+#ifdef NCURSES_WGETCH_EVENTS
+ if (evl && (evl->count == 0))
+ evl = NULL;
+ event_delay = _nc_eventlist_timeout(evl);
+#endif
/*
* Handle cooked mode. Grab a string from the screen,
* stuff its contents in the FIFO queue, and pop off
* the first character to return it.
*/
- if (head == -1 && !SP->_raw && !SP->_cbreak) {
+ if (head == -1 &&
+ !SP->_notty &&
+ !SP->_raw &&
+ !SP->_cbreak &&
+ !SP->_called_wgetch) {
char buf[MAXCOLUMNS], *sp;
+ int rc;
TR(TRACE_IEVENT, ("filling queue in cooked mode"));
- wgetnstr(win, buf, MAXCOLUMNS);
+ SP->_called_wgetch = TRUE;
+ rc = wgetnstr(win, buf, MAXCOLUMNS);
+ SP->_called_wgetch = FALSE;
/* ungetch in reverse order */
- ungetch('\n');
+#ifdef NCURSES_WGETCH_EVENTS
+ if (rc != KEY_EVENT)
+#endif
+ ungetch('\n');
for (sp = buf + strlen(buf); sp > buf; sp--)
ungetch(sp[-1]);
+#ifdef NCURSES_WGETCH_EVENTS
+ /* Return it first */
+ if (rc == KEY_EVENT) {
+ *result = rc;
+ returnCode(OK);
+ }
+#endif
+
*result = fifo_pull();
returnCode(OK);
}
@@ -199,19 +296,34 @@ _nc_wgetch(WINDOW *win, unsigned long *result, int use_meta)
wrefresh(win);
if (!win->_notimeout && (win->_delay >= 0 || SP->_cbreak > 1)) {
- int delay;
+ if (head == -1) { /* fifo is empty */
+ int delay;
+ int rc;
+
+ TR(TRACE_IEVENT, ("timed delay in wgetch()"));
+ if (SP->_cbreak > 1)
+ delay = (SP->_cbreak - 1) * 100;
+ else
+ delay = win->_delay;
+
+#ifdef NCURSES_WGETCH_EVENTS
+ if (event_delay >= 0 && delay > event_delay)
+ delay = event_delay;
+#endif
- TR(TRACE_IEVENT, ("timed delay in wgetch()"));
- if (SP->_cbreak > 1)
- delay = (SP->_cbreak - 1) * 100;
- else
- delay = win->_delay;
+ TR(TRACE_IEVENT, ("delay is %d milliseconds", delay));
- TR(TRACE_IEVENT, ("delay is %d milliseconds", delay));
+ rc = check_mouse_activity(delay EVENTLIST_2nd(evl));
- if (head == -1) /* fifo is empty */
- if (!_nc_timed_wait(3, delay, (int *) 0))
+#ifdef NCURSES_WGETCH_EVENTS
+ if (rc & 4) {
+ *result = KEY_EVENT;
+ returnCode(OK);
+ }
+#endif
+ if (!rc)
returnCode(ERR);
+ }
/* else go on to read data available */
}
@@ -228,9 +340,10 @@ _nc_wgetch(WINDOW *win, unsigned long *result, int use_meta)
* increase the wait with mouseinterval().
*/
int runcount = 0;
+ int rc;
do {
- ch = kgetch();
+ ch = kgetch(EVENTLIST_1st(evl));
if (ch == KEY_MOUSE) {
++runcount;
if (SP->_mouse_inline(SP))
@@ -240,16 +353,32 @@ _nc_wgetch(WINDOW *win, unsigned long *result, int use_meta)
break;
} while
(ch == KEY_MOUSE
- && (_nc_timed_wait(3, SP->_maxclick, (int *) 0)
+ && (((rc = check_mouse_activity(SP->_maxclick
+ EVENTLIST_2nd(evl))) != 0
+ && !(rc & 4))
|| !SP->_mouse_parse(runcount)));
- if (runcount > 0 && ch != KEY_MOUSE) {
- /* mouse event sequence ended by keystroke, push it */
+#ifdef NCURSES_WGETCH_EVENTS
+ if ((rc & 4) && !ch == KEY_EVENT) {
ungetch(ch);
- ch = KEY_MOUSE;
+ ch = KEY_EVENT;
+ }
+#endif
+ if (runcount > 0 && ch != KEY_MOUSE) {
+#ifdef NCURSES_WGETCH_EVENTS
+ /* mouse event sequence ended by an event, report event */
+ if (ch == KEY_EVENT) {
+ ungetch(KEY_MOUSE); /* FIXME This interrupts a gesture... */
+ } else
+#endif
+ {
+ /* mouse event sequence ended by keystroke, store keystroke */
+ ungetch(ch);
+ ch = KEY_MOUSE;
+ }
}
} else {
if (head == -1)
- fifo_push();
+ fifo_push(EVENTLIST_1st(evl));
ch = fifo_pull();
}
@@ -312,6 +441,24 @@ _nc_wgetch(WINDOW *win, unsigned long *result, int use_meta)
returnCode(ch >= KEY_MIN ? KEY_CODE_YES : OK);
}
+#ifdef NCURSES_WGETCH_EVENTS
+NCURSES_EXPORT(int)
+wgetch_events(WINDOW *win, _nc_eventlist * evl)
+{
+ int code;
+ unsigned long value;
+
+ T((T_CALLED("wgetch_events(%p,%p)"), win, evl));
+ code = _nc_wgetch(win,
+ &value,
+ SP->_use_meta
+ EVENTLIST_2nd(evl));
+ if (code != ERR)
+ code = value;
+ returnCode(code);
+}
+#endif
+
NCURSES_EXPORT(int)
wgetch(WINDOW *win)
{
@@ -319,7 +466,10 @@ wgetch(WINDOW *win)
unsigned long value;
T((T_CALLED("wgetch(%p)"), win));
- code = _nc_wgetch(win, &value, SP->_use_meta);
+ code = _nc_wgetch(win,
+ &value,
+ (SP ? SP->_use_meta : 0)
+ EVENTLIST_2nd((_nc_eventlist *) 0));
if (code != ERR)
code = value;
returnCode(code);
@@ -341,7 +491,7 @@ wgetch(WINDOW *win)
*/
static int
-kgetch(void)
+kgetch(EVENTLIST_0th(_nc_eventlist * evl))
{
struct tries *ptr;
int ch = 0;
@@ -352,14 +502,28 @@ kgetch(void)
ptr = SP->_keytry;
for (;;) {
- if (!raw_key_in_fifo()) {
- if (fifo_push() == ERR) {
+ if (cooked_key_in_fifo() && SP->_fifo[head] >= KEY_MIN) {
+ break;
+ } else if (!raw_key_in_fifo()) {
+ ch = fifo_push(EVENTLIST_1st(evl));
+ if (ch == ERR) {
peek = head; /* the keys stay uninterpreted */
return ERR;
}
+#ifdef NCURSES_WGETCH_EVENTS
+ else if (ch == KEY_EVENT) {
+ peek = head; /* the keys stay uninterpreted */
+ return fifo_pull(); /* Remove KEY_EVENT from the queue */
+ }
+#endif
}
+
ch = fifo_peek();
if (ch >= KEY_MIN) {
+ /* If not first in queue, somebody put this key there on purpose in
+ * emergency. Consider it higher priority than the unfinished
+ * keysequence we are parsing.
+ */
peek = head;
/* assume the key is the last in fifo */
t_dec(); /* remove the key */
@@ -389,8 +553,19 @@ kgetch(void)
ptr = ptr->child;
if (!raw_key_in_fifo()) {
+ int rc;
+
TR(TRACE_IEVENT, ("waiting for rest of sequence"));
- if (!_nc_timed_wait(3, timeleft, &timeleft)) {
+ rc = check_mouse_activity(timeleft EVENTLIST_2nd(evl));
+#ifdef NCURSES_WGETCH_EVENTS
+ if (rc & 4) {
+ TR(TRACE_IEVENT, ("interrupted by a user event"));
+ /* FIXME Should have preserved remainder timeleft for reuse... */
+ peek = head; /* Restart interpreting later */
+ return KEY_EVENT;
+ }
+#endif
+ if (!rc) {
TR(TRACE_IEVENT, ("ran out of time"));
break;
}
diff --git a/contrib/ncurses/ncurses/base/lib_getstr.c b/contrib/ncurses/ncurses/base/lib_getstr.c
index cd58f1821a7f..274e87887371 100644
--- a/contrib/ncurses/ncurses/base/lib_getstr.c
+++ b/contrib/ncurses/ncurses/base/lib_getstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: lib_getstr.c,v 1.23 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_getstr.c,v 1.25 2006/01/12 00:33:52 tom Exp $")
/*
* This wipes out the last character, no matter whether it was a tab, control
@@ -70,7 +70,10 @@ WipeOut(WINDOW *win, int y, int x, char *first, char *last, bool echoed)
}
NCURSES_EXPORT(int)
-wgetnstr(WINDOW *win, char *str, int maxlen)
+wgetnstr_events(WINDOW *win,
+ char *str,
+ int maxlen,
+ EVENTLIST_1st(_nc_eventlist * evl))
{
TTY buf;
bool oldnl, oldecho, oldraw, oldcbreak;
@@ -105,7 +108,7 @@ wgetnstr(WINDOW *win, char *str, int maxlen)
if (is_wintouched(win) || (win->_flags & _HASMOVED))
wrefresh(win);
- while ((ch = wgetch(win)) != ERR) {
+ while ((ch = wgetch_events(win, evl)) != ERR) {
/*
* Some terminals (the Wyse-50 is the most common) generate
* a \n from the down-arrow key. With this logic, it's the
@@ -122,6 +125,14 @@ wgetnstr(WINDOW *win, char *str, int maxlen)
wechochar(win, (chtype) '\n');
break;
}
+#ifdef KEY_EVENT
+ if (ch == KEY_EVENT)
+ break;
+#endif
+#ifdef KEY_RESIZE
+ if (ch == KEY_RESIZE)
+ break;
+#endif
if (ch == erasec || ch == KEY_LEFT || ch == KEY_BACKSPACE) {
if (str > oldstr) {
str = WipeOut(win, y, x, oldstr, str, oldecho);
@@ -185,9 +196,29 @@ wgetnstr(WINDOW *win, char *str, int maxlen)
*str = '\0';
if (ch == ERR)
- returnCode(ERR);
+ returnCode(ch);
T(("wgetnstr returns %s", _nc_visbuf(oldstr)));
+#ifdef KEY_EVENT
+ if (ch == KEY_EVENT)
+ returnCode(ch);
+#endif
+#ifdef KEY_RESIZE
+ if (ch == KEY_RESIZE)
+ returnCode(ch);
+#endif
+
returnCode(OK);
}
+
+#ifdef NCURSES_WGETCH_EVENTS
+NCURSES_EXPORT(int)
+wgetnstr(WINDOW *win, char *str, int maxlen)
+{
+ returnCode(wgetnstr_events(win,
+ str,
+ maxlen,
+ EVENTLIST_1st((_nc_eventlist *) 0)));
+}
+#endif
diff --git a/contrib/ncurses/ncurses/base/lib_hline.c b/contrib/ncurses/ncurses/base/lib_hline.c
index 2cb6cc5ce6fd..2ef2cc585e10 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2006 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.10 2001/06/03 00:39:24 skimo Exp $")
+MODULE_ID("$Id: lib_hline.c,v 1.11 2006/03/11 21:52:27 tom Exp $")
NCURSES_EXPORT(int)
whline(WINDOW *win, chtype ch, int n)
@@ -63,9 +63,9 @@ whline(WINDOW *win, chtype ch, int n)
CHANGED_RANGE(line, start, end);
if (ch == 0)
- SetChar(wch, ChCharOf(ACS_HLINE), ChAttrOf(ACS_HLINE));
+ SetChar2(wch, ACS_HLINE);
else
- SetChar(wch, ChCharOf(ch), ChAttrOf(ch));
+ SetChar2(wch, ch);
wch = _nc_render(win, wch);
while (end >= start) {
diff --git a/contrib/ncurses/ncurses/base/lib_initscr.c b/contrib/ncurses/ncurses/base/lib_initscr.c
index 832da742f47b..d2ae281972a9 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-2003 *
****************************************************************************/
/*
@@ -39,27 +40,20 @@
*/
#include <curses.priv.h>
-#include <tic.h> /* for MAX_ALIAS */
#if HAVE_SYS_TERMIO_H
#include <sys/termio.h> /* needed for ISC */
#endif
-MODULE_ID("$Id: lib_initscr.c,v 1.29 2001/08/26 01:05:05 tom Exp $")
+MODULE_ID("$Id: lib_initscr.c,v 1.34 2005/10/22 20:30:38 tom Exp $")
NCURSES_EXPORT(WINDOW *)
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
+ START_TRACE();
T((T_CALLED("initscr()")));
/* Portable applications must not call initscr() more than once */
if (!initialized) {
@@ -68,16 +62,28 @@ initscr(void)
if ((name = getenv("TERM")) == 0
|| *name == '\0')
name = "unknown";
+#ifdef __CYGWIN__
+ /*
+ * 2002/9/21
+ * Work around a bug in Cygwin. Full-screen subprocesses run from
+ * bash, in turn spawned from another full-screen process, will dump
+ * core when attempting to write to stdout. Opening /dev/tty
+ * explicitly seems to fix the problem.
+ */
+ if (isatty(fileno(stdout))) {
+ FILE *fp = fopen("/dev/tty", "w");
+ if (fp != 0 && isatty(fileno(fp))) {
+ fclose(stdout);
+ dup2(fileno(fp), STDOUT_FILENO);
+ stdout = fdopen(STDOUT_FILENO, "w");
+ }
+ }
+#endif
if (newterm(name, stdout, stdin) == 0) {
fprintf(stderr, "Error opening terminal: %s.\n", name);
exit(EXIT_FAILURE);
}
- /* allow user to set maximum escape delay from the environment */
- if ((value = _nc_getenv_num("ESCDELAY")) >= 0) {
- ESCDELAY = value;
- }
-
/* def_shell_mode - done in newterm/_nc_setupscreen */
def_prog_mode();
}
diff --git a/contrib/ncurses/ncurses/base/lib_insch.c b/contrib/ncurses/ncurses/base/lib_insch.c
index c3671e5d235b..b8a856df3a82 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,8 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Sven Verdoolaege *
+ * and: Thomas E. Dickey *
****************************************************************************/
/*
@@ -39,30 +41,99 @@
*/
#include <curses.priv.h>
+#include <ctype.h>
-MODULE_ID("$Id: lib_insch.c,v 1.15 2001/06/09 23:47:38 skimo Exp $")
+MODULE_ID("$Id: lib_insch.c,v 1.24 2005/02/26 19:27:28 tom Exp $")
+
+/*
+ * Insert the given character, updating the current location to simplify
+ * inserting a string.
+ */
+NCURSES_EXPORT(int)
+_nc_insert_ch(WINDOW *win, chtype ch)
+{
+ int code = OK;
+ NCURSES_CH_T wch;
+ int count;
+ NCURSES_CONST char *s;
+
+ switch (ch) {
+ case '\t':
+ for (count = (TABSIZE - (win->_curx % TABSIZE)); count > 0; count--) {
+ if ((code = _nc_insert_ch(win, ' ')) != OK)
+ break;
+ }
+ break;
+ case '\n':
+ case '\r':
+ case '\b':
+ SetChar2(wch, ch);
+ _nc_waddch_nosync(win, wch);
+ break;
+ default:
+ if (
+#if USE_WIDEC_SUPPORT
+ WINDOW_EXT(win, addch_used) == 0 &&
+#endif
+ is8bits(ChCharOf(ch)) &&
+ isprint(ChCharOf(ch))) {
+ if (win->_curx <= win->_maxx) {
+ struct ldat *line = &(win->_line[win->_cury]);
+ NCURSES_CH_T *end = &(line->text[win->_curx]);
+ NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
+ NCURSES_CH_T *temp2 = temp1 - 1;
+
+ SetChar2(wch, ch);
+
+ CHANGED_TO_EOL(line, win->_curx, win->_maxx);
+ while (temp1 > end)
+ *temp1-- = *temp2--;
+
+ *temp1 = _nc_render(win, wch);
+ win->_curx++;
+ }
+ } else if (is8bits(ChCharOf(ch)) && iscntrl(ChCharOf(ch))) {
+ s = unctrl(ChCharOf(ch));
+ while (*s != '\0') {
+ if ((code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s))) != OK)
+ break;
+ ++s;
+ }
+ }
+#if USE_WIDEC_SUPPORT
+ else {
+ /*
+ * Handle multibyte characters here
+ */
+ SetChar2(wch, ch);
+ wch = _nc_render(win, wch);
+ if (_nc_build_wch(win, &wch) >= 0)
+ code = wins_wch(win, &wch);
+ }
+#endif
+ break;
+ }
+ return code;
+}
NCURSES_EXPORT(int)
winsch(WINDOW *win, chtype c)
{
+ NCURSES_SIZE_T oy;
+ NCURSES_SIZE_T ox;
int code = ERR;
T((T_CALLED("winsch(%p, %s)"), win, _tracechtype(c)));
- if (win) {
- struct ldat *line = &(win->_line[win->_cury]);
- 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);
+ if (win != 0) {
+ oy = win->_cury;
+ ox = win->_curx;
- CHANGED_TO_EOL(line, win->_curx, win->_maxx);
- while (temp1 > end)
- *temp1-- = *temp2--;
+ code = _nc_insert_ch(win, c);
- *temp1 = _nc_render(win, wch);
- code = OK;
+ win->_curx = ox;
+ win->_cury = oy;
+ _nc_synchook(win);
}
returnCode(code);
}
diff --git a/contrib/ncurses/ncurses/base/lib_insdel.c b/contrib/ncurses/ncurses/base/lib_insdel.c
index 432bcace9e6a..342c6541f95f 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2003 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,14 +42,14 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_insdel.c,v 1.11 2001/12/19 01:10:49 tom Exp $")
+MODULE_ID("$Id: lib_insdel.c,v 1.12 2003/07/26 22:40:06 tom Exp $")
NCURSES_EXPORT(int)
winsdelln(WINDOW *win, int n)
{
int code = ERR;
- T((T_CALLED("winsdel(%p,%d)"), win, n));
+ T((T_CALLED("winsdelln(%p,%d)"), win, n));
if (win) {
if (n != 0) {
diff --git a/contrib/ncurses/ncurses/base/lib_insnstr.c b/contrib/ncurses/ncurses/base/lib_insnstr.c
new file mode 100644
index 000000000000..b6ddfde3c52b
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_insnstr.c
@@ -0,0 +1,68 @@
+/****************************************************************************
+ * Copyright (c) 2004 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey *
+ ****************************************************************************/
+
+/*
+** lib_insnstr.c
+**
+** The routine winsnstr().
+**
+*/
+
+#include <curses.priv.h>
+#include <ctype.h>
+
+MODULE_ID("$Id: lib_insnstr.c,v 1.1 2004/02/28 23:44:56 tom Exp $")
+
+NCURSES_EXPORT(int)
+winsnstr(WINDOW *win, const char *s, int n)
+{
+ int code = ERR;
+ NCURSES_SIZE_T oy;
+ NCURSES_SIZE_T ox;
+ const unsigned char *str = (const unsigned char *) s;
+ const unsigned char *cp;
+
+ T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbufn(s, n), n));
+
+ if (win != 0 && str != 0) {
+ oy = win->_cury;
+ ox = win->_curx;
+ for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
+ _nc_insert_ch(win, (chtype) UChar(*cp));
+ }
+ win->_curx = ox;
+ win->_cury = oy;
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_instr.c b/contrib/ncurses/ncurses/base/lib_instr.c
index 3eaf9892b45b..809952fdf82f 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -40,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_instr.c,v 1.11 2001/06/02 23:42:06 skimo Exp $")
+MODULE_ID("$Id: lib_instr.c,v 1.15 2005/11/20 01:38:03 tom Exp $")
NCURSES_EXPORT(int)
winnstr(WINDOW *win, char *str, int n)
@@ -59,7 +60,47 @@ winnstr(WINDOW *win, char *str, int n)
n = win->_maxx - win->_curx + 1;
for (; i < n;) {
- str[i++] = CharOf(win->_line[row].text[col]);
+#if USE_WIDEC_SUPPORT
+ cchar_t *cell = &(win->_line[row].text[col]);
+ wchar_t *wch;
+ attr_t attrs;
+ short pair;
+ int n2;
+ bool done = FALSE;
+ mbstate_t state;
+ size_t i3, n3;
+ char *tmp;
+
+ if (!isWidecExt(*cell)) {
+ n2 = getcchar(cell, 0, 0, 0, 0);
+ if (n2 > 0
+ && (wch = typeCalloc(wchar_t, (unsigned) n2 + 1)) != 0) {
+ if (getcchar(cell, wch, &attrs, &pair, 0) == OK) {
+
+ init_mb(state);
+ n3 = wcstombs(0, wch, 0);
+ if (isEILSEQ(n3) || (n3 == 0)) {
+ ;
+ } else if ((int) (n3 + i) >= n) {
+ done = TRUE;
+ } else if ((tmp = typeCalloc(char, n3 + 10)) == 0) {
+ done = TRUE;
+ } else {
+ init_mb(state);
+ wcstombs(tmp, wch, n3);
+ for (i3 = 0; i3 < n3; ++i3)
+ str[i++] = tmp[i3];
+ free(tmp);
+ }
+ }
+ free(wch);
+ if (done)
+ break;
+ }
+ }
+#else
+ str[i++] = (char) CharOf(win->_line[row].text[col]);
+#endif
if (++col > win->_maxx) {
col = 0;
if (++row > win->_maxy)
@@ -68,5 +109,6 @@ winnstr(WINDOW *win, char *str, int n)
}
}
str[i] = '\0'; /* SVr4 does not seem to count the null */
+ T(("winnstr returns %s", _nc_visbuf(str)));
returnCode(i);
}
diff --git a/contrib/ncurses/ncurses/base/lib_mouse.c b/contrib/ncurses/ncurses/base/lib_mouse.c
index 69af58d5fe24..f30232795be4 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,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,14 +29,18 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
* This module is intended to encapsulate ncurses's interface to pointing
* devices.
*
- * The first method used is xterm's internal mouse-tracking facility.
- * The second is Alessandro Rubini's GPM server.
+ * The primary method used is xterm's internal mouse-tracking facility.
+ * Additional methods depend on the platform:
+ * Alessandro Rubini's GPM server (Linux)
+ * sysmouse (FreeBSD)
+ * special-purpose mouse interface for OS/2 EMX.
*
* Notes for implementors of new mouse-interface methods:
*
@@ -74,36 +78,81 @@
#endif
#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_mouse.c,v 1.85 2006/11/25 22:30:28 tom Exp $")
+
#include <term.h>
+#include <tic.h>
#if USE_GPM_SUPPORT
-#ifndef LINT /* don't need this for llib-lncurses */
-#undef buttons /* term.h defines this, and gpm uses it! */
-#include <gpm.h>
#include <linux/keyboard.h> /* defines KG_* macros */
+
+#ifdef HAVE_LIBDL
+/* use dynamic loader to avoid linkage dependency */
+#include <dlfcn.h>
+
+#ifdef RTLD_NOW
+#define my_RTLD RTLD_NOW
+#else
+#ifdef RTLD_LAZY
+#define my_RTLD RTLD_LAZY
+#else
+make an error
#endif
+#endif /* RTLD_NOW */
+#endif /* HAVE_LIBDL */
+
+#endif /* USE_GPM_SUPPORT */
+
+#if USE_SYSMOUSE
+#undef buttons /* symbol conflict in consio.h */
+#undef mouse_info /* symbol conflict in consio.h */
+#include <osreldate.h>
+#if (__FreeBSD_version >= 400017)
+#include <sys/consio.h>
+#include <sys/fbio.h>
+#else
+#include <machine/console.h>
#endif
-
-MODULE_ID("$Id: lib_mouse.c,v 1.58 2002/01/12 22:38:07 tom Exp $")
+#endif /* use_SYSMOUSE */
#define MY_TRACE TRACE_ICALLS|TRACE_IEVENT
-#define INVALID_EVENT -1
+#define MASK_RELEASE(x) NCURSES_MOUSE_MASK(x, 001)
+#define MASK_PRESS(x) NCURSES_MOUSE_MASK(x, 002)
+#define MASK_CLICK(x) NCURSES_MOUSE_MASK(x, 004)
+#define MASK_DOUBLE_CLICK(x) NCURSES_MOUSE_MASK(x, 010)
+#define MASK_TRIPLE_CLICK(x) NCURSES_MOUSE_MASK(x, 020)
+#define MASK_RESERVED_EVENT(x) NCURSES_MOUSE_MASK(x, 040)
+
+#if NCURSES_MOUSE_VERSION == 1
+#define BUTTON_CLICKED (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED | BUTTON4_CLICKED)
+#define BUTTON_PRESSED (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED | BUTTON4_PRESSED)
+#define BUTTON_RELEASED (BUTTON1_RELEASED | BUTTON2_RELEASED | BUTTON3_RELEASED | BUTTON4_RELEASED)
+#define BUTTON_DOUBLE_CLICKED (BUTTON1_DOUBLE_CLICKED | BUTTON2_DOUBLE_CLICKED | BUTTON3_DOUBLE_CLICKED | BUTTON4_DOUBLE_CLICKED)
+#define BUTTON_TRIPLE_CLICKED (BUTTON1_TRIPLE_CLICKED | BUTTON2_TRIPLE_CLICKED | BUTTON3_TRIPLE_CLICKED | BUTTON4_TRIPLE_CLICKED)
+#define MAX_BUTTONS 4
+#else
+#define BUTTON_CLICKED (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED | BUTTON4_CLICKED | BUTTON5_CLICKED)
+#define BUTTON_PRESSED (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED | BUTTON4_PRESSED | BUTTON5_PRESSED)
+#define BUTTON_RELEASED (BUTTON1_RELEASED | BUTTON2_RELEASED | BUTTON3_RELEASED | BUTTON4_RELEASED | BUTTON5_RELEASED)
+#define BUTTON_DOUBLE_CLICKED (BUTTON1_DOUBLE_CLICKED | BUTTON2_DOUBLE_CLICKED | BUTTON3_DOUBLE_CLICKED | BUTTON4_DOUBLE_CLICKED | BUTTON5_DOUBLE_CLICKED)
+#define BUTTON_TRIPLE_CLICKED (BUTTON1_TRIPLE_CLICKED | BUTTON2_TRIPLE_CLICKED | BUTTON3_TRIPLE_CLICKED | BUTTON4_TRIPLE_CLICKED | BUTTON5_TRIPLE_CLICKED)
+#define MAX_BUTTONS 5
+#endif
-static int mousetype;
-#define M_XTERM -1 /* use xterm's mouse tracking? */
-#define M_NONE 0 /* no mouse device */
-#define M_GPM 1 /* use GPM */
-#define M_QNX 2 /* QNX mouse on console */
-#define M_QNX_TERM 3 /* QNX mouse on pterm/xterm (using qansi-m) */
+#define INVALID_EVENT -1
+#define NORMAL_EVENT 0
#if USE_GPM_SUPPORT
-#ifndef LINT
-static Gpm_Connect gpm_connect;
-#endif
+
+#ifndef LIBGPM_SONAME
+#define LIBGPM_SONAME "libgpm.so"
#endif
-static mmask_t eventmask; /* current event mask */
+#define GET_DLSYM(name) (my_##name = (TYPE_##name) dlsym(obj, #name))
+
+#endif /* USE_GPM_SUPPORT */
static bool _nc_mouse_parse(int);
static void _nc_mouse_resume(SCREEN *);
@@ -111,14 +160,15 @@ static void _nc_mouse_wrap(SCREEN *);
/* maintain a circular list of mouse events */
-/* The definition of the circular list size (EV_MAX), is in curses.priv.h, so
- * wgetch() may refer to the size and call _nc_mouse_parse() before circular
- * list overflow.
- */
-static MEVENT events[EV_MAX]; /* hold the last mouse event seen */
-static MEVENT *eventp = events; /* next free slot in event queue */
-#define NEXT(ep) ((ep == events + EV_MAX - 1) ? events : ep + 1)
-#define PREV(ep) ((ep == events) ? events + EV_MAX - 1 : ep - 1)
+#undef NEXT
+#define NEXT(ep) ((ep == SP->_mouse_events + EV_MAX - 1) \
+ ? SP->_mouse_events \
+ : ep + 1)
+
+#undef PREV
+#define PREV(ep) ((ep == SP->_mouse_events) \
+ ? SP->_mouse_events + EV_MAX - 1 \
+ : ep - 1)
#ifdef TRACE
static void
@@ -128,24 +178,18 @@ _trace_slot(const char *tag)
_tracef(tag);
- for (ep = events; ep < events + EV_MAX; ep++)
+ for (ep = SP->_mouse_events; ep < SP->_mouse_events + EV_MAX; ep++)
_tracef("mouse event queue slot %ld = %s",
- (long) (ep - events),
+ (long) (ep - SP->_mouse_events),
_tracemouse(ep));
}
#endif
-#ifdef USE_EMX_MOUSE
+#if USE_EMX_MOUSE
# define TOP_ROW 0
# define LEFT_COL 0
-static int mouse_wfd;
-static int mouse_thread;
-static int mouse_activated;
-static char mouse_buttons[] =
-{0, 1, 3, 2};
-
# define M_FD(sp) sp->_mouse_fd
static void
@@ -158,7 +202,7 @@ write_event(int down, int button, int x, int y)
buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40);
buf[4] = ' ' + x - LEFT_COL + 1;
buf[5] = ' ' + y - TOP_ROW + 1;
- DosWrite(mouse_wfd, buf, 6, &ignore);
+ DosWrite(SP->_emxmouse_wfd, buf, 6, &ignore);
}
static void
@@ -190,7 +234,7 @@ mouse_server(unsigned long ignored GCC_UNUSED)
sprintf(err, "Error reading mouse queue, rc=%lu.\r\n", rc);
break;
}
- if (!mouse_activated)
+ if (!SP->_emxmouse_activated)
goto finish;
/*
@@ -202,13 +246,13 @@ mouse_server(unsigned long ignored GCC_UNUSED)
*/
if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)
write_event(mouev.fs & MOUSE_BN1_DOWN,
- mouse_buttons[1], mouev.col, mouev.row);
+ SP->_emxmouse_buttons[1], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN)
write_event(mouev.fs & MOUSE_BN2_DOWN,
- mouse_buttons[3], mouev.col, mouev.row);
+ SP->_emxmouse_buttons[3], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN)
write_event(mouev.fs & MOUSE_BN3_DOWN,
- mouse_buttons[2], mouev.col, mouev.row);
+ SP->_emxmouse_buttons[2], mouev.col, mouev.row);
finish:
oldstate = mouev.fs;
@@ -223,185 +267,455 @@ mouse_server(unsigned long ignored GCC_UNUSED)
DosExit(EXIT_THREAD, 0L);
}
+#endif /* USE_EMX_MOUSE */
+
+#if USE_SYSMOUSE
+static void
+handle_sysmouse(int sig GCC_UNUSED)
+{
+ struct mouse_info the_mouse;
+ MEVENT *work;
+
+ the_mouse.operation = MOUSE_GETINFO;
+ if (SP != 0
+ && SP->_mouse_fd >= 0
+ && SP->_sysmouse_tail < FIFO_SIZE
+ && ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {
+
+ if (SP->_sysmouse_head > SP->_sysmouse_tail) {
+ SP->_sysmouse_tail = 0;
+ SP->_sysmouse_head = 0;
+ }
+ work = &(SP->_sysmouse_fifo[SP->_sysmouse_tail]);
+ memset(work, 0, sizeof(*work));
+ work->id = NORMAL_EVENT; /* there's only one mouse... */
+
+ SP->_sysmouse_old_buttons = SP->_sysmouse_new_buttons;
+ SP->_sysmouse_new_buttons = the_mouse.u.data.buttons & 0x7;
+
+ if (SP->_sysmouse_new_buttons) {
+ if (SP->_sysmouse_new_buttons & 1)
+ work->bstate |= BUTTON1_PRESSED;
+ if (SP->_sysmouse_new_buttons & 2)
+ work->bstate |= BUTTON2_PRESSED;
+ if (SP->_sysmouse_new_buttons & 4)
+ work->bstate |= BUTTON3_PRESSED;
+ } else {
+ if (SP->_sysmouse_old_buttons & 1)
+ work->bstate |= BUTTON1_RELEASED;
+ if (SP->_sysmouse_old_buttons & 2)
+ work->bstate |= BUTTON2_RELEASED;
+ if (SP->_sysmouse_old_buttons & 4)
+ work->bstate |= BUTTON3_RELEASED;
+ }
+
+ /* for cosmetic bug in syscons.c on FreeBSD 3.[34] */
+ the_mouse.operation = MOUSE_HIDE;
+ ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse);
+ the_mouse.operation = MOUSE_SHOW;
+ ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse);
+
+ /*
+ * We're only interested if the button is pressed or released.
+ * FIXME: implement continuous event-tracking.
+ */
+ if (SP->_sysmouse_new_buttons != SP->_sysmouse_old_buttons) {
+ SP->_sysmouse_tail += 1;
+ }
+ work->x = the_mouse.u.data.x / SP->_sysmouse_char_width;
+ work->y = the_mouse.u.data.y / SP->_sysmouse_char_height;
+ }
+}
+#endif /* USE_SYSMOUSE */
+
static void
-server_state(const int state)
-{ /* It would be nice to implement pointer-off and stop looping... */
- mouse_activated = state;
+init_xterm_mouse(void)
+{
+ SP->_mouse_type = M_XTERM;
+ SP->_mouse_xtermcap = tigetstr("XM");
+ if (!VALID_STRING(SP->_mouse_xtermcap))
+ SP->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
}
+static void
+enable_xterm_mouse(int enable)
+{
+#if USE_EMX_MOUSE
+ SP->_emxmouse_activated = enable;
+#else
+ putp(TPARM_1(SP->_mouse_xtermcap, enable));
#endif
+ SP->_mouse_active = enable;
+}
+
+#if USE_GPM_SUPPORT
+static int
+allow_gpm_mouse(void)
+{
+ /* GPM does printf's without checking if stdout is a terminal */
+ if (isatty(fileno(stdout))) {
+ char *env = getenv("TERM");
+ /* GPM checks the beginning of the $TERM variable to decide if
+ * it should pass xterm events through. There is no real advantage
+ * in allowing GPM to do this.
+ */
+ if (env == 0 || strncmp(env, "xterm", 5))
+ return TRUE;
+ }
+ return FALSE;
+}
-static int initialized;
+static bool
+enable_gpm_mouse(int enable)
+{
+ bool result;
+
+ T((T_CALLED("enable_gpm_mouse(%d)"), enable));
+
+ if (enable && !SP->_mouse_active) {
+ /* GPM: initialize connection to gpm server */
+ SP->_mouse_gpm_connect.eventMask = GPM_DOWN | GPM_UP;
+ SP->_mouse_gpm_connect.defaultMask =
+ ~(SP->_mouse_gpm_connect.eventMask | GPM_HARD);
+ SP->_mouse_gpm_connect.minMod = 0;
+ SP->_mouse_gpm_connect.maxMod =
+ (unsigned short) (~((1 << KG_SHIFT) |
+ (1 << KG_SHIFTL) |
+ (1 << KG_SHIFTR)));
+ /*
+ * Note: GPM hardcodes \E[?1001s and \E[?1000h during its open.
+ * The former is recognized by wscons (SunOS), and the latter by
+ * xterm. Those will not show up in ncurses' traces.
+ */
+ result = (my_Gpm_Open(&SP->_mouse_gpm_connect, 0) >= 0);
+ SP->_mouse_active = result;
+ T(("GPM open %s", result ? "succeeded" : "failed"));
+ } else {
+ if (!enable && SP->_mouse_active) {
+ /* GPM: close connection to gpm server */
+ my_Gpm_Close();
+ SP->_mouse_active = FALSE;
+ T(("GPM closed"));
+ }
+ result = FALSE;
+ }
+ returnBool(result);
+}
+#endif /* USE_GPM_SUPPORT */
static void
initialize_mousetype(void)
{
static const char *xterm_kmous = "\033[M";
+ T((T_CALLED("initialize_mousetype()")));
+
/* Try gpm first, because gpm may be configured to run in xterm */
#if USE_GPM_SUPPORT
- /* GPM: initialize connection to gpm server */
- gpm_connect.eventMask = GPM_DOWN | GPM_UP;
- gpm_connect.defaultMask = ~(gpm_connect.eventMask | GPM_HARD);
- gpm_connect.minMod = 0;
- gpm_connect.maxMod = ~((1 << KG_SHIFT) | (1 << KG_SHIFTL) | (1 << KG_SHIFTR));
- if (Gpm_Open(&gpm_connect, 0) >= 0) { /* returns the file-descriptor */
- mousetype = M_GPM;
- SP->_mouse_fd = gpm_fd;
- return;
- }
+ if (allow_gpm_mouse()) {
+ if (!SP->_mouse_gpm_loaded) {
+#ifdef HAVE_LIBDL
+ void *obj;
+
+ if ((obj = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) {
+ if (GET_DLSYM(gpm_fd) == 0 ||
+ GET_DLSYM(Gpm_Open) == 0 ||
+ GET_DLSYM(Gpm_Close) == 0 ||
+ GET_DLSYM(Gpm_GetEvent) == 0) {
+ T(("GPM initialization failed: %s", dlerror()));
+ dlclose(obj);
+ } else {
+ SP->_mouse_gpm_found = TRUE;
+ }
+ }
+#else /* !HAVE_LIBDL */
+ SP->_mouse_gpm_found = TRUE;
#endif
+ SP->_mouse_gpm_loaded = TRUE;
+ }
+
+ /*
+ * The gpm_fd file-descriptor may be negative (xterm). So we have to
+ * maintain our notion of whether the mouse connection is active
+ * without testing the file-descriptor.
+ */
+ if (SP->_mouse_gpm_found && enable_gpm_mouse(TRUE)) {
+ SP->_mouse_type = M_GPM;
+ SP->_mouse_fd = *(my_gpm_fd);
+ T(("GPM mouse_fd %d", SP->_mouse_fd));
+ returnVoid;
+ }
+ }
+#endif /* USE_GPM_SUPPORT */
/* OS/2 VIO */
-#ifdef USE_EMX_MOUSE
- if (!mouse_thread
+#if USE_EMX_MOUSE
+ if (!SP->_emxmouse_thread
&& strstr(cur_term->type.term_names, "xterm") == 0
&& key_mouse) {
int handles[2];
if (pipe(handles) < 0) {
perror("mouse pipe error");
- return;
+ returnVoid;
} else {
int rc;
- if (!mouse_buttons[0]) {
+ if (!SP->_emxmouse_buttons[0]) {
char *s = getenv("MOUSE_BUTTONS_123");
- mouse_buttons[0] = 1;
+ SP->_emxmouse_buttons[0] = 1;
if (s && strlen(s) >= 3) {
- mouse_buttons[1] = s[0] - '0';
- mouse_buttons[2] = s[1] - '0';
- mouse_buttons[3] = s[2] - '0';
+ SP->_emxmouse_buttons[1] = s[0] - '0';
+ SP->_emxmouse_buttons[2] = s[1] - '0';
+ SP->_emxmouse_buttons[3] = s[2] - '0';
+ } else {
+ SP->_emxmouse_buttons[1] = 1;
+ SP->_emxmouse_buttons[2] = 3;
+ SP->_emxmouse_buttons[3] = 2;
}
}
- mouse_wfd = handles[1];
+ SP->_emxmouse_wfd = handles[1];
M_FD(SP) = handles[0];
/* Needed? */
setmode(handles[0], O_BINARY);
setmode(handles[1], O_BINARY);
/* Do not use CRT functions, we may single-threaded. */
- rc = DosCreateThread((unsigned long *) &mouse_thread,
+ rc = DosCreateThread((unsigned long *) &SP->_emxmouse_thread,
mouse_server, 0, 0, 8192);
if (rc) {
printf("mouse thread error %d=%#x", rc, rc);
- return;
} else {
- mousetype = M_XTERM;
- return;
+ SP->_mouse_type = M_XTERM;
}
+ returnVoid;
}
}
-#endif
+#endif /* USE_EMX_MOUSE */
+
+#if USE_SYSMOUSE
+ {
+ struct mouse_info the_mouse;
+ char *the_device = 0;
+
+ if (isatty(SP->_ifd))
+ the_device = ttyname(SP->_ifd);
+ if (the_device == 0)
+ the_device = "/dev/tty";
+
+ SP->_mouse_fd = open(the_device, O_RDWR);
+
+ if (SP->_mouse_fd >= 0) {
+ /*
+ * sysmouse does not have a usable user interface for obtaining
+ * mouse events. The logical way to proceed (reading data on a
+ * stream) only works if one opens the device as root. Even in
+ * that mode, careful examination shows we lose events
+ * occasionally. The interface provided for user programs is to
+ * establish a signal handler. really.
+ *
+ * Take over SIGUSR2 for this purpose since SIGUSR1 is more
+ * likely to be used by an application. getch() will have to
+ * handle the misleading EINTR's.
+ */
+ signal(SIGUSR2, SIG_IGN);
+ the_mouse.operation = MOUSE_MODE;
+ the_mouse.u.mode.mode = 0;
+ the_mouse.u.mode.signal = SIGUSR2;
+ if (ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {
+ signal(SIGUSR2, handle_sysmouse);
+ the_mouse.operation = MOUSE_SHOW;
+ ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse);
+
+#if defined(FBIO_MODEINFO) || defined(CONS_MODEINFO) /* FreeBSD > 2.x */
+ {
+#ifndef FBIO_GETMODE /* FreeBSD 3.x */
+#define FBIO_GETMODE CONS_GET
+#define FBIO_MODEINFO CONS_MODEINFO
+#endif /* FBIO_GETMODE */
+ video_info_t the_video;
+
+ if (ioctl(SP->_mouse_fd,
+ FBIO_GETMODE,
+ &the_video.vi_mode) != -1
+ && ioctl(SP->_mouse_fd,
+ FBIO_MODEINFO,
+ &the_video) != -1) {
+ SP->_sysmouse_char_width = the_video.vi_cwidth;
+ SP->_sysmouse_char_height = the_video.vi_cheight;
+ }
+ }
+#endif /* defined(FBIO_MODEINFO) || defined(CONS_MODEINFO) */
+
+ if (SP->_sysmouse_char_width <= 0)
+ SP->_sysmouse_char_width = 8;
+ if (SP->_sysmouse_char_height <= 0)
+ SP->_sysmouse_char_height = 16;
+ SP->_mouse_type = M_SYSMOUSE;
+ returnVoid;
+ }
+ }
+ }
+#endif /* USE_SYSMOUSE */
/* we know how to recognize mouse events under "xterm" */
if (key_mouse != 0) {
- if (!strcmp(key_mouse, xterm_kmous)) {
- mousetype = M_XTERM;
- return;
+ if (!strcmp(key_mouse, xterm_kmous)
+ || strstr(cur_term->type.term_names, "xterm") != 0) {
+ init_xterm_mouse();
}
} else if (strstr(cur_term->type.term_names, "xterm") != 0) {
(void) _nc_add_to_try(&(SP->_keytry), xterm_kmous, KEY_MOUSE);
- mousetype = M_XTERM;
- return;
+ init_xterm_mouse();
}
+ returnVoid;
}
-static void
+static bool
_nc_mouse_init(void)
/* initialize the mouse */
{
+ bool result = FALSE;
int i;
- if (!initialized) {
- initialized = TRUE;
+ if (SP != 0) {
+ if (!SP->_mouse_initialized) {
+ SP->_mouse_initialized = TRUE;
- TR(MY_TRACE, ("_nc_mouse_init() called"));
+ TR(MY_TRACE, ("_nc_mouse_init() called"));
- for (i = 0; i < EV_MAX; i++)
- events[i].id = INVALID_EVENT;
+ SP->_mouse_eventp = SP->_mouse_events;
+ for (i = 0; i < EV_MAX; i++)
+ SP->_mouse_events[i].id = INVALID_EVENT;
- initialize_mousetype();
+ initialize_mousetype();
- T(("_nc_mouse_init() set mousetype to %d", mousetype));
+ T(("_nc_mouse_init() set mousetype to %d", SP->_mouse_type));
+ }
+ result = SP->_mouse_initialized;
}
+ return result;
}
+/*
+ * Query to see if there is a pending mouse event. This is called from
+ * fifo_push() in lib_getch.c
+ */
static bool
-_nc_mouse_event(SCREEN * sp GCC_UNUSED)
-/* query to see if there is a pending mouse event */
+_nc_mouse_event(SCREEN *sp GCC_UNUSED)
{
-#if USE_GPM_SUPPORT
- /* GPM: query server for event, return TRUE if we find one */
- Gpm_Event ev;
+ MEVENT *eventp = SP->_mouse_eventp;
+ bool result = FALSE;
- if (gpm_fd >= 0
- && (_nc_timed_wait(3, 0, (int *) 0) & 2) != 0
- && Gpm_GetEvent(&ev) == 1) {
- eventp->id = 0; /* there's only one mouse... */
+ (void) eventp;
- eventp->bstate = 0;
- switch (ev.type & 0x0f) {
- case (GPM_DOWN):
- if (ev.buttons & GPM_B_LEFT)
- eventp->bstate |= BUTTON1_PRESSED;
- if (ev.buttons & GPM_B_MIDDLE)
- eventp->bstate |= BUTTON2_PRESSED;
- if (ev.buttons & GPM_B_RIGHT)
- eventp->bstate |= BUTTON3_PRESSED;
- break;
- case (GPM_UP):
- if (ev.buttons & GPM_B_LEFT)
- eventp->bstate |= BUTTON1_RELEASED;
- if (ev.buttons & GPM_B_MIDDLE)
- eventp->bstate |= BUTTON2_RELEASED;
- if (ev.buttons & GPM_B_RIGHT)
- eventp->bstate |= BUTTON3_RELEASED;
- break;
- default:
- break;
+ switch (SP->_mouse_type) {
+ case M_XTERM:
+ /* xterm: never have to query, mouse events are in the keyboard stream */
+#if USE_EMX_MOUSE
+ {
+ char kbuf[3];
+
+ int i, res = read(M_FD(sp), &kbuf, 3); /* Eat the prefix */
+ if (res != 3)
+ printf("Got %d chars instead of 3 for prefix.\n", res);
+ for (i = 0; i < res; i++) {
+ if (kbuf[i] != key_mouse[i])
+ printf("Got char %d instead of %d for prefix.\n",
+ (int) kbuf[i], (int) key_mouse[i]);
+ }
+ result = TRUE;
}
+#endif /* USE_EMX_MOUSE */
+ break;
- eventp->x = ev.x - 1;
- eventp->y = ev.y - 1;
- eventp->z = 0;
+#if USE_GPM_SUPPORT
+ case M_GPM:
+ {
+ /* query server for event, return TRUE if we find one */
+ Gpm_Event ev;
+
+ if (my_Gpm_GetEvent(&ev) == 1) {
+ /* there's only one mouse... */
+ eventp->id = NORMAL_EVENT;
+
+ eventp->bstate = 0;
+ switch (ev.type & 0x0f) {
+ case (GPM_DOWN):
+ if (ev.buttons & GPM_B_LEFT)
+ eventp->bstate |= BUTTON1_PRESSED;
+ if (ev.buttons & GPM_B_MIDDLE)
+ eventp->bstate |= BUTTON2_PRESSED;
+ if (ev.buttons & GPM_B_RIGHT)
+ eventp->bstate |= BUTTON3_PRESSED;
+ break;
+ case (GPM_UP):
+ if (ev.buttons & GPM_B_LEFT)
+ eventp->bstate |= BUTTON1_RELEASED;
+ if (ev.buttons & GPM_B_MIDDLE)
+ eventp->bstate |= BUTTON2_RELEASED;
+ if (ev.buttons & GPM_B_RIGHT)
+ eventp->bstate |= BUTTON3_RELEASED;
+ break;
+ default:
+ break;
+ }
- /* bump the next-free pointer into the circular list */
- eventp = NEXT(eventp);
- return (TRUE);
- }
+ eventp->x = ev.x - 1;
+ eventp->y = ev.y - 1;
+ eventp->z = 0;
+
+ /* bump the next-free pointer into the circular list */
+ SP->_mouse_eventp = eventp = NEXT(eventp);
+ result = TRUE;
+ }
+ }
+ break;
#endif
-#ifdef USE_EMX_MOUSE
- if (SP->_mouse_fd >= 0
- && (_nc_timed_wait(3, 0, (int *) 0) & 2) != 0) {
- char kbuf[3];
-
- int i, res = read(M_FD(sp), &kbuf, 3); /* Eat the prefix */
- if (res != 3)
- printf("Got %d chars instead of 3 for prefix.\n", res);
- for (i = 0; i < res; i++) {
- if (kbuf[i] != key_mouse[i])
- printf("Got char %d instead of %d for prefix.\n",
- (int) kbuf[i], (int) key_mouse[i]);
+#if USE_SYSMOUSE
+ case M_SYSMOUSE:
+ if (SP->_sysmouse_head < SP->_sysmouse_tail) {
+ *eventp = SP->_sysmouse_fifo[SP->_sysmouse_head];
+
+ /*
+ * Point the fifo-head to the next possible location. If there
+ * are none, reset the indices. This may be interrupted by the
+ * signal handler, doing essentially the same reset.
+ */
+ SP->_sysmouse_head += 1;
+ if (SP->_sysmouse_head == SP->_sysmouse_tail) {
+ SP->_sysmouse_tail = 0;
+ SP->_sysmouse_head = 0;
+ }
+
+ /* bump the next-free pointer into the circular list */
+ SP->_mouse_eventp = eventp = NEXT(eventp);
+ result = TRUE;
}
- return TRUE;
+ break;
+#endif /* USE_SYSMOUSE */
+
+ case M_NONE:
+ break;
}
-#endif /* USE_EMX_MOUSE */
- /* xterm: never have to query, mouse events are in the keyboard stream */
- return (FALSE); /* no event waiting */
+ return result; /* true if we found an event */
}
static bool
-_nc_mouse_inline(SCREEN * sp)
+_nc_mouse_inline(SCREEN *sp)
/* mouse report received in the keyboard stream -- parse its info */
{
+ int b;
+ bool result = FALSE;
+ MEVENT *eventp = SP->_mouse_eventp;
+
TR(MY_TRACE, ("_nc_mouse_inline() called"));
- if (mousetype == M_XTERM) {
+ if (SP->_mouse_type == M_XTERM) {
unsigned char kbuf[4];
- MEVENT *prev;
+ mmask_t prev;
size_t grabbed;
int res;
@@ -432,13 +746,15 @@ _nc_mouse_inline(SCREEN * sp)
* (End quote) By the time we get here, we've eaten the
* key prefix. FYI, the loop below is necessary because
* mouse click info isn't guaranteed to present as a
- * single clist item. It always does under Linux but often
- * fails to under Solaris.
+ * single clist item.
+ *
+ * Wheel mice may return buttons 4 and 5 when the wheel is turned.
+ * We encode those as button presses.
*/
for (grabbed = 0; grabbed < 3; grabbed += res) {
/* For VIO mouse we add extra bit 64 to disambiguate button-up. */
-#ifdef USE_EMX_MOUSE
+#if USE_EMX_MOUSE
res = read(M_FD(sp) >= 0 ? M_FD(sp) : sp->_ifd, &kbuf, 3);
#else
res = read(sp->_ifd, kbuf + grabbed, 3 - grabbed);
@@ -451,59 +767,71 @@ _nc_mouse_inline(SCREEN * sp)
TR(TRACE_IEVENT,
("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
- eventp->id = 0; /* there's only one mouse... */
+ /* there's only one mouse... */
+ eventp->id = NORMAL_EVENT;
/* processing code goes here */
eventp->bstate = 0;
+ prev = PREV(eventp)->bstate;
+
+#if USE_EMX_MOUSE
+#define PRESS_POSITION(n) \
+ eventp->bstate = MASK_PRESS(n); \
+ if (kbuf[0] & 0x40) \
+ eventp->bstate = MASK_RELEASE(n)
+#else
+#define PRESS_POSITION(n) \
+ eventp->bstate = (prev & MASK_PRESS(n) \
+ ? REPORT_MOUSE_POSITION \
+ : MASK_PRESS(n))
+#endif
+
switch (kbuf[0] & 0x3) {
case 0x0:
- eventp->bstate = BUTTON1_PRESSED;
-#ifdef USE_EMX_MOUSE
- if (kbuf[0] & 0x40)
- eventp->bstate = BUTTON1_RELEASED;
-#endif
+ if (kbuf[0] & 64)
+ eventp->bstate = MASK_PRESS(4);
+ else
+ PRESS_POSITION(1);
break;
case 0x1:
- eventp->bstate = BUTTON2_PRESSED;
-#ifdef USE_EMX_MOUSE
- if (kbuf[0] & 0x40)
- eventp->bstate = BUTTON2_RELEASED;
+#if NCURSES_MOUSE_VERSION == 2
+ if (kbuf[0] & 64)
+ eventp->bstate = MASK_PRESS(5);
+ else
#endif
+ PRESS_POSITION(2);
break;
case 0x2:
- eventp->bstate = BUTTON3_PRESSED;
-#ifdef USE_EMX_MOUSE
- if (kbuf[0] & 0x40)
- eventp->bstate = BUTTON3_RELEASED;
-#endif
+ PRESS_POSITION(3);
break;
case 0x3:
/*
- * Release events aren't reported for individual buttons,
- * just for the button set as a whole...
+ * Release events aren't reported for individual buttons, just for
+ * the button set as a whole. However, because there are normally
+ * no mouse events under xterm that intervene between press and
+ * release, we can infer the button actually released by looking at
+ * the previous event.
*/
- eventp->bstate =
- (BUTTON1_RELEASED |
- BUTTON2_RELEASED |
- BUTTON3_RELEASED);
- /*
- * ...however, because there are no kinds of mouse events under
- * xterm that can intervene between press and release, we can
- * deduce which buttons were actually released by looking at the
- * previous event.
- */
- prev = PREV(eventp);
- if (!(prev->bstate & BUTTON1_PRESSED))
- eventp->bstate &= ~BUTTON1_RELEASED;
- if (!(prev->bstate & BUTTON2_PRESSED))
- eventp->bstate &= ~BUTTON2_RELEASED;
- if (!(prev->bstate & BUTTON3_PRESSED))
- eventp->bstate &= ~BUTTON3_RELEASED;
+ if (prev & (BUTTON_PRESSED | BUTTON_RELEASED)) {
+ eventp->bstate = BUTTON_RELEASED;
+ for (b = 1; b <= MAX_BUTTONS; ++b) {
+ if (!(prev & MASK_PRESS(b)))
+ eventp->bstate &= ~MASK_RELEASE(b);
+ }
+ } else {
+ /*
+ * XFree86 xterm will return a stream of release-events to
+ * let the application know where the mouse is going, if the
+ * private mode 1002 or 1003 is enabled.
+ */
+ eventp->bstate = REPORT_MOUSE_POSITION;
+ }
break;
}
+ result = (eventp->bstate & REPORT_MOUSE_POSITION) ? TRUE : FALSE;
if (kbuf[0] & 4) {
eventp->bstate |= BUTTON_SHIFT;
@@ -520,45 +848,53 @@ _nc_mouse_inline(SCREEN * sp)
TR(MY_TRACE,
("_nc_mouse_inline: primitive mouse-event %s has slot %ld",
_tracemouse(eventp),
- (long) (eventp - events)));
+ (long) (eventp - SP->_mouse_events)));
/* bump the next-free pointer into the circular list */
- eventp = NEXT(eventp);
+ SP->_mouse_eventp = NEXT(eventp);
#if 0 /* this return would be needed for QNX's mods to lib_getch.c */
return (TRUE);
#endif
}
- return (FALSE);
+ return (result);
}
static void
mouse_activate(bool on)
{
- if (!on && !initialized)
+ if (!on && !SP->_mouse_initialized)
return;
- _nc_mouse_init();
+ if (!_nc_mouse_init())
+ return;
if (on) {
- switch (mousetype) {
+ switch (SP->_mouse_type) {
case M_XTERM:
#if NCURSES_EXT_FUNCS
keyok(KEY_MOUSE, on);
#endif
TPUTS_TRACE("xterm mouse initialization");
-#ifdef USE_EMX_MOUSE
- server_state(1);
-#else
- putp("\033[?1000h");
-#endif
+ enable_xterm_mouse(1);
break;
#if USE_GPM_SUPPORT
case M_GPM:
- SP->_mouse_fd = gpm_fd;
+ if (enable_gpm_mouse(1)) {
+ SP->_mouse_fd = *(my_gpm_fd);
+ T(("GPM mouse_fd %d", SP->_mouse_fd));
+ }
+ break;
+#endif
+#if USE_SYSMOUSE
+ case M_SYSMOUSE:
+ signal(SIGUSR2, handle_sysmouse);
+ SP->_mouse_active = TRUE;
break;
#endif
+ case M_NONE:
+ return;
}
/* Make runtime binding to cut down on object size of applications that
* do not use the mouse (e.g., 'clear').
@@ -568,22 +904,26 @@ mouse_activate(bool on)
SP->_mouse_parse = _nc_mouse_parse;
SP->_mouse_resume = _nc_mouse_resume;
SP->_mouse_wrap = _nc_mouse_wrap;
-
} else {
- switch (mousetype) {
+ switch (SP->_mouse_type) {
case M_XTERM:
TPUTS_TRACE("xterm mouse deinitialization");
-#ifdef USE_EMX_MOUSE
- server_state(0);
-#else
- putp("\033[?1000l");
-#endif
+ enable_xterm_mouse(0);
break;
#if USE_GPM_SUPPORT
case M_GPM:
+ enable_gpm_mouse(0);
+ break;
+#endif
+#if USE_SYSMOUSE
+ case M_SYSMOUSE:
+ signal(SIGUSR2, SIG_IGN);
+ SP->_mouse_active = FALSE;
break;
#endif
+ case M_NONE:
+ return;
}
}
_nc_flush();
@@ -599,8 +939,10 @@ static bool
_nc_mouse_parse(int runcount)
/* parse a run of atomic mouse events into a gesture */
{
+ MEVENT *eventp = SP->_mouse_eventp;
MEVENT *ep, *runp, *next, *prev = PREV(eventp);
int n;
+ int b;
bool merge;
TR(MY_TRACE, ("_nc_mouse_parse(%d) called", runcount));
@@ -609,7 +951,7 @@ _nc_mouse_parse(int runcount)
* When we enter this routine, the event list next-free pointer
* points just past a run of mouse events that we know were separated
* in time by less than the critical click interval. The job of this
- * routine is to collaps this run into a single higher-level event
+ * routine is to collapse this run into a single higher-level event
* or gesture.
*
* We accomplish this in two passes. The first pass merges press/release
@@ -630,9 +972,9 @@ _nc_mouse_parse(int runcount)
TR(MY_TRACE,
("_nc_mouse_parse: returning simple mouse event %s at slot %ld",
_tracemouse(prev),
- (long) (prev - events)));
- return (prev->id >= 0)
- ? ((prev->bstate & eventmask) ? TRUE : FALSE)
+ (long) (prev - SP->_mouse_events)));
+ return (prev->id >= NORMAL_EVENT)
+ ? ((prev->bstate & SP->_mouse_mask) ? TRUE : FALSE)
: FALSE;
}
@@ -646,8 +988,8 @@ _nc_mouse_parse(int runcount)
if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("before mouse press/release merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - events),
- (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
+ (long) (runp - SP->_mouse_events),
+ (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
#endif /* TRACE */
@@ -656,32 +998,27 @@ _nc_mouse_parse(int runcount)
do {
merge = FALSE;
for (ep = runp; (next = NEXT(ep)) != eventp; ep = next) {
+
+#define MASK_CHANGED(x) (!(ep->bstate & MASK_PRESS(x)) \
+ == !(next->bstate & MASK_RELEASE(x)))
+
if (ep->x == next->x && ep->y == next->y
- && (ep->bstate & (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED))
- && (!(ep->bstate & BUTTON1_PRESSED)
- == !(next->bstate & BUTTON1_RELEASED))
- && (!(ep->bstate & BUTTON2_PRESSED)
- == !(next->bstate & BUTTON2_RELEASED))
- && (!(ep->bstate & BUTTON3_PRESSED)
- == !(next->bstate & BUTTON3_RELEASED))
+ && (ep->bstate & BUTTON_PRESSED)
+ && MASK_CHANGED(1)
+ && MASK_CHANGED(2)
+ && MASK_CHANGED(3)
+ && MASK_CHANGED(4)
+#if NCURSES_MOUSE_VERSION == 2
+ && MASK_CHANGED(5)
+#endif
) {
- if ((eventmask & BUTTON1_CLICKED)
- && (ep->bstate & BUTTON1_PRESSED)) {
- ep->bstate &= ~BUTTON1_PRESSED;
- ep->bstate |= BUTTON1_CLICKED;
- merge = TRUE;
- }
- if ((eventmask & BUTTON2_CLICKED)
- && (ep->bstate & BUTTON2_PRESSED)) {
- ep->bstate &= ~BUTTON2_PRESSED;
- ep->bstate |= BUTTON2_CLICKED;
- merge = TRUE;
- }
- if ((eventmask & BUTTON3_CLICKED)
- && (ep->bstate & BUTTON3_PRESSED)) {
- ep->bstate &= ~BUTTON3_PRESSED;
- ep->bstate |= BUTTON3_CLICKED;
- merge = TRUE;
+ for (b = 1; b <= MAX_BUTTONS; ++b) {
+ if ((SP->_mouse_mask & MASK_CLICK(b))
+ && (ep->bstate & MASK_PRESS(b))) {
+ ep->bstate &= ~MASK_PRESS(b);
+ ep->bstate |= MASK_CLICK(b);
+ merge = TRUE;
+ }
}
if (merge)
next->id = INVALID_EVENT;
@@ -694,8 +1031,8 @@ _nc_mouse_parse(int runcount)
if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("before mouse click merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - events),
- (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
+ (long) (runp - SP->_mouse_events),
+ (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
#endif /* TRACE */
@@ -729,56 +1066,30 @@ _nc_mouse_parse(int runcount)
continue;
/* merge click events forward */
- if ((ep->bstate &
- (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))
- && (follower->bstate &
- (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))) {
- if ((eventmask & BUTTON1_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON1_CLICKED)) {
- follower->bstate &= ~BUTTON1_CLICKED;
- follower->bstate |= BUTTON1_DOUBLE_CLICKED;
- merge = TRUE;
- }
- if ((eventmask & BUTTON2_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON2_CLICKED)) {
- follower->bstate &= ~BUTTON2_CLICKED;
- follower->bstate |= BUTTON2_DOUBLE_CLICKED;
- merge = TRUE;
- }
- if ((eventmask & BUTTON3_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON3_CLICKED)) {
- follower->bstate &= ~BUTTON3_CLICKED;
- follower->bstate |= BUTTON3_DOUBLE_CLICKED;
- merge = TRUE;
+ if ((ep->bstate & BUTTON_CLICKED)
+ && (follower->bstate & BUTTON_CLICKED)) {
+ for (b = 1; b <= MAX_BUTTONS; ++b) {
+ if ((SP->_mouse_mask & MASK_DOUBLE_CLICK(b))
+ && (follower->bstate & MASK_CLICK(b))) {
+ follower->bstate &= ~MASK_CLICK(b);
+ follower->bstate |= MASK_DOUBLE_CLICK(b);
+ merge = TRUE;
+ }
}
if (merge)
ep->id = INVALID_EVENT;
}
/* merge double-click events forward */
- if ((ep->bstate &
- (BUTTON1_DOUBLE_CLICKED
- | BUTTON2_DOUBLE_CLICKED
- | BUTTON3_DOUBLE_CLICKED))
- && (follower->bstate &
- (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))) {
- if ((eventmask & BUTTON1_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON1_CLICKED)) {
- follower->bstate &= ~BUTTON1_CLICKED;
- follower->bstate |= BUTTON1_TRIPLE_CLICKED;
- merge = TRUE;
- }
- if ((eventmask & BUTTON2_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON2_CLICKED)) {
- follower->bstate &= ~BUTTON2_CLICKED;
- follower->bstate |= BUTTON2_TRIPLE_CLICKED;
- merge = TRUE;
- }
- if ((eventmask & BUTTON3_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON3_CLICKED)) {
- follower->bstate &= ~BUTTON3_CLICKED;
- follower->bstate |= BUTTON3_TRIPLE_CLICKED;
- merge = TRUE;
+ if ((ep->bstate & BUTTON_DOUBLE_CLICKED)
+ && (follower->bstate & BUTTON_CLICKED)) {
+ for (b = 1; b <= MAX_BUTTONS; ++b) {
+ if ((SP->_mouse_mask & MASK_TRIPLE_CLICK(b))
+ && (follower->bstate & MASK_CLICK(b))) {
+ follower->bstate &= ~MASK_CLICK(b);
+ follower->bstate |= MASK_TRIPLE_CLICK(b);
+ merge = TRUE;
+ }
}
if (merge)
ep->id = INVALID_EVENT;
@@ -791,8 +1102,8 @@ _nc_mouse_parse(int runcount)
if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("before mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - events),
- (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
+ (long) (runp - SP->_mouse_events),
+ (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
#endif /* TRACE */
@@ -802,15 +1113,15 @@ _nc_mouse_parse(int runcount)
* don't match the current event mask.
*/
for (; runcount; prev = PREV(eventp), runcount--)
- if (prev->id == INVALID_EVENT || !(prev->bstate & eventmask)) {
- eventp = prev;
+ if (prev->id == INVALID_EVENT || !(prev->bstate & SP->_mouse_mask)) {
+ SP->_mouse_eventp = eventp = prev;
}
#ifdef TRACE
if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("after mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - events),
- (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
+ (long) (runp - SP->_mouse_events),
+ (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
for (ep = runp; ep != eventp; ep = NEXT(ep))
@@ -818,7 +1129,7 @@ _nc_mouse_parse(int runcount)
TR(MY_TRACE,
("_nc_mouse_parse: returning composite mouse event %s at slot %ld",
_tracemouse(ep),
- (long) (ep - events)));
+ (long) (ep - SP->_mouse_events)));
#endif /* TRACE */
/* after all this, do we have a valid event? */
@@ -826,35 +1137,62 @@ _nc_mouse_parse(int runcount)
}
static void
-_nc_mouse_wrap(SCREEN * sp GCC_UNUSED)
+_nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
/* release mouse -- called by endwin() before shellout/exit */
{
TR(MY_TRACE, ("_nc_mouse_wrap() called"));
- switch (mousetype) {
+ switch (SP->_mouse_type) {
case M_XTERM:
- if (eventmask)
+ if (SP->_mouse_mask)
mouse_activate(FALSE);
break;
#if USE_GPM_SUPPORT
/* GPM: pass all mouse events to next client */
case M_GPM:
+ if (SP->_mouse_mask)
+ mouse_activate(FALSE);
+ break;
+#endif
+#if USE_SYSMOUSE
+ case M_SYSMOUSE:
+ mouse_activate(FALSE);
break;
#endif
+ case M_NONE:
+ break;
}
}
static void
-_nc_mouse_resume(SCREEN * sp GCC_UNUSED)
+_nc_mouse_resume(SCREEN *sp GCC_UNUSED)
/* re-connect to mouse -- called by doupdate() after shellout */
{
TR(MY_TRACE, ("_nc_mouse_resume() called"));
- /* xterm: re-enable reporting */
- if (mousetype == M_XTERM && eventmask)
- mouse_activate(TRUE);
+ switch (SP->_mouse_type) {
+ case M_XTERM:
+ /* xterm: re-enable reporting */
+ if (SP->_mouse_mask)
+ mouse_activate(TRUE);
+ break;
- /* GPM: reclaim our event set */
+#if USE_GPM_SUPPORT
+ case M_GPM:
+ /* GPM: reclaim our event set */
+ if (SP->_mouse_mask)
+ mouse_activate(TRUE);
+ break;
+#endif
+
+#if USE_SYSMOUSE
+ case M_SYSMOUSE:
+ mouse_activate(TRUE);
+ break;
+#endif
+ case M_NONE:
+ break;
+ }
}
/**************************************************************************
@@ -869,7 +1207,8 @@ getmouse(MEVENT * aevent)
{
T((T_CALLED("getmouse(%p)"), aevent));
- if (aevent && (mousetype != M_NONE)) {
+ if ((aevent != 0) && (SP != 0) && (SP->_mouse_type != M_NONE)) {
+ MEVENT *eventp = SP->_mouse_eventp;
/* compute the current-event pointer */
MEVENT *prev = PREV(eventp);
@@ -878,7 +1217,7 @@ getmouse(MEVENT * aevent)
TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
_tracemouse(prev),
- (long) (prev - events)));
+ (long) (prev - SP->_mouse_events)));
prev->id = INVALID_EVENT; /* so the queue slot becomes free */
returnCode(OK);
@@ -890,14 +1229,23 @@ NCURSES_EXPORT(int)
ungetmouse(MEVENT * aevent)
/* enqueue a synthesized mouse event to be seen by the next wgetch() */
{
- /* stick the given event in the next-free slot */
- *eventp = *aevent;
+ int result = ERR;
+
+ T((T_CALLED("ungetmouse(%p)"), aevent));
- /* bump the next-free pointer into the circular list */
- eventp = NEXT(eventp);
+ if (aevent != 0 && SP != 0) {
+ MEVENT *eventp = SP->_mouse_eventp;
- /* push back the notification event on the keyboard queue */
- return ungetch(KEY_MOUSE);
+ /* stick the given event in the next-free slot */
+ *eventp = *aevent;
+
+ /* bump the next-free pointer into the circular list */
+ SP->_mouse_eventp = NEXT(eventp);
+
+ /* push back the notification event on the keyboard queue */
+ result = ungetch(KEY_MOUSE);
+ }
+ returnCode(result);
}
NCURSES_EXPORT(mmask_t)
@@ -906,45 +1254,54 @@ mousemask(mmask_t newmask, mmask_t * oldmask)
{
mmask_t result = 0;
- T((T_CALLED("mousemask(%#lx,%p)"), newmask, oldmask));
+ T((T_CALLED("mousemask(%#lx,%p)"), (unsigned long) newmask, oldmask));
- if (oldmask)
- *oldmask = eventmask;
-
- if (!newmask && !initialized)
- returnCode(0);
-
- _nc_mouse_init();
- if (mousetype != M_NONE) {
- eventmask = newmask &
- (BUTTON_ALT | BUTTON_CTRL | BUTTON_SHIFT
- | BUTTON1_PRESSED | BUTTON1_RELEASED | BUTTON1_CLICKED
- | BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED
- | BUTTON2_PRESSED | BUTTON2_RELEASED | BUTTON2_CLICKED
- | BUTTON2_DOUBLE_CLICKED | BUTTON2_TRIPLE_CLICKED
- | BUTTON3_PRESSED | BUTTON3_RELEASED | BUTTON3_CLICKED
- | BUTTON3_DOUBLE_CLICKED | BUTTON3_TRIPLE_CLICKED);
-
- mouse_activate(eventmask != 0);
-
- result = eventmask;
+ if (SP != 0) {
+ if (oldmask)
+ *oldmask = SP->_mouse_mask;
+
+ if (newmask || SP->_mouse_initialized) {
+ _nc_mouse_init();
+ if (SP->_mouse_type != M_NONE) {
+ result = newmask &
+ (REPORT_MOUSE_POSITION
+ | BUTTON_ALT
+ | BUTTON_CTRL
+ | BUTTON_SHIFT
+ | BUTTON_PRESSED
+ | BUTTON_RELEASED
+ | BUTTON_CLICKED
+ | BUTTON_DOUBLE_CLICKED
+ | BUTTON_TRIPLE_CLICKED);
+
+ mouse_activate((bool) (result != 0));
+
+ SP->_mouse_mask = result;
+ }
+ }
+ } else {
+ if (oldmask)
+ *oldmask = SP->_mouse_mask;
}
-
- returnCode(result);
+ returnBits(result);
}
NCURSES_EXPORT(bool)
wenclose(const WINDOW *win, int y, int x)
/* check to see if given window encloses given screen location */
{
- if (win) {
+ bool result = FALSE;
+
+ T((T_CALLED("wenclose(%p,%d,%d)"), win, y, x));
+
+ if (win != 0) {
y -= win->_yoffset;
- return ((win->_begy <= y &&
- win->_begx <= x &&
- (win->_begx + win->_maxx) >= x &&
- (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
+ result = ((win->_begy <= y &&
+ win->_begx <= x &&
+ (win->_begx + win->_maxx) >= x &&
+ (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
}
- return FALSE;
+ returnBool(result);
}
NCURSES_EXPORT(int)
@@ -953,6 +1310,8 @@ mouseinterval(int maxclick)
{
int oldval;
+ T((T_CALLED("mouseinterval(%d)"), maxclick));
+
if (SP != 0) {
oldval = SP->_maxclick;
if (maxclick >= 0)
@@ -961,7 +1320,7 @@ mouseinterval(int maxclick)
oldval = DEFAULT_MAXCLICK;
}
- return (oldval);
+ returnCode(oldval);
}
/* This may be used by other routines to ask for the existence of mouse
@@ -969,15 +1328,16 @@ mouseinterval(int maxclick)
NCURSES_EXPORT(int)
_nc_has_mouse(void)
{
- return (mousetype == M_NONE ? 0 : 1);
+ return (SP->_mouse_type == M_NONE ? 0 : 1);
}
NCURSES_EXPORT(bool)
-wmouse_trafo
-(const WINDOW *win, int *pY, int *pX, bool to_screen)
+wmouse_trafo(const WINDOW *win, int *pY, int *pX, bool to_screen)
{
bool result = FALSE;
+ T((T_CALLED("wmouse_trafo(%p,%p,%p,%d)"), win, pY, pX, to_screen));
+
if (win && pY && pX) {
int y = *pY;
int x = *pX;
@@ -999,7 +1359,5 @@ wmouse_trafo
*pY = y;
}
}
- return (result);
+ returnBool(result);
}
-
-/* lib_mouse.c ends here */
diff --git a/contrib/ncurses/ncurses/base/lib_move.c b/contrib/ncurses/ncurses/base/lib_move.c
index e917eb780525..652c44d7b718 100644
--- a/contrib/ncurses/ncurses/base/lib_move.c
+++ b/contrib/ncurses/ncurses/base/lib_move.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -40,16 +41,14 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_move.c,v 1.11 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_move.c,v 1.12 2004/12/04 21:50:07 tom Exp $")
NCURSES_EXPORT(int)
wmove(WINDOW *win, int y, int x)
{
T((T_CALLED("wmove(%p,%d,%d)"), win, y, x));
- if (win &&
- x >= 0 && x <= win->_maxx &&
- y >= 0 && y <= win->_maxy) {
+ if (LEGALYX(win, y, x)) {
win->_curx = (NCURSES_SIZE_T) x;
win->_cury = (NCURSES_SIZE_T) y;
diff --git a/contrib/ncurses/ncurses/base/lib_mvwin.c b/contrib/ncurses/ncurses/base/lib_mvwin.c
index 63d54ccda574..e4dad4a746f0 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2006 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.12 2001/12/19 01:06:22 tom Exp $")
+MODULE_ID("$Id: lib_mvwin.c,v 1.14 2006/02/25 22:53:46 tom Exp $")
NCURSES_EXPORT(int)
mvwin(WINDOW *win, int by, int bx)
@@ -50,6 +50,11 @@ mvwin(WINDOW *win, int by, int bx)
if (!win || (win->_flags & _ISPAD))
returnCode(ERR);
+ /*
+ * mvwin() should only modify the indices. See test/demo_menus.c and
+ * test/movewindow.c for examples.
+ */
+#if 0
/* Copying subwindows is allowed, but it is expensive... */
if (win->_flags & _SUBWIN) {
int err = ERR;
@@ -89,6 +94,7 @@ mvwin(WINDOW *win, int by, int bx)
}
returnCode(err);
}
+#endif
if (by + win->_maxy > screen_lines - 1
|| bx + win->_maxx > screen_columns - 1
diff --git a/contrib/ncurses/ncurses/base/lib_newterm.c b/contrib/ncurses/ncurses/base/lib_newterm.c
index d95c4a9575c8..fe201d6b8e27 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -47,7 +48,7 @@
#include <term.h> /* clear_screen, cup & friends, cur_term */
#include <tic.h>
-MODULE_ID("$Id: lib_newterm.c,v 1.52 2001/08/04 16:47:48 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.64 2006/01/14 15:36:24 tom Exp $")
#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
@@ -61,21 +62,30 @@ MODULE_ID("$Id: lib_newterm.c,v 1.52 2001/08/04 16:47:48 tom Exp $")
* The newterm function also initializes terminal settings, and since initscr
* is supposed to behave as if it calls newterm, we do it here.
*/
-static inline int
+static NCURSES_INLINE int
_nc_initscr(void)
{
+ int result = ERR;
+
/* for extended XPG4 conformance requires cbreak() at this point */
/* (SVr4 curses does this anyway) */
- cbreak();
+ if (cbreak() == OK) {
+ TTY buf;
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- cur_term->Nttyb.c_lflag &= ~(ECHO | ECHONL);
- cur_term->Nttyb.c_iflag &= ~(ICRNL | INLCR | IGNCR);
- cur_term->Nttyb.c_oflag &= ~(ONLCR);
+ buf.c_lflag &= ~(ECHO | ECHONL);
+ buf.c_iflag &= ~(ICRNL | INLCR | IGNCR);
+ buf.c_oflag &= ~(ONLCR);
+#elif HAVE_SGTTY_H
+ buf.sg_flags &= ~(ECHO | CRMOD);
#else
- cur_term->Nttyb.sg_flags &= ~(ECHO | CRMOD);
+ memset(&buf, 0, sizeof(buf));
#endif
- return _nc_set_tty_mode(&cur_term->Nttyb);
+ if ((result = _nc_set_tty_mode(&buf)) == OK)
+ cur_term->Nttyb = buf;
+ }
+ return result;
}
/*
@@ -84,126 +94,123 @@ _nc_initscr(void)
* aside from possibly delaying a filter() call until some terminals have been
* initialized.
*/
-static int filter_mode = FALSE;
+static bool filter_mode = FALSE;
NCURSES_EXPORT(void)
filter(void)
{
+ START_TRACE();
T((T_CALLED("filter")));
filter_mode = TRUE;
returnVoid;
}
+#if NCURSES_EXT_FUNCS
+/*
+ * An extension, allowing the application to open a new screen without
+ * requiring it to also be filtered.
+ */
+NCURSES_EXPORT(void)
+nofilter(void)
+{
+ START_TRACE();
+ T((T_CALLED("nofilter")));
+ filter_mode = FALSE;
+ returnVoid;
+}
+#endif
+
NCURSES_EXPORT(SCREEN *)
-newterm
-(NCURSES_CONST char *name, FILE * ofp, FILE * ifp)
+newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
{
+ int value;
int errret;
int slk_format = _nc_slk_format;
SCREEN *current;
-#ifdef TRACE
- int t = _nc_getenv_num("NCURSES_TRACE");
-
- if (t >= 0)
- trace(t);
-#endif
+ SCREEN *result = 0;
+ START_TRACE();
T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp));
- /* this loads the capability entry, then sets LINES and COLS */
- if (setupterm(name, fileno(ofp), &errret) == ERR)
- returnSP(0);
-
- /* implement filter mode */
- if (filter_mode) {
- LINES = 1;
-
- if (VALID_NUMERIC(init_tabs))
- TABSIZE = init_tabs;
- else
- TABSIZE = 8;
-
- T(("TABSIZE = %d", TABSIZE));
-
- clear_screen = 0;
- cursor_down = parm_down_cursor = 0;
- cursor_address = 0;
- cursor_up = parm_up_cursor = 0;
- row_address = 0;
-
- cursor_home = carriage_return;
- }
+ _nc_handle_sigwinch(0);
- /* If we must simulate soft labels, grab off the line to be used.
- We assume that we must simulate, if it is none of the standard
- formats (4-4 or 3-2-3) for which there may be some hardware
- support. */
- if (num_labels <= 0 || !SLK_STDFMT(slk_format))
- if (slk_format) {
- if (ERR == _nc_ripoffline(-SLK_LINES(slk_format),
- _nc_slk_initialize))
- returnSP(0);
- }
- /* this actually allocates the screen structure, and saves the
- * original terminal settings.
- */
- current = SP;
- _nc_set_screen(0);
- if (_nc_setupscreen(LINES, COLS, ofp) == ERR) {
- _nc_set_screen(current);
- returnSP(0);
+ /* allow user to set maximum escape delay from the environment */
+ if ((value = _nc_getenv_num("ESCDELAY")) >= 0) {
+ ESCDELAY = value;
}
- /* if the terminal type has real soft labels, set those up */
- if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
- _nc_slk_initialize(stdscr, COLS);
-
- SP->_ifd = fileno(ifp);
- SP->_checkfd = fileno(ifp);
- typeahead(fileno(ifp));
+ /* this loads the capability entry, then sets LINES and COLS */
+ if (setupterm(name, fileno(ofp), &errret) == ERR) {
+ result = 0;
+ } else {
+ /*
+ * This actually allocates the screen structure, and saves the original
+ * terminal settings.
+ */
+ current = SP;
+ _nc_set_screen(0);
+ if (_nc_setupscreen(LINES, COLS, ofp, filter_mode, slk_format) == ERR) {
+ _nc_set_screen(current);
+ result = 0;
+ } else {
+ /* if the terminal type has real soft labels, set those up */
+ if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
+ _nc_slk_initialize(stdscr, COLS);
+
+ SP->_ifd = fileno(ifp);
+ typeahead(fileno(ifp));
#ifdef TERMIOS
- SP->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
- !(cur_term->Ottyb.c_iflag & ISTRIP));
+ SP->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
+ !(cur_term->Ottyb.c_iflag & ISTRIP));
#else
- SP->_use_meta = FALSE;
+ SP->_use_meta = FALSE;
#endif
- SP->_endwin = FALSE;
-
- /* Check whether we can optimize scrolling under dumb terminals in case
- * we do not have any of these capabilities, scrolling optimization
- * will be useless.
- */
- SP->_scrolling = ((scroll_forward && scroll_reverse) ||
- ((parm_rindex || parm_insert_line || insert_line) &&
- (parm_index || parm_delete_line || delete_line)));
-
- baudrate(); /* sets a field in the SP structure */
-
- SP->_keytry = 0;
-
- /*
- * Check for mismatched graphic-rendition capabilities. Most SVr4
- * terminfo trees contain entries that have rmul or rmso equated to
- * sgr0 (Solaris curses copes with those entries). We do this only for
- * curses, since many termcap applications assume that smso/rmso and
- * smul/rmul are paired, and will not function properly if we remove
- * rmso or rmul. Curses applications shouldn't be looking at this
- * detail.
- */
+ SP->_endwin = FALSE;
+
+ /*
+ * Check whether we can optimize scrolling under dumb terminals in
+ * case we do not have any of these capabilities, scrolling
+ * optimization will be useless.
+ */
+ SP->_scrolling = ((scroll_forward && scroll_reverse) ||
+ ((parm_rindex ||
+ parm_insert_line ||
+ insert_line) &&
+ (parm_index ||
+ parm_delete_line ||
+ delete_line)));
+
+ baudrate(); /* sets a field in the SP structure */
+
+ SP->_keytry = 0;
+
+ /*
+ * Check for mismatched graphic-rendition capabilities. Most SVr4
+ * terminfo trees contain entries that have rmul or rmso equated to
+ * sgr0 (Solaris curses copes with those entries). We do this only
+ * for curses, since many termcap applications assume that
+ * smso/rmso and smul/rmul are paired, and will not function
+ * properly if we remove rmso or rmul. Curses applications
+ * shouldn't be looking at this detail.
+ */
#define SGR0_TEST(mode) (mode != 0) && (exit_attribute_mode == 0 || strcmp(mode, exit_attribute_mode))
- SP->_use_rmso = SGR0_TEST(exit_standout_mode);
- SP->_use_rmul = SGR0_TEST(exit_underline_mode);
+ SP->_use_rmso = SGR0_TEST(exit_standout_mode);
+ SP->_use_rmul = SGR0_TEST(exit_underline_mode);
- /* compute movement costs so we can do better move optimization */
- _nc_mvcur_init();
+ /* compute movement costs so we can do better move optimization */
+ _nc_mvcur_init();
- /* initialize terminal to a sane state */
- _nc_screen_init();
+ /* initialize terminal to a sane state */
+ _nc_screen_init();
- /* Initialize the terminal line settings. */
- _nc_initscr();
+ /* Initialize the terminal line settings. */
+ _nc_initscr();
- _nc_signal_handler(TRUE);
+ _nc_signal_handler(TRUE);
- returnSP(SP);
+ result = SP;
+ }
+ }
+ _nc_handle_sigwinch(1);
+ returnSP(result);
}
diff --git a/contrib/ncurses/ncurses/base/lib_newwin.c b/contrib/ncurses/ncurses/base/lib_newwin.c
index 3cd8238b1e2e..ba516337b996 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -40,7 +41,36 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_newwin.c,v 1.33 2001/12/19 01:06:30 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.38 2006/10/14 20:31:19 tom Exp $")
+
+static WINDOW *
+remove_window_from_screen(WINDOW *win)
+{
+ SCREEN **scan = &_nc_screen_chain;
+
+ while (*scan) {
+ SCREEN *sp = *scan;
+ if (sp->_curscr == win) {
+ sp->_curscr = 0;
+ if (win == curscr)
+ curscr = 0;
+ } else if (sp->_stdscr == win) {
+ sp->_stdscr = 0;
+ if (win == stdscr)
+ stdscr = 0;
+ } else if (sp->_newscr == win) {
+ sp->_newscr = 0;
+ if (win == newscr)
+ newscr = 0;
+ } else {
+ scan = &(*scan)->_next_screen;
+ continue;
+ }
+ break;
+ }
+
+ return 0;
+}
NCURSES_EXPORT(int)
_nc_freewin(WINDOW *win)
@@ -52,6 +82,7 @@ _nc_freewin(WINDOW *win)
if (win != 0) {
for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) {
if (&(p->win) == win) {
+ remove_window_from_screen(win);
if (q == 0)
_nc_windows = p->next;
else
@@ -64,13 +95,6 @@ _nc_freewin(WINDOW *win)
free(win->_line);
free(p);
- if (win == curscr)
- curscr = 0;
- if (win == stdscr)
- stdscr = 0;
- if (win == newscr)
- newscr = 0;
-
result = OK;
T(("...deleted win=%p", win));
break;
@@ -97,9 +121,6 @@ newwin(int num_lines, int num_columns, int begy, int begx)
if (num_columns == 0)
num_columns = screen_columns - begx;
- if (num_columns + begx > SP->_columns || num_lines + begy > SP->_lines_avail)
- returnWin(0);
-
if ((win = _nc_makenew(num_lines, num_columns, begy, begx, 0)) == 0)
returnWin(0);
@@ -152,7 +173,7 @@ derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
win->_pary = begy;
win->_parx = begx;
- win->_attrs = orig->_attrs;
+ WINDOW_ATTRS(win) = WINDOW_ATTRS(orig);
win->_nc_bkgd = orig->_nc_bkgd;
for (i = 0; i < num_lines; i++)
@@ -167,7 +188,7 @@ NCURSES_EXPORT(WINDOW *)
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));
+ T(("parent has begy = %ld, begx = %ld", (long) w->_begy, (long) w->_begx));
returnWin(derwin(w, l, c, y - w->_begy, x - w->_begx));
}
@@ -189,6 +210,9 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
T(("_nc_makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx));
+ if (SP == 0)
+ return 0;
+
if (!dimension_limit(num_lines) || !dimension_limit(num_columns))
return 0;
@@ -211,7 +235,7 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
win->_yoffset = SP->_topstolen;
win->_flags = flags;
- win->_attrs = A_NORMAL;
+ WINDOW_ATTRS(win) = A_NORMAL;
SetChar(win->_nc_bkgd, BLANK_TEXT, BLANK_ATTR);
win->_clear = is_pad ? FALSE : (num_lines == screen_lines
diff --git a/contrib/ncurses/ncurses/base/lib_overlay.c b/contrib/ncurses/ncurses/base/lib_overlay.c
index 010e6d18c861..9ecc45821591 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2006 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,30 +40,60 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_overlay.c,v 1.20 2001/12/19 01:06:37 tom Exp $")
+MODULE_ID("$Id: lib_overlay.c,v 1.22 2006/10/14 20:43:31 tom Exp $")
static int
overlap(const WINDOW *const s, WINDOW *const d, int const flag)
{
- int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol;
+ int sx1, sy1, sx2, sy2;
+ int dx1, dy1, dx2, dy2;
+ int sminrow, smincol;
+ int dminrow, dmincol;
+ int dmaxrow, dmaxcol;
- T(("overlap : sby %d, sbx %d, smy %d, smx %d, dby %d, dbx %d, dmy %d, dmx %d",
- s->_begy, s->_begx, s->_maxy, s->_maxx,
- d->_begy, d->_begx, d->_maxy, d->_maxx));
+ T((T_CALLED("overlap(%p,%p,%d)"), s, d, flag));
- if (!s || !d)
+ if (s == 0 || d == 0) {
returnCode(ERR);
-
- sminrow = max(s->_begy, d->_begy) - s->_begy;
- smincol = max(s->_begx, d->_begx) - s->_begx;
- dminrow = max(s->_begy, d->_begy) - d->_begy;
- dmincol = max(s->_begx, d->_begx) - d->_begx;
- dmaxrow = min(s->_maxy + s->_begy, d->_maxy + d->_begy) - d->_begy;
- dmaxcol = min(s->_maxx + s->_begx, d->_maxx + d->_begx) - d->_begx;
-
- return (copywin(s, d,
- sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol,
- flag));
+ } else {
+ T(("src : begy %ld, begx %ld, maxy %ld, maxx %ld",
+ (long) s->_begy,
+ (long) s->_begx,
+ (long) s->_maxy,
+ (long) s->_maxx));
+ T(("dst : begy %ld, begx %ld, maxy %ld, maxx %ld",
+ (long) d->_begy,
+ (long) d->_begx,
+ (long) d->_maxy,
+ (long) d->_maxx));
+
+ sx1 = s->_begx;
+ sy1 = s->_begy;
+ sx2 = sx1 + s->_maxx;
+ sy2 = sy1 + s->_maxy;
+
+ dx1 = d->_begx;
+ dy1 = d->_begy;
+ dx2 = dx1 + d->_maxx;
+ dy2 = dy1 + d->_maxy;
+
+ if (dx2 < sx1 || dx1 > sx2 || dy2 < sy1 || dy1 > sy2) {
+ returnCode(ERR); /* No intersection */
+ } else {
+ sminrow = max(sy1, dy1) - sy1;
+ smincol = max(sx1, dx1) - sx1;
+ dminrow = max(sy1, dy1) - dy1;
+ dmincol = max(sx1, dx1) - dx1;
+ dmaxrow = min(sy2, dy2) - dy1;
+ dmaxcol = min(sx2, dx2) - dx1;
+
+ returnCode(copywin(s, d,
+ sminrow, smincol,
+ dminrow, dmincol,
+ dmaxrow, dmaxcol,
+ flag));
+ }
+ }
}
/*
@@ -101,11 +131,11 @@ overwrite(const WINDOW *win1, WINDOW *win2)
}
NCURSES_EXPORT(int)
-copywin
-(const WINDOW *src, WINDOW *dst,
- int sminrow, int smincol,
- int dminrow, int dmincol, int dmaxrow, int dmaxcol,
- int over)
+copywin(const WINDOW *src, WINDOW *dst,
+ int sminrow, int smincol,
+ int dminrow, int dmincol,
+ int dmaxrow, int dmaxcol,
+ int over)
{
int sx, sy, dx, dy;
bool touched;
@@ -152,7 +182,7 @@ copywin
}
}
if (touched) {
- touchline(dst, 0, getmaxy(dst));
+ touchline(dst, dminrow, (dmaxrow - dminrow + 1));
}
}
T(("finished copywin"));
diff --git a/contrib/ncurses/ncurses/base/lib_pad.c b/contrib/ncurses/ncurses/base/lib_pad.c
index 83983c3bbd1c..6cad9c54b064 100644
--- a/contrib/ncurses/ncurses/base/lib_pad.c
+++ b/contrib/ncurses/ncurses/base/lib_pad.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2006 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_pad.c,v 1.37 2002/05/23 23:39:26 tom Exp $")
+MODULE_ID("$Id: lib_pad.c,v 1.41 2006/10/14 20:47:13 tom Exp $")
NCURSES_EXPORT(WINDOW *)
newpad(int l, int c)
@@ -71,8 +71,7 @@ newpad(int l, int c)
}
NCURSES_EXPORT(WINDOW *)
-subpad
-(WINDOW *orig, int l, int c, int begy, int begx)
+subpad(WINDOW *orig, int l, int c, int begy, int begx)
{
WINDOW *win = (WINDOW *) 0;
@@ -87,9 +86,13 @@ subpad
}
NCURSES_EXPORT(int)
-prefresh
-(WINDOW *win, int pminrow, int pmincol,
- int sminrow, int smincol, int smaxrow, int smaxcol)
+prefresh(WINDOW *win,
+ int pminrow,
+ int pmincol,
+ int sminrow,
+ int smincol,
+ int smaxrow,
+ int smaxcol)
{
T((T_CALLED("prefresh()")));
if (pnoutrefresh(win, pminrow, pmincol, sminrow, smincol, smaxrow,
@@ -101,9 +104,13 @@ prefresh
}
NCURSES_EXPORT(int)
-pnoutrefresh
-(WINDOW *win, int pminrow, int pmincol,
- int sminrow, int smincol, int smaxrow, int smaxcol)
+pnoutrefresh(WINDOW *win,
+ int pminrow,
+ int pmincol,
+ int sminrow,
+ int smincol,
+ int smaxrow,
+ int smaxcol)
{
NCURSES_SIZE_T i, j;
NCURSES_SIZE_T m, n;
@@ -138,8 +145,10 @@ pnoutrefresh
pmaxrow = pminrow + smaxrow - sminrow;
pmaxcol = pmincol + smaxcol - smincol;
- T((" pminrow + smaxrow - sminrow %d, win->_maxy %d", pmaxrow, win->_maxy));
- T((" pmincol + smaxcol - smincol %d, win->_maxx %d", pmaxcol, win->_maxx));
+ T((" pminrow + smaxrow - sminrow %ld, win->_maxy %ld",
+ (long) pmaxrow, (long) win->_maxy));
+ T((" pmincol + smaxcol - smincol %ld, win->_maxx %ld",
+ (long) pmaxcol, (long) win->_maxx));
/*
* Trim the caller's screen size back to the actual limits.
@@ -153,8 +162,8 @@ pnoutrefresh
pmaxcol = pmincol + smaxcol - smincol;
}
- if (smaxrow > screen_lines
- || smaxcol > screen_columns
+ if (smaxrow >= screen_lines
+ || smaxcol >= screen_columns
|| sminrow > smaxrow
|| smincol > smaxcol)
returnCode(ERR);
@@ -202,7 +211,7 @@ pnoutrefresh
*/
if (j == pmincol
&& j > 0
- && isnac(ch)) {
+ && isWidecExt(ch)) {
SetChar(ch, L(' '), AttrOf(oline->text[j - 1]));
}
#endif
diff --git a/contrib/ncurses/ncurses/base/lib_printw.c b/contrib/ncurses/ncurses/base/lib_printw.c
index f821a96ba7f0..62ae921e650d 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2005 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,10 +39,10 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_printw.c,v 1.12 2001/10/20 20:33:46 tom Exp $")
+MODULE_ID("$Id: lib_printw.c,v 1.18 2006/12/17 19:21:39 tom Exp $")
NCURSES_EXPORT(int)
-printw(NCURSES_CONST char *fmt,...)
+printw(const char *fmt,...)
{
va_list argp;
int code;
@@ -62,7 +62,7 @@ printw(NCURSES_CONST char *fmt,...)
}
NCURSES_EXPORT(int)
-wprintw(WINDOW *win, NCURSES_CONST char *fmt,...)
+wprintw(WINDOW *win, const char *fmt,...)
{
va_list argp;
int code;
@@ -82,7 +82,7 @@ wprintw(WINDOW *win, NCURSES_CONST char *fmt,...)
}
NCURSES_EXPORT(int)
-mvprintw(int y, int x, NCURSES_CONST char *fmt,...)
+mvprintw(int y, int x, const char *fmt,...)
{
va_list argp;
int code;
@@ -103,7 +103,7 @@ mvprintw(int y, int x, NCURSES_CONST char *fmt,...)
}
NCURSES_EXPORT(int)
-mvwprintw(WINDOW *win, int y, int x, NCURSES_CONST char *fmt,...)
+mvwprintw(WINDOW *win, int y, int x, const char *fmt,...)
{
va_list argp;
int code;
@@ -124,19 +124,15 @@ mvwprintw(WINDOW *win, int y, int x, NCURSES_CONST char *fmt,...)
}
NCURSES_EXPORT(int)
-vwprintw(WINDOW *win, NCURSES_CONST char *fmt, va_list argp)
+vwprintw(WINDOW *win, const char *fmt, va_list argp)
{
char *buf;
int code = ERR;
- T((T_CALLED("wprintw(%p,%s,%p)"),
- win, _nc_visbuf(fmt), argp));
+ T((T_CALLED("vwprintw(%p,%s,va_list)"), win, _nc_visbuf(fmt)));
if ((buf = _nc_printf_string(fmt, argp)) != 0) {
code = waddstr(win, buf);
-#if USE_SAFE_SPRINTF
- free(buf);
-#endif
}
returnCode(code);
}
diff --git a/contrib/ncurses/ncurses/base/lib_redrawln.c b/contrib/ncurses/ncurses/base/lib_redrawln.c
index 91a03711de7c..548ca97e24c4 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2006 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_redrawln.c,v 1.10 2001/09/29 17:41:31 tom Exp $")
+MODULE_ID("$Id: lib_redrawln.c,v 1.11 2006/11/04 23:08:47 tom Exp $")
NCURSES_EXPORT(int)
wredrawln(WINDOW *win, int beg, int num)
@@ -56,6 +56,9 @@ wredrawln(WINDOW *win, int beg, int num)
if (touchline(win, beg, num) == ERR)
returnCode(ERR);
+ if (touchline(curscr, beg + win->_begy, num) == ERR)
+ returnCode(ERR);
+
end = beg + num;
if (end > curscr->_maxy + 1)
end = curscr->_maxy + 1;
@@ -67,8 +70,10 @@ wredrawln(WINDOW *win, int beg, int num)
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);
+ int crow = i + win->_begy;
+
+ memset(curscr->_line[crow].text + win->_begx, 0, len);
+ _nc_make_oldhash(crow);
}
returnCode(OK);
diff --git a/contrib/ncurses/ncurses/base/lib_refresh.c b/contrib/ncurses/ncurses/base/lib_refresh.c
index 42c1f496c10a..27649df0669a 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -40,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_refresh.c,v 1.31 2001/12/19 01:06:41 tom Exp $")
+MODULE_ID("$Id: lib_refresh.c,v 1.34 2006/05/27 19:21:19 tom Exp $")
NCURSES_EXPORT(int)
wrefresh(WINDOW *win)
@@ -49,7 +50,9 @@ wrefresh(WINDOW *win)
T((T_CALLED("wrefresh(%p)"), win));
- if (win == curscr) {
+ if (win == 0) {
+ code = ERR;
+ } else if (win == curscr) {
curscr->_clear = TRUE;
code = doupdate();
} else if ((code = wnoutrefresh(win)) == OK) {
@@ -97,7 +100,7 @@ wnoutrefresh(WINDOW *win)
begy = win->_begy;
newscr->_nc_bkgd = win->_nc_bkgd;
- newscr->_attrs = win->_attrs;
+ WINDOW_ATTRS(newscr) = WINDOW_ATTRS(win);
/* merge in change information from all subwindows of this window */
wsyncdown(win);
@@ -132,8 +135,8 @@ wnoutrefresh(WINDOW *win)
/* limit(n) */
limit_x = win->_maxx;
/* limit(j) */
- if (limit_x > win->_maxx)
- limit_x = win->_maxx;
+ if (limit_x > newscr->_maxx - begx)
+ limit_x = newscr->_maxx - begx;
for (i = 0, m = begy + win->_yoffset;
i <= win->_maxy && m <= newscr->_maxy;
diff --git a/contrib/ncurses/ncurses/base/lib_restart.c b/contrib/ncurses/ncurses/base/lib_restart.c
index 0068554cecb1..ca27a0fc4c60 100644
--- a/contrib/ncurses/ncurses/base/lib_restart.c
+++ b/contrib/ncurses/ncurses/base/lib_restart.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -47,46 +48,52 @@
#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$Id: lib_restart.c,v 1.4 2000/12/10 01:26:52 tom Exp $")
+MODULE_ID("$Id: lib_restart.c,v 1.6 2006/01/14 15:58:23 tom Exp $")
NCURSES_EXPORT(int)
-restartterm
-(NCURSES_CONST char *termp, int filenum, int *errret)
+restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
{
int saveecho = SP->_echo;
int savecbreak = SP->_cbreak;
int saveraw = SP->_raw;
int savenl = SP->_nl;
+ int result;
T((T_CALLED("restartterm(%s,%d,%p)"), termp, filenum, errret));
- setupterm(termp, filenum, errret);
+ _nc_handle_sigwinch(0);
+ if (setupterm(termp, filenum, errret) != OK) {
+ result = ERR;
+ } else {
- if (saveecho)
- echo();
- else
- noecho();
+ if (saveecho)
+ echo();
+ else
+ noecho();
- if (savecbreak) {
- cbreak();
- noraw();
- } else if (saveraw) {
- nocbreak();
- raw();
- } else {
- nocbreak();
- noraw();
- }
- if (savenl)
- nl();
- else
- nonl();
+ if (savecbreak) {
+ cbreak();
+ noraw();
+ } else if (saveraw) {
+ nocbreak();
+ raw();
+ } else {
+ nocbreak();
+ noraw();
+ }
+ if (savenl)
+ nl();
+ else
+ nonl();
- reset_prog_mode();
+ reset_prog_mode();
#if USE_SIZECHANGE
- _nc_update_screensize();
+ _nc_update_screensize();
#endif
- returnCode(OK);
+ result = OK;
+ }
+ _nc_handle_sigwinch(1);
+ returnCode(result);
}
diff --git a/contrib/ncurses/ncurses/base/lib_screen.c b/contrib/ncurses/ncurses/base/lib_screen.c
index 3b2d9296a59a..5d67e1993cd9 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,92 +29,105 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996 on *
****************************************************************************/
#include <curses.priv.h>
-#include <sys/stat.h>
-#include <time.h>
-#include <term.h> /* exit_ca_mode, non_rev_rmcup */
-
-MODULE_ID("$Id: lib_screen.c,v 1.19 2001/12/19 00:55:28 tom Exp $")
-
-static time_t dumptime;
+MODULE_ID("$Id: lib_screen.c,v 1.29 2006/05/27 19:21:38 tom Exp $")
NCURSES_EXPORT(WINDOW *)
-getwin(FILE * filep)
+getwin(FILE *filep)
{
WINDOW tmp, *nwin;
int n;
T((T_CALLED("getwin(%p)"), filep));
+ clearerr(filep);
(void) fread(&tmp, sizeof(WINDOW), 1, filep);
if (ferror(filep))
returnWin(0);
- if ((nwin = newwin(tmp._maxy + 1, tmp._maxx + 1, 0, 0)) == 0)
- returnWin(0);
+ if (tmp._flags & _ISPAD) {
+ nwin = newpad(tmp._maxy + 1, tmp._maxx + 1);
+ } else {
+ nwin = newwin(tmp._maxy + 1, tmp._maxx + 1, 0, 0);
+ }
/*
* We deliberately do not restore the _parx, _pary, or _parent
* fields, because the window hierarchy within which they
* made sense is probably gone.
*/
- nwin->_curx = tmp._curx;
- nwin->_cury = tmp._cury;
- nwin->_maxy = tmp._maxy;
- nwin->_maxx = tmp._maxx;
- nwin->_begy = tmp._begy;
- nwin->_begx = tmp._begx;
- nwin->_yoffset = tmp._yoffset;
- nwin->_flags = tmp._flags & ~(_SUBWIN | _ISPAD);
-
- nwin->_attrs = tmp._attrs;
- nwin->_nc_bkgd = tmp._nc_bkgd;
-
- nwin->_clear = tmp._clear;
- nwin->_scroll = tmp._scroll;
- nwin->_leaveok = tmp._leaveok;
- nwin->_use_keypad = tmp._use_keypad;
- nwin->_delay = tmp._delay;
- nwin->_immed = tmp._immed;
- nwin->_sync = tmp._sync;
-
- nwin->_regtop = tmp._regtop;
- nwin->_regbottom = tmp._regbottom;
-
- for (n = 0; n < nwin->_maxy + 1; n++) {
- (void) fread(nwin->_line[n].text,
- sizeof(chtype), (size_t) (nwin->_maxx + 1), filep);
- if (ferror(filep)) {
- delwin(nwin);
- returnWin(0);
+ if (nwin != 0) {
+ nwin->_curx = tmp._curx;
+ nwin->_cury = tmp._cury;
+ nwin->_maxy = tmp._maxy;
+ nwin->_maxx = tmp._maxx;
+ nwin->_begy = tmp._begy;
+ nwin->_begx = tmp._begx;
+ nwin->_yoffset = tmp._yoffset;
+ nwin->_flags = tmp._flags & ~(_SUBWIN);
+
+ WINDOW_ATTRS(nwin) = WINDOW_ATTRS(&tmp);
+ nwin->_nc_bkgd = tmp._nc_bkgd;
+
+ nwin->_notimeout = tmp._notimeout;
+ nwin->_clear = tmp._clear;
+ nwin->_leaveok = tmp._leaveok;
+ nwin->_idlok = tmp._idlok;
+ nwin->_idcok = tmp._idcok;
+ nwin->_immed = tmp._immed;
+ nwin->_scroll = tmp._scroll;
+ nwin->_sync = tmp._sync;
+ nwin->_use_keypad = tmp._use_keypad;
+ nwin->_delay = tmp._delay;
+
+ nwin->_regtop = tmp._regtop;
+ nwin->_regbottom = tmp._regbottom;
+
+ if (tmp._flags & _ISPAD)
+ nwin->_pad = tmp._pad;
+
+ for (n = 0; n <= nwin->_maxy; n++) {
+ clearerr(filep);
+ (void) fread(nwin->_line[n].text,
+ sizeof(NCURSES_CH_T),
+ (size_t) (nwin->_maxx + 1),
+ filep);
+ if (ferror(filep)) {
+ delwin(nwin);
+ returnWin(0);
+ }
}
+ touchwin(nwin);
}
- touchwin(nwin);
-
returnWin(nwin);
}
NCURSES_EXPORT(int)
-putwin(WINDOW *win, FILE * filep)
+putwin(WINDOW *win, FILE *filep)
{
int code = ERR;
int n;
T((T_CALLED("putwin(%p,%p)"), win, filep));
- if (win) {
- (void) fwrite(win, sizeof(WINDOW), 1, filep);
- if (ferror(filep))
- returnCode(code);
+ if (win != 0) {
+ size_t len = (win->_maxx + 1);
+
+ clearerr(filep);
+ if (fwrite(win, sizeof(WINDOW), 1, filep) != 1
+ || ferror(filep))
+ returnCode(code);
- for (n = 0; n < win->_maxy + 1; n++) {
- (void) fwrite(win->_line[n].text,
- sizeof(chtype), (size_t) (win->_maxx + 1), filep);
- if (ferror(filep))
+ for (n = 0; n <= win->_maxy; n++) {
+ if (fwrite(win->_line[n].text,
+ sizeof(NCURSES_CH_T), len, filep) != len
+ || ferror(filep)) {
returnCode(code);
+ }
}
code = OK;
}
@@ -129,11 +142,11 @@ scr_restore(const char *file)
T((T_CALLED("scr_restore(%s)"), _nc_visbuf(file)));
if (_nc_access(file, R_OK) < 0
- || (fp = fopen(file, "rb")) == 0)
+ || (fp = fopen(file, "rb")) == 0) {
returnCode(ERR);
- else {
+ } else {
delwin(newscr);
- newscr = getwin(fp);
+ SP->_newscr = newscr = getwin(fp);
(void) fclose(fp);
returnCode(OK);
}
@@ -147,12 +160,11 @@ scr_dump(const char *file)
T((T_CALLED("scr_dump(%s)"), _nc_visbuf(file)));
if (_nc_access(file, W_OK) < 0
- || (fp = fopen(file, "wb")) == 0)
+ || (fp = fopen(file, "wb")) == 0) {
returnCode(ERR);
- else {
+ } else {
(void) putwin(newscr, fp);
(void) fclose(fp);
- dumptime = time((time_t *) 0);
returnCode(OK);
}
}
@@ -161,7 +173,6 @@ NCURSES_EXPORT(int)
scr_init(const char *file)
{
FILE *fp = 0;
- struct stat stb;
T((T_CALLED("scr_init(%s)"), _nc_visbuf(file)));
@@ -169,13 +180,11 @@ scr_init(const char *file)
returnCode(ERR);
if (_nc_access(file, R_OK) < 0
- || (fp = fopen(file, "rb")) == 0)
- returnCode(ERR);
- else if (fstat(STDOUT_FILENO, &stb) || stb.st_mtime > dumptime)
+ || (fp = fopen(file, "rb")) == 0) {
returnCode(ERR);
- else {
+ } else {
delwin(curscr);
- curscr = getwin(fp);
+ SP->_curscr = curscr = getwin(fp);
(void) fclose(fp);
returnCode(OK);
}
@@ -186,11 +195,11 @@ scr_set(const char *file)
{
T((T_CALLED("scr_set(%s)"), _nc_visbuf(file)));
- if (scr_init(file) == ERR)
+ if (scr_init(file) == ERR) {
returnCode(ERR);
- else {
+ } else {
delwin(newscr);
- newscr = dupwin(curscr);
+ SP->_newscr = newscr = dupwin(curscr);
returnCode(OK);
}
}
diff --git a/contrib/ncurses/ncurses/base/lib_scroll.c b/contrib/ncurses/ncurses/base/lib_scroll.c
index 39c62d0850e5..ac85bd55ea1d 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2006 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,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey 1996-2001 *
+ * Author: Thomas E. Dickey 1996-2003 *
* and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
@@ -43,18 +43,22 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_scroll.c,v 1.23 2001/12/19 01:06:55 tom Exp $")
+MODULE_ID("$Id: lib_scroll.c,v 1.26 2006/10/14 20:46:08 tom Exp $")
NCURSES_EXPORT(void)
-_nc_scroll_window(WINDOW *win, int const n, NCURSES_SIZE_T const top,
- NCURSES_SIZE_T const bottom, NCURSES_CH_T blank)
+_nc_scroll_window(WINDOW *win,
+ int const n,
+ NCURSES_SIZE_T const top,
+ NCURSES_SIZE_T const bottom,
+ NCURSES_CH_T blank)
{
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));
+ TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %ld, %ld)",
+ win, n, (long) top, (long) bottom));
if (top < 0
|| bottom < top
@@ -77,24 +81,15 @@ _nc_scroll_window(WINDOW *win, int const n, NCURSES_SIZE_T const top,
/* shift n lines downwards */
if (n < 0) {
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 = bottom; line >= limit && line >= 0; line--) {
+ 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);
}
- for (line = top; line < limit; line++) {
+ for (line = top; line < limit && line <= win->_maxy; line++) {
TR(TRACE_MOVE, ("...filling %d", line));
for (j = 0; j <= win->_maxx; j++)
win->_line[line].text[j] = blank;
@@ -105,31 +100,36 @@ _nc_scroll_window(WINDOW *win, int const n, NCURSES_SIZE_T const top,
/* shift n lines upwards */
if (n > 0) {
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 = top; line <= limit && line <= win->_maxy; 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);
}
- for (line = bottom; line > limit; line--) {
- TR(TRACE_MOVE, ("...filling %d", line));
+ for (line = bottom; line > limit && line >= 0; line--) {
for (j = 0; j <= win->_maxx; j++)
win->_line[line].text[j] = blank;
if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
}
}
touchline(win, top, bottom - top + 1);
+
+ if_WIDEC({
+ if (WINDOW_EXT(win, addch_used) != 0) {
+ int next = WINDOW_EXT(win, addch_y) + n;
+ if (next < 0 || next > win->_maxy) {
+ TR(TRACE_VIRTPUT,
+ ("Alert discarded multibyte on scroll"));
+ WINDOW_EXT(win, addch_y) = 0;
+ } else {
+ TR(TRACE_VIRTPUT, ("scrolled working position to %d,%d",
+ WINDOW_EXT(win, addch_y),
+ WINDOW_EXT(win, addch_x)));
+ WINDOW_EXT(win, addch_y) = next;
+ }
+ }
+ })
}
NCURSES_EXPORT(int)
@@ -142,11 +142,9 @@ wscrl(WINDOW *win, int n)
returnCode(ERR);
}
- if (n == 0)
- returnCode(OK);
-
- _nc_scroll_window(win, n, win->_regtop, win->_regbottom, win->_nc_bkgd);
-
- _nc_synchook(win);
+ if (n != 0) {
+ _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 f3940fa03c1c..bcc42d12298c 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-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -43,10 +44,10 @@
#include <term.h> /* cur_term */
#include <tic.h>
-MODULE_ID("$Id: lib_set_term.c,v 1.65 2002/06/15 18:40:20 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.91 2006/05/20 14:58:02 tom Exp $")
NCURSES_EXPORT(SCREEN *)
-set_term(SCREEN * screenp)
+set_term(SCREEN *screenp)
{
SCREEN *oldSP;
@@ -61,7 +62,6 @@ set_term(SCREEN * screenp)
stdscr = SP->_stdscr;
COLORS = SP->_color_count;
COLOR_PAIRS = SP->_pair_count;
- memcpy(acs_map, SP->_acs_map, sizeof(chtype) * ACS_LEN);
T((T_RETURN("%p"), oldSP));
return (oldSP);
@@ -81,9 +81,10 @@ _nc_free_keytry(struct tries *kt)
* Free the storage associated with the given SCREEN sp.
*/
NCURSES_EXPORT(void)
-delscreen(SCREEN * sp)
+delscreen(SCREEN *sp)
{
SCREEN **scan = &_nc_screen_chain;
+ int i;
T((T_CALLED("delscreen(%p)"), sp));
@@ -98,14 +99,36 @@ delscreen(SCREEN * sp)
(void) _nc_freewin(sp->_curscr);
(void) _nc_freewin(sp->_newscr);
(void) _nc_freewin(sp->_stdscr);
+
+ if (sp->_slk != 0) {
+ if (sp->_slk->ent != 0) {
+ for (i = 0; i < sp->_slk->labcnt; ++i) {
+ FreeIfNeeded(sp->_slk->ent[i].ent_text);
+ FreeIfNeeded(sp->_slk->ent[i].form_text);
+ }
+ free(sp->_slk->ent);
+ }
+ free(sp->_slk);
+ sp->_slk = 0;
+ }
+
_nc_free_keytry(sp->_keytry);
+ sp->_keytry = 0;
+
_nc_free_keytry(sp->_key_ok);
+ sp->_key_ok = 0;
+
+ FreeIfNeeded(sp->_current_attr);
FreeIfNeeded(sp->_color_table);
FreeIfNeeded(sp->_color_pairs);
FreeIfNeeded(sp->oldhash);
FreeIfNeeded(sp->newhash);
+ FreeIfNeeded(sp->hashtab);
+
+ FreeIfNeeded(sp->_acs_map);
+ FreeIfNeeded(sp->_screen_acs_map);
del_curterm(sp->_term);
@@ -141,16 +164,16 @@ delscreen(SCREEN * sp)
static ripoff_t rippedoff[5];
static ripoff_t *rsp = rippedoff;
-#define N_RIPS SIZEOF(rippedoff)
+#define N_RIPS SIZEOF(SP->_rippedoff)
static bool
-no_mouse_event(SCREEN * sp GCC_UNUSED)
+no_mouse_event(SCREEN *sp GCC_UNUSED)
{
return FALSE;
}
static bool
-no_mouse_inline(SCREEN * sp GCC_UNUSED)
+no_mouse_inline(SCREEN *sp GCC_UNUSED)
{
return FALSE;
}
@@ -162,12 +185,12 @@ no_mouse_parse(int code GCC_UNUSED)
}
static void
-no_mouse_resume(SCREEN * sp GCC_UNUSED)
+no_mouse_resume(SCREEN *sp GCC_UNUSED)
{
}
static void
-no_mouse_wrap(SCREEN * sp GCC_UNUSED)
+no_mouse_wrap(SCREEN *sp GCC_UNUSED)
{
}
@@ -191,21 +214,67 @@ extract_fgbg(char *src, int *result)
}
#endif
-NCURSES_EXPORT(int)
-_nc_setupscreen
-(short slines, short const scolumns, FILE * output)
/* OS-independent screen initializations */
+NCURSES_EXPORT(int)
+_nc_setupscreen(int slines,
+ int scolumns,
+ FILE *output,
+ bool filtered,
+ int slk_format)
{
int bottom_stolen = 0;
- size_t i;
+ int i;
+ bool support_cookies = USE_XMC_SUPPORT;
+
+ T((T_CALLED("_nc_setupscreen(%d, %d, %p, %d, %d)"),
+ slines, scolumns, output, filtered, slk_format));
assert(SP == 0); /* has been reset in newterm() ! */
- if (!_nc_alloc_screen())
- return ERR;
+ if (!_nc_alloc_screen()
+ || ((SP->_acs_map = typeCalloc(chtype, ACS_LEN)) == 0)
+ || ((SP->_screen_acs_map = typeCalloc(bool, ACS_LEN)) == 0)) {
+ returnCode(ERR);
+ }
+ T(("created SP %p", SP));
SP->_next_screen = _nc_screen_chain;
_nc_screen_chain = SP;
+ if ((SP->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == 0)
+ returnCode(ERR);
+
+ SP->_filtered = filtered;
+
+ /* implement filter mode */
+ if (filtered) {
+ slines = LINES = 1;
+
+ clear_screen = 0;
+ cursor_down = parm_down_cursor = 0;
+ cursor_address = 0;
+ cursor_up = parm_up_cursor = 0;
+ row_address = 0;
+
+ cursor_home = carriage_return;
+ T(("filter screensize %dx%d", LINES, COLS));
+ }
+
+ /* If we must simulate soft labels, grab off the line to be used.
+ We assume that we must simulate, if it is none of the standard
+ formats (4-4 or 3-2-3) for which there may be some hardware
+ support. */
+ if (num_labels <= 0 || !SLK_STDFMT(slk_format)) {
+ if (slk_format) {
+ if (ERR == _nc_ripoffline(-SLK_LINES(slk_format),
+ _nc_slk_initialize))
+ returnCode(ERR);
+ }
+ }
+#ifdef __DJGPP__
+ T(("setting output mode to binary"));
+ fflush(output);
+ setmode(output, O_BINARY);
+#endif
_nc_set_buffer(output, TRUE);
SP->_term = cur_term;
SP->_lines = slines;
@@ -259,6 +328,26 @@ _nc_setupscreen
SP->_default_bg = C_MASK;
#endif
+ /*
+ * Allow those assumed/default color assumptions to be overridden at
+ * runtime:
+ */
+ if (getenv("NCURSES_ASSUMED_COLORS") != 0) {
+ char *p = getenv("NCURSES_ASSUMED_COLORS");
+ int fg, bg;
+ char sep1, sep2;
+ int count = sscanf(p, "%d%c%d%c", &fg, &sep1, &bg, &sep2);
+ if (count >= 1) {
+ SP->_default_fg = (fg >= 0 && fg < max_colors) ? fg : C_MASK;
+ if (count >= 3) {
+ SP->_default_bg = (bg >= 0 && bg < max_colors) ? bg : C_MASK;
+ }
+ TR(TRACE_CHARPUT | TRACE_MOVE,
+ ("from environment assumed fg=%d, bg=%d",
+ SP->_default_fg,
+ SP->_default_bg));
+ }
+ }
#if USE_COLORFGBG
/*
* If rxvt's $COLORFGBG variable is set, use it to specify the assumed
@@ -275,7 +364,7 @@ _nc_setupscreen
p = extract_fgbg(p, &(SP->_default_bg));
TR(TRACE_CHARPUT | TRACE_MOVE, ("decoded fg=%d, bg=%d",
SP->_default_fg, SP->_default_bg));
- if (SP->_default_fg > max_colors) {
+ if (SP->_default_fg >= max_colors) {
if (set_a_foreground != ABSENT_STRING
&& !strcmp(set_a_foreground, "\033[3%p1%dm")) {
set_a_foreground = "\033[3%?%p1%{8}%>%t9%e%p1%d%;m";
@@ -283,7 +372,7 @@ _nc_setupscreen
SP->_default_fg %= max_colors;
}
}
- if (SP->_default_bg > max_colors) {
+ if (SP->_default_bg >= max_colors) {
if (set_a_background != ABSENT_STRING
&& !strcmp(set_a_background, "\033[4%p1%dm")) {
set_a_background = "\033[4%?%p1%{8}%>%t9%e%p1%d%;m";
@@ -309,42 +398,104 @@ _nc_setupscreen
SP->_panelHook.stdscr_pseudo_panel = (struct panel *) 0;
/*
- * If we've no magic cookie support, we suppress attributes that xmc
- * would affect, i.e., the attributes that affect the rendition of a
- * space. Note that this impacts the alternate character set mapping
- * as well.
+ * If we've no magic cookie support, we suppress attributes that xmc would
+ * affect, i.e., the attributes that affect the rendition of a space.
+ */
+ SP->_ok_attributes = termattrs();
+ if (has_colors()) {
+ SP->_ok_attributes |= A_COLOR;
+ }
+#if USE_XMC_SUPPORT
+ /*
+ * If we have no magic-cookie support compiled-in, or if it is suppressed
+ * in the environment, reset the support-flag.
*/
- if (magic_cookie_glitch > 0) {
-
- SP->_xmc_triggers = termattrs() & (
- A_ALTCHARSET |
- A_BLINK |
- A_BOLD |
- A_REVERSE |
- A_STANDOUT |
- A_UNDERLINE
+ if (magic_cookie_glitch >= 0) {
+ if (getenv("NCURSES_NO_MAGIC_COOKIE") != 0) {
+ support_cookies = FALSE;
+ }
+ }
+#endif
+
+ if (!support_cookies && magic_cookie_glitch >= 0) {
+ T(("will disable attributes to work w/o magic cookies"));
+ }
+
+ if (magic_cookie_glitch > 0) { /* tvi, wyse */
+
+ SP->_xmc_triggers = SP->_ok_attributes & (
+ A_STANDOUT |
+ A_UNDERLINE |
+ A_REVERSE |
+ A_BLINK |
+ A_DIM |
+ A_BOLD |
+ A_INVIS |
+ A_PROTECT
);
- SP->_xmc_suppress = SP->_xmc_triggers & (chtype) ~ (A_BOLD);
+#if 0
+ /*
+ * We "should" treat colors as an attribute. The wyse350 (and its
+ * clones) appear to be the only ones that have both colors and magic
+ * cookies.
+ */
+ if (has_colors()) {
+ SP->_xmc_triggers |= A_COLOR;
+ }
+#endif
+ SP->_xmc_suppress = SP->_xmc_triggers & (chtype) ~(A_BOLD);
T(("magic cookie attributes %s", _traceattr(SP->_xmc_suppress)));
+ /*
+ * Supporting line-drawing may be possible. But make the regular
+ * video attributes work first.
+ */
+ acs_chars = ABSENT_STRING;
+ ena_acs = ABSENT_STRING;
+ enter_alt_charset_mode = ABSENT_STRING;
+ exit_alt_charset_mode = ABSENT_STRING;
#if USE_XMC_SUPPORT
/*
- * To keep this simple, suppress all of the optimization hooks
- * except for clear_screen and the cursor addressing.
+ * To keep the cookie support simple, suppress all of the optimization
+ * hooks except for clear_screen and the cursor addressing.
*/
- clr_eol = 0;
- clr_eos = 0;
- set_attributes = 0;
-#else
- magic_cookie_glitch = ABSENT_NUMERIC;
- acs_chars = 0;
+ if (support_cookies) {
+ clr_eol = ABSENT_STRING;
+ clr_eos = ABSENT_STRING;
+ set_attributes = ABSENT_STRING;
+ }
#endif
+ } else if (magic_cookie_glitch == 0) { /* hpterm */
}
+
+ /*
+ * If magic cookies are not supported, cancel the strings that set
+ * video attributes.
+ */
+ if (!support_cookies && magic_cookie_glitch >= 0) {
+ magic_cookie_glitch = ABSENT_NUMERIC;
+ set_attributes = ABSENT_STRING;
+ enter_blink_mode = ABSENT_STRING;
+ enter_bold_mode = ABSENT_STRING;
+ enter_dim_mode = ABSENT_STRING;
+ enter_reverse_mode = ABSENT_STRING;
+ enter_standout_mode = ABSENT_STRING;
+ enter_underline_mode = ABSENT_STRING;
+ }
+
+ /* initialize normal acs before wide, since we use mapping in the latter */
+ _nc_init_acs();
#if USE_WIDEC_SUPPORT
_nc_init_wacs();
+
+ SP->_screen_acs_fix = (_nc_unicode_locale() && _nc_locale_breaks_acs());
+ {
+ char *env = _nc_get_locale();
+ SP->_legacy_coding = ((env == 0)
+ || !strcmp(env, "C")
+ || !strcmp(env, "POSIX"));
+ }
#endif
- _nc_init_acs();
- memcpy(SP->_acs_map, acs_map, sizeof(chtype) * ACS_LEN);
_nc_idcok = TRUE;
_nc_idlok = FALSE;
@@ -356,11 +507,11 @@ _nc_setupscreen
T(("creating newscr"));
if ((newscr = newwin(slines, scolumns, 0, 0)) == 0)
- return ERR;
+ returnCode(ERR);
T(("creating curscr"));
if ((curscr = newwin(slines, scolumns, 0, 0)) == 0)
- return ERR;
+ returnCode(ERR);
SP->_newscr = newscr;
SP->_curscr = curscr;
@@ -374,42 +525,41 @@ _nc_setupscreen
def_shell_mode();
def_prog_mode();
- for (i = 0, rsp = rippedoff; rsp->line && (i < N_RIPS); rsp++, i++) {
+ for (i = 0, rsp = rippedoff; rsp->line && (i < (int) N_RIPS); rsp++, i++) {
+ T(("ripping off line %d at %s", i, rsp->line < 0 ? "bottom" : "top"));
+ SP->_rippedoff[i] = rippedoff[i];
if (rsp->hook) {
- WINDOW *w;
int count = (rsp->line < 0) ? -rsp->line : rsp->line;
- if (rsp->line < 0) {
- w = newwin(count, scolumns, SP->_lines_avail - count, 0);
- if (w) {
- rsp->w = w;
- rsp->hook(w, scolumns);
- bottom_stolen += count;
- } else
- return ERR;
- } else {
- w = newwin(count, scolumns, 0, 0);
- if (w) {
- rsp->w = w;
- rsp->hook(w, scolumns);
- SP->_topstolen += count;
- } else
- return ERR;
- }
+ SP->_rippedoff[i].w = newwin(count,
+ scolumns,
+ ((rsp->line < 0)
+ ? SP->_lines_avail - count
+ : 0),
+ 0);
+ if (SP->_rippedoff[i].w != 0)
+ SP->_rippedoff[i].hook(SP->_rippedoff[i].w, scolumns);
+ else
+ returnCode(ERR);
+ if (rsp->line < 0)
+ bottom_stolen += count;
+ else
+ SP->_topstolen += count;
SP->_lines_avail -= count;
}
rsp->line = 0;
}
+ SP->_rip_count = i;
/* reset the stack */
rsp = rippedoff;
T(("creating stdscr"));
assert((SP->_lines_avail + SP->_topstolen + bottom_stolen) == slines);
if ((stdscr = newwin(LINES = SP->_lines_avail, scolumns, 0, 0)) == 0)
- return ERR;
+ returnCode(ERR);
SP->_stdscr = stdscr;
- return OK;
+ returnCode(OK);
}
/* The internal implementation interprets line as the number of
@@ -418,18 +568,20 @@ _nc_setupscreen
NCURSES_EXPORT(int)
_nc_ripoffline(int line, int (*init) (WINDOW *, int))
{
- if (line == 0)
- return (OK);
+ T((T_CALLED("_nc_ripoffline(%d, %p)"), line, init));
+
+ if (line != 0) {
- if (rsp >= rippedoff + N_RIPS)
- return (ERR);
+ if (rsp >= rippedoff + N_RIPS)
+ returnCode(ERR);
- rsp->line = line;
- rsp->hook = init;
- rsp->w = 0;
- rsp++;
+ rsp->line = line;
+ rsp->hook = init;
+ rsp->w = 0;
+ rsp++;
+ }
- return (OK);
+ returnCode(OK);
}
NCURSES_EXPORT(int)
diff --git a/contrib/ncurses/ncurses/base/lib_slk.c b/contrib/ncurses/ncurses/base/lib_slk.c
index 020449383e6c..5609e3b59024 100644
--- a/contrib/ncurses/ncurses/base/lib_slk.c
+++ b/contrib/ncurses/ncurses/base/lib_slk.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 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,8 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Authors: *
+ * Gerhard Fuernkranz 1993 (original) *
+ * Zeyd M. Ben-Halim 1992,1995 (sic) *
+ * Eric S. Raymond *
+ * Juergen Pfeifer 1996-on *
+ * Thomas E. Dickey *
****************************************************************************/
/*
@@ -41,7 +45,7 @@
#include <ctype.h>
#include <term.h> /* num_labels, label_*, plab_norm */
-MODULE_ID("$Id: lib_slk.c,v 1.20 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slk.c,v 1.30 2005/01/08 21:56:36 tom Exp $")
/*
* We'd like to move these into the screen context structure, but cannot,
@@ -54,8 +58,8 @@ _nc_slk_format = 0; /* one more than format specified in slk_init() */
* Paint the info line for the PC style SLK emulation.
*
*/
- static void
- slk_paint_info(WINDOW *win)
+static void
+slk_paint_info(WINDOW *win)
{
if (win && SP->slk_format == 4) {
int i;
@@ -64,20 +68,26 @@ _nc_slk_format = 0; /* one more than format specified in slk_init() */
wmove(win, 0, 0);
for (i = 0; i < SP->_slk->maxlab; i++) {
- if (win && SP->slk_format == 4) {
- mvwaddch(win, 0, SP->_slk->ent[i].x, (chtype) 'F');
- if (i < 9)
- waddch(win, (chtype) '1' + i);
- else {
- waddch(win, (chtype) '1');
- waddch(win, (chtype) '0' + (i - 9));
- }
- }
+ mvwprintw(win, 0, SP->_slk->ent[i].ent_x, "F%d", i + 1);
}
}
}
/*
+ * Free any memory related to soft labels, return an error.
+ */
+static int
+slk_failed(void)
+{
+ if (SP->_slk) {
+ FreeIfNeeded(SP->_slk->ent);
+ free(SP->_slk);
+ SP->_slk = (SLK *) 0;
+ }
+ return ERR;
+}
+
+/*
* Initialize soft labels.
* Called from newterm()
*/
@@ -86,92 +96,100 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
{
int i, x;
int res = OK;
- char *p;
+ unsigned max_length;
- T(("slk_initialize()"));
+ T((T_CALLED("_nc_slk_initialize()")));
if (SP->_slk) { /* we did this already, so simply return */
- return (OK);
+ returnCode(OK);
} else if ((SP->_slk = typeCalloc(SLK, 1)) == 0)
- return (ERR);
+ returnCode(ERR);
SP->_slk->ent = NULL;
- SP->_slk->buffer = NULL;
- SP->_slk->attr = A_STANDOUT;
- SP->_slk->maxlab = (num_labels > 0) ?
- num_labels : MAX_SKEY(_nc_slk_format);
- SP->_slk->maxlen = (num_labels > 0) ?
- label_width * label_height : MAX_SKEY_LEN(_nc_slk_format);
- SP->_slk->labcnt = (SP->_slk->maxlab < MAX_SKEY(_nc_slk_format)) ?
- MAX_SKEY(_nc_slk_format) : SP->_slk->maxlab;
+ /*
+ * If we use colors, vidputs() will suppress video attributes that conflict
+ * with colors. In that case, we're still guaranteed that "reverse" would
+ * work.
+ */
+ if ((no_color_video & 1) == 0)
+ SetAttr(SP->_slk->attr, A_STANDOUT);
+ else
+ SetAttr(SP->_slk->attr, A_REVERSE);
+
+ SP->_slk->maxlab = ((num_labels > 0)
+ ? num_labels
+ : MAX_SKEY(_nc_slk_format));
+ SP->_slk->maxlen = ((num_labels > 0)
+ ? label_width * label_height
+ : MAX_SKEY_LEN(_nc_slk_format));
+ SP->_slk->labcnt = ((SP->_slk->maxlab < MAX_SKEY(_nc_slk_format))
+ ? MAX_SKEY(_nc_slk_format)
+ : SP->_slk->maxlab);
+
+ if (SP->_slk->maxlen <= 0
+ || SP->_slk->labcnt <= 0
+ || (SP->_slk->ent = typeCalloc(slk_ent,
+ (unsigned) SP->_slk->labcnt)) == NULL)
+ returnCode(slk_failed());
+
+ max_length = SP->_slk->maxlen;
+ for (i = 0; i < SP->_slk->labcnt; i++) {
+ size_t used = max_length + 1;
- SP->_slk->ent = typeCalloc(slk_ent, SP->_slk->labcnt);
- if (SP->_slk->ent == NULL)
- goto exception;
+ if ((SP->_slk->ent[i].ent_text = (char *) _nc_doalloc(0, used)) == 0)
+ returnCode(slk_failed());
+ memset(SP->_slk->ent[i].ent_text, 0, used);
- p = SP->_slk->buffer = (char *) calloc(2 * SP->_slk->labcnt, (1 + SP->_slk->maxlen));
- if (SP->_slk->buffer == NULL)
- goto exception;
+ if ((SP->_slk->ent[i].form_text = (char *) _nc_doalloc(0, used)) == 0)
+ returnCode(slk_failed());
+ memset(SP->_slk->ent[i].form_text, 0, used);
- for (i = 0; i < SP->_slk->labcnt; i++) {
- SP->_slk->ent[i].text = p;
- p += (1 + SP->_slk->maxlen);
- SP->_slk->ent[i].form_text = p;
- p += (1 + SP->_slk->maxlen);
- memset(SP->_slk->ent[i].form_text, ' ', (unsigned) (SP->_slk->maxlen));
+ memset(SP->_slk->ent[i].form_text, ' ', max_length);
SP->_slk->ent[i].visible = (i < SP->_slk->maxlab);
}
if (_nc_slk_format >= 3) { /* PC style */
- int gap = (cols - 3 * (3 + 4 * SP->_slk->maxlen)) / 2;
+ int gap = (cols - 3 * (3 + 4 * max_length)) / 2;
if (gap < 1)
gap = 1;
for (i = x = 0; i < SP->_slk->maxlab; i++) {
- SP->_slk->ent[i].x = x;
- x += SP->_slk->maxlen;
+ SP->_slk->ent[i].ent_x = x;
+ x += max_length;
x += (i == 3 || i == 7) ? gap : 1;
}
- if (_nc_slk_format == 4)
- slk_paint_info(stwin);
+ slk_paint_info(stwin);
} else {
if (_nc_slk_format == 2) { /* 4-4 */
- int gap = cols - (SP->_slk->maxlab * SP->_slk->maxlen) - 6;
+ int gap = cols - (SP->_slk->maxlab * max_length) - 6;
if (gap < 1)
gap = 1;
for (i = x = 0; i < SP->_slk->maxlab; i++) {
- SP->_slk->ent[i].x = x;
- x += SP->_slk->maxlen;
+ SP->_slk->ent[i].ent_x = x;
+ x += max_length;
x += (i == 3) ? gap : 1;
}
} else {
if (_nc_slk_format == 1) { /* 1 -> 3-2-3 */
- int gap = (cols - (SP->_slk->maxlab * SP->_slk->maxlen) - 5)
+ int gap = (cols - (SP->_slk->maxlab * max_length) - 5)
/ 2;
if (gap < 1)
gap = 1;
for (i = x = 0; i < SP->_slk->maxlab; i++) {
- SP->_slk->ent[i].x = x;
- x += SP->_slk->maxlen;
+ SP->_slk->ent[i].ent_x = x;
+ x += max_length;
x += (i == 2 || i == 4) ? gap : 1;
}
} else
- goto exception;
+ returnCode(slk_failed());
}
}
SP->_slk->dirty = TRUE;
if ((SP->_slk->win = stwin) == NULL) {
- exception:
- if (SP->_slk) {
- FreeIfNeeded(SP->_slk->buffer);
- FreeIfNeeded(SP->_slk->ent);
- free(SP->_slk);
- SP->_slk = (SLK *) 0;
- res = (ERR);
- }
+ returnCode(slk_failed());
}
/* We now reset the format so that the next newterm has again
@@ -180,7 +198,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
*/
SP->slk_format = _nc_slk_format;
_nc_slk_format = 0;
- return (res);
+ returnCode(res);
}
/*
diff --git a/contrib/ncurses/ncurses/base/lib_slkatr_set.c b/contrib/ncurses/ncurses/base/lib_slkatr_set.c
index 5df314c6dca8..f83616beaf17 100644
--- a/contrib/ncurses/ncurses/base/lib_slkatr_set.c
+++ b/contrib/ncurses/ncurses/base/lib_slkatr_set.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2005 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,28 +27,32 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1998 *
+ * Author: Juergen Pfeifer, 1998 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
* lib_slkatr_set.c
* Soft key routines.
- * Set the labels attributes
+ * Set the label's attributes
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkatr_set.c,v 1.5 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkatr_set.c,v 1.10 2005/01/28 21:11:53 tom Exp $")
NCURSES_EXPORT(int)
-slk_attr_set
-(const attr_t attr, short color_pair_number, void *opts)
+slk_attr_set(const attr_t attr, short color_pair_number, void *opts)
{
T((T_CALLED("slk_attr_set(%s,%d)"), _traceattr(attr), color_pair_number));
if (SP != 0 && SP->_slk != 0 && !opts &&
color_pair_number >= 0 && color_pair_number < COLOR_PAIRS) {
- SP->_slk->attr = attr;
- toggle_attr_on(SP->_slk->attr, COLOR_PAIR(color_pair_number));
+ TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr))));
+ SetAttr(SP->_slk->attr, attr);
+ if (color_pair_number > 0) {
+ SetPair(SP->_slk->attr, color_pair_number);
+ }
+ TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
returnCode(OK);
} else
returnCode(ERR);
diff --git a/contrib/ncurses/ncurses/base/lib_slkatrof.c b/contrib/ncurses/ncurses/base/lib_slkatrof.c
index c271c342101a..14b4c3bfadcc 100644
--- a/contrib/ncurses/ncurses/base/lib_slkatrof.c
+++ b/contrib/ncurses/ncurses/base/lib_slkatrof.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 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,8 +27,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Author: Juergen Pfeifer, 1997 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
@@ -38,7 +38,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkatrof.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkatrof.c,v 1.8 2005/01/08 23:01:32 tom Exp $")
NCURSES_EXPORT(int)
slk_attroff(const chtype attr)
@@ -46,7 +46,12 @@ slk_attroff(const chtype attr)
T((T_CALLED("slk_attroff(%s)"), _traceattr(attr)));
if (SP != 0 && SP->_slk != 0) {
- toggle_attr_off(SP->_slk->attr, attr);
+ TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr))));
+ RemAttr(SP->_slk->attr, attr);
+ if ((attr & A_COLOR) != 0) {
+ SetPair(SP->_slk->attr, 0);
+ }
+ TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
returnCode(OK);
} else
returnCode(ERR);
diff --git a/contrib/ncurses/ncurses/base/lib_slkatron.c b/contrib/ncurses/ncurses/base/lib_slkatron.c
index d174b0394926..90add86dc1c8 100644
--- a/contrib/ncurses/ncurses/base/lib_slkatron.c
+++ b/contrib/ncurses/ncurses/base/lib_slkatron.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 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,8 +27,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Author: Juergen Pfeifer, 1997 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
@@ -38,7 +38,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkatron.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkatron.c,v 1.8 2005/01/08 23:02:01 tom Exp $")
NCURSES_EXPORT(int)
slk_attron(const chtype attr)
@@ -46,7 +46,12 @@ slk_attron(const chtype attr)
T((T_CALLED("slk_attron(%s)"), _traceattr(attr)));
if (SP != 0 && SP->_slk != 0) {
- toggle_attr_on(SP->_slk->attr, attr);
+ TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr))));
+ AddAttr(SP->_slk->attr, attr);
+ if ((attr & A_COLOR) != 0) {
+ SetPair(SP->_slk->attr, PAIR_NUMBER(attr));
+ }
+ TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
returnCode(OK);
} else
returnCode(ERR);
diff --git a/contrib/ncurses/ncurses/base/lib_slkatrset.c b/contrib/ncurses/ncurses/base/lib_slkatrset.c
index cda74cad42d0..8da9981b3b3e 100644
--- a/contrib/ncurses/ncurses/base/lib_slkatrset.c
+++ b/contrib/ncurses/ncurses/base/lib_slkatrset.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 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,8 +27,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Author: Juergen Pfeifer, 1997 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
@@ -38,7 +38,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkatrset.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkatrset.c,v 1.7 2005/01/08 21:46:47 tom Exp $")
NCURSES_EXPORT(int)
slk_attrset(const chtype attr)
@@ -46,7 +46,7 @@ slk_attrset(const chtype attr)
T((T_CALLED("slk_attrset(%s)"), _traceattr(attr)));
if (SP != 0 && SP->_slk != 0) {
- SP->_slk->attr = attr;
+ SetAttr(SP->_slk->attr, attr);
returnCode(OK);
} else
returnCode(ERR);
diff --git a/contrib/ncurses/ncurses/base/lib_slkattr.c b/contrib/ncurses/ncurses/base/lib_slkattr.c
index 5044a08d727a..da82ee5b623e 100644
--- a/contrib/ncurses/ncurses/base/lib_slkattr.c
+++ b/contrib/ncurses/ncurses/base/lib_slkattr.c
@@ -27,8 +27,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Author: Juergen Pfeifer, 1997 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
@@ -38,7 +38,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkattr.c,v 1.5 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkattr.c,v 1.6 2005/01/08 21:44:28 tom Exp $")
NCURSES_EXPORT(attr_t)
slk_attr(void)
@@ -46,7 +46,11 @@ slk_attr(void)
T((T_CALLED("slk_attr()")));
if (SP != 0 && SP->_slk != 0) {
- returnAttr(SP->_slk->attr);
+ attr_t result = AttrOf(SP->_slk->attr) & ALL_BUT_COLOR;
+ int pair = GetPair(SP->_slk->attr);
+
+ result |= COLOR_PAIR(pair);
+ returnAttr(result);
} else
returnAttr(0);
}
diff --git a/contrib/ncurses/ncurses/base/lib_slkclear.c b/contrib/ncurses/ncurses/base/lib_slkclear.c
index 03e6721cbb29..99edcd538ec5 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2006 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.8 2001/12/19 01:07:01 tom Exp $")
+MODULE_ID("$Id: lib_slkclear.c,v 1.9 2006/05/27 19:21:19 tom Exp $")
NCURSES_EXPORT(int)
slk_clear(void)
@@ -51,7 +51,7 @@ slk_clear(void)
/* For simulated SLK's it's looks much more natural to
inherit those attributes from the standard screen */
SP->_slk->win->_nc_bkgd = stdscr->_nc_bkgd;
- SP->_slk->win->_attrs = stdscr->_attrs;
+ WINDOW_ATTRS(SP->_slk->win) = WINDOW_ATTRS(stdscr);
if (SP->_slk->win == stdscr) {
returnCode(OK);
} else {
diff --git a/contrib/ncurses/ncurses/base/lib_slkcolor.c b/contrib/ncurses/ncurses/base/lib_slkcolor.c
index 3e878e0024b2..b677b65a529a 100644
--- a/contrib/ncurses/ncurses/base/lib_slkcolor.c
+++ b/contrib/ncurses/ncurses/base/lib_slkcolor.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2005 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,15 +27,18 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1998 *
+ * Author: Juergen Pfeifer, 1998 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
* lib_slkcolor.c
+ * Soft key routines.
+ * Set the label's color
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkcolor.c,v 1.7 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkcolor.c,v 1.12 2005/01/28 21:11:53 tom Exp $")
NCURSES_EXPORT(int)
slk_color(short color_pair_number)
@@ -44,8 +47,9 @@ slk_color(short color_pair_number)
if (SP != 0 && SP->_slk != 0 &&
color_pair_number >= 0 && color_pair_number < COLOR_PAIRS) {
- T(("... current %ld", (long) PAIR_NUMBER(SP->_slk->attr)));
- toggle_attr_on(SP->_slk->attr, COLOR_PAIR(color_pair_number));
+ TR(TRACE_ATTRS, ("... current is %s", _tracech_t(CHREF(SP->_slk->attr))));
+ SetPair(SP->_slk->attr, color_pair_number);
+ TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
returnCode(OK);
} else
returnCode(ERR);
diff --git a/contrib/ncurses/ncurses/base/lib_slklab.c b/contrib/ncurses/ncurses/base/lib_slklab.c
index 0224e9b0c863..42bb4ac1425d 100644
--- a/contrib/ncurses/ncurses/base/lib_slklab.c
+++ b/contrib/ncurses/ncurses/base/lib_slklab.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2003 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_slklab.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slklab.c,v 1.7 2003/03/29 22:53:48 tom Exp $")
NCURSES_EXPORT(char *)
slk_label(int n)
@@ -47,5 +47,5 @@ slk_label(int n)
if (SP == NULL || SP->_slk == NULL || n < 1 || n > SP->_slk->labcnt)
returnPtr(0);
- returnPtr(SP->_slk->ent[n - 1].text);
+ returnPtr(SP->_slk->ent[n - 1].ent_text);
}
diff --git a/contrib/ncurses/ncurses/base/lib_slkrefr.c b/contrib/ncurses/ncurses/base/lib_slkrefr.c
index 18e5b0c1c2f7..c8ca28b9dd84 100644
--- a/contrib/ncurses/ncurses/base/lib_slkrefr.c
+++ b/contrib/ncurses/ncurses/base/lib_slkrefr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,8 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Juergen Pfeifer 1996-on *
+ * and: Thomas E. Dickey *
****************************************************************************/
/*
@@ -38,7 +40,7 @@
#include <curses.priv.h>
#include <term.h> /* num_labels, label_*, plab_norm */
-MODULE_ID("$Id: lib_slkrefr.c,v 1.10 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkrefr.c,v 1.15 2006/11/25 22:32:15 tom Exp $")
/*
* Write the soft labels to the soft-key window.
@@ -55,18 +57,18 @@ slk_intern_refresh(SLK * slk)
if (num_labels > 0 && SLK_STDFMT(fmt)) {
if (i < num_labels) {
TPUTS_TRACE("plab_norm");
- putp(tparm(plab_norm, i + 1, slk->ent[i].form_text));
+ putp(TPARM_2(plab_norm, i + 1, slk->ent[i].form_text));
}
} else {
- wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].x);
- if (SP && SP->_slk)
- wattrset(slk->win, SP->_slk->attr);
- waddnstr(slk->win, slk->ent[i].form_text,
- MAX_SKEY_LEN(fmt));
+ wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x);
+ if (SP && SP->_slk) {
+ wattrset(slk->win, AttrOf(SP->_slk->attr));
+ }
+ waddstr(slk->win, slk->ent[i].form_text);
/* if we simulate SLK's, it's looking much more
natural to use the current ATTRIBUTE also
for the label window */
- wattrset(slk->win, stdscr->_attrs);
+ wattrset(slk->win, WINDOW_ATTRS(stdscr));
}
}
slk->ent[i].dirty = FALSE;
diff --git a/contrib/ncurses/ncurses/base/lib_slkset.c b/contrib/ncurses/ncurses/base/lib_slkset.c
index d15002f17dba..9379b36322e2 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 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,8 +27,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Author: Juergen Pfeifer *
+ * and: Thomas E. Dickey *
****************************************************************************/
/*
@@ -38,13 +38,22 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_slkset.c,v 1.7 2001/06/02 22:50:29 skimo Exp $")
+#if USE_WIDEC_SUPPORT
+#if HAVE_WCTYPE_H
+#include <wctype.h>
+#endif
+#endif
+
+MODULE_ID("$Id: lib_slkset.c,v 1.16 2006/12/17 19:47:09 tom Exp $")
NCURSES_EXPORT(int)
slk_set(int i, const char *astr, int format)
{
SLK *slk = SP->_slk;
- size_t len;
+ int offset;
+ int numchrs;
+ int numcols;
+ int limit;
const char *str = astr;
const char *p;
@@ -54,44 +63,82 @@ slk_set(int i, const char *astr, int format)
returnCode(ERR);
if (str == NULL)
str = "";
+ --i; /* Adjust numbering of labels */
+ limit = MAX_SKEY_LEN(SP->slk_format);
while (isspace(UChar(*str)))
str++; /* skip over leading spaces */
p = str;
+
+#if USE_WIDEC_SUPPORT
+ numcols = 0;
+ while (*p != 0) {
+ mbstate_t state;
+ wchar_t wc;
+ size_t need;
+
+ init_mb(state);
+ need = mbrtowc(0, p, strlen(p), &state);
+ if (need == (size_t) -1)
+ break;
+ mbrtowc(&wc, p, need, &state);
+ if (!iswprint((wint_t) wc))
+ break;
+ if (wcwidth(wc) + numcols > limit)
+ break;
+ numcols += wcwidth(wc);
+ p += need;
+ }
+ numchrs = (p - str);
+#else
while (isprint(UChar(*p)))
p++; /* The first non-print stops */
- --i; /* Adjust numbering of labels */
+ numcols = (p - str);
+ if (numcols > limit)
+ numcols = limit;
+ numchrs = numcols;
+#endif
- len = (size_t) (p - str);
- if (len > (unsigned) slk->maxlen)
- len = slk->maxlen;
- if (len == 0)
- slk->ent[i].text[0] = 0;
- else
- (void) strncpy(slk->ent[i].text, str, len);
- memset(slk->ent[i].form_text, ' ', (unsigned) slk->maxlen);
- slk->ent[i].text[slk->maxlen] = 0;
- /* len = strlen(slk->ent[i].text); */
+ FreeIfNeeded(slk->ent[i].ent_text);
+ if ((slk->ent[i].ent_text = strdup(str)) == 0)
+ returnCode(ERR);
+ slk->ent[i].ent_text[numchrs] = '\0';
+
+ if ((slk->ent[i].form_text = (char *) _nc_doalloc(slk->ent[i].form_text,
+ (unsigned) (limit +
+ numchrs + 1))
+ ) == 0)
+ returnCode(ERR);
switch (format) {
+ default:
case 0: /* left-justified */
- memcpy(slk->ent[i].form_text,
- slk->ent[i].text,
- len);
+ offset = 0;
break;
case 1: /* centered */
- memcpy(slk->ent[i].form_text + (slk->maxlen - len) / 2,
- slk->ent[i].text,
- len);
+ offset = (limit - numcols) / 2;
break;
case 2: /* right-justified */
- memcpy(slk->ent[i].form_text + slk->maxlen - len,
- slk->ent[i].text,
- len);
+ offset = limit - numcols;
break;
}
- slk->ent[i].form_text[slk->maxlen] = 0;
+ if (offset <= 0)
+ offset = 0;
+ else
+ memset(slk->ent[i].form_text, ' ', (unsigned) offset);
+
+ memcpy(slk->ent[i].form_text + offset,
+ slk->ent[i].ent_text,
+ (unsigned) numchrs);
+
+ if (offset < limit) {
+ memset(slk->ent[i].form_text + offset + numchrs,
+ ' ',
+ (unsigned) (limit - (offset + numcols)));
+ }
+
+ slk->ent[i].form_text[numchrs - numcols + limit] = 0;
slk->ent[i].dirty = TRUE;
returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_ungetch.c b/contrib/ncurses/ncurses/base/lib_ungetch.c
index ba057c043901..a6164df5edc1 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,2001 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,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_ungetch.c,v 1.7 2001/12/29 23:01:09 tom Exp $")
+MODULE_ID("$Id: lib_ungetch.c,v 1.8 2002/08/24 22:08:48 tom Exp $")
#include <fifo_defs.h>
@@ -58,7 +58,7 @@ _nc_fifo_dump(void)
NCURSES_EXPORT(int)
ungetch(int ch)
{
- T((T_CALLED("ungetch(%d)"), ch));
+ T((T_CALLED("ungetch(%s)"), _tracechar(ch)));
if (tail == -1)
returnCode(ERR);
@@ -70,7 +70,7 @@ ungetch(int ch)
h_dec();
SP->_fifo[head] = ch;
- T(("ungetch %#x ok", ch));
+ T(("ungetch %s ok", _tracechar(ch)));
#ifdef TRACE
if (_nc_tracing & TRACE_IEVENT)
_nc_fifo_dump();
diff --git a/contrib/ncurses/ncurses/base/lib_vline.c b/contrib/ncurses/ncurses/base/lib_vline.c
index c19570b66265..1a2537e7eb6a 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2006 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.9 2001/06/03 00:39:24 skimo Exp $")
+MODULE_ID("$Id: lib_vline.c,v 1.10 2006/03/11 21:52:19 tom Exp $")
NCURSES_EXPORT(int)
wvline(WINDOW *win, chtype ch, int n)
@@ -60,9 +60,9 @@ wvline(WINDOW *win, chtype ch, int n)
end = win->_maxy;
if (ch == 0)
- SetChar(wch, ChCharOf(ACS_VLINE), ChAttrOf(ACS_VLINE));
+ SetChar2(wch, ACS_VLINE);
else
- SetChar(wch, ChCharOf(ch), ChAttrOf(ch));
+ SetChar2(wch, ch);
wch = _nc_render(win, wch);
while (end >= row) {
diff --git a/contrib/ncurses/ncurses/base/lib_wattroff.c b/contrib/ncurses/ncurses/base/lib_wattroff.c
index fa29b1a759a6..bf2020e06027 100644
--- a/contrib/ncurses/ncurses/base/lib_wattroff.c
+++ b/contrib/ncurses/ncurses/base/lib_wattroff.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -41,16 +42,22 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_wattroff.c,v 1.6 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: lib_wattroff.c,v 1.9 2006/05/27 19:30:33 tom Exp $")
NCURSES_EXPORT(int)
-wattr_off
-(WINDOW *win, NCURSES_CONST attr_t at, void *opts GCC_UNUSED)
+wattr_off(WINDOW *win, attr_t at, void *opts GCC_UNUSED)
{
T((T_CALLED("wattr_off(%p,%s)"), win, _traceattr(at)));
if (win) {
- T(("... current %s", _traceattr(win->_attrs)));
- toggle_attr_off(win->_attrs, at);
+ T(("... current %s (%d)",
+ _traceattr(WINDOW_ATTRS(win)),
+ GET_WINDOW_PAIR(win)));
+
+ if_EXT_COLORS({
+ if (at & A_COLOR)
+ win->_color = 0;
+ });
+ toggle_attr_off(WINDOW_ATTRS(win), at);
returnCode(OK);
} else
returnCode(ERR);
diff --git a/contrib/ncurses/ncurses/base/lib_wattron.c b/contrib/ncurses/ncurses/base/lib_wattron.c
index 7bbc555e2c52..2e17d965e94a 100644
--- a/contrib/ncurses/ncurses/base/lib_wattron.c
+++ b/contrib/ncurses/ncurses/base/lib_wattron.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -41,16 +42,22 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_wattron.c,v 1.6 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: lib_wattron.c,v 1.9 2006/05/27 19:30:46 tom Exp $")
NCURSES_EXPORT(int)
-wattr_on
-(WINDOW *win, NCURSES_CONST attr_t at, void *opts GCC_UNUSED)
+wattr_on(WINDOW *win, attr_t at, void *opts GCC_UNUSED)
{
T((T_CALLED("wattr_on(%p,%s)"), win, _traceattr(at)));
- if (win) {
- T(("... current %s", _traceattr(win->_attrs)));
- toggle_attr_on(win->_attrs, at);
+ if (win != 0) {
+ T(("... current %s (%d)",
+ _traceattr(WINDOW_ATTRS(win)),
+ GET_WINDOW_PAIR(win)));
+
+ if_EXT_COLORS({
+ if (at & A_COLOR)
+ win->_color = PAIR_NUMBER(at);
+ });
+ toggle_attr_on(WINDOW_ATTRS(win), at);
returnCode(OK);
} else
returnCode(ERR);
diff --git a/contrib/ncurses/ncurses/base/lib_window.c b/contrib/ncurses/ncurses/base/lib_window.c
index 943f6e004312..bb20f4faf2a2 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,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2006 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.18 2001/12/19 01:07:15 tom Exp $")
+MODULE_ID("$Id: lib_window.c,v 1.22 2006/05/27 19:21:19 tom Exp $")
NCURSES_EXPORT(void)
_nc_synchook(WINDOW *win)
@@ -178,55 +178,71 @@ NCURSES_EXPORT(WINDOW *)
dupwin(WINDOW *win)
/* make an exact duplicate of the given window */
{
- WINDOW *nwin;
+ WINDOW *nwin = 0;
size_t linesize;
int i;
T((T_CALLED("dupwin(%p)"), win));
- if ((win == NULL) ||
- ((nwin = newwin(win->_maxy + 1, win->_maxx + 1, win->_begy,
- win->_begx)) == NULL))
- returnWin(0);
-
- nwin->_curx = win->_curx;
- nwin->_cury = win->_cury;
- nwin->_maxy = win->_maxy;
- nwin->_maxx = win->_maxx;
- nwin->_begy = win->_begy;
- nwin->_begx = win->_begx;
- nwin->_yoffset = win->_yoffset;
-
- nwin->_flags = win->_flags & ~_SUBWIN;
- /* Due to the use of newwin(), the clone is not a subwindow.
- * The text is really copied into the clone.
- */
-
- nwin->_attrs = win->_attrs;
- nwin->_nc_bkgd = win->_nc_bkgd;
-
- nwin->_clear = win->_clear;
- nwin->_scroll = win->_scroll;
- nwin->_leaveok = win->_leaveok;
- nwin->_use_keypad = win->_use_keypad;
- nwin->_delay = win->_delay;
- nwin->_immed = win->_immed;
- nwin->_sync = win->_sync;
-
- nwin->_parx = 0;
- nwin->_pary = 0;
- nwin->_parent = (WINDOW *) 0;
- /* See above: the clone isn't a subwindow! */
-
- nwin->_regtop = win->_regtop;
- nwin->_regbottom = win->_regbottom;
-
- linesize = (win->_maxx + 1) * sizeof(chtype);
- for (i = 0; i <= nwin->_maxy; i++) {
- memcpy(nwin->_line[i].text, win->_line[i].text, linesize);
- nwin->_line[i].firstchar = win->_line[i].firstchar;
- nwin->_line[i].lastchar = win->_line[i].lastchar;
- }
+ if (win != 0) {
+
+ if (win->_flags & _ISPAD) {
+ nwin = newpad(win->_maxy + 1,
+ win->_maxx + 1);
+ } else {
+ nwin = newwin(win->_maxy + 1,
+ win->_maxx + 1,
+ win->_begy,
+ win->_begx);
+ }
+ if (nwin != 0) {
+
+ nwin->_curx = win->_curx;
+ nwin->_cury = win->_cury;
+ nwin->_maxy = win->_maxy;
+ nwin->_maxx = win->_maxx;
+ nwin->_begy = win->_begy;
+ nwin->_begx = win->_begx;
+ nwin->_yoffset = win->_yoffset;
+
+ nwin->_flags = win->_flags & ~_SUBWIN;
+ /* Due to the use of newwin(), the clone is not a subwindow.
+ * The text is really copied into the clone.
+ */
+
+ WINDOW_ATTRS(nwin) = WINDOW_ATTRS(win);
+ nwin->_nc_bkgd = win->_nc_bkgd;
+
+ nwin->_notimeout = win->_notimeout;
+ nwin->_clear = win->_clear;
+ nwin->_leaveok = win->_leaveok;
+ nwin->_scroll = win->_scroll;
+ nwin->_idlok = win->_idlok;
+ nwin->_idcok = win->_idcok;
+ nwin->_immed = win->_immed;
+ nwin->_sync = win->_sync;
+ nwin->_use_keypad = win->_use_keypad;
+ nwin->_delay = win->_delay;
+
+ nwin->_parx = 0;
+ nwin->_pary = 0;
+ nwin->_parent = (WINDOW *) 0;
+ /* See above: the clone isn't a subwindow! */
+
+ nwin->_regtop = win->_regtop;
+ nwin->_regbottom = win->_regbottom;
+
+ if (win->_flags & _ISPAD)
+ nwin->_pad = win->_pad;
+
+ linesize = (win->_maxx + 1) * sizeof(NCURSES_CH_T);
+ for (i = 0; i <= nwin->_maxy; i++) {
+ memcpy(nwin->_line[i].text, win->_line[i].text, linesize);
+ nwin->_line[i].firstchar = win->_line[i].firstchar;
+ nwin->_line[i].lastchar = win->_line[i].lastchar;
+ }
+ }
+ }
returnWin(nwin);
}
diff --git a/contrib/ncurses/ncurses/base/resizeterm.c b/contrib/ncurses/ncurses/base/resizeterm.c
index f454b20c8437..46faccb74380 100644
--- a/contrib/ncurses/ncurses/base/resizeterm.c
+++ b/contrib/ncurses/ncurses/base/resizeterm.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2006 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,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
/*
@@ -41,13 +41,191 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: resizeterm.c,v 1.13 2002/02/02 19:26:27 tom Exp $")
+MODULE_ID("$Id: resizeterm.c,v 1.18 2006/10/14 20:43:31 tom Exp $")
+
+#define stolen_lines (screen_lines - SP->_lines_avail)
+
+static int current_lines;
+static int current_cols;
+
+#ifdef TRACE
+static void
+show_window_sizes(const char *name)
+{
+ WINDOWLIST *wp;
+
+ _tracef("%s resizing: %2d x %2d (%2d x %2d)", name, LINES, COLS,
+ screen_lines, screen_columns);
+ for (wp = _nc_windows; wp != 0; wp = wp->next) {
+ _tracef(" window %p is %2ld x %2ld at %2ld,%2ld",
+ &(wp->win),
+ (long) wp->win._maxy + 1,
+ (long) wp->win._maxx + 1,
+ (long) wp->win._begy,
+ (long) wp->win._begx);
+ }
+}
+#endif
NCURSES_EXPORT(bool)
is_term_resized(int ToLines, int ToCols)
{
- return (ToLines != screen_lines
- || ToCols != screen_columns);
+ T((T_CALLED("is_term_resized(%d, %d)"), ToLines, ToCols));
+ returnCode(ToLines > 0
+ && ToCols > 0
+ && (ToLines != screen_lines
+ || ToCols != screen_columns));
+}
+
+/*
+ * Return the number of levels of child-windows under the current window.
+ */
+static int
+child_depth(WINDOW *cmp)
+{
+ int depth = 0;
+
+ if (cmp != 0) {
+ WINDOWLIST *wp;
+
+ for (wp = _nc_windows; wp != 0; wp = wp->next) {
+ WINDOW *tst = &(wp->win);
+ if (tst->_parent == cmp) {
+ depth = 1 + child_depth(tst);
+ break;
+ }
+ }
+ }
+ return depth;
+}
+
+/*
+ * Return the number of levels of parent-windows above the current window.
+ */
+static int
+parent_depth(WINDOW *cmp)
+{
+ int depth = 0;
+
+ if (cmp != 0) {
+ WINDOW *tst;
+ while ((tst = cmp->_parent) != 0) {
+ ++depth;
+ cmp = tst;
+ }
+ }
+ return depth;
+}
+
+/*
+ * FIXME: must adjust position so it's within the parent!
+ */
+static int
+adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen)
+{
+ int result;
+ int bottom = current_lines + SP->_topstolen - stolen;
+ int myLines = win->_maxy + 1;
+ int myCols = win->_maxx + 1;
+
+ T((T_CALLED("adjust_window(%p,%d,%d) currently %ldx%ld at %ld,%ld"),
+ win, ToLines, ToCols,
+ (long) getmaxy(win), (long) getmaxx(win),
+ (long) getbegy(win), (long) getbegx(win)));
+
+ if (win->_begy >= bottom) {
+ win->_begy += (ToLines - current_lines);
+ } else {
+ if (myLines == current_lines - stolen
+ && ToLines != current_lines)
+ myLines = ToLines - stolen;
+ else if (myLines == current_lines
+ && ToLines != current_lines)
+ myLines = ToLines;
+ }
+
+ if (myLines > ToLines)
+ myLines = ToLines;
+
+ if (myCols > ToCols)
+ myCols = ToCols;
+
+ if (myLines == current_lines
+ && ToLines != current_lines)
+ myLines = ToLines;
+
+ if (myCols == current_cols
+ && ToCols != current_cols)
+ myCols = ToCols;
+
+ result = wresize(win, myLines, myCols);
+ returnCode(result);
+}
+
+/*
+ * If we're decreasing size, recursively search for windows that have no
+ * children, decrease those to fit, then decrease the containing window, etc.
+ */
+static int
+decrease_size(int ToLines, int ToCols, int stolen)
+{
+ bool found;
+ int depth = 0;
+ WINDOWLIST *wp;
+
+ T((T_CALLED("decrease_size(%d, %d)"), ToLines, ToCols));
+
+ do {
+ found = FALSE;
+ TR(TRACE_UPDATE, ("decreasing size of windows to %dx%d, depth=%d",
+ ToLines, ToCols, depth));
+ for (wp = _nc_windows; wp != 0; wp = wp->next) {
+ WINDOW *win = &(wp->win);
+
+ if (!(win->_flags & _ISPAD)) {
+ if (child_depth(win) == depth) {
+ found = TRUE;
+ if (adjust_window(win, ToLines, ToCols, stolen) != OK)
+ returnCode(ERR);
+ }
+ }
+ }
+ ++depth;
+ } while (found);
+ returnCode(OK);
+}
+
+/*
+ * If we're increasing size, recursively search for windows that have no
+ * parent, increase those to fit, then increase the contained window, etc.
+ */
+static int
+increase_size(int ToLines, int ToCols, int stolen)
+{
+ bool found;
+ int depth = 0;
+ WINDOWLIST *wp;
+
+ T((T_CALLED("increase_size(%d, %d)"), ToLines, ToCols));
+
+ do {
+ found = FALSE;
+ TR(TRACE_UPDATE, ("increasing size of windows to %dx%d, depth=%d",
+ ToLines, ToCols, depth));
+ for (wp = _nc_windows; wp != 0; wp = wp->next) {
+ WINDOW *win = &(wp->win);
+
+ if (!(win->_flags & _ISPAD)) {
+ if (parent_depth(win) == depth) {
+ found = TRUE;
+ if (adjust_window(win, ToLines, ToCols, stolen) != OK)
+ returnCode(ERR);
+ }
+ }
+ }
+ ++depth;
+ } while (found);
+ returnCode(OK);
}
/*
@@ -57,48 +235,42 @@ is_term_resized(int ToLines, int ToCols)
NCURSES_EXPORT(int)
resize_term(int ToLines, int ToCols)
{
- int stolen = screen_lines - SP->_lines_avail;
- int bottom = screen_lines + SP->_topstolen - stolen;
+ int result = OK;
+ int was_stolen = (screen_lines - SP->_lines_avail);
T((T_CALLED("resize_term(%d,%d) old(%d,%d)"),
ToLines, ToCols,
screen_lines, screen_columns));
if (is_term_resized(ToLines, ToCols)) {
- WINDOWLIST *wp;
+ int myLines = current_lines = screen_lines;
+ int myCols = current_cols = screen_columns;
- for (wp = _nc_windows; wp != 0; wp = wp->next) {
- WINDOW *win = &(wp->win);
- int myLines = win->_maxy + 1;
- int myCols = win->_maxx + 1;
-
- /* pads aren't treated this way */
- if (win->_flags & _ISPAD)
- continue;
-
- if (win->_begy >= bottom) {
- win->_begy += (ToLines - screen_lines);
- } else {
- if (myLines == screen_lines - stolen
- && ToLines != screen_lines)
- myLines = ToLines - stolen;
- else if (myLines == screen_lines
- && ToLines != screen_lines)
- myLines = ToLines;
- }
+#ifdef TRACE
+ if (_nc_tracing & TRACE_UPDATE)
+ show_window_sizes("before");
+#endif
+ if (ToLines > screen_lines) {
+ increase_size(myLines = ToLines, myCols, was_stolen);
+ current_lines = myLines;
+ current_cols = myCols;
+ }
- if (myCols == screen_columns
- && ToCols != screen_columns)
- myCols = ToCols;
+ if (ToCols > screen_columns) {
+ increase_size(myLines, myCols = ToCols, was_stolen);
+ current_lines = myLines;
+ current_cols = myCols;
+ }
- if (wresize(win, myLines, myCols) != OK)
- returnCode(ERR);
+ if (ToLines < myLines ||
+ ToCols < myCols) {
+ decrease_size(ToLines, ToCols, was_stolen);
}
screen_lines = lines = ToLines;
screen_columns = columns = ToCols;
- SP->_lines_avail = lines - stolen;
+ SP->_lines_avail = lines - was_stolen;
if (SP->oldhash) {
FreeAndNull(SP->oldhash);
@@ -106,16 +278,23 @@ resize_term(int ToLines, int ToCols)
if (SP->newhash) {
FreeAndNull(SP->newhash);
}
+#ifdef TRACE
+ if (_nc_tracing & TRACE_UPDATE) {
+ LINES = ToLines - was_stolen;
+ COLS = ToCols;
+ show_window_sizes("after");
+ }
+#endif
}
/*
* Always update LINES, to allow for call from lib_doupdate.c which
* needs to have the count adjusted by the stolen (ripped off) lines.
*/
- LINES = ToLines - stolen;
+ LINES = ToLines - was_stolen;
COLS = ToCols;
- returnCode(OK);
+ returnCode(result);
}
/*
diff --git a/contrib/ncurses/ncurses/base/safe_sprintf.c b/contrib/ncurses/ncurses/base/safe_sprintf.c
index cb48365f7f51..81fe44f0c783 100644
--- a/contrib/ncurses/ncurses/base/safe_sprintf.c
+++ b/contrib/ncurses/ncurses/base/safe_sprintf.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2003 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,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: safe_sprintf.c,v 1.14 2001/07/08 00:58:34 tom Exp $")
+MODULE_ID("$Id: safe_sprintf.c,v 1.18 2003/08/09 21:52:04 tom Exp $")
#if USE_SAFE_SPRINTF
@@ -56,10 +56,13 @@ _nc_printf_length(const char *fmt, va_list ap)
char *buffer;
char *format;
int len = 0;
+ size_t fmt_len;
+ char fmt_arg[BUFSIZ];
if (fmt == 0 || *fmt == '\0')
- return -1;
- if ((format = typeMalloc(char, strlen(fmt) + 1)) == 0)
+ return 0;
+ fmt_len = strlen(fmt) + 1;
+ if ((format = typeMalloc(char, fmt_len)) == 0)
return -1;
if ((buffer = typeMalloc(char, length)) == 0) {
free(format);
@@ -106,7 +109,12 @@ _nc_printf_length(const char *fmt, va_list ap)
} else if (state == Prec) {
prec = ival;
}
- sprintf(&format[--f], "%d", ival);
+ sprintf(fmt_arg, "%d", ival);
+ fmt_len += strlen(fmt_arg);
+ if ((format = realloc(format, fmt_len)) == 0) {
+ return -1;
+ }
+ strcpy(&format[--f], fmt_arg);
f = strlen(format);
} else if (isalpha(UChar(*fmt))) {
done = TRUE;
@@ -203,42 +211,52 @@ _nc_printf_length(const char *fmt, va_list ap)
* Wrapper for vsprintf that allocates a buffer big enough to hold the result.
*/
NCURSES_EXPORT(char *)
-_nc_printf_string
-(const char *fmt, va_list ap)
+_nc_printf_string(const char *fmt, va_list ap)
{
+ static char *buf;
+ static size_t used;
+ char *result = 0;
+
+ if (fmt != 0) {
#if USE_SAFE_SPRINTF
- char *buf = 0;
- int len = _nc_printf_length(fmt, ap);
+ int len = _nc_printf_length(fmt, ap);
- if (len > 0) {
- if ((buf = typeMalloc(char, len + 1)) == 0)
- return (0);
- vsprintf(buf, fmt, ap);
- }
+ if ((int) used < len + 1) {
+ used = 2 * (len + 1);
+ buf = typeRealloc(char, used, buf);
+ }
+ if (buf != 0) {
+ *buf = '\0';
+ if (len >= 0) {
+ vsprintf(buf, fmt, ap);
+ }
+ result = buf;
+ }
#else
- static int rows, cols;
- static char *buf;
- static size_t len;
-
- if (screen_lines > rows || screen_columns > cols) {
- if (screen_lines > rows)
- rows = screen_lines;
- if (screen_columns > cols)
- cols = screen_columns;
- len = (rows * (cols + 1)) + 1;
- buf = typeRealloc(char, len, buf);
- if (buf == 0) {
- return (0);
+ static int rows, cols;
+
+ if (screen_lines > rows || screen_columns > cols) {
+ if (screen_lines > rows)
+ rows = screen_lines;
+ if (screen_columns > cols)
+ cols = screen_columns;
+ used = (rows * (cols + 1)) + 1;
+ buf = typeRealloc(char, used, buf);
}
- }
- if (buf != 0) {
+ if (buf != 0) {
# if HAVE_VSNPRINTF
- vsnprintf(buf, len, fmt, ap); /* GNU extension */
+ vsnprintf(buf, used, fmt, ap); /* GNU extension */
# else
- vsprintf(buf, fmt, ap); /* ANSI */
+ vsprintf(buf, fmt, ap); /* ANSI */
# endif
- }
+ result = buf;
+ }
#endif
- return buf;
+ } else if (buf != 0) { /* see _nc_freeall() */
+ free(buf);
+ buf = 0;
+ used = 0;
+ }
+ return result;
}
diff --git a/contrib/ncurses/ncurses/base/sigaction.c b/contrib/ncurses/ncurses/base/sigaction.c
index 8ba8629a4f50..36442e090a41 100644
--- a/contrib/ncurses/ncurses/base/sigaction.c
+++ b/contrib/ncurses/ncurses/base/sigaction.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,37 +29,29 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-2003 *
****************************************************************************/
-#include <curses.priv.h>
-
-#include <SigAction.h>
-
/* This file provides sigaction() emulation using sigvec() */
/* Use only if this is non POSIX system */
-#if !HAVE_SIGACTION && HAVE_SIGVEC
+MODULE_ID("$Id: sigaction.c,v 1.14 2003/12/07 01:06:52 tom Exp $")
-MODULE_ID("$Id: sigaction.c,v 1.13 2002/05/18 19:56:26 tom Exp $")
-
-NCURSES_EXPORT(int)
-sigaction
-(int sig, sigaction_t * sigact, sigaction_t * osigact)
+static int
+_nc_sigaction(int sig, sigaction_t * sigact, sigaction_t * osigact)
{
return sigvec(sig, sigact, osigact);
}
-NCURSES_EXPORT(int)
-sigemptyset
-(sigset_t * mask)
+static int
+_nc_sigemptyset(sigset_t * mask)
{
*mask = 0;
return 0;
}
-NCURSES_EXPORT(int)
-sigprocmask
-(int mode, sigset_t * mask, sigset_t * omask)
+static int
+_nc_sigprocmask(int mode, sigset_t * mask, sigset_t * omask)
{
sigset_t current = sigsetmask(0);
@@ -77,41 +69,31 @@ sigprocmask
return 0;
}
-NCURSES_EXPORT(int)
-sigsuspend(sigset_t * mask)
+static int
+_nc_sigaddset(sigset_t * mask, int sig)
{
- return sigpause(*mask);
+ *mask |= sigmask(sig);
+ return 0;
}
-NCURSES_EXPORT(int)
-sigdelset
-(sigset_t * mask, int sig)
+/* not used in lib_tstp.c */
+#if 0
+static int
+_nc_sigsuspend(sigset_t * mask)
{
- *mask &= ~sigmask(sig);
- return 0;
+ return sigpause(*mask);
}
-NCURSES_EXPORT(int)
-sigaddset
-(sigset_t * mask, int sig)
+static int
+_nc_sigdelset(sigset_t * mask, int sig)
{
- *mask |= sigmask(sig);
+ *mask &= ~sigmask(sig);
return 0;
}
-NCURSES_EXPORT(int)
-sigismember
-(sigset_t * mask, int sig)
+static int
+_nc_sigismember(sigset_t * mask, int sig)
{
return (*mask & sigmask(sig)) != 0;
}
-
-#else
-extern
-NCURSES_EXPORT(void)
-_nc_sigaction(void); /* quiet's gcc warning */
-NCURSES_EXPORT(void)
-_nc_sigaction(void)
-{
-} /* nonempty for strict ANSI compilers */
#endif
diff --git a/contrib/ncurses/ncurses/base/tries.c b/contrib/ncurses/ncurses/base/tries.c
index fe7d93ed5e10..4edb7317483c 100644
--- a/contrib/ncurses/ncurses/base/tries.c
+++ b/contrib/ncurses/ncurses/base/tries.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2005 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,15 +39,14 @@
#include <curses.priv.h>
-MODULE_ID("$Id: tries.c,v 1.15 2001/12/16 00:50:40 tom Exp $")
+MODULE_ID("$Id: tries.c,v 1.22 2005/11/26 20:09:18 tom Exp $")
/*
* Expand a keycode into the string that it corresponds to, returning null if
* no match was found, otherwise allocating a string of the result.
*/
NCURSES_EXPORT(char *)
-_nc_expand_try
-(struct tries *tree, unsigned short code, int *count, size_t len)
+_nc_expand_try(struct tries *tree, unsigned code, int *count, size_t len)
{
struct tries *ptr = tree;
char *result = 0;
@@ -72,7 +71,7 @@ _nc_expand_try
if ((result[len] = ptr->ch) == 0)
*((unsigned char *) (result + len)) = 128;
#ifdef TRACE
- if (len == 0)
+ if (len == 0 && _nc_tracing != 0)
_tracef("expand_key %s %s", _tracechar(code), _nc_visbuf(result));
#endif
}
@@ -84,8 +83,7 @@ _nc_expand_try
* true if the code was found/removed.
*/
NCURSES_EXPORT(int)
-_nc_remove_key
-(struct tries **tree, unsigned short code)
+_nc_remove_key(struct tries **tree, unsigned code)
{
T((T_CALLED("_nc_remove_key(%p,%d)"), tree, code));
@@ -117,7 +115,7 @@ _nc_remove_key
* true if the string was found/removed.
*/
NCURSES_EXPORT(int)
-_nc_remove_string(struct tries **tree, char *string)
+_nc_remove_string(struct tries **tree, const char *string)
{
T((T_CALLED("_nc_remove_string(%p,%s)"), tree, _nc_visbuf(string)));
@@ -125,18 +123,17 @@ _nc_remove_string(struct tries **tree, char *string)
returnCode(FALSE);
while (*tree != 0) {
- if ((unsigned char) (*tree)->ch == (unsigned char) *string) {
+ if (UChar((*tree)->ch) == UChar(*string)) {
if (string[1] != 0)
returnCode(_nc_remove_string(&(*tree)->child, string + 1));
- if ((*tree)->child) {
- /* don't cut the whole sub-tree */
- (*tree)->value = 0;
- } else {
+ if ((*tree)->child == 0) {
struct tries *to_free = *tree;
*tree = (*tree)->sibling;
free(to_free);
+ returnCode(TRUE);
+ } else {
+ returnCode(FALSE);
}
- returnCode(TRUE);
}
tree = &(*tree)->sibling;
}
diff --git a/contrib/ncurses/ncurses/base/version.c b/contrib/ncurses/ncurses/base/version.c
index b78c99d00e05..ef83967d46b3 100644
--- a/contrib/ncurses/ncurses/base/version.c
+++ b/contrib/ncurses/ncurses/base/version.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2004,2005 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,16 +32,11 @@
#include <curses.priv.h>
-MODULE_ID("$Id: version.c,v 1.4 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: version.c,v 1.6 2005/01/02 01:23:54 tom Exp $")
NCURSES_EXPORT(const char *)
curses_version(void)
{
- static char my_version[80];
-
T((T_CALLED("curses_version()")));
- sprintf(my_version, "ncurses %s.%d",
- NCURSES_VERSION,
- NCURSES_VERSION_PATCH);
- returnPtr(my_version);
+ returnCPtr("ncurses " NCURSES_VERSION_STRING);
}
diff --git a/contrib/ncurses/ncurses/base/vsscanf.c b/contrib/ncurses/ncurses/base/vsscanf.c
index 65794b76623b..e6253c3a38a3 100644
--- a/contrib/ncurses/ncurses/base/vsscanf.c
+++ b/contrib/ncurses/ncurses/base/vsscanf.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000,2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 @@
#if !HAVE_VSSCANF
-MODULE_ID("$Id: vsscanf.c,v 1.15 2002/02/03 00:49:45 tom Exp $")
+MODULE_ID("$Id: vsscanf.c,v 1.18 2004/04/03 20:27:02 tom Exp $")
#if !(HAVE_VFSCANF || HAVE__DOSCAN)
@@ -210,7 +210,8 @@ vsscanf(const char *str, const char *format, va_list ap)
if (can_convert) {
size_t len_fmt = strlen(format) + 32;
char *my_fmt = malloc(len_fmt);
- ChunkType other, chunk, check;
+ ChunkType chunk, ctest;
+ OtherType other, otest;
ScanState state;
unsigned n;
int eaten;
@@ -229,7 +230,7 @@ vsscanf(const char *str, const char *format, va_list ap)
/* find a chunk */
state = sUnknown;
chunk = cUnknown;
- other = cUnknown;
+ other = oUnknown;
pointer = 0;
for (n = 0; format[n] != 0 && state != sFinal; ++n) {
my_fmt[n] = format[n];
@@ -265,12 +266,12 @@ vsscanf(const char *str, const char *format, va_list ap)
if (format[n] == '*') {
state = sUnknown;
} else {
- if ((check = final_ch(format[n], other)) != cUnknown) {
+ if ((ctest = 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])) {
+ chunk = ctest;
+ } else if ((otest = other_ch(format[n])) != oUnknown) {
+ other = otest;
+ } else if (isalpha(UChar(format[n]))) {
state = sFinal;
chunk = cError;
}
diff --git a/contrib/ncurses/ncurses/base/wresize.c b/contrib/ncurses/ncurses/base/wresize.c
index fa97a2bee52b..ca6336dc94b5 100644
--- a/contrib/ncurses/ncurses/base/wresize.c
+++ b/contrib/ncurses/ncurses/base/wresize.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2006 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,38 +27,75 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997 *
+ * Author: Thomas E. Dickey 1996-2002 *
****************************************************************************/
#include <curses.priv.h>
-MODULE_ID("$Id: wresize.c,v 1.21 2002/05/11 19:36:29 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.24 2006/10/14 20:43:31 tom Exp $")
+
+static int
+cleanup_lines(struct ldat *data, int length)
+{
+ while (--length >= 0)
+ free(data->text);
+ free(data);
+ return ERR;
+}
+
+/*
+ * If we have reallocated the ldat structs, we will have to repair pointers
+ * used in subwindows.
+ */
+static void
+repair_subwindows(WINDOW *cmp)
+{
+ WINDOWLIST *wp;
+ struct ldat *pline = cmp->_line;
+ int row;
+
+ for (wp = _nc_windows; wp != 0; wp = wp->next) {
+ WINDOW *tst = &(wp->win);
+
+ if (tst->_parent == cmp) {
+
+ if (tst->_pary > cmp->_maxy)
+ tst->_pary = cmp->_maxy;
+ if (tst->_parx > cmp->_maxx)
+ tst->_parx = cmp->_maxx;
+
+ if (tst->_maxy + tst->_pary > cmp->_maxy)
+ tst->_maxy = cmp->_maxy - tst->_pary;
+ if (tst->_maxx + tst->_parx > cmp->_maxx)
+ tst->_maxx = cmp->_maxx - tst->_parx;
+
+ for (row = 0; row <= tst->_maxy; ++row) {
+ tst->_line[row].text = &pline[tst->_pary + row].text[tst->_parx];
+ }
+ repair_subwindows(tst);
+ }
+ }
+}
/*
* Reallocate a curses WINDOW struct to either shrink or grow to the specified
* new lines/columns. If it grows, the new character cells are filled with
* blanks. The application is responsible for repainting the blank area.
*/
-
-#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,NCURSES_CH_T,n)
-
NCURSES_EXPORT(int)
wresize(WINDOW *win, int ToLines, int ToCols)
{
- register int row;
- int size_x, size_y;
+ int col, row, size_x, size_y;
struct ldat *pline;
- NCURSES_CH_T blank;
+ struct ldat *new_lines = 0;
#ifdef TRACE
T((T_CALLED("wresize(%p,%d,%d)"), win, ToLines, ToCols));
if (win) {
- TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
- win->_begy, win->_begx,
- win->_maxy, win->_maxx,
- win->_regtop, win->_regbottom));
+ TR(TRACE_UPDATE, ("...beg (%ld, %ld), max(%ld,%ld), reg(%ld,%ld)",
+ (long) win->_begy, (long) win->_begx,
+ (long) win->_maxy, (long) win->_maxx,
+ (long) win->_regtop, (long) win->_regbottom));
if (_nc_tracing & TRACE_UPDATE)
_tracedump("...before", win);
}
@@ -90,67 +127,83 @@ wresize(WINDOW *win, int ToLines, int ToCols)
}
/*
- * If the number of lines has changed, adjust the size of the overall
- * vector:
+ * Allocate new memory as needed. Do the allocations without modifying
+ * the original window, in case an allocation fails. Always allocate
+ * (at least temporarily) the array pointing to the individual lines.
*/
- if (ToLines != size_y) {
- if (!(win->_flags & _SUBWIN)) {
- for (row = ToLines + 1; row <= size_y; row++)
- free((char *) (win->_line[row].text));
- }
-
- win->_line = ld_ALLOC(win->_line, ToLines + 1);
- if (win->_line == 0)
- returnCode(ERR);
-
- for (row = size_y + 1; row <= ToLines; row++) {
- win->_line[row].text = 0;
- win->_line[row].firstchar = 0;
- win->_line[row].lastchar = ToCols;
- if ((win->_flags & _SUBWIN)) {
- win->_line[row].text =
- &pline[win->_pary + row].text[win->_parx];
- }
- }
- }
+ new_lines = typeCalloc(struct ldat, (unsigned) (ToLines + 1));
+ if (new_lines == 0)
+ returnCode(ERR);
/*
- * Adjust the width of the columns:
+ * For each line in the target, allocate or adjust pointers for the
+ * corresponding text, depending on whether this is a window or a
+ * subwindow.
*/
- blank = win->_nc_bkgd;
- for (row = 0; row <= ToLines; row++) {
- NCURSES_CH_T *s = win->_line[row].text;
- int begin = (s == 0) ? 0 : size_x + 1;
+ for (row = 0; row <= ToLines; ++row) {
+ int begin = (row > size_y) ? 0 : (size_x + 1);
int end = ToCols;
+ NCURSES_CH_T *s;
- if_USE_SCROLL_HINTS(win->_line[row].oldindex = row);
-
- if (ToCols != size_x || s == 0) {
- if (!(win->_flags & _SUBWIN)) {
- win->_line[row].text = s = c_ALLOC(s, ToCols + 1);
- if (win->_line[row].text == 0)
- returnCode(ERR);
+ if (!(win->_flags & _SUBWIN)) {
+ if (row <= size_y) {
+ if (ToCols != size_x) {
+ if ((s = typeMalloc(NCURSES_CH_T, ToCols + 1)) == 0)
+ returnCode(cleanup_lines(new_lines, row));
+ for (col = 0; col <= ToCols; ++col) {
+ s[col] = (col <= size_x
+ ? win->_line[row].text[col]
+ : win->_nc_bkgd);
+ }
+ } else {
+ s = win->_line[row].text;
+ }
} else {
- win->_line[row].text = s =
- &pline[win->_pary + row].text[win->_parx];
+ if ((s = typeMalloc(NCURSES_CH_T, ToCols + 1)) == 0)
+ returnCode(cleanup_lines(new_lines, row));
+ for (col = 0; col <= ToCols; ++col)
+ s[col] = win->_nc_bkgd;
}
+ } else {
+ s = &pline[win->_pary + row].text[win->_parx];
+ }
+ if_USE_SCROLL_HINTS(new_lines[row].oldindex = row);
+ if (row <= size_y) {
+ new_lines[row].firstchar = win->_line[row].firstchar;
+ new_lines[row].lastchar = win->_line[row].lastchar;
+ }
+ if ((ToCols != size_x) || (row > size_y)) {
if (end >= begin) { /* growing */
- if (win->_line[row].firstchar < begin)
- win->_line[row].firstchar = begin;
- if (!(win->_flags & _SUBWIN)) {
- do {
- s[end] = blank;
- } while (--end >= begin);
- }
+ if (new_lines[row].firstchar < begin)
+ new_lines[row].firstchar = begin;
} else { /* shrinking */
- win->_line[row].firstchar = 0;
+ new_lines[row].firstchar = 0;
}
- win->_line[row].lastchar = ToCols;
+ new_lines[row].lastchar = ToCols;
}
+ new_lines[row].text = s;
}
/*
+ * Dispose of unwanted memory.
+ */
+ if (!(win->_flags & _SUBWIN)) {
+ if (ToCols == size_x) {
+ for (row = ToLines + 1; row <= size_y; row++) {
+ free(win->_line[row].text);
+ }
+ } else {
+ for (row = 0; row <= size_y; row++) {
+ free(win->_line[row].text);
+ }
+ }
+ }
+
+ free(win->_line);
+ win->_line = new_lines;
+
+ /*
* Finally, adjust the parameters showing screen size and cursor
* position:
*/
@@ -168,11 +221,17 @@ wresize(WINDOW *win, int ToLines, int ToCols)
if (win->_cury > win->_maxy)
win->_cury = win->_maxy;
+ /*
+ * Check for subwindows of this one, and readjust pointers to our text,
+ * if needed.
+ */
+ repair_subwindows(win);
+
#ifdef TRACE
- TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
- win->_begy, win->_begx,
- win->_maxy, win->_maxx,
- win->_regtop, win->_regbottom));
+ TR(TRACE_UPDATE, ("...beg (%ld, %ld), max(%ld,%ld), reg(%ld,%ld)",
+ (long) win->_begy, (long) win->_begx,
+ (long) win->_maxy, (long) win->_maxx,
+ (long) win->_regtop, (long) win->_regbottom));
if (_nc_tracing & TRACE_UPDATE)
_tracedump("...after:", win);
#endif
diff --git a/contrib/ncurses/ncurses/curses.priv.h b/contrib/ncurses/ncurses/curses.priv.h
index efac8ae3e6e2..cfb3e62a62b0 100644
--- a/contrib/ncurses/ncurses/curses.priv.h
+++ b/contrib/ncurses/ncurses/curses.priv.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +29,12 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
- * and: Thomas E. Dickey 1996-2002 *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
- * $Id: curses.priv.h,v 1.219 2002/05/25 12:22:43 tom Exp $
+ * $Id: curses.priv.h,v 1.314 2006/12/10 00:55:14 tom Exp $
*
* curses.priv.h
*
@@ -78,6 +78,11 @@ extern "C" {
# include <sys/param.h>
#endif
+#include <assert.h>
+#include <stdio.h>
+
+#include <errno.h>
+
#ifndef PATH_MAX
# if defined(_POSIX_PATH_MAX)
# define PATH_MAX _POSIX_PATH_MAX
@@ -88,11 +93,6 @@ extern "C" {
# endif
#endif
-#include <assert.h>
-#include <stdio.h>
-
-#include <errno.h>
-
#if DECL_ERRNO
extern int errno;
#endif
@@ -130,7 +130,9 @@ extern int errno;
/* EMX mouse support */
#ifdef __EMX__
-#define USE_EMX_MOUSE
+#define USE_EMX_MOUSE 1
+#else
+#define USE_EMX_MOUSE 0
#endif
#define DEFAULT_MAXCLICK 166
@@ -142,12 +144,15 @@ extern int errno;
*/
#if !NCURSES_EXT_FUNCS
#undef HAVE_SIZECHANGE
+#define HAVE_SIZECHANGE 0
#endif
#if HAVE_SIZECHANGE && defined(SIGWINCH)
#define USE_SIZECHANGE 1
#else
+#define USE_SIZECHANGE 0
#undef USE_SIGWINCH
+#define USE_SIGWINCH 0
#endif
/*
@@ -205,14 +210,6 @@ struct tries {
};
/*
- * Definitions for color pairs
- */
-#define C_SHIFT 8 /* we need more bits than there are colors */
-#define C_MASK ((1 << C_SHIFT) - 1)
-
-#define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
-
-/*
* Common/troublesome character definitions
*/
#define L_BRACE '{'
@@ -228,7 +225,9 @@ struct tries {
typedef struct
{
- short red, green, blue;
+ short red, green, blue; /* what color_content() returns */
+ short r, g, b; /* params to init_color() */
+ int init; /* true if we called init_color() */
}
color_t;
@@ -251,150 +250,267 @@ color_t;
#include <curses.h> /* we'll use -Ipath directive to get the right one! */
#include <term.h>
+#include <term_entry.h>
+#include <nc_tparm.h>
+
+#if NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT
+#define if_EXT_COLORS(stmt) stmt
+#define NetPair(value,p) (value).ext_color = (p), \
+ AttrOf(value) &= ALL_BUT_COLOR, \
+ AttrOf(value) |= (A_COLOR & COLOR_PAIR((p > 255) ? 255 : p))
+#define SetPair(value,p) (value).ext_color = (p)
+#define GetPair(value) (value).ext_color
+#define unColor(n) (AttrOf(n) & ALL_BUT_COLOR)
+#define GET_WINDOW_PAIR(w) (w)->_color
+#define SET_WINDOW_PAIR(w,p) (w)->_color = (p)
+#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b))
+#define VIDATTR(attr, pair) vid_attr(attr, pair, 0)
+#else
+#define if_EXT_COLORS(stmt) /* nothing */
+#define SetPair(value,p) RemAttr(value, A_COLOR), \
+ SetAttr(value, AttrOf(value) | (A_COLOR & COLOR_PAIR(p)))
+#define GetPair(value) PAIR_NUMBER(AttrOf(value))
+#define unColor(n) (AttrOf(n) & ALL_BUT_COLOR)
+#define GET_WINDOW_PAIR(w) PAIR_NUMBER(WINDOW_ATTRS(w))
+#define SET_WINDOW_PAIR(w,p) WINDOW_ATTRS(w) &= ALL_BUT_COLOR, \
+ WINDOW_ATTRS(w) |= (A_COLOR & COLOR_PAIR(p))
+#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b))
+#define VIDATTR(attr, pair) vidattr(attr)
+#endif
+
+#define WINDOW_ATTRS(w) ((w)->_attrs)
+
+#define SCREEN_ATTRS(s) (*((s)->_current_attr))
+#define GET_SCREEN_PAIR(s) GetPair(SCREEN_ATTRS(s))
+#define SET_SCREEN_PAIR(s,p) SetPair(SCREEN_ATTRS(s), p)
+/*
+ * Definitions for color pairs
+ */
+typedef unsigned colorpair_t; /* type big enough to store PAIR_OF() */
+#define C_SHIFT 9 /* we need more bits than there are colors */
+#define C_MASK ((1 << C_SHIFT) - 1)
+#define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
+#define isDefaultColor(c) ((c) >= COLOR_DEFAULT || (c) < 0)
+
+#define COLOR_DEFAULT C_MASK
+
+#if defined(USE_TERMLIB) && !defined(NEED_NCURSES_CH_T)
+
+#undef NCURSES_CH_T /* this is not a termlib feature */
+#define NCURSES_CH_T void /* ...but we need a pointer in SCREEN */
+
+#endif /* USE_TERMLIB */
+
+#ifndef USE_TERMLIB
struct ldat
{
- NCURSES_CH_T *text; /* text of the line */
- NCURSES_SIZE_T firstchar; /* first changed character in the line */
- NCURSES_SIZE_T lastchar; /* last changed character in the line */
- NCURSES_SIZE_T oldindex; /* index of the line at last update */
+ NCURSES_CH_T *text; /* text of the line */
+ NCURSES_SIZE_T firstchar; /* first changed character in the line */
+ NCURSES_SIZE_T lastchar; /* last changed character in the line */
+ NCURSES_SIZE_T oldindex; /* index of the line at last update */
};
+#endif /* USE_TERMLIB */
+
+typedef enum {
+ M_XTERM = -1 /* use xterm's mouse tracking? */
+ ,M_NONE = 0 /* no mouse device */
+#if USE_GPM_SUPPORT
+ ,M_GPM /* use GPM */
+#endif
+#if USE_SYSMOUSE
+ ,M_SYSMOUSE /* FreeBSD sysmouse on console */
+#endif
+} MouseType;
/*
- * Structure for soft labels.
+ * Structures for scrolling.
*/
+typedef struct {
+ unsigned long hashval;
+ int oldcount, newcount;
+ int oldindex, newindex;
+} HASHMAP;
+
+/*
+ * Structures for soft labels.
+ */
+
+struct _SLK;
+
+#ifndef USE_TERMLIB
+
typedef struct
{
- char *text; /* text for the label */
- char *form_text; /* formatted text (left/center/...) */
- int x; /* x coordinate of this field */
- char dirty; /* this label has changed */
- char visible; /* field is visible */
+ char *ent_text; /* text for the label */
+ char *form_text; /* formatted text (left/center/...) */
+ int ent_x; /* x coordinate of this field */
+ char dirty; /* this label has changed */
+ char visible; /* field is visible */
} slk_ent;
-typedef struct {
- char dirty; /* all labels have changed */
- char hidden; /* soft labels are hidden */
- struct _win_st *win;
+typedef struct _SLK {
+ char dirty; /* all labels have changed */
+ char hidden; /* soft labels are hidden */
+ WINDOW *win;
slk_ent *ent;
- char* buffer; /* buffer for labels */
- short maxlab; /* number of available labels */
- short labcnt; /* number of allocated labels */
- short maxlen; /* length of labels */
- chtype attr; /* soft label attribute */
+ short maxlab; /* number of available labels */
+ short labcnt; /* number of allocated labels */
+ short maxlen; /* length of labels */
+ NCURSES_CH_T attr; /* soft label attribute */
} SLK;
-typedef struct {
- unsigned long hashval;
- int oldcount, newcount;
- int oldindex, newindex;
-} HASHMAP;
+#endif /* USE_TERMLIB */
+
+typedef struct {
+ int line; /* lines to take, < 0 => from bottom*/
+ int (*hook)(WINDOW *, int); /* callback for user */
+ WINDOW *w; /* maybe we need this for cleanup */
+} ripoff_t;
+
+#if USE_GPM_SUPPORT
+#undef buttons /* term.h defines this, and gpm uses it! */
+#include <gpm.h>
+
+#ifdef HAVE_LIBDL
+/* link dynamically to GPM */
+typedef int *TYPE_gpm_fd;
+typedef int (*TYPE_Gpm_Open) (Gpm_Connect *, int);
+typedef int (*TYPE_Gpm_Close) (void);
+typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *);
+
+#define my_gpm_fd SP->_mouse_gpm_fd
+#define my_Gpm_Open SP->_mouse_Gpm_Open
+#define my_Gpm_Close SP->_mouse_Gpm_Close
+#define my_Gpm_GetEvent SP->_mouse_Gpm_GetEvent
+#else
+/* link statically to GPM */
+#define my_gpm_fd &gpm_fd
+#define my_Gpm_Open Gpm_Open
+#define my_Gpm_Close Gpm_Close
+#define my_Gpm_GetEvent Gpm_GetEvent
+#endif /* HAVE_LIBDL */
+#endif /* USE_GPM_SUPPORT */
+
+/*
+ * The SCREEN structure.
+ */
struct screen {
- int _ifd; /* input file ptr for screen */
- FILE *_ofp; /* output file ptr for screen */
- char *_setbuf; /* buffered I/O for output */
- int _buffered; /* setvbuf uses _setbuf data */
- int _checkfd; /* filedesc for typeahead check */
- struct term *_term; /* terminal type information */
- short _lines; /* screen lines */
- short _columns; /* screen columns */
- short _lines_avail; /* lines available for stdscr */
- short _topstolen; /* lines stolen from top */
-
- WINDOW *_curscr; /* current screen */
- WINDOW *_newscr; /* virtual screen to be updated to */
- WINDOW *_stdscr; /* screen's full-window context */
-
- struct tries *_keytry; /* "Try" for use with keypad mode */
- struct tries *_key_ok; /* Disabled keys via keyok(,FALSE) */
- bool _tried; /* keypad mode was initialized */
- bool _keypad_on; /* keypad mode is currently on */
-
- unsigned int _fifo[FIFO_SIZE]; /* input push-back buffer */
- short _fifohead, /* head of fifo queue */
- _fifotail, /* tail of fifo queue */
- _fifopeek, /* where to peek for next char */
- _fifohold; /* set if breakout marked */
-
- int _endwin; /* are we out of window mode? */
- attr_t _current_attr; /* terminal attribute current set */
- int _coloron; /* is color enabled? */
- int _cursor; /* visibility of the cursor */
- int _cursrow; /* physical cursor row */
- int _curscol; /* physical cursor column */
- int _nl; /* True if NL -> CR/NL is on */
- int _raw; /* True if in raw mode */
- int _cbreak; /* 1 if in cbreak mode */
- /* > 1 if in halfdelay mode */
- int _echo; /* True if echo on */
- int _use_meta; /* use the meta key? */
- SLK *_slk; /* ptr to soft key struct / NULL */
- int slk_format; /* selected format for this screen */
+ int _ifd; /* input file ptr for screen */
+ FILE *_ofp; /* output file ptr for screen */
+ char *_setbuf; /* buffered I/O for output */
+ bool _filtered; /* filter() was called */
+ bool _buffered; /* setvbuf uses _setbuf data */
+ int _checkfd; /* filedesc for typeahead check */
+ TERMINAL *_term; /* terminal type information */
+ short _lines; /* screen lines */
+ short _columns; /* screen columns */
+
+ short _lines_avail; /* lines available for stdscr */
+ short _topstolen; /* lines stolen from top */
+ ripoff_t _rippedoff[5]; /* list of lines stolen */
+ int _rip_count; /* ...and total lines stolen */
+
+ WINDOW *_curscr; /* current screen */
+ WINDOW *_newscr; /* virtual screen to be updated to */
+ WINDOW *_stdscr; /* screen's full-window context */
+
+ struct tries *_keytry; /* "Try" for use with keypad mode */
+ struct tries *_key_ok; /* Disabled keys via keyok(,FALSE) */
+ bool _tried; /* keypad mode was initialized */
+ bool _keypad_on; /* keypad mode is currently on */
+
+ bool _called_wgetch; /* check for recursion in wgetch() */
+ int _fifo[FIFO_SIZE]; /* input push-back buffer */
+ short _fifohead, /* head of fifo queue */
+ _fifotail, /* tail of fifo queue */
+ _fifopeek, /* where to peek for next char */
+ _fifohold; /* set if breakout marked */
+
+ int _endwin; /* are we out of window mode? */
+ NCURSES_CH_T *_current_attr; /* holds current attributes set */
+ int _coloron; /* is color enabled? */
+ int _color_defs; /* are colors modified */
+ int _cursor; /* visibility of the cursor */
+ int _cursrow; /* physical cursor row */
+ int _curscol; /* physical cursor column */
+ bool _notty; /* true if we cannot switch non-tty */
+ int _nl; /* True if NL -> CR/NL is on */
+ int _raw; /* True if in raw mode */
+ int _cbreak; /* 1 if in cbreak mode */
+ /* > 1 if in halfdelay mode */
+ int _echo; /* True if echo on */
+ int _use_meta; /* use the meta key? */
+ struct _SLK *_slk; /* ptr to soft key struct / NULL */
+ int slk_format; /* selected format for this screen */
/* cursor movement costs; units are 10ths of milliseconds */
#if NCURSES_NO_PADDING
- int _no_padding; /* flag to set if padding disabled */
+ int _no_padding; /* flag to set if padding disabled */
#endif
- int _char_padding; /* cost of character put */
- int _cr_cost; /* cost of (carriage_return) */
- int _cup_cost; /* cost of (cursor_address) */
- int _home_cost; /* cost of (cursor_home) */
- int _ll_cost; /* cost of (cursor_to_ll) */
+ int _char_padding; /* cost of character put */
+ int _cr_cost; /* cost of (carriage_return) */
+ int _cup_cost; /* cost of (cursor_address) */
+ int _home_cost; /* cost of (cursor_home) */
+ int _ll_cost; /* cost of (cursor_to_ll) */
#if USE_HARD_TABS
- int _ht_cost; /* cost of (tab) */
- int _cbt_cost; /* cost of (backtab) */
+ int _ht_cost; /* cost of (tab) */
+ int _cbt_cost; /* cost of (backtab) */
#endif /* USE_HARD_TABS */
- int _cub1_cost; /* cost of (cursor_left) */
- int _cuf1_cost; /* cost of (cursor_right) */
- int _cud1_cost; /* cost of (cursor_down) */
- int _cuu1_cost; /* cost of (cursor_up) */
- int _cub_cost; /* cost of (parm_cursor_left) */
- int _cuf_cost; /* cost of (parm_cursor_right) */
- int _cud_cost; /* cost of (parm_cursor_down) */
- int _cuu_cost; /* cost of (parm_cursor_up) */
- int _hpa_cost; /* cost of (column_address) */
- int _vpa_cost; /* cost of (row_address) */
+ int _cub1_cost; /* cost of (cursor_left) */
+ int _cuf1_cost; /* cost of (cursor_right) */
+ int _cud1_cost; /* cost of (cursor_down) */
+ int _cuu1_cost; /* cost of (cursor_up) */
+ int _cub_cost; /* cost of (parm_cursor_left) */
+ int _cuf_cost; /* cost of (parm_cursor_right) */
+ int _cud_cost; /* cost of (parm_cursor_down) */
+ int _cuu_cost; /* cost of (parm_cursor_up) */
+ int _hpa_cost; /* cost of (column_address) */
+ int _vpa_cost; /* cost of (row_address) */
/* used in tty_update.c, must be chars */
- int _ed_cost; /* cost of (clr_eos) */
- int _el_cost; /* cost of (clr_eol) */
- int _el1_cost; /* cost of (clr_bol) */
- int _dch1_cost; /* cost of (delete_character) */
- int _ich1_cost; /* cost of (insert_character) */
- int _dch_cost; /* cost of (parm_dch) */
- int _ich_cost; /* cost of (parm_ich) */
- int _ech_cost; /* cost of (erase_chars) */
- int _rep_cost; /* cost of (repeat_char) */
- int _hpa_ch_cost; /* cost of (column_address) */
- int _cup_ch_cost; /* cost of (cursor_address) */
- int _cuf_ch_cost; /* cost of (parm_cursor_right) */
- int _inline_cost; /* cost of inline-move */
- int _smir_cost; /* cost of (enter_insert_mode) */
- int _rmir_cost; /* cost of (exit_insert_mode) */
- int _ip_cost; /* cost of (insert_padding) */
+ int _ed_cost; /* cost of (clr_eos) */
+ int _el_cost; /* cost of (clr_eol) */
+ int _el1_cost; /* cost of (clr_bol) */
+ int _dch1_cost; /* cost of (delete_character) */
+ int _ich1_cost; /* cost of (insert_character) */
+ int _dch_cost; /* cost of (parm_dch) */
+ int _ich_cost; /* cost of (parm_ich) */
+ int _ech_cost; /* cost of (erase_chars) */
+ int _rep_cost; /* cost of (repeat_char) */
+ int _hpa_ch_cost; /* cost of (column_address) */
+ int _cup_ch_cost; /* cost of (cursor_address) */
+ int _cuf_ch_cost; /* cost of (parm_cursor_right) */
+ int _inline_cost; /* cost of inline-move */
+ int _smir_cost; /* cost of (enter_insert_mode) */
+ int _rmir_cost; /* cost of (exit_insert_mode) */
+ int _ip_cost; /* cost of (insert_padding) */
/* used in lib_mvcur.c */
- char * _address_cursor;
+ char * _address_cursor;
/* used in tty_update.c */
- int _scrolling; /* 1 if terminal's smart enough to */
+ int _scrolling; /* 1 if terminal's smart enough to */
/* used in lib_color.c */
- color_t *_color_table; /* screen's color palette */
- int _color_count; /* count of colors in palette */
- unsigned short *_color_pairs; /* screen's color pair list */
- int _pair_count; /* count of color pairs */
+ color_t *_color_table; /* screen's color palette */
+ int _color_count; /* count of colors in palette */
+ colorpair_t *_color_pairs; /* screen's color pair list */
+ int _pair_count; /* count of color pairs */
#if NCURSES_EXT_FUNCS
- bool _default_color; /* use default colors */
- bool _has_sgr_39_49; /* has ECMA default color support */
- int _default_fg; /* assumed default foreground */
- int _default_bg; /* assumed default background */
+ bool _default_color; /* use default colors */
+ bool _has_sgr_39_49; /* has ECMA default color support */
+ int _default_fg; /* assumed default foreground */
+ int _default_bg; /* assumed default background */
#endif
- chtype _xmc_suppress; /* attributes to suppress if xmc */
- chtype _xmc_triggers; /* attributes to process if xmc */
- chtype _acs_map[ACS_LEN];
+ chtype _ok_attributes; /* valid attributes for terminal */
+ chtype _xmc_suppress; /* attributes to suppress if xmc */
+ chtype _xmc_triggers; /* attributes to process if xmc */
+ chtype * _acs_map; /* the real alternate-charset map */
+ bool * _screen_acs_map;
+
/* used in lib_vidattr.c */
- bool _use_rmso; /* true if we may use 'rmso' */
- bool _use_rmul; /* true if we may use 'rmul' */
+ bool _use_rmso; /* true if we may use 'rmso' */
+ bool _use_rmul; /* true if we may use 'rmul' */
/*
* These data correspond to the state of the idcok() and idlok()
@@ -403,21 +519,57 @@ struct screen {
* is given as an argument. However, ncurses implements this logic
* only for the newscr/curscr update process, _not_ per-window.
*/
- bool _nc_sp_idlok;
- bool _nc_sp_idcok;
+ bool _nc_sp_idlok;
+ bool _nc_sp_idcok;
#define _nc_idlok SP->_nc_sp_idlok
#define _nc_idcok SP->_nc_sp_idcok
/*
* These are the data that support the mouse interface.
*/
- int _maxclick;
- bool (*_mouse_event) (SCREEN *);
- bool (*_mouse_inline)(SCREEN *);
- bool (*_mouse_parse) (int);
- void (*_mouse_resume)(SCREEN *);
- void (*_mouse_wrap) (SCREEN *);
- int _mouse_fd; /* file-descriptor, if any */
+ bool _mouse_initialized;
+ MouseType _mouse_type;
+ int _maxclick;
+ bool (*_mouse_event) (SCREEN *);
+ bool (*_mouse_inline)(SCREEN *);
+ bool (*_mouse_parse) (int);
+ void (*_mouse_resume)(SCREEN *);
+ void (*_mouse_wrap) (SCREEN *);
+ int _mouse_fd; /* file-descriptor, if any */
+ bool _mouse_active; /* true if initialized */
+ mmask_t _mouse_mask;
+ NCURSES_CONST char *_mouse_xtermcap; /* string to enable/disable mouse */
+ MEVENT _mouse_events[EV_MAX]; /* hold the last mouse event seen */
+ MEVENT *_mouse_eventp; /* next free slot in event queue */
+
+#if USE_GPM_SUPPORT
+ bool _mouse_gpm_loaded;
+ bool _mouse_gpm_found;
+#ifdef HAVE_LIBDL
+ TYPE_gpm_fd _mouse_gpm_fd;
+ TYPE_Gpm_Open _mouse_Gpm_Open;
+ TYPE_Gpm_Close _mouse_Gpm_Close;
+ TYPE_Gpm_GetEvent _mouse_Gpm_GetEvent;
+#endif
+ Gpm_Connect _mouse_gpm_connect;
+#endif /* USE_GPM_SUPPORT */
+
+#if USE_EMX_MOUSE
+ int _emxmouse_wfd;
+ int _emxmouse_thread;
+ int _emxmouse_activated;
+ char _emxmouse_buttons[4];
+#endif
+
+#if USE_SYSMOUSE
+ MEVENT _sysmouse_fifo[FIFO_SIZE];
+ int _sysmouse_head;
+ int _sysmouse_tail;
+ int _sysmouse_char_width; /* character width */
+ int _sysmouse_char_height; /* character height */
+ int _sysmouse_old_buttons;
+ int _sysmouse_new_buttons;
+#endif
/*
* This supports automatic resizing
@@ -426,60 +578,68 @@ struct screen {
int (*_resize)(int,int);
#endif
- /*
+ /*
* These are data that support the proper handling of the panel stack on an
* per screen basis.
*/
- struct panelhook _panelHook;
+ struct panelhook _panelHook;
/*
* Linked-list of all windows, to support '_nc_resizeall()' and
* '_nc_freeall()'
*/
- WINDOWLIST *_nc_sp_windows;
+ WINDOWLIST *_nc_sp_windows;
#define _nc_windows SP->_nc_sp_windows
- bool _sig_winch;
- SCREEN *_next_screen;
+ bool _sig_winch;
+ SCREEN *_next_screen;
/* hashes for old and new lines */
unsigned long *oldhash, *newhash;
- HASHMAP *hashtab;
+ HASHMAP *hashtab;
int hashtab_len;
- bool _cleanup; /* cleanup after int/quit signal */
- int (*_outch)(int); /* output handler if not putc */
-};
+ bool _cleanup; /* cleanup after int/quit signal */
+ int (*_outch)(int); /* output handler if not putc */
-extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
+ int _legacy_coding; /* see use_legacy_coding() */
-#if NCURSES_NOMACROS
-#include <nomacros.h>
+ /*
+ * ncurses/ncursesw are the same up to this point.
+ */
+#if USE_WIDEC_SUPPORT
+ /* recent versions of 'screen' have partially-working support for
+ * UTF-8, but do not permit ACS at the same time (see tty_update.c).
+ */
+ bool _screen_acs_fix;
#endif
+};
+
+extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
-/*
- * The margins are used in resizeterm() to retain the original layout after
- * resizing.
- */
WINDOWLIST {
+ WINDOW win; /* first, so WINDOW_EXT() works */
WINDOWLIST *next;
-#if HAVE_RESIZETERM
- int l_margin;
- int r_margin;
- int t_margin;
- int b_margin;
+#ifdef _XOPEN_SOURCE_EXTENDED
+ char addch_work[(MB_LEN_MAX * 9) + 1];
+ unsigned addch_used; /* number of bytes in addch_work[] */
+ int addch_x; /* x-position for addch_work[] */
+ int addch_y; /* y-position for addch_work[] */
#endif
- WINDOW win;
};
-typedef struct {
- int line; /* lines to take, < 0 => from bottom*/
- int (*hook)(struct _win_st *, int); /* callback for user */
- struct _win_st *w; /* maybe we need this for cleanup */
-} ripoff_t;
+#define WINDOW_EXT(win,field) (((WINDOWLIST *)(win))->field)
+
+/* usually in <limits.h> */
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
/* The terminfo source is assumed to be 7-bit ASCII */
#define is7bits(c) ((unsigned)(c) < 128)
+/* Checks for isprint() should be done on 8-bit characters (non-wide) */
+#define is8bits(c) ((unsigned)(c) <= UCHAR_MAX)
+
#ifndef min
#define min(a,b) ((a) > (b) ? (b) : (a))
#endif
@@ -530,22 +690,46 @@ typedef struct {
#define O_BINARY 0
#endif
+#ifdef TRACE
+#define TRACE_OUTCHARS(n) _nc_outchars += (n);
+#else
+#define TRACE_OUTCHARS(n) /* nothing */
+#endif
+
#define UChar(c) ((unsigned char)(c))
#define ChCharOf(c) ((c) & (chtype)A_CHARTEXT)
-#define ChAttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
+#define ChAttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
+
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
+#endif
#if USE_WIDEC_SUPPORT /* { */
+#define isEILSEQ(status) ((status == (size_t)-1) && (errno == EILSEQ))
+
+#define init_mb(state) memset(&state, 0, sizeof(state))
+
+#if NCURSES_EXT_COLORS
+#define NulColor , 0
+#else
+#define NulColor /* nothing */
+#endif
+
+#define NulChar 0,0,0,0 /* FIXME: see CCHARW_MAX */
#define CharOf(c) ((c).chars[0])
#define AttrOf(c) ((c).attr)
-#define AddAttr(c,a) (c).attr |= a
-#define RemAttr(c,a) (c).attr &= ~(a)
-#define SetAttr(c,a) (c).attr = a
-#define NewChar(ch) { ChAttrOf(ch), { ChCharOf(ch) } }
-#define NewChar2(c,a) { a, { c } }
-#define CharEq(a,b) (!memcmp(&a, &b, sizeof(a)))
-#define SetChar(ch,c,a) do { \
+#define AddAttr(c,a) AttrOf(c) |= ((a) & A_ATTRIBUTES)
+#define RemAttr(c,a) AttrOf(c) &= ~((a) & A_ATTRIBUTES)
+#define SetAttr(c,a) AttrOf(c) = ((a) & A_ATTRIBUTES)
+#define NewChar2(c,a) { a, { c, NulChar } NulColor }
+#define NewChar(ch) NewChar2(ChCharOf(ch), ChAttrOf(ch))
+#define CharEq(a,b) (!memcmp(&(a), &(b), sizeof(a)))
+#define SetChar(ch,c,a) do { \
NCURSES_CH_T *_cp = &ch; \
- memset(_cp,0,sizeof(ch)); _cp->chars[0] = c; _cp->attr = a; \
+ memset(_cp, 0, sizeof(ch)); \
+ _cp->chars[0] = (c); \
+ _cp->attr = (a); \
+ if_EXT_COLORS(SetPair(ch, PAIR_NUMBER(a))); \
} while (0)
#define CHREF(wch) (&wch)
#define CHDEREF(wch) (*wch)
@@ -553,55 +737,76 @@ typedef struct {
#define CARG_CH_T const NCURSES_CH_T *
#define PUTC_DATA char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \
mbstate_t PUT_st; wchar_t PUTC_ch
-#define PUTC(ch,b) do { if(!isnac(ch)) { \
- memset (&PUT_st, '\0', sizeof (PUT_st)); \
- PUTC_i = 0; \
- do { \
- PUTC_ch = PUTC_i < CCHARW_MAX ? \
- (ch).chars[PUTC_i] : L'\0'; \
+#define PUTC_INIT init_mb (PUT_st)
+#define PUTC(ch,b) do { if(!isWidecExt(ch)) { \
+ if (Charable(ch)) { \
+ fputc(CharOf(ch), b); \
+ TRACE_OUTCHARS(1); \
+ } else { \
+ PUTC_INIT; \
+ for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { \
+ PUTC_ch = (ch).chars[PUTC_i]; \
+ if (PUTC_ch == L'\0') \
+ break; \
PUTC_n = wcrtomb(PUTC_buf, \
(ch).chars[PUTC_i], &PUT_st); \
- if (PUTC_ch == L'\0') \
- --PUTC_n; \
- if (PUTC_n <= 0) \
+ if (PUTC_n <= 0) { \
+ if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) \
+ putc(PUTC_ch,b); \
break; \
+ } \
fwrite(PUTC_buf, (unsigned) PUTC_n, 1, b); \
- ++PUTC_i; \
- } while (PUTC_ch != L'\0'); \
- } } while (0)
+ } \
+ TRACE_OUTCHARS(PUTC_i); \
+ } } } while (0)
-#define BLANK { WA_NORMAL, ' ' }
+#define BLANK { WA_NORMAL, {' '} NulColor }
+#define ZEROS { WA_NORMAL, {'\0'} NulColor }
#define ISBLANK(ch) ((ch).chars[0] == L' ' && (ch).chars[1] == L'\0')
-#define WA_NAC 1
-#define isnac(ch) (AttrOf(ch) & WA_NAC)
+ /*
+ * Wide characters cannot be represented in the A_CHARTEXT mask of
+ * attr_t's but an application might have set a narrow character there.
+ * But even in that case, it would only be a printable character, or
+ * zero. Otherwise we can use those bits to tell if a cell is the
+ * first or extension part of a wide character.
+ */
+#define WidecExt(ch) (AttrOf(ch) & A_CHARTEXT)
+#define isWidecBase(ch) (WidecExt(ch) == 1)
+#define isWidecExt(ch) (WidecExt(ch) > 1 && WidecExt(ch) < 32)
+#define SetWidecExt(dst, ext) AttrOf(dst) &= ~A_CHARTEXT, \
+ AttrOf(dst) |= (ext + 1)
+
#define if_WIDEC(code) code
-#define Charable(ch) (!isnac(ch) && \
- (ch).chars[1] == L'\0' && \
- (wctob(CharOf(ch)) == (char)CharOf(ch)))
+#define Charable(ch) ((SP != 0 && SP->_legacy_coding) \
+ || (AttrOf(ch) & A_ALTCHARSET) \
+ || (!isWidecExt(ch) && \
+ (ch).chars[1] == L'\0' && \
+ _nc_is_charable(CharOf(ch))))
#define L(ch) L ## ch
#else /* }{ */
#define CharOf(c) ChCharOf(c)
#define AttrOf(c) ChAttrOf(c)
-#define AddAttr(c,a) c |= a
-#define RemAttr(c,a) c &= ~(a & A_ATTRIBUTES)
-#define SetAttr(c,a) c = (c & ~A_ATTRIBUTES) | a
+#define AddAttr(c,a) c |= (a)
+#define RemAttr(c,a) c &= ~((a) & A_ATTRIBUTES)
+#define SetAttr(c,a) c = ((c) & ~A_ATTRIBUTES) | (a)
#define NewChar(ch) (ch)
-#define NewChar2(c,a) (c | a)
-#define CharEq(a,b) (a == b)
-#define SetChar(ch,c,a) ch = c | a
+#define NewChar2(c,a) ((c) | (a))
+#define CharEq(a,b) ((a) == (b))
+#define SetChar(ch,c,a) ch = (c) | (a)
#define CHREF(wch) wch
#define CHDEREF(wch) wch
#define ARG_CH_T NCURSES_CH_T
#define CARG_CH_T NCURSES_CH_T
#define PUTC_DATA int data = 0
-#define PUTC(a,b) do { data = CharOf(ch); putc(data,b); } while (0)
+#define PUTC(ch,b) do { data = CharOf(ch); putc(data,b); } while (0)
#define BLANK (' '|A_NORMAL)
+#define ZEROS ('\0'|A_NORMAL)
#define ISBLANK(ch) (CharOf(ch) == ' ')
-#define isnac(ch) (0)
+#define isWidecExt(ch) (0)
#define if_WIDEC(code) /* nothing */
#define L(ch) ch
@@ -616,6 +821,11 @@ typedef struct {
#define CHANGED -1
+#define LEGALYX(w, y, x) \
+ ((w) != 0 && \
+ ((x) >= 0 && (x) <= (w)->_maxx && \
+ (y) >= 0 && (y) <= (w)->_maxy))
+
#define CHANGED_CELL(line,col) \
if (line->firstchar == _NOCHANGE) \
line->firstchar = line->lastchar = col; \
@@ -650,6 +860,23 @@ typedef struct {
#include <nc_alloc.h>
/*
+ * TTY bit definition for converting tabs to spaces.
+ */
+#ifdef TAB3
+# define OFLAGS_TABS TAB3 /* POSIX specifies TAB3 */
+#else
+# ifdef XTABS
+# define OFLAGS_TABS XTABS /* XTABS is usually the "same" */
+# else
+# ifdef OXTABS
+# define OFLAGS_TABS OXTABS /* the traditional BSD equivalent */
+# else
+# define OFLAGS_TABS 0
+# endif
+# endif
+#endif
+
+/*
* Prefixes for call/return points of library function traces. We use these to
* instrument the public functions so that the traces can be easily transformed
* into regression scripts.
@@ -659,80 +886,114 @@ typedef struct {
#define T_RETURN(fmt) "return }" fmt
#ifdef TRACE
+
+#define START_TRACE() \
+ if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
+ int t = _nc_getenv_num("NCURSES_TRACE"); \
+ if (t >= 0) \
+ trace((unsigned) t); \
+ }
+
#define TR(n, a) if (_nc_tracing & (n)) _tracef a
#define T(a) TR(TRACE_CALLS, a)
#define TPUTS_TRACE(s) _nc_tputs_trace = s;
#define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
-#define returnAttr(code) TRACE_RETURN(code,attr_t)
-#define returnChar(code) TRACE_RETURN(code,chtype)
-#define returnCode(code) TRACE_RETURN(code,int)
-#define returnPtr(code) TRACE_RETURN(code,ptr)
-#define returnSP(code) TRACE_RETURN(code,sp)
-#define returnVoid T((T_RETURN(""))); return
-#define returnWin(code) TRACE_RETURN(code,win)
-extern NCURSES_EXPORT(SCREEN *) _nc_retrace_sp (SCREEN *);
-extern NCURSES_EXPORT(WINDOW *) _nc_retrace_win (WINDOW *);
-extern NCURSES_EXPORT(attr_t) _nc_retrace_attr_t (attr_t);
-extern NCURSES_EXPORT(attr_t) _nc_retrace_chtype (chtype);
-extern NCURSES_EXPORT(char *) _nc_retrace_ptr (char *);
-extern NCURSES_EXPORT(char *) _nc_trace_ttymode(TTY *tty);
-extern NCURSES_EXPORT(char *) _nc_varargs (const char *, va_list);
-extern NCURSES_EXPORT(const char *) _nc_altcharset_name(attr_t, chtype);
-extern NCURSES_EXPORT(int) _nc_retrace_int (int);
-extern NCURSES_EXPORT(void) _nc_fifo_dump (void);
+
+#define returnAttr(code) TRACE_RETURN(code,attr_t)
+#define returnBits(code) TRACE_RETURN(code,unsigned)
+#define returnBool(code) TRACE_RETURN(code,bool)
+#define returnCPtr(code) TRACE_RETURN(code,cptr)
+#define returnCVoidPtr(code) TRACE_RETURN(code,cvoid_ptr)
+#define returnChar(code) TRACE_RETURN(code,chtype)
+#define returnCode(code) TRACE_RETURN(code,int)
+#define returnPtr(code) TRACE_RETURN(code,ptr)
+#define returnSP(code) TRACE_RETURN(code,sp)
+#define returnVoid T((T_RETURN(""))); return
+#define returnVoidPtr(code) TRACE_RETURN(code,void_ptr)
+#define returnWin(code) TRACE_RETURN(code,win)
+
+extern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (NCURSES_BOOL);
+extern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *);
+extern NCURSES_EXPORT(SCREEN *) _nc_retrace_sp (SCREEN *);
+extern NCURSES_EXPORT(WINDOW *) _nc_retrace_win (WINDOW *);
+extern NCURSES_EXPORT(attr_t) _nc_retrace_attr_t (attr_t);
+extern NCURSES_EXPORT(char *) _nc_retrace_ptr (char *);
+extern NCURSES_EXPORT(char *) _nc_trace_ttymode(TTY *tty);
+extern NCURSES_EXPORT(char *) _nc_varargs (const char *, va_list);
+extern NCURSES_EXPORT(chtype) _nc_retrace_chtype (chtype);
+extern NCURSES_EXPORT(const char *) _nc_altcharset_name(attr_t, chtype);
+extern NCURSES_EXPORT(const char *) _nc_retrace_cptr (const char *);
+extern NCURSES_EXPORT(int) _nc_retrace_int (int);
+extern NCURSES_EXPORT(unsigned) _nc_retrace_unsigned (unsigned);
+extern NCURSES_EXPORT(void *) _nc_retrace_void_ptr (void *);
+extern NCURSES_EXPORT(void) _nc_fifo_dump (void);
extern NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace;
-extern NCURSES_EXPORT_VAR(long) _nc_outchars;
-extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
+extern NCURSES_EXPORT_VAR(long) _nc_outchars;
+extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
+
#if USE_WIDEC_SUPPORT
extern NCURSES_EXPORT(const char *) _nc_viswbuf2 (int, const wchar_t *);
-extern NCURSES_EXPORT(const char *) _nc_viscbuf2 (int, const cchar_t *, int);
-extern NCURSES_EXPORT(const char *) _nc_viscbuf (const cchar_t *, int);
+extern NCURSES_EXPORT(const char *) _nc_viswbufn (const wchar_t *, int);
#endif
-#else
+
+extern NCURSES_EXPORT(const char *) _nc_viscbuf2 (int, const NCURSES_CH_T *, int);
+extern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int);
+
+#else /* !TRACE */
+
+#define START_TRACE() /* nothing */
+
#define T(a)
#define TR(n, a)
#define TPUTS_TRACE(s)
-#define returnAttr(code) return code
-#define returnChar(code) return code
-#define returnCode(code) return code
-#define returnPtr(code) return code
-#define returnSP(code) return code
-#define returnVoid return
-#define returnWin(code) return code
-#endif
+
+#define returnAttr(code) return code
+#define returnBits(code) return code
+#define returnBool(code) return code
+#define returnCPtr(code) return code
+#define returnCVoidPtr(code) return code
+#define returnChar(code) return code
+#define returnCode(code) return code
+#define returnPtr(code) return code
+#define returnSP(code) return code
+#define returnVoid return
+#define returnVoidPtr(code) return code
+#define returnWin(code) return code
+
+#endif /* TRACE/!TRACE */
+
+/*
+ * Return-codes for tgetent() and friends.
+ */
+#define TGETENT_YES 1 /* entry is found */
+#define TGETENT_NO 0 /* entry is not found */
+#define TGETENT_ERR -1 /* an error occurred */
+
+extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
+extern NCURSES_EXPORT(const char *) _nc_visbufn (const char *, int);
#define empty_module(name) \
extern NCURSES_EXPORT(void) name (void); \
NCURSES_EXPORT(void) name (void) { }
-/* used in _nc_visbuf() whether or not we're tracing */
-extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
-
#define ALL_BUT_COLOR ((chtype)~(A_COLOR))
-#define IGNORE_COLOR_OFF FALSE
-#define NONBLANK_ATTR (A_BOLD|A_DIM|A_BLINK)
+#define NONBLANK_ATTR (A_NORMAL|A_BOLD|A_DIM|A_BLINK)
#define XMC_CHANGES(c) ((c) & SP->_xmc_suppress)
-
#define toggle_attr_on(S,at) {\
- if (PAIR_NUMBER(at) > 0)\
+ if (PAIR_NUMBER(at) > 0) {\
(S) = ((S) & ALL_BUT_COLOR) | (at);\
- else\
+ } else {\
(S) |= (at);\
+ }\
TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
#define toggle_attr_off(S,at) {\
- if (IGNORE_COLOR_OFF == TRUE) {\
- if (PAIR_NUMBER(at) == 0xff) /* turn off color */\
- (S) &= ~(at);\
- else /* leave color alone */\
- (S) &= ~((at)&ALL_BUT_COLOR);\
+ if (PAIR_NUMBER(at) > 0) {\
+ (S) &= ~(at|A_COLOR);\
} else {\
- if (PAIR_NUMBER(at) > 0x00) /* turn off color */\
- (S) &= ~(at|A_COLOR);\
- else /* leave color alone */\
- (S) &= ~(at);\
+ (S) &= ~(at);\
}\
TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
@@ -749,15 +1010,15 @@ extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
: ((enter_insert_mode && exit_insert_mode) \
? SP->_smir_cost + SP->_rmir_cost + (SP->_ip_cost * count) \
: ((insert_character != 0) \
- ? (SP->_ich1_cost * count) \
+ ? ((SP->_ich1_cost + SP->_ip_cost) * count) \
: INFINITY)))
#if USE_XMC_SUPPORT
-#define UpdateAttrs(a) if (SP->_current_attr != (a)) { \
- attr_t chg = SP->_current_attr; \
- vidattr((a)); \
+#define UpdateAttrs(c) if (!SameAttrOf(SCREEN_ATTRS(SP), c)) { \
+ attr_t chg = AttrOf(SCREEN_ATTRS(SP)); \
+ VIDATTR(AttrOf(c), GetPair(c)); \
if (magic_cookie_glitch > 0 \
- && XMC_CHANGES((chg ^ SP->_current_attr))) { \
+ && XMC_CHANGES((chg ^ AttrOf(SCREEN_ATTRS(SP))))) { \
T(("%s @%d before glitch %d,%d", \
__FILE__, __LINE__, \
SP->_cursrow, \
@@ -766,8 +1027,21 @@ extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
} \
}
#else
-#define UpdateAttrs(a) if (SP->_current_attr != (a)) \
- vidattr((a));
+#define UpdateAttrs(c) if (!SameAttrOf(SCREEN_ATTRS(SP), c)) \
+ VIDATTR(AttrOf(c), GetPair(c));
+#endif
+
+/*
+ * Macros to make additional parameter to implement wgetch_events()
+ */
+#ifdef NCURSES_WGETCH_EVENTS
+#define EVENTLIST_0th(param) param
+#define EVENTLIST_1st(param) param
+#define EVENTLIST_2nd(param) , param
+#else
+#define EVENTLIST_0th(param) void
+#define EVENTLIST_1st(param) /* nothing */
+#define EVENTLIST_2nd(param) /* nothing */
#endif
#if NCURSES_EXPANDED && NCURSES_EXT_FUNCS
@@ -790,7 +1064,7 @@ extern NCURSES_EXPORT(int) _nc_InsCharCost (int);
#undef UpdateAttrs
#define UpdateAttrs(c) _nc_UpdateAttrs(c)
-extern NCURSES_EXPORT(void) _nc_UpdateAttrs (chtype);
+extern NCURSES_EXPORT(void) _nc_UpdateAttrs (NCURSES_CH_T);
#else
@@ -802,6 +1076,13 @@ extern NCURSES_EXPORT(void) _nc_expanded (void);
#define getcwd(buf,len) getwd(buf)
#endif
+/* charable.c */
+#if USE_WIDEC_SUPPORT
+extern NCURSES_EXPORT(bool) _nc_is_charable(wchar_t);
+extern NCURSES_EXPORT(int) _nc_to_char(wint_t);
+extern NCURSES_EXPORT(wint_t) _nc_to_widechar(int);
+#endif
+
/* doupdate.c */
#if USE_XMC_SUPPORT
extern NCURSES_EXPORT(void) _nc_do_xmc_glitch (attr_t);
@@ -816,13 +1097,24 @@ extern NCURSES_EXPORT(void) _nc_linedump (void);
extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int); /* used by 'tack' program */
-/* lib_addstr.c */
+/* lib_addch.c */
#if USE_WIDEC_SUPPORT
+NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch);
+#endif
+
+/* lib_addstr.c */
+#if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB)
extern NCURSES_EXPORT(int) _nc_wchstrlen(const cchar_t *);
#endif
+/* lib_color.c */
+extern NCURSES_EXPORT(bool) _nc_reset_colors(void);
+
/* lib_getch.c */
-extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, unsigned long *, int);
+extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, unsigned long *, int EVENTLIST_2nd(_nc_eventlist *));
+
+/* lib_insch.c */
+extern NCURSES_EXPORT(int) _nc_insert_ch(WINDOW *, chtype);
/* lib_mvcur.c */
#define INFINITY 1000000 /* cost: too high to use */
@@ -842,6 +1134,20 @@ extern NCURSES_EXPORT(int) _nc_has_mouse (void);
/* lib_mvcur.c */
#define INFINITY 1000000 /* cost: too high to use */
+#define BAUDBYTE 9 /* 9 = 7 bits + 1 parity + 1 stop */
+
+/* lib_setup.c */
+extern NCURSES_EXPORT(char *) _nc_get_locale(void);
+extern NCURSES_EXPORT(int) _nc_unicode_locale(void);
+extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(void);
+extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, bool);
+
+/* lib_tstp.c */
+#if USE_SIGWINCH
+extern NCURSES_EXPORT(int) _nc_handle_sigwinch(int);
+#else
+#define _nc_handle_sigwinch(a) /* nothing */
+#endif
/* lib_wacs.c */
#if USE_WIDEC_SUPPORT
@@ -849,9 +1155,10 @@ extern NCURSES_EXPORT(void) _nc_init_wacs(void);
#endif
typedef struct {
- char *s_head;
- char *s_tail;
- size_t s_size;
+ char *s_head; /* beginning of the string (may be null) */
+ char *s_tail; /* end of the string (may be null) */
+ size_t s_size; /* current remaining size available */
+ size_t s_init; /* total size available */
} string_desc;
/* strings.c */
@@ -861,16 +1168,6 @@ extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, string_desc *)
extern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc *, const char *);
extern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc *, const char *);
-extern NCURSES_EXPORT(void) _nc_mvcur_init (void);
-extern NCURSES_EXPORT(void) _nc_mvcur_resume (void);
-extern NCURSES_EXPORT(void) _nc_mvcur_wrap (void);
-
-extern NCURSES_EXPORT(int) _nc_scrolln (int, int, int, int);
-
-extern NCURSES_EXPORT(void) _nc_screen_init (void);
-extern NCURSES_EXPORT(void) _nc_screen_resume (void);
-extern NCURSES_EXPORT(void) _nc_screen_wrap (void);
-
#if !HAVE_STRSTR
#define strstr _nc_strstr
extern NCURSES_EXPORT(char *) _nc_strstr (const char *, const char *);
@@ -880,42 +1177,63 @@ extern NCURSES_EXPORT(char *) _nc_strstr (const char *, const char *);
extern NCURSES_EXPORT(char *) _nc_printf_string (const char *, va_list);
/* tries.c */
-extern NCURSES_EXPORT(void) _nc_add_to_try (struct tries **, const char *, unsigned short);
-extern NCURSES_EXPORT(char *) _nc_expand_try (struct tries *, unsigned short, int *, size_t);
-extern NCURSES_EXPORT(int) _nc_remove_key (struct tries **, unsigned short);
-extern NCURSES_EXPORT(int) _nc_remove_string (struct tries **, char *);
+extern NCURSES_EXPORT(void) _nc_add_to_try (struct tries **, const char *, unsigned);
+extern NCURSES_EXPORT(char *) _nc_expand_try (struct tries *, unsigned, int *, size_t);
+extern NCURSES_EXPORT(int) _nc_remove_key (struct tries **, unsigned);
+extern NCURSES_EXPORT(int) _nc_remove_string (struct tries **, const char *);
/* elsewhere ... */
+extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry(ENTRY *, TERMTYPE *);
extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
-extern NCURSES_EXPORT(char *) _nc_home_terminfo (void);
extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
-extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
-extern NCURSES_EXPORT(int) _nc_access (const char *, int);
+extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *);
+extern NCURSES_EXPORT(int) _nc_access (const char *, int);
extern NCURSES_EXPORT(int) _nc_baudrate (int);
extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
extern NCURSES_EXPORT(int) _nc_getenv_num (const char *);
extern NCURSES_EXPORT(int) _nc_keypad (bool);
extern NCURSES_EXPORT(int) _nc_ospeed (int);
extern NCURSES_EXPORT(int) _nc_outch (int);
-extern NCURSES_EXPORT(int) _nc_setupscreen (short, short const, FILE *);
-extern NCURSES_EXPORT(int) _nc_timed_wait (int, int, int *);
-extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T);
-extern NCURSES_EXPORT(void) _nc_do_color (int, int, bool, int (*)(int));
+extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const);
+extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, bool, int);
+extern NCURSES_EXPORT(int) _nc_timed_wait(int, int, int * EVENTLIST_2nd(_nc_eventlist *));
+extern NCURSES_EXPORT(void) _nc_do_color (short, short, bool, int (*)(int));
extern NCURSES_EXPORT(void) _nc_flush (void);
+extern NCURSES_EXPORT(void) _nc_free_entry(ENTRY *, TERMTYPE *);
extern NCURSES_EXPORT(void) _nc_freeall (void);
extern NCURSES_EXPORT(void) _nc_hash_map (void);
extern NCURSES_EXPORT(void) _nc_init_keytry (void);
extern NCURSES_EXPORT(void) _nc_keep_tic_dir (const char *);
extern NCURSES_EXPORT(void) _nc_make_oldhash (int i);
-extern NCURSES_EXPORT(void) _nc_outstr (const char *str);
extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot);
extern NCURSES_EXPORT(void) _nc_scroll_optimize (void);
-extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, short const, short const, NCURSES_CH_T);
extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, bool);
extern NCURSES_EXPORT(void) _nc_signal_handler (bool);
extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *);
extern NCURSES_EXPORT(void) _nc_trace_tries (struct tries *);
+#if NO_LEAKS
+extern NCURSES_EXPORT(void) _nc_alloc_entry_leaks(void);
+extern NCURSES_EXPORT(void) _nc_captoinfo_leaks(void);
+extern NCURSES_EXPORT(void) _nc_comp_scan_leaks(void);
+extern NCURSES_EXPORT(void) _nc_keyname_leaks(void);
+extern NCURSES_EXPORT(void) _nc_tgetent_leaks(void);
+#endif
+
+#ifndef USE_TERMLIB
+extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
+extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T);
+extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, NCURSES_SIZE_T const, NCURSES_SIZE_T const, NCURSES_CH_T);
+#endif
+
+#if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB)
+#ifdef linux
+extern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *);
+#else
+#define _nc_wcrtomb(s,wc,ps) wcrtomb(s,wc,ps)
+#endif
+#endif
+
#if USE_SIZECHANGE
extern NCURSES_EXPORT(void) _nc_update_screensize (void);
#endif
@@ -926,6 +1244,13 @@ extern NCURSES_EXPORT(void) _nc_resize_margins (WINDOW *);
#define _nc_resize_margins(wp) /* nothing */
#endif
+#ifdef NCURSES_WGETCH_EVENTS
+extern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *);
+#else
+#define wgetch_events(win, evl) wgetch(win)
+#define wgetnstr_events(win, str, maxlen, evl) wgetnstr(win, str, maxlen)
+#endif
+
/*
* Not everyone has vsscanf(), but we'd like to use it for scanw().
*/
@@ -938,9 +1263,7 @@ extern NCURSES_EXPORT_VAR(int *) _nc_oldnums;
#define USE_SETBUF_0 0
-#define NC_BUFFERED(flag) \
- if ((SP->_buffered != 0) != flag) \
- _nc_set_buffer(SP->_ofp, flag)
+#define NC_BUFFERED(flag) _nc_set_buffer(SP->_ofp, flag)
#define NC_OUTPUT ((SP != 0) ? SP->_ofp : stdout)
@@ -989,6 +1312,12 @@ extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int);
extern NCURSES_EXPORT(int) _nc_ripoffline (int line, int (*init)(WINDOW *,int));
+/*
+ * Common error messages
+ */
+#define MSG_NO_MEMORY "Out of memory"
+#define MSG_NO_INPUTS "Premature EOF"
+
#ifdef __cplusplus
}
#endif
diff --git a/contrib/ncurses/ncurses/llib-lncurses b/contrib/ncurses/ncurses/llib-lncurses
index 1a6e5cf109ba..594c72cd66f4 100644
--- a/contrib/ncurses/ncurses/llib-lncurses
+++ b/contrib/ncurses/ncurses/llib-lncurses
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 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,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey 1996-2001,2002 *
+ * Author: Thomas E. Dickey 1996-2006 *
****************************************************************************/
/* LINTLIBRARY */
@@ -99,14 +99,14 @@ int wechochar(
#undef waddnstr
int waddnstr(
WINDOW *win,
- const char *const astr,
+ const char *astr,
int n)
{ return(*(int *)0); }
#undef waddchnstr
int waddchnstr(
WINDOW *win,
- const chtype *const astr,
+ const chtype *astr,
int n)
{ return(*(int *)0); }
@@ -127,7 +127,7 @@ void wbkgdset(
#undef wbkgd
int wbkgd(
WINDOW *win,
- const chtype ch)
+ chtype ch)
{ return(*(int *)0); }
/* ./base/lib_box.c */
@@ -194,6 +194,10 @@ int COLOR_PAIRS;
#undef COLORS
int COLORS;
+#undef _nc_reset_colors
+NCURSES_BOOL _nc_reset_colors(void)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef start_color
int start_color(void)
{ return(*(int *)0); }
@@ -238,8 +242,8 @@ int pair_content(
#undef _nc_do_color
void _nc_do_color(
- int old_pair,
- int pair,
+ short old_pair,
+ short pair,
NCURSES_BOOL reverse,
int (*outc)(
int p1))
@@ -912,7 +916,7 @@ int vline(
#undef vw_printw
int vw_printw(
WINDOW *a1,
- char *a2,
+ const char *a2,
va_list z)
{ return(*(int *)0); }
@@ -1013,11 +1017,51 @@ int wstandend(
WINDOW *z)
{ return(*(int *)0); }
+#undef getcurx
+int getcurx(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getcury
+int getcury(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getbegx
+int getbegx(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getbegy
+int getbegy(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getmaxx
+int getmaxx(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getmaxy
+int getmaxy(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getparx
+int getparx(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getpary
+int getpary(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
#undef mouse_trafo
NCURSES_BOOL mouse_trafo(
int *a1,
int *a2,
- NCURSES_BOOL z)
+ NCURSES_BOOL z)
{ return(*(NCURSES_BOOL *)0); }
/* ./base/lib_getch.c */
@@ -1082,6 +1126,12 @@ WINDOW *initscr(void)
/* ./base/lib_insch.c */
+#undef _nc_insert_ch
+int _nc_insert_ch(
+ WINDOW *win,
+ chtype ch)
+ { return(*(int *)0); }
+
#undef winsch
int winsch(
WINDOW *win,
@@ -1096,7 +1146,7 @@ int winsdelln(
int n)
{ return(*(int *)0); }
-/* ./base/lib_insstr.c */
+/* ./base/lib_insnstr.c */
#undef winsnstr
int winsnstr(
@@ -1225,6 +1275,10 @@ int mvwin(
void filter(void)
{ /* void */ }
+#undef nofilter
+void nofilter(void)
+ { /* void */ }
+
#undef newterm
SCREEN *newterm(
char *name,
@@ -1360,14 +1414,14 @@ int pechochar(
#undef printw
int printw(
- char *fmt,
+ const char *fmt,
...)
{ return(*(int *)0); }
#undef wprintw
int wprintw(
WINDOW *win,
- char *fmt,
+ const char *fmt,
...)
{ return(*(int *)0); }
@@ -1375,7 +1429,7 @@ int wprintw(
int mvprintw(
int y,
int x,
- char *fmt,
+ const char *fmt,
...)
{ return(*(int *)0); }
@@ -1384,14 +1438,14 @@ int mvwprintw(
WINDOW *win,
int y,
int x,
- char *fmt,
+ const char *fmt,
...)
{ return(*(int *)0); }
#undef vwprintw
int vwprintw(
WINDOW *win,
- char *fmt,
+ const char *fmt,
va_list argp)
{ return(*(int *)0); }
@@ -1466,8 +1520,6 @@ int mvwscanw(
/* ./base/lib_screen.c */
-#include <time.h>
-
#undef getwin
WINDOW *getwin(
FILE *filep)
@@ -1547,9 +1599,11 @@ void delscreen(
#undef _nc_setupscreen
int _nc_setupscreen(
- short slines,
- short const scolumns,
- FILE *output)
+ int slines,
+ int scolumns,
+ FILE *output,
+ NCURSES_BOOL filtered,
+ int slk_format)
{ return(*(int *)0); }
#undef _nc_ripoffline
@@ -1692,46 +1746,6 @@ int wtouchln(
int changed)
{ return(*(int *)0); }
-/* ./trace/lib_traceatr.c */
-
-#undef _traceattr2
-char *_traceattr2(
- int bufnum,
- attr_t newmode)
- { return(*(char **)0); }
-
-#undef _traceattr
-char *_traceattr(
- attr_t newmode)
- { return(*(char **)0); }
-
-#undef _nc_retrace_attr_t
-attr_t _nc_retrace_attr_t(
- attr_t code)
- { return(*(attr_t *)0); }
-
-#undef _nc_altcharset_name
-const char *_nc_altcharset_name(
- attr_t attr,
- chtype ch)
- { return(*(const char **)0); }
-
-#undef _tracechtype2
-char *_tracechtype2(
- int bufnum,
- chtype ch)
- { return(*(char **)0); }
-
-#undef _tracechtype
-char *_tracechtype(
- chtype ch)
- { return(*(char **)0); }
-
-#undef _nc_retrace_chtype
-attr_t _nc_retrace_chtype(
- attr_t code)
- { return(*(attr_t *)0); }
-
/* ./trace/lib_tracedmp.c */
#undef _tracedump
@@ -1749,7 +1763,6 @@ char *_tracemouse(
/* ./tty/lib_tstp.c */
-#include <signal.h>
#include <SigAction.h>
#undef _nc_signal_handler
@@ -1883,11 +1896,6 @@ char *_nc_printf_string(
int doupdate(void)
{ return(*(int *)0); }
-#undef _nc_outstr
-void _nc_outstr(
- const char *str)
- { /* void */ }
-
#undef _nc_scrolln
int _nc_scrolln(
int n,
@@ -1931,25 +1939,19 @@ char *_nc_varargs(
void _nc_memmove(void)
{ /* void */ }
-/* ./base/sigaction.c */
-
-#undef _nc_sigaction
-void _nc_sigaction(void)
- { /* void */ }
-
/* ./base/vsscanf.c */
#undef _nc_vsscanf
void _nc_vsscanf(void)
{ /* void */ }
-/* ./base/define_key.c */
+/* ./base/lib_freeall.c */
-#undef define_key
-int define_key(
- char *str,
- int keycode)
- { return(*(int *)0); }
+#include <term_entry.h>
+
+#undef _nc_freeall
+void _nc_freeall(void)
+ { /* void */ }
/* ./expanded.c */
@@ -1980,20 +1982,11 @@ void _nc_UpdateAttrs(
chtype c)
{ /* void */ }
-/* ./base/keybound.c */
-
-#undef keybound
-char *keybound(
- int code,
- int count)
- { return(*(char **)0); }
+/* ./base/legacy_coding.c */
-/* ./base/keyok.c */
-
-#undef keyok
-int keyok(
- int c,
- NCURSES_BOOL flag)
+#undef use_legacy_coding
+int use_legacy_coding(
+ int level)
{ return(*(int *)0); }
/* ./base/lib_dft_fgbg.c */
@@ -2008,14 +2001,6 @@ int assume_default_colors(
int bg)
{ return(*(int *)0); }
-/* ./base/lib_freeall.c */
-
-#include <term_entry.h>
-
-#undef _nc_freeall
-void _nc_freeall(void)
- { /* void */ }
-
/* ./tinfo/lib_print.c */
#undef mcprint
@@ -2051,34 +2036,6 @@ void _nc_trace_xnames(
TERMTYPE *tp)
{ /* void */ }
-/* ./base/tries.c */
-
-#undef _nc_expand_try
-char *_nc_expand_try(
- struct tries *tree,
- unsigned short code,
- int *count,
- size_t len)
- { return(*(char **)0); }
-
-#undef _nc_remove_key
-int _nc_remove_key(
- struct tries **tree,
- unsigned short code)
- { return(*(int *)0); }
-
-#undef _nc_remove_string
-int _nc_remove_string(
- struct tries **tree,
- char *string)
- { return(*(int *)0); }
-
-/* ./base/version.c */
-
-#undef curses_version
-const char *curses_version(void)
- { return(*(const char **)0); }
-
/* ./base/wresize.c */
#undef wresize
@@ -2090,11 +2047,24 @@ int wresize(
/* ./tinfo/access.c */
+#include <sys/stat.h>
+#include <nc_alloc.h>
+
#undef _nc_rootname
char *_nc_rootname(
char *path)
{ return(*(char **)0); }
+#undef _nc_is_abs_path
+NCURSES_BOOL _nc_is_abs_path(
+ const char *path)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_pathlast
+unsigned _nc_pathlast(
+ const char *path)
+ { return(*(unsigned *)0); }
+
#undef _nc_basename
char *_nc_basename(
char *path)
@@ -2106,6 +2076,16 @@ int _nc_access(
int mode)
{ return(*(int *)0); }
+#undef _nc_is_dir_path
+NCURSES_BOOL _nc_is_dir_path(
+ const char *path)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_is_file_path
+NCURSES_BOOL _nc_is_file_path(
+ const char *path)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef _nc_env_access
int _nc_env_access(void)
{ return(*(int *)0); }
@@ -2116,7 +2096,7 @@ int _nc_env_access(void)
void _nc_add_to_try(
struct tries **tree,
const char *str,
- unsigned short code)
+ unsigned code)
{ /* void */ }
/* ./tinfo/alloc_entry.c */
@@ -2168,14 +2148,14 @@ void _nc_copy_termtype(
char *_nc_captoinfo(
const char *cap,
const char *s,
- int const parametrized)
+ int const parameterized)
{ return(*(char **)0); }
#undef _nc_infotocap
char *_nc_infotocap(
const char *cap,
const char *str,
- int const parametrized)
+ int const parameterized)
{ return(*(char **)0); }
/* ./codes.c */
@@ -2219,6 +2199,10 @@ int _nc_curr_line;
#undef _nc_curr_col
int _nc_curr_col;
+#undef _nc_get_source
+const char *_nc_get_source(void)
+ { return(*(const char **)0); }
+
#undef _nc_set_source
void _nc_set_source(
const char *const name)
@@ -2280,6 +2264,10 @@ struct name_table_entry const *_nc_find_type_entry(
/* ./tinfo/comp_parse.c */
+#undef _nc_check_termtype2
+void (*_nc_check_termtype2)(
+ TERMTYPE *p1,
+ NCURSES_BOOL p2);
#undef _nc_check_termtype
void (*_nc_check_termtype)(
TERMTYPE *p1);
@@ -2293,6 +2281,18 @@ void _nc_free_entries(
ENTRY *headp)
{ /* void */ }
+#undef _nc_delink_entry
+ENTRY *_nc_delink_entry(
+ ENTRY *headp,
+ TERMTYPE *tterm)
+ { return(*(ENTRY **)0); }
+
+#undef _nc_free_entry
+void _nc_free_entry(
+ ENTRY *headp,
+ TERMTYPE *tterm)
+ { /* void */ }
+
#undef _nc_entry_match
NCURSES_BOOL _nc_entry_match(
char *n1,
@@ -2309,6 +2309,12 @@ void _nc_read_entry_source(
ENTRY *p1))
{ /* void */ }
+#undef _nc_resolve_uses2
+int _nc_resolve_uses2(
+ NCURSES_BOOL fullresolve,
+ NCURSES_BOOL literal)
+ { return(*(int *)0); }
+
#undef _nc_resolve_uses
int _nc_resolve_uses(
NCURSES_BOOL fullresolve)
@@ -2331,16 +2337,22 @@ struct token _nc_curr_token;
#undef _nc_disable_period
NCURSES_BOOL _nc_disable_period;
+#undef _nc_reset_input
+void _nc_reset_input(
+ FILE *fp,
+ char *buf)
+ { /* void */ }
+
#undef _nc_get_token
int _nc_get_token(
NCURSES_BOOL silent)
{ return(*(int *)0); }
#undef _nc_trans_string
-char _nc_trans_string(
+int _nc_trans_string(
char *ptr,
char *last)
- { return(*(char *)0); }
+ { return(*(int *)0); }
#undef _nc_push_token
void _nc_push_token(
@@ -2352,10 +2364,32 @@ void _nc_panic_mode(
char ch)
{ /* void */ }
-#undef _nc_reset_input
-void _nc_reset_input(
- FILE *fp,
- char *buf)
+/* ./tinfo/db_iterator.c */
+
+#undef _nc_tic_dir
+const char *_nc_tic_dir(
+ const char *path)
+ { return(*(const char **)0); }
+
+#undef _nc_keep_tic_dir
+void _nc_keep_tic_dir(
+ const char *path)
+ { /* void */ }
+
+#undef _nc_last_db
+void _nc_last_db(void)
+ { /* void */ }
+
+#undef _nc_next_db
+const char *_nc_next_db(
+ DBDIRS *state,
+ int *offset)
+ { return(*(const char **)0); }
+
+#undef _nc_first_db
+void _nc_first_db(
+ DBDIRS *state,
+ int *offset)
{ /* void */ }
/* ./tinfo/doalloc.c */
@@ -2419,7 +2453,7 @@ void _nc_init_keytry(void)
/* ./tinfo/lib_acs.c */
#undef acs_map
-chtype acs_map[128 ];
+chtype acs_map[128];
#undef _nc_init_acs
void _nc_init_acs(void)
@@ -2430,8 +2464,8 @@ void _nc_init_acs(void)
#include <termcap.h>
struct speed {
- int s;
- int sp;
+ int s;
+ int sp;
};
#undef _nc_baudrate
@@ -2518,6 +2552,8 @@ char *longname(void)
/* ./tinfo/lib_napms.c */
+#include <time.h>
+
#undef napms
int napms(
int ms)
@@ -2626,13 +2662,12 @@ int intrflush(
/* ./tinfo/lib_setup.c */
+#include <locale.h>
#include <sys/ioctl.h>
+#include <langinfo.h>
-#undef use_env
-void use_env(
- NCURSES_BOOL f)
- { /* void */ }
-
+#undef ttytype
+char ttytype[256];
#undef LINES
int LINES;
#undef COLS
@@ -2640,12 +2675,39 @@ int COLS;
#undef TABSIZE
int TABSIZE;
+#undef _nc_handle_sigwinch
+int _nc_handle_sigwinch(
+ int enable)
+ { return(*(int *)0); }
+
+#undef use_env
+void use_env(
+ NCURSES_BOOL f)
+ { /* void */ }
+
#undef _nc_update_screensize
void _nc_update_screensize(void)
{ /* void */ }
-#undef ttytype
-char ttytype[256 ];
+#undef _nc_get_locale
+char *_nc_get_locale(void)
+ { return(*(char **)0); }
+
+#undef _nc_unicode_locale
+int _nc_unicode_locale(void)
+ { return(*(int *)0); }
+
+#undef _nc_locale_breaks_acs
+int _nc_locale_breaks_acs(void)
+ { return(*(int *)0); }
+
+#undef _nc_setupterm
+int _nc_setupterm(
+ char *tname,
+ int Filedes,
+ int *errret,
+ NCURSES_BOOL reuse)
+ { return(*(int *)0); }
#undef setupterm
int setupterm(
@@ -2725,15 +2787,22 @@ char *tigetstr(
typedef struct {
union {
- unsigned int num;
- char *str;
+ int num;
+ char *str;
} data;
- NCURSES_BOOL num_type;
+ NCURSES_BOOL num_type;
} stack_frame;
#undef _nc_tparm_err
int _nc_tparm_err;
+#undef _nc_tparm_analyze
+int _nc_tparm_analyze(
+ const char *string,
+ char *p_is_s[9],
+ int *popcount)
+ { return(*(int *)0); }
+
#undef tparm
char *tparm(
char *string,
@@ -2796,16 +2865,41 @@ void _tracef(
...)
{ /* void */ }
+#undef _nc_retrace_bool
+NCURSES_BOOL _nc_retrace_bool(
+ NCURSES_BOOL code)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef _nc_retrace_int
int _nc_retrace_int(
int code)
{ return(*(int *)0); }
+#undef _nc_retrace_unsigned
+unsigned _nc_retrace_unsigned(
+ unsigned code)
+ { return(*(unsigned *)0); }
+
#undef _nc_retrace_ptr
char *_nc_retrace_ptr(
char *code)
{ return(*(char **)0); }
+#undef _nc_retrace_cptr
+const char *_nc_retrace_cptr(
+ const char *code)
+ { return(*(const char **)0); }
+
+#undef _nc_retrace_cvoid_ptr
+void *_nc_retrace_cvoid_ptr(
+ void *code)
+ { return(*(void **)0); }
+
+#undef _nc_retrace_void_ptr
+void *_nc_retrace_void_ptr(
+ void *code)
+ { return(*(void **)0); }
+
#undef _nc_retrace_sp
SCREEN *_nc_retrace_sp(
SCREEN *code)
@@ -2816,6 +2910,46 @@ WINDOW *_nc_retrace_win(
WINDOW *code)
{ return(*(WINDOW **)0); }
+/* ./trace/lib_traceatr.c */
+
+#undef _traceattr2
+char *_traceattr2(
+ int bufnum,
+ chtype newmode)
+ { return(*(char **)0); }
+
+#undef _traceattr
+char *_traceattr(
+ attr_t newmode)
+ { return(*(char **)0); }
+
+#undef _nc_retrace_attr_t
+attr_t _nc_retrace_attr_t(
+ attr_t code)
+ { return(*(attr_t *)0); }
+
+#undef _nc_altcharset_name
+const char *_nc_altcharset_name(
+ attr_t attr,
+ chtype ch)
+ { return(*(const char **)0); }
+
+#undef _tracechtype2
+char *_tracechtype2(
+ int bufnum,
+ chtype ch)
+ { return(*(char **)0); }
+
+#undef _tracechtype
+char *_tracechtype(
+ chtype ch)
+ { return(*(char **)0); }
+
+#undef _nc_retrace_chtype
+chtype _nc_retrace_chtype(
+ chtype code)
+ { return(*(chtype *)0); }
+
/* ./trace/lib_tracebits.c */
typedef struct {
@@ -2823,6 +2957,11 @@ typedef struct {
const char *name;
} BITNAMES;
+#undef _nc_trace_ttymode
+char *_nc_trace_ttymode(
+ struct termios *tty)
+ { return(*(char **)0); }
+
#undef _nc_tracebits
char *_nc_tracebits(void)
{ return(*(char **)0); }
@@ -2930,15 +3069,14 @@ typedef struct {
/* ./tinfo/read_entry.c */
-#undef _nc_tic_dir
-const char *_nc_tic_dir(
- const char *path)
- { return(*(const char **)0); }
+#include <hashed_db.h>
-#undef _nc_keep_tic_dir
-void _nc_keep_tic_dir(
- const char *path)
- { /* void */ }
+#undef _nc_read_termtype
+int _nc_read_termtype(
+ TERMTYPE *ptr,
+ char *buffer,
+ int limit)
+ { return(*(int *)0); }
#undef _nc_read_file_entry
int _nc_read_file_entry(
@@ -2948,13 +3086,15 @@ int _nc_read_file_entry(
#undef _nc_read_entry
int _nc_read_entry(
- const char *const tn,
+ const char *const name,
char *const filename,
TERMTYPE *const tp)
{ return(*(int *)0); }
/* ./tinfo/read_termcap.c */
+#include <sys/types.h>
+
#undef _nc_read_termcap_entry
int _nc_read_termcap_entry(
const char *const tn,
@@ -3015,6 +3155,12 @@ char *_nc_trace_buf(
size_t want)
{ return(*(char **)0); }
+#undef _nc_trace_bufcat
+char *_nc_trace_bufcat(
+ int bufnum,
+ const char *value)
+ { return(*(char **)0); }
+
/* ./trace/trace_tries.c */
#undef _nc_trace_tries
@@ -3022,6 +3168,35 @@ void _nc_trace_tries(
struct tries *tree)
{ /* void */ }
+/* ./base/tries.c */
+
+#undef _nc_expand_try
+char *_nc_expand_try(
+ struct tries *tree,
+ unsigned code,
+ int *count,
+ size_t len)
+ { return(*(char **)0); }
+
+#undef _nc_remove_key
+int _nc_remove_key(
+ struct tries **tree,
+ unsigned code)
+ { return(*(int *)0); }
+
+#undef _nc_remove_string
+int _nc_remove_string(
+ struct tries **tree,
+ const char *string)
+ { return(*(int *)0); }
+
+/* ./tinfo/trim_sgr0.c */
+
+#undef _nc_trim_sgr0
+char *_nc_trim_sgr0(
+ TERMTYPE *tp)
+ { return(*(char **)0); }
+
/* ./unctrl.c */
#undef unctrl
@@ -3042,6 +3217,25 @@ const char *_nc_visbuf(
const char *buf)
{ return(*(const char **)0); }
+#undef _nc_visbufn
+const char *_nc_visbufn(
+ const char *buf,
+ int len)
+ { return(*(const char **)0); }
+
+#undef _nc_viscbuf2
+const char *_nc_viscbuf2(
+ int bufnum,
+ const chtype *buf,
+ int len)
+ { return(*(const char **)0); }
+
+#undef _nc_viscbuf
+const char *_nc_viscbuf(
+ const chtype *buf,
+ int len)
+ { return(*(const char **)0); }
+
/* ./tinfo/write_entry.c */
#undef _nc_set_writedir
@@ -3057,3 +3251,46 @@ void _nc_write_entry(
#undef _nc_tic_written
int _nc_tic_written(void)
{ return(*(int *)0); }
+
+/* ./base/define_key.c */
+
+#undef define_key
+int define_key(
+ const char *str,
+ int keycode)
+ { return(*(int *)0); }
+
+/* ./tinfo/hashed_db.c */
+
+#undef _nc_hashed_db
+void _nc_hashed_db(void)
+ { /* void */ }
+
+/* ./base/key_defined.c */
+
+#undef key_defined
+int key_defined(
+ const char *str)
+ { return(*(int *)0); }
+
+/* ./base/keybound.c */
+
+#undef keybound
+char *keybound(
+ int code,
+ int count)
+ { return(*(char **)0); }
+
+/* ./base/keyok.c */
+
+#undef keyok
+int keyok(
+ int c,
+ NCURSES_BOOL flag)
+ { return(*(int *)0); }
+
+/* ./base/version.c */
+
+#undef curses_version
+const char *curses_version(void)
+ { return(*(const char **)0); }
diff --git a/contrib/ncurses/ncurses/llib-lncursesw b/contrib/ncurses/ncurses/llib-lncursesw
index ffb0af650c61..86ef2845d1ff 100644
--- a/contrib/ncurses/ncurses/llib-lncursesw
+++ b/contrib/ncurses/ncurses/llib-lncursesw
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 2001-2005,2006 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,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey 2001,2002 *
+ * Author: Thomas E. Dickey 2001-2006 *
****************************************************************************/
/* LINTLIBRARY */
@@ -76,6 +76,12 @@ cchar_t _nc_render(
cchar_t ch)
{ return(*(cchar_t *)0); }
+#undef _nc_build_wch
+int _nc_build_wch(
+ WINDOW *win,
+ cchar_t *ch)
+ { return(*(int *)0); }
+
#undef _nc_waddch_nosync
int _nc_waddch_nosync(
WINDOW *win,
@@ -94,31 +100,19 @@ int wechochar(
const chtype ch)
{ return(*(int *)0); }
-#undef wadd_wch
-int wadd_wch(
- WINDOW *win,
- const cchar_t *wch)
- { return(*(int *)0); }
-
-#undef wecho_wchar
-int wecho_wchar(
- WINDOW *win,
- const cchar_t *wch)
- { return(*(int *)0); }
-
/* ./base/lib_addstr.c */
#undef waddnstr
int waddnstr(
WINDOW *win,
- const char *const astr,
+ const char *astr,
int n)
{ return(*(int *)0); }
#undef waddchnstr
int waddchnstr(
WINDOW *win,
- const chtype *const astr,
+ const chtype *astr,
int n)
{ return(*(int *)0); }
@@ -130,7 +124,7 @@ int _nc_wchstrlen(
#undef wadd_wchnstr
int wadd_wchnstr(
WINDOW *win,
- const cchar_t *const astr,
+ const cchar_t *astr,
int n)
{ return(*(int *)0); }
@@ -170,7 +164,7 @@ int wbkgrnd(
#undef wbkgd
int wbkgd(
WINDOW *win,
- const chtype ch)
+ chtype ch)
{ return(*(int *)0); }
/* ./base/lib_box.c */
@@ -237,6 +231,10 @@ int COLOR_PAIRS;
#undef COLORS
int COLORS;
+#undef _nc_reset_colors
+NCURSES_BOOL _nc_reset_colors(void)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef start_color
int start_color(void)
{ return(*(int *)0); }
@@ -281,8 +279,8 @@ int pair_content(
#undef _nc_do_color
void _nc_do_color(
- int old_pair,
- int pair,
+ short old_pair,
+ short pair,
NCURSES_BOOL reverse,
int (*outc)(
int p1))
@@ -958,13 +956,6 @@ int untouchwin(
WINDOW *z)
{ return(*(int *)0); }
-#undef vid_attr
-int vid_attr(
- attr_t a1,
- short a2,
- void *z)
- { return(*(int *)0); }
-
#undef vline
int vline(
chtype a1,
@@ -974,7 +965,7 @@ int vline(
#undef vw_printw
int vw_printw(
WINDOW *a1,
- char *a2,
+ const char *a2,
va_list z)
{ return(*(int *)0); }
@@ -1075,6 +1066,46 @@ int wstandend(
WINDOW *z)
{ return(*(int *)0); }
+#undef getcurx
+int getcurx(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getcury
+int getcury(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getbegx
+int getbegx(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getbegy
+int getbegy(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getmaxx
+int getmaxx(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getmaxy
+int getmaxy(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getparx
+int getparx(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
+#undef getpary
+int getpary(
+ const WINDOW *z)
+ { return(*(int *)0); }
+
#undef add_wch
int add_wch(
const cchar_t *z)
@@ -1138,12 +1169,12 @@ int echo_wchar(
#undef get_wch
int get_wch(
- wint_t *z)
+ wint_t *z)
{ return(*(int *)0); }
#undef get_wstr
int get_wstr(
- wint_t *z)
+ wint_t *z)
{ return(*(int *)0); }
#undef getbkgrnd
@@ -1153,7 +1184,7 @@ int getbkgrnd(
#undef getn_wstr
int getn_wstr(
- wint_t *a1,
+ wint_t *a1,
int z)
{ return(*(int *)0); }
@@ -1181,7 +1212,7 @@ int in_wchstr(
#undef innwstr
int innwstr(
- wchar_t *a1,
+ wchar_t *a1,
int z)
{ return(*(int *)0); }
@@ -1203,7 +1234,7 @@ int ins_wstr(
#undef inwstr
int inwstr(
- wchar_t *z)
+ wchar_t *z)
{ return(*(int *)0); }
#undef mvadd_wch
@@ -1247,21 +1278,21 @@ int mvaddwstr(
int mvget_wch(
int a1,
int a2,
- wint_t *z)
+ wint_t *z)
{ return(*(int *)0); }
#undef mvget_wstr
int mvget_wstr(
int a1,
int a2,
- wint_t *z)
+ wint_t *z)
{ return(*(int *)0); }
#undef mvgetn_wstr
int mvgetn_wstr(
int a1,
int a2,
- wint_t *a3,
+ wint_t *a3,
int z)
{ return(*(int *)0); }
@@ -1299,7 +1330,7 @@ int mvin_wchstr(
int mvinnwstr(
int a1,
int a2,
- wchar_t *a3,
+ wchar_t *a3,
int z)
{ return(*(int *)0); }
@@ -1329,7 +1360,7 @@ int mvins_wstr(
int mvinwstr(
int a1,
int a2,
- wchar_t *z)
+ wchar_t *z)
{ return(*(int *)0); }
#undef mvvline_set
@@ -1387,7 +1418,7 @@ int mvwget_wch(
WINDOW *a1,
int a2,
int a3,
- wint_t *z)
+ wint_t *z)
{ return(*(int *)0); }
#undef mvwget_wstr
@@ -1395,7 +1426,7 @@ int mvwget_wstr(
WINDOW *a1,
int a2,
int a3,
- wint_t *z)
+ wint_t *z)
{ return(*(int *)0); }
#undef mvwgetn_wstr
@@ -1403,7 +1434,7 @@ int mvwgetn_wstr(
WINDOW *a1,
int a2,
int a3,
- wint_t *a4,
+ wint_t *a4,
int z)
{ return(*(int *)0); }
@@ -1446,7 +1477,7 @@ int mvwinnwstr(
WINDOW *a1,
int a2,
int a3,
- wchar_t *a4,
+ wchar_t *a4,
int z)
{ return(*(int *)0); }
@@ -1480,7 +1511,7 @@ int mvwinwstr(
WINDOW *a1,
int a2,
int a3,
- wchar_t *z)
+ wchar_t *z)
{ return(*(int *)0); }
#undef mvwvline_set
@@ -1513,7 +1544,13 @@ int waddwstr(
#undef wget_wstr
int wget_wstr(
WINDOW *a1,
- wint_t *z)
+ wint_t *z)
+ { return(*(int *)0); }
+
+#undef wgetbkgrnd
+int wgetbkgrnd(
+ WINDOW *a1,
+ cchar_t *z)
{ return(*(int *)0); }
#undef win_wchstr
@@ -1532,7 +1569,7 @@ int wins_wstr(
NCURSES_BOOL mouse_trafo(
int *a1,
int *a2,
- NCURSES_BOOL z)
+ NCURSES_BOOL z)
{ return(*(NCURSES_BOOL *)0); }
/* ./base/lib_getch.c */
@@ -1597,6 +1634,12 @@ WINDOW *initscr(void)
/* ./base/lib_insch.c */
+#undef _nc_insert_ch
+int _nc_insert_ch(
+ WINDOW *win,
+ chtype ch)
+ { return(*(int *)0); }
+
#undef winsch
int winsch(
WINDOW *win,
@@ -1611,7 +1654,7 @@ int winsdelln(
int n)
{ return(*(int *)0); }
-/* ./base/lib_insstr.c */
+/* ./base/lib_insnstr.c */
#undef winsnstr
int winsnstr(
@@ -1740,6 +1783,10 @@ int mvwin(
void filter(void)
{ /* void */ }
+#undef nofilter
+void nofilter(void)
+ { /* void */ }
+
#undef newterm
SCREEN *newterm(
char *name,
@@ -1875,14 +1922,14 @@ int pechochar(
#undef printw
int printw(
- char *fmt,
+ const char *fmt,
...)
{ return(*(int *)0); }
#undef wprintw
int wprintw(
WINDOW *win,
- char *fmt,
+ const char *fmt,
...)
{ return(*(int *)0); }
@@ -1890,7 +1937,7 @@ int wprintw(
int mvprintw(
int y,
int x,
- char *fmt,
+ const char *fmt,
...)
{ return(*(int *)0); }
@@ -1899,14 +1946,14 @@ int mvwprintw(
WINDOW *win,
int y,
int x,
- char *fmt,
+ const char *fmt,
...)
{ return(*(int *)0); }
#undef vwprintw
int vwprintw(
WINDOW *win,
- char *fmt,
+ const char *fmt,
va_list argp)
{ return(*(int *)0); }
@@ -1981,8 +2028,6 @@ int mvwscanw(
/* ./base/lib_screen.c */
-#include <time.h>
-
#undef getwin
WINDOW *getwin(
FILE *filep)
@@ -2062,9 +2107,11 @@ void delscreen(
#undef _nc_setupscreen
int _nc_setupscreen(
- short slines,
- short const scolumns,
- FILE *output)
+ int slines,
+ int scolumns,
+ FILE *output,
+ NCURSES_BOOL filtered,
+ int slk_format)
{ return(*(int *)0); }
#undef _nc_ripoffline
@@ -2173,6 +2220,8 @@ int slk_refresh(void)
/* ./base/lib_slkset.c */
+#include <wctype.h>
+
#undef slk_set
int slk_set(
int i,
@@ -2207,57 +2256,6 @@ int wtouchln(
int changed)
{ return(*(int *)0); }
-/* ./trace/lib_traceatr.c */
-
-#undef _traceattr2
-char *_traceattr2(
- int bufnum,
- attr_t newmode)
- { return(*(char **)0); }
-
-#undef _traceattr
-char *_traceattr(
- attr_t newmode)
- { return(*(char **)0); }
-
-#undef _nc_retrace_attr_t
-attr_t _nc_retrace_attr_t(
- attr_t code)
- { return(*(attr_t *)0); }
-
-#undef _nc_altcharset_name
-const char *_nc_altcharset_name(
- attr_t attr,
- chtype ch)
- { return(*(const char **)0); }
-
-#undef _tracechtype2
-char *_tracechtype2(
- int bufnum,
- chtype ch)
- { return(*(char **)0); }
-
-#undef _tracechtype
-char *_tracechtype(
- chtype ch)
- { return(*(char **)0); }
-
-#undef _nc_retrace_chtype
-attr_t _nc_retrace_chtype(
- attr_t code)
- { return(*(attr_t *)0); }
-
-#undef _tracecchar_t2
-char *_tracecchar_t2(
- int bufnum,
- const cchar_t *ch)
- { return(*(char **)0); }
-
-#undef _tracecchar_t
-char *_tracecchar_t(
- const cchar_t *ch)
- { return(*(char **)0); }
-
/* ./trace/lib_tracedmp.c */
#undef _tracedump
@@ -2275,7 +2273,6 @@ char *_tracemouse(
/* ./tty/lib_tstp.c */
-#include <signal.h>
#include <SigAction.h>
#undef _nc_signal_handler
@@ -2409,11 +2406,6 @@ char *_nc_printf_string(
int doupdate(void)
{ return(*(int *)0); }
-#undef _nc_outstr
-void _nc_outstr(
- const char *str)
- { /* void */ }
-
#undef _nc_scrolln
int _nc_scrolln(
int n,
@@ -2457,18 +2449,51 @@ char *_nc_varargs(
void _nc_memmove(void)
{ /* void */ }
-/* ./base/sigaction.c */
-
-#undef _nc_sigaction
-void _nc_sigaction(void)
- { /* void */ }
-
/* ./base/vsscanf.c */
#undef _nc_vsscanf
void _nc_vsscanf(void)
{ /* void */ }
+/* ./base/lib_freeall.c */
+
+#include <term_entry.h>
+
+#undef _nc_freeall
+void _nc_freeall(void)
+ { /* void */ }
+
+/* ./widechar/charable.c */
+
+#undef _nc_is_charable
+NCURSES_BOOL _nc_is_charable(
+ wchar_t ch)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_to_char
+int _nc_to_char(
+ wint_t ch)
+ { return(*(int *)0); }
+
+#undef _nc_to_widechar
+wint_t _nc_to_widechar(
+ int ch)
+ { return(*(wint_t *)0); }
+
+/* ./widechar/lib_add_wch.c */
+
+#undef wadd_wch
+int wadd_wch(
+ WINDOW *win,
+ const cchar_t *wch)
+ { return(*(int *)0); }
+
+#undef wecho_wchar
+int wecho_wchar(
+ WINDOW *win,
+ const cchar_t *wch)
+ { return(*(int *)0); }
+
/* ./widechar/lib_box_set.c */
#undef wborder_set
@@ -2498,7 +2523,7 @@ int setcchar(
#undef getcchar
int getcchar(
const cchar_t *wcval,
- wchar_t *wch,
+ wchar_t *wch,
attr_t *attrs,
short *color_pair,
void *opts)
@@ -2509,7 +2534,19 @@ int getcchar(
#undef wget_wch
int wget_wch(
WINDOW *win,
- wint_t *result)
+ wint_t *result)
+ { return(*(int *)0); }
+
+/* ./widechar/lib_erasewchar.c */
+
+#undef erasewchar
+int erasewchar(
+ wchar_t *wch)
+ { return(*(int *)0); }
+
+#undef killwchar
+int killwchar(
+ wchar_t *wch)
{ return(*(int *)0); }
/* ./widechar/lib_get_wstr.c */
@@ -2517,7 +2554,7 @@ int wget_wch(
#undef wgetn_wstr
int wgetn_wstr(
WINDOW *win,
- wint_t *str,
+ wint_t *str,
int maxlen)
{ return(*(int *)0); }
@@ -2547,15 +2584,6 @@ int win_wchnstr(
int n)
{ return(*(int *)0); }
-/* ./widechar/lib_ins_nwstr.c */
-
-#undef wins_nwstr
-int wins_nwstr(
- WINDOW *win,
- const wchar_t *wstr,
- int n)
- { return(*(int *)0); }
-
/* ./widechar/lib_ins_wch.c */
#undef wins_wch
@@ -2564,28 +2592,81 @@ int wins_wch(
const cchar_t *wch)
{ return(*(int *)0); }
+#undef wins_nwstr
+int wins_nwstr(
+ WINDOW *win,
+ const wchar_t *wstr,
+ int n)
+ { return(*(int *)0); }
+
/* ./widechar/lib_inwstr.c */
#undef winnwstr
int winnwstr(
WINDOW *win,
- wchar_t *wstr,
+ wchar_t *wstr,
int n)
{ return(*(int *)0); }
#undef winwstr
int winwstr(
WINDOW *win,
- wchar_t *wstr)
+ wchar_t *wstr)
+ { return(*(int *)0); }
+
+/* ./widechar/lib_pecho_wchar.c */
+
+#undef pecho_wchar
+int pecho_wchar(
+ WINDOW *pad,
+ const cchar_t *wch)
+ { return(*(int *)0); }
+
+/* ./widechar/lib_slk_wset.c */
+
+#undef slk_wset
+int slk_wset(
+ int i,
+ const wchar_t *astr,
+ int format)
{ return(*(int *)0); }
/* ./widechar/lib_unget_wch.c */
+#undef _nc_wcrtomb
+size_t _nc_wcrtomb(
+ char *target,
+ wchar_t source,
+ mbstate_t *state)
+ { return(*(size_t *)0); }
+
#undef unget_wch
int unget_wch(
const wchar_t wch)
{ return(*(int *)0); }
+/* ./widechar/lib_vid_attr.c */
+
+#undef vid_puts
+int vid_puts(
+ attr_t newmode,
+ short pair,
+ void *opts,
+ int (*outc)(
+ int p1))
+ { return(*(int *)0); }
+
+#undef vid_attr
+int vid_attr(
+ attr_t newmode,
+ short pair,
+ void *opts)
+ { return(*(int *)0); }
+
+#undef term_attrs
+attr_t term_attrs(void)
+ { return(*(attr_t *)0); }
+
/* ./widechar/lib_vline_set.c */
#undef wvline_set
@@ -2607,18 +2688,10 @@ void _nc_init_wacs(void)
/* ./widechar/lib_wunctrl.c */
#undef wunctrl
-wchar_t *wunctrl(
+wchar_t *wunctrl(
cchar_t *wc)
{ return(*(wchar_t **)0); }
-/* ./base/define_key.c */
-
-#undef define_key
-int define_key(
- char *str,
- int keycode)
- { return(*(int *)0); }
-
/* ./expanded.c */
#undef _nc_toggle_attr_on
@@ -2645,23 +2718,14 @@ int _nc_InsCharCost(
#undef _nc_UpdateAttrs
void _nc_UpdateAttrs(
- chtype c)
+ cchar_t c)
{ /* void */ }
-/* ./base/keybound.c */
+/* ./base/legacy_coding.c */
-#undef keybound
-char *keybound(
- int code,
- int count)
- { return(*(char **)0); }
-
-/* ./base/keyok.c */
-
-#undef keyok
-int keyok(
- int c,
- NCURSES_BOOL flag)
+#undef use_legacy_coding
+int use_legacy_coding(
+ int level)
{ return(*(int *)0); }
/* ./base/lib_dft_fgbg.c */
@@ -2676,14 +2740,6 @@ int assume_default_colors(
int bg)
{ return(*(int *)0); }
-/* ./base/lib_freeall.c */
-
-#include <term_entry.h>
-
-#undef _nc_freeall
-void _nc_freeall(void)
- { /* void */ }
-
/* ./tinfo/lib_print.c */
#undef mcprint
@@ -2719,34 +2775,6 @@ void _nc_trace_xnames(
TERMTYPE *tp)
{ /* void */ }
-/* ./base/tries.c */
-
-#undef _nc_expand_try
-char *_nc_expand_try(
- struct tries *tree,
- unsigned short code,
- int *count,
- size_t len)
- { return(*(char **)0); }
-
-#undef _nc_remove_key
-int _nc_remove_key(
- struct tries **tree,
- unsigned short code)
- { return(*(int *)0); }
-
-#undef _nc_remove_string
-int _nc_remove_string(
- struct tries **tree,
- char *string)
- { return(*(int *)0); }
-
-/* ./base/version.c */
-
-#undef curses_version
-const char *curses_version(void)
- { return(*(const char **)0); }
-
/* ./base/wresize.c */
#undef wresize
@@ -2758,11 +2786,24 @@ int wresize(
/* ./tinfo/access.c */
+#include <sys/stat.h>
+#include <nc_alloc.h>
+
#undef _nc_rootname
char *_nc_rootname(
char *path)
{ return(*(char **)0); }
+#undef _nc_is_abs_path
+NCURSES_BOOL _nc_is_abs_path(
+ const char *path)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_pathlast
+unsigned _nc_pathlast(
+ const char *path)
+ { return(*(unsigned *)0); }
+
#undef _nc_basename
char *_nc_basename(
char *path)
@@ -2774,6 +2815,16 @@ int _nc_access(
int mode)
{ return(*(int *)0); }
+#undef _nc_is_dir_path
+NCURSES_BOOL _nc_is_dir_path(
+ const char *path)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_is_file_path
+NCURSES_BOOL _nc_is_file_path(
+ const char *path)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef _nc_env_access
int _nc_env_access(void)
{ return(*(int *)0); }
@@ -2784,7 +2835,7 @@ int _nc_env_access(void)
void _nc_add_to_try(
struct tries **tree,
const char *str,
- unsigned short code)
+ unsigned code)
{ /* void */ }
/* ./tinfo/alloc_entry.c */
@@ -2836,14 +2887,14 @@ void _nc_copy_termtype(
char *_nc_captoinfo(
const char *cap,
const char *s,
- int const parametrized)
+ int const parameterized)
{ return(*(char **)0); }
#undef _nc_infotocap
char *_nc_infotocap(
const char *cap,
const char *str,
- int const parametrized)
+ int const parameterized)
{ return(*(char **)0); }
/* ./codes.c */
@@ -2887,6 +2938,10 @@ int _nc_curr_line;
#undef _nc_curr_col
int _nc_curr_col;
+#undef _nc_get_source
+const char *_nc_get_source(void)
+ { return(*(const char **)0); }
+
#undef _nc_set_source
void _nc_set_source(
const char *const name)
@@ -2948,6 +3003,10 @@ struct name_table_entry const *_nc_find_type_entry(
/* ./tinfo/comp_parse.c */
+#undef _nc_check_termtype2
+void (*_nc_check_termtype2)(
+ TERMTYPE *p1,
+ NCURSES_BOOL p2);
#undef _nc_check_termtype
void (*_nc_check_termtype)(
TERMTYPE *p1);
@@ -2961,6 +3020,18 @@ void _nc_free_entries(
ENTRY *headp)
{ /* void */ }
+#undef _nc_delink_entry
+ENTRY *_nc_delink_entry(
+ ENTRY *headp,
+ TERMTYPE *tterm)
+ { return(*(ENTRY **)0); }
+
+#undef _nc_free_entry
+void _nc_free_entry(
+ ENTRY *headp,
+ TERMTYPE *tterm)
+ { /* void */ }
+
#undef _nc_entry_match
NCURSES_BOOL _nc_entry_match(
char *n1,
@@ -2977,6 +3048,12 @@ void _nc_read_entry_source(
ENTRY *p1))
{ /* void */ }
+#undef _nc_resolve_uses2
+int _nc_resolve_uses2(
+ NCURSES_BOOL fullresolve,
+ NCURSES_BOOL literal)
+ { return(*(int *)0); }
+
#undef _nc_resolve_uses
int _nc_resolve_uses(
NCURSES_BOOL fullresolve)
@@ -2999,16 +3076,22 @@ struct token _nc_curr_token;
#undef _nc_disable_period
NCURSES_BOOL _nc_disable_period;
+#undef _nc_reset_input
+void _nc_reset_input(
+ FILE *fp,
+ char *buf)
+ { /* void */ }
+
#undef _nc_get_token
int _nc_get_token(
NCURSES_BOOL silent)
{ return(*(int *)0); }
#undef _nc_trans_string
-char _nc_trans_string(
+int _nc_trans_string(
char *ptr,
char *last)
- { return(*(char *)0); }
+ { return(*(int *)0); }
#undef _nc_push_token
void _nc_push_token(
@@ -3020,10 +3103,32 @@ void _nc_panic_mode(
char ch)
{ /* void */ }
-#undef _nc_reset_input
-void _nc_reset_input(
- FILE *fp,
- char *buf)
+/* ./tinfo/db_iterator.c */
+
+#undef _nc_tic_dir
+const char *_nc_tic_dir(
+ const char *path)
+ { return(*(const char **)0); }
+
+#undef _nc_keep_tic_dir
+void _nc_keep_tic_dir(
+ const char *path)
+ { /* void */ }
+
+#undef _nc_last_db
+void _nc_last_db(void)
+ { /* void */ }
+
+#undef _nc_next_db
+const char *_nc_next_db(
+ DBDIRS *state,
+ int *offset)
+ { return(*(const char **)0); }
+
+#undef _nc_first_db
+void _nc_first_db(
+ DBDIRS *state,
+ int *offset)
{ /* void */ }
/* ./tinfo/doalloc.c */
@@ -3087,7 +3192,7 @@ void _nc_init_keytry(void)
/* ./tinfo/lib_acs.c */
#undef acs_map
-chtype acs_map[128 ];
+chtype acs_map[128];
#undef _nc_init_acs
void _nc_init_acs(void)
@@ -3098,8 +3203,8 @@ void _nc_init_acs(void)
#include <termcap.h>
struct speed {
- int s;
- int sp;
+ int s;
+ int sp;
};
#undef _nc_baudrate
@@ -3180,7 +3285,7 @@ char *keyname(
#undef key_name
char *key_name(
- wchar_t c)
+ wchar_t c)
{ return(*(char **)0); }
/* ./tinfo/lib_longname.c */
@@ -3191,6 +3296,8 @@ char *longname(void)
/* ./tinfo/lib_napms.c */
+#include <time.h>
+
#undef napms
int napms(
int ms)
@@ -3299,13 +3406,12 @@ int intrflush(
/* ./tinfo/lib_setup.c */
+#include <locale.h>
#include <sys/ioctl.h>
+#include <langinfo.h>
-#undef use_env
-void use_env(
- NCURSES_BOOL f)
- { /* void */ }
-
+#undef ttytype
+char ttytype[256];
#undef LINES
int LINES;
#undef COLS
@@ -3313,12 +3419,39 @@ int COLS;
#undef TABSIZE
int TABSIZE;
+#undef _nc_handle_sigwinch
+int _nc_handle_sigwinch(
+ int enable)
+ { return(*(int *)0); }
+
+#undef use_env
+void use_env(
+ NCURSES_BOOL f)
+ { /* void */ }
+
#undef _nc_update_screensize
void _nc_update_screensize(void)
{ /* void */ }
-#undef ttytype
-char ttytype[256 ];
+#undef _nc_get_locale
+char *_nc_get_locale(void)
+ { return(*(char **)0); }
+
+#undef _nc_unicode_locale
+int _nc_unicode_locale(void)
+ { return(*(int *)0); }
+
+#undef _nc_locale_breaks_acs
+int _nc_locale_breaks_acs(void)
+ { return(*(int *)0); }
+
+#undef _nc_setupterm
+int _nc_setupterm(
+ char *tname,
+ int Filedes,
+ int *errret,
+ NCURSES_BOOL reuse)
+ { return(*(int *)0); }
#undef setupterm
int setupterm(
@@ -3398,15 +3531,22 @@ char *tigetstr(
typedef struct {
union {
- unsigned int num;
- char *str;
+ int num;
+ char *str;
} data;
- NCURSES_BOOL num_type;
+ NCURSES_BOOL num_type;
} stack_frame;
#undef _nc_tparm_err
int _nc_tparm_err;
+#undef _nc_tparm_analyze
+int _nc_tparm_analyze(
+ const char *string,
+ char *p_is_s[9],
+ int *popcount)
+ { return(*(int *)0); }
+
#undef tparm
char *tparm(
char *string,
@@ -3418,7 +3558,7 @@ char *tparm(
#undef PC
char PC;
#undef ospeed
-short ospeed;
+NCURSES_OSPEED ospeed;
#undef _nc_nulls_sent
int _nc_nulls_sent;
@@ -3469,16 +3609,41 @@ void _tracef(
...)
{ /* void */ }
+#undef _nc_retrace_bool
+NCURSES_BOOL _nc_retrace_bool(
+ NCURSES_BOOL code)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef _nc_retrace_int
int _nc_retrace_int(
int code)
{ return(*(int *)0); }
+#undef _nc_retrace_unsigned
+unsigned _nc_retrace_unsigned(
+ unsigned code)
+ { return(*(unsigned *)0); }
+
#undef _nc_retrace_ptr
char *_nc_retrace_ptr(
char *code)
{ return(*(char **)0); }
+#undef _nc_retrace_cptr
+const char *_nc_retrace_cptr(
+ const char *code)
+ { return(*(const char **)0); }
+
+#undef _nc_retrace_cvoid_ptr
+void *_nc_retrace_cvoid_ptr(
+ void *code)
+ { return(*(void **)0); }
+
+#undef _nc_retrace_void_ptr
+void *_nc_retrace_void_ptr(
+ void *code)
+ { return(*(void **)0); }
+
#undef _nc_retrace_sp
SCREEN *_nc_retrace_sp(
SCREEN *code)
@@ -3489,6 +3654,57 @@ WINDOW *_nc_retrace_win(
WINDOW *code)
{ return(*(WINDOW **)0); }
+/* ./trace/lib_traceatr.c */
+
+#undef _traceattr2
+char *_traceattr2(
+ int bufnum,
+ chtype newmode)
+ { return(*(char **)0); }
+
+#undef _traceattr
+char *_traceattr(
+ attr_t newmode)
+ { return(*(char **)0); }
+
+#undef _nc_retrace_attr_t
+attr_t _nc_retrace_attr_t(
+ attr_t code)
+ { return(*(attr_t *)0); }
+
+#undef _nc_altcharset_name
+const char *_nc_altcharset_name(
+ attr_t attr,
+ chtype ch)
+ { return(*(const char **)0); }
+
+#undef _tracechtype2
+char *_tracechtype2(
+ int bufnum,
+ chtype ch)
+ { return(*(char **)0); }
+
+#undef _tracechtype
+char *_tracechtype(
+ chtype ch)
+ { return(*(char **)0); }
+
+#undef _nc_retrace_chtype
+chtype _nc_retrace_chtype(
+ chtype code)
+ { return(*(chtype *)0); }
+
+#undef _tracecchar_t2
+char *_tracecchar_t2(
+ int bufnum,
+ const cchar_t *ch)
+ { return(*(char **)0); }
+
+#undef _tracecchar_t
+char *_tracecchar_t(
+ const cchar_t *ch)
+ { return(*(char **)0); }
+
/* ./trace/lib_tracebits.c */
typedef struct {
@@ -3496,6 +3712,11 @@ typedef struct {
const char *name;
} BITNAMES;
+#undef _nc_trace_ttymode
+char *_nc_trace_ttymode(
+ struct termios *tty)
+ { return(*(char **)0); }
+
#undef _nc_tracebits
char *_nc_tracebits(void)
{ return(*(char **)0); }
@@ -3603,15 +3824,14 @@ typedef struct {
/* ./tinfo/read_entry.c */
-#undef _nc_tic_dir
-const char *_nc_tic_dir(
- const char *path)
- { return(*(const char **)0); }
+#include <hashed_db.h>
-#undef _nc_keep_tic_dir
-void _nc_keep_tic_dir(
- const char *path)
- { /* void */ }
+#undef _nc_read_termtype
+int _nc_read_termtype(
+ TERMTYPE *ptr,
+ char *buffer,
+ int limit)
+ { return(*(int *)0); }
#undef _nc_read_file_entry
int _nc_read_file_entry(
@@ -3621,13 +3841,15 @@ int _nc_read_file_entry(
#undef _nc_read_entry
int _nc_read_entry(
- const char *const tn,
+ const char *const name,
char *const filename,
TERMTYPE *const tp)
{ return(*(int *)0); }
/* ./tinfo/read_termcap.c */
+#include <sys/types.h>
+
#undef _nc_read_termcap_entry
int _nc_read_termcap_entry(
const char *const tn,
@@ -3688,6 +3910,12 @@ char *_nc_trace_buf(
size_t want)
{ return(*(char **)0); }
+#undef _nc_trace_bufcat
+char *_nc_trace_bufcat(
+ int bufnum,
+ const char *value)
+ { return(*(char **)0); }
+
/* ./trace/trace_tries.c */
#undef _nc_trace_tries
@@ -3695,6 +3923,35 @@ void _nc_trace_tries(
struct tries *tree)
{ /* void */ }
+/* ./base/tries.c */
+
+#undef _nc_expand_try
+char *_nc_expand_try(
+ struct tries *tree,
+ unsigned code,
+ int *count,
+ size_t len)
+ { return(*(char **)0); }
+
+#undef _nc_remove_key
+int _nc_remove_key(
+ struct tries **tree,
+ unsigned code)
+ { return(*(int *)0); }
+
+#undef _nc_remove_string
+int _nc_remove_string(
+ struct tries **tree,
+ const char *string)
+ { return(*(int *)0); }
+
+/* ./tinfo/trim_sgr0.c */
+
+#undef _nc_trim_sgr0
+char *_nc_trim_sgr0(
+ TERMTYPE *tp)
+ { return(*(char **)0); }
+
/* ./unctrl.c */
#undef unctrl
@@ -3715,6 +3972,12 @@ const char *_nc_visbuf(
const char *buf)
{ return(*(const char **)0); }
+#undef _nc_visbufn
+const char *_nc_visbufn(
+ const char *buf,
+ int len)
+ { return(*(const char **)0); }
+
#undef _nc_viswbuf2
const char *_nc_viswbuf2(
int bufnum,
@@ -3726,6 +3989,17 @@ const char *_nc_viswbuf(
const wchar_t *buf)
{ return(*(const char **)0); }
+#undef _nc_viswbufn
+const char *_nc_viswbufn(
+ const wchar_t *buf,
+ int len)
+ { return(*(const char **)0); }
+
+#undef _nc_viswibuf
+const char *_nc_viswibuf(
+ const wint_t *buf)
+ { return(*(const char **)0); }
+
#undef _nc_viscbuf2
const char *_nc_viscbuf2(
int bufnum,
@@ -3754,3 +4028,46 @@ void _nc_write_entry(
#undef _nc_tic_written
int _nc_tic_written(void)
{ return(*(int *)0); }
+
+/* ./base/define_key.c */
+
+#undef define_key
+int define_key(
+ const char *str,
+ int keycode)
+ { return(*(int *)0); }
+
+/* ./tinfo/hashed_db.c */
+
+#undef _nc_hashed_db
+void _nc_hashed_db(void)
+ { /* void */ }
+
+/* ./base/key_defined.c */
+
+#undef key_defined
+int key_defined(
+ const char *str)
+ { return(*(int *)0); }
+
+/* ./base/keybound.c */
+
+#undef keybound
+char *keybound(
+ int code,
+ int count)
+ { return(*(char **)0); }
+
+/* ./base/keyok.c */
+
+#undef keyok
+int keyok(
+ int c,
+ NCURSES_BOOL flag)
+ { return(*(int *)0); }
+
+/* ./base/version.c */
+
+#undef curses_version
+const char *curses_version(void)
+ { return(*(const char **)0); }
diff --git a/contrib/ncurses/ncurses/modules b/contrib/ncurses/ncurses/modules
index 541df6f2493c..2e863dad0c38 100644
--- a/contrib/ncurses/ncurses/modules
+++ b/contrib/ncurses/ncurses/modules
@@ -1,6 +1,6 @@
-# $Id: modules,v 1.90 2002/05/11 20:14:41 tom Exp $
+# $Id: modules,v 1.107 2006/08/12 14:19:44 tom Exp $
##############################################################################
-# Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. #
+# Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@@ -27,7 +27,7 @@
# authorization. #
##############################################################################
#
-# Author: Thomas E. Dickey <dickey@clark.net> 1996-1998, etc.
+# Author: Thomas E. Dickey 1996-on
#
@ base
@@ -61,7 +61,7 @@ lib_inchstr lib $(base)
lib_initscr lib $(base) $(INCDIR)/tic.h
lib_insch lib $(base)
lib_insdel lib $(base)
-lib_insstr lib $(base)
+lib_insnstr lib $(base)
lib_instr lib $(base)
lib_isendwin lib $(base)
lib_leaveok lib $(base)
@@ -98,10 +98,9 @@ lib_slkrefr lib $(base) ../include/term.h
lib_slkset lib $(base)
lib_slktouch lib $(base)
lib_touch lib $(base)
-lib_traceatr lib $(trace) ../include/term.h
lib_tracedmp lib $(trace)
lib_tracemse lib $(trace)
-lib_tstp lib $(serial)
+lib_tstp lib $(serial) $(srcdir)/SigAction.h
lib_ungetch lib $(base)
lib_vidattr lib $(serial) ../include/term.h
lib_vline lib $(base)
@@ -117,11 +116,15 @@ varargs lib $(trace)
# Modules for porting
memmove lib $(base)
-sigaction lib $(base)
vsscanf lib $(base)
+# actually an extension, but with its own configure option (--disable-leaks)
+lib_freeall lib $(base)
+
# XSI extensions to the base library (wide-character)
@ widechar
+charable lib $(wide)
+lib_add_wch lib $(wide)
lib_box_set lib $(wide)
lib_cchar lib $(wide)
lib_get_wch lib $(wide)
@@ -130,9 +133,10 @@ lib_get_wstr lib $(wide)
lib_hline_set lib $(wide)
lib_in_wch lib $(wide)
lib_in_wchnstr lib $(wide)
-lib_ins_nwstr lib $(wide)
lib_ins_wch lib $(wide)
lib_inwstr lib $(wide)
+lib_pecho_wchar lib $(wide)
+lib_slk_wset lib $(wide)
lib_unget_wch lib $(wide)
lib_vid_attr lib $(wide) ../include/term.h
lib_vline_set lib $(wide)
@@ -141,17 +145,12 @@ lib_wunctrl lib $(wide)
# Extensions to the base library
@ ext_funcs
-define_key lib $(base)
expanded lib .
-keybound lib $(base)
-keyok lib $(base)
+legacy_coding lib $(base) ../include/term.h
lib_dft_fgbg lib $(base) ../include/term.h
-lib_freeall lib $(base)
lib_print lib $(tinfo) ../include/term.h
resizeterm lib $(base) ../include/term.h
trace_xnames lib $(trace) ../include/term.h $(INCDIR)/term_entry.h
-tries lib $(base)
-version lib $(base)
wresize lib $(base) ../include/term.h
# Support for termcap (and tic, etc.), which can be a separate library
@@ -168,6 +167,7 @@ comp_expand lib $(tinfo) $(INCDIR)/tic.h
comp_hash lib $(tinfo) ../include/term.h $(INCDIR)/tic.h ../include/hashsize.h
comp_parse lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
comp_scan lib $(tinfo) $(INCDIR)/tic.h
+db_iterator lib $(tinfo) $(INCDIR)/tic.h
doalloc lib $(tinfo)
fallback lib . ../include/term.h $(INCDIR)/tic.h
free_ttype lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
@@ -193,6 +193,7 @@ lib_ti lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
lib_tparm lib $(tinfo) ../include/term.h $(INCDIR)/tic.h
lib_tputs lib $(tinfo) ../include/term.h $(INCDIR)/tic.h
lib_trace lib $(trace) $(INCDIR)/tic.h
+lib_traceatr lib $(trace) ../include/term.h
lib_tracebits lib $(trace) ../include/term.h
lib_tracechr lib $(trace)
lib_ttyflags lib $(tinfo) ../include/term.h
@@ -206,6 +207,17 @@ setbuf lib $(tinfo)
strings lib $(tinfo)
trace_buf lib $(trace)
trace_tries lib $(trace)
+tries lib $(base)
+trim_sgr0 lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
unctrl lib .
visbuf lib $(trace) $(INCDIR)/tic.h
write_entry lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
+
+# Extensions to the termlib library
+@ ext_tinfo
+define_key lib $(base)
+hashed_db lib $(tinfo)
+key_defined lib $(base)
+keybound lib $(base)
+keyok lib $(base)
+version lib $(base)
diff --git a/contrib/ncurses/ncurses/tinfo/MKcaptab.awk b/contrib/ncurses/ncurses/tinfo/MKcaptab.awk
index ff9601ba62c5..57087b820e3b 100644
--- a/contrib/ncurses/ncurses/tinfo/MKcaptab.awk
+++ b/contrib/ncurses/ncurses/tinfo/MKcaptab.awk
@@ -1,5 +1,32 @@
#!/bin/sh
-# $Id: MKcaptab.awk,v 1.12 2000/12/10 00:14:12 tom Exp $
+##############################################################################
+# Copyright (c) 1998-2000,2006 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. #
+##############################################################################
+# $Id: MKcaptab.awk,v 1.13 2006/04/22 21:46:17 tom Exp $
AWK=${1-awk}
DATA=${2-../include/Caps}
diff --git a/contrib/ncurses/ncurses/tinfo/MKfallback.sh b/contrib/ncurses/ncurses/tinfo/MKfallback.sh
index d1abcd2eed3f..9feab3507cc0 100755
--- a/contrib/ncurses/ncurses/tinfo/MKfallback.sh
+++ b/contrib/ncurses/ncurses/tinfo/MKfallback.sh
@@ -1,5 +1,32 @@
#!/bin/sh
-# $Id: MKfallback.sh,v 1.11 2001/12/02 01:55:30 tom Exp $
+##############################################################################
+# Copyright (c) 1998-2001,2006 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. #
+##############################################################################
+# $Id: MKfallback.sh,v 1.13 2006/07/15 16:54:20 tom Exp $
#
# MKfallback.sh -- create fallback table for entry reads
#
@@ -25,7 +52,7 @@ if test $# != 0 ; then
TERMINFO_DIRS=$TERMINFO:$terminfo_dir
export TERMINFO_DIRS
- tic $terminfo_src >&2
+ tic -x $terminfo_src >&2
else
tmp_info=
fi
diff --git a/contrib/ncurses/ncurses/tinfo/MKkeys_list.sh b/contrib/ncurses/ncurses/tinfo/MKkeys_list.sh
index 98d5b1379a1c..14017b016896 100755
--- a/contrib/ncurses/ncurses/tinfo/MKkeys_list.sh
+++ b/contrib/ncurses/ncurses/tinfo/MKkeys_list.sh
@@ -1,7 +1,7 @@
#! /bin/sh
-# $Id: MKkeys_list.sh,v 1.2 2001/06/16 16:50:35 tom Exp $
+# $Id: MKkeys_list.sh,v 1.4 2003/10/25 16:19:54 tom Exp $
##############################################################################
-# Copyright (c) 2001 Free Software Foundation, Inc. #
+# Copyright (c) 2001,2003 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"), #
@@ -30,7 +30,7 @@
#
# MKkey_defs.sh -- generate list of function-keys for terminfo database
#
-# Author: Thomas E. Dickey <dickey@herndon4.his.com> 2001
+# Author: Thomas E. Dickey 2001
#
# Extract function-key names from the Caps file
#
@@ -39,7 +39,7 @@ DATA=${1-../../include/Caps}
data=data$$
trap 'rm -f $data' 0 1 2 5 15
-sed -e 's/[ ]\+/ /g' < $DATA >$data
+sed -e 's/[ ][ ]*/ /g' < $DATA >$data
cat <<EOF
# These definitions were generated by $0 $DATA
diff --git a/contrib/ncurses/ncurses/tinfo/MKnames.awk b/contrib/ncurses/ncurses/tinfo/MKnames.awk
index 455efc01dea3..6be00ad4488d 100644
--- a/contrib/ncurses/ncurses/tinfo/MKnames.awk
+++ b/contrib/ncurses/ncurses/tinfo/MKnames.awk
@@ -1,4 +1,31 @@
-# $Id: MKnames.awk,v 1.11 2000/12/09 23:46:13 tom Exp $
+##############################################################################
+# Copyright (c) 1998-2000,2006 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. #
+##############################################################################
+# $Id: MKnames.awk,v 1.12 2006/04/22 21:46:17 tom Exp $
BEGIN {
print "/* This file was generated by MKnames.awk */" > "namehdr"
print "" > "namehdr"
diff --git a/contrib/ncurses/ncurses/tinfo/README b/contrib/ncurses/ncurses/tinfo/README
index 8b092c1ba41c..14c4220c4431 100644
--- a/contrib/ncurses/ncurses/tinfo/README
+++ b/contrib/ncurses/ncurses/tinfo/README
@@ -1,4 +1,32 @@
--- $Id: README,v 1.1 1998/11/07 22:59:07 tom Exp $
+-------------------------------------------------------------------------------
+-- Copyright (c) 1998,2006 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. --
+-------------------------------------------------------------------------------
+-- $Id: README,v 1.2 2006/04/22 22:19:37 tom Exp $
+-------------------------------------------------------------------------------
The files in this directory (tinfo) are those that support the terminfo
database and interfaces for ncurses. The terminfo library can be built
diff --git a/contrib/ncurses/ncurses/tinfo/access.c b/contrib/ncurses/ncurses/tinfo/access.c
index f5240c121c26..c10b7e0af556 100644
--- a/contrib/ncurses/ncurses/tinfo/access.c
+++ b/contrib/ncurses/ncurses/tinfo/access.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2006 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,14 +27,17 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1998,2000,2001 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
#include <curses.priv.h>
+
+#include <sys/stat.h>
+
#include <tic.h>
#include <nc_alloc.h>
-MODULE_ID("$Id: access.c,v 1.9 2001/06/23 22:11:49 tom Exp $")
+MODULE_ID("$Id: access.c,v 1.12 2006/08/05 17:18:14 tom Exp $")
#define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))
@@ -64,19 +67,43 @@ _nc_rootname(char *path)
return result;
}
-NCURSES_EXPORT(char *)
-_nc_basename(char *path)
+/*
+ * Check if a string appears to be an absolute pathname.
+ */
+NCURSES_EXPORT(bool)
+_nc_is_abs_path(const char *path)
{
- char *result = strrchr(path, '/');
+#if defined(__EMX__) || defined(__DJGPP__)
+#define is_pathname(s) ((((s) != 0) && ((s)[0] == '/')) \
+ || (((s)[0] != 0) && ((s)[1] == ':')))
+#else
+#define is_pathname(s) ((s) != 0 && (s)[0] == '/')
+#endif
+ return is_pathname(path);
+}
+
+/*
+ * Return index of the basename
+ */
+NCURSES_EXPORT(unsigned)
+_nc_pathlast(const char *path)
+{
+ const char *test = strrchr(path, '/');
#ifdef __EMX__
- if (result == 0)
- result = strrchr(path, '\\');
+ if (test == 0)
+ test = strrchr(path, '\\');
#endif
- if (result == 0)
- result = path;
+ if (test == 0)
+ test = path;
else
- result++;
- return result;
+ test++;
+ return (test - path);
+}
+
+NCURSES_EXPORT(char *)
+_nc_basename(char *path)
+{
+ return path + _nc_pathlast(path);
}
NCURSES_EXPORT(int)
@@ -102,6 +129,32 @@ _nc_access(const char *path, int mode)
return 0;
}
+NCURSES_EXPORT(bool)
+_nc_is_dir_path(const char *path)
+{
+ bool result = FALSE;
+ struct stat sb;
+
+ if (stat(path, &sb) == 0
+ && (sb.st_mode & S_IFMT) == S_IFDIR) {
+ result = TRUE;
+ }
+ return result;
+}
+
+NCURSES_EXPORT(bool)
+_nc_is_file_path(const char *path)
+{
+ bool result = FALSE;
+ struct stat sb;
+
+ if (stat(path, &sb) == 0
+ && (sb.st_mode & S_IFMT) == S_IFREG) {
+ result = TRUE;
+ }
+ return result;
+}
+
#ifndef USE_ROOT_ENVIRON
/*
* Returns true if we allow application to use environment variables that are
diff --git a/contrib/ncurses/ncurses/tinfo/add_tries.c b/contrib/ncurses/ncurses/tinfo/add_tries.c
index f83249ccf01a..46c93b8fecc7 100644
--- a/contrib/ncurses/ncurses/tinfo/add_tries.c
+++ b/contrib/ncurses/ncurses/tinfo/add_tries.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 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,13 +39,13 @@
#include <curses.priv.h>
-MODULE_ID("$Id: add_tries.c,v 1.4 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: add_tries.c,v 1.5 2005/11/20 01:32:48 tom Exp $")
#define SET_TRY(dst,src) if ((dst->ch = *src++) == 128) dst->ch = '\0'
#define CMP_TRY(a,b) ((a)? (a == b) : (b == 128))
NCURSES_EXPORT(void)
-_nc_add_to_try(struct tries **tree, const char *str, unsigned short code)
+_nc_add_to_try(struct tries **tree, const char *str, unsigned code)
{
static bool out_of_memory = FALSE;
struct tries *ptr, *savedptr;
diff --git a/contrib/ncurses/ncurses/tinfo/alloc_entry.c b/contrib/ncurses/ncurses/tinfo/alloc_entry.c
index 5c064cfd8246..1496752f1956 100644
--- a/contrib/ncurses/ncurses/tinfo/alloc_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/alloc_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -47,7 +48,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: alloc_entry.c,v 1.36 2001/09/22 21:10:26 tom Exp $")
+MODULE_ID("$Id: alloc_entry.c,v 1.47 2006/12/16 19:06:58 tom Exp $")
#define ABSENT_OFFSET -1
#define CANCELLED_OFFSET -2
@@ -58,13 +59,20 @@ static char *stringbuf; /* buffer for string capabilities */
static size_t next_free; /* next free character in stringbuf */
NCURSES_EXPORT(void)
-_nc_init_entry(TERMTYPE * const tp)
+_nc_init_entry(TERMTYPE *const tp)
/* initialize a terminal type data block */
{
- int i;
+ unsigned i;
+
+#if NO_LEAKS
+ if (tp == 0 && stringbuf != 0) {
+ FreeAndNull(stringbuf);
+ return;
+ }
+#endif
if (stringbuf == 0)
- stringbuf = malloc(MAX_STRTAB);
+ stringbuf = (char *) malloc(MAX_STRTAB);
#if NCURSES_XNAMES
tp->num_Booleans = BOOLCOUNT;
@@ -75,7 +83,7 @@ _nc_init_entry(TERMTYPE * const tp)
tp->ext_Strings = 0;
#endif
if (tp->Booleans == 0)
- tp->Booleans = typeMalloc(char, BOOLCOUNT);
+ tp->Booleans = typeMalloc(NCURSES_SBOOL, BOOLCOUNT);
if (tp->Numbers == 0)
tp->Numbers = typeMalloc(short, NUMCOUNT);
if (tp->Strings == 0)
@@ -105,20 +113,32 @@ _nc_copy_entry(ENTRY * oldp)
return newp;
}
+/* save a copy of string in the string buffer */
NCURSES_EXPORT(char *)
_nc_save_str(const char *const string)
-/* save a copy of string in the string buffer */
{
+ char *result = 0;
size_t old_next_free = next_free;
size_t len = strlen(string) + 1;
- if (next_free + len < MAX_STRTAB) {
+ if (len == 1 && next_free != 0) {
+ /*
+ * Cheat a little by making an empty string point to the end of the
+ * previous string.
+ */
+ if (next_free < MAX_STRTAB) {
+ result = (stringbuf + next_free - 1);
+ }
+ } else if (next_free + len < MAX_STRTAB) {
strcpy(&stringbuf[next_free], string);
DEBUG(7, ("Saved string %s", _nc_visbuf(string)));
DEBUG(7, ("at location %d", (int) next_free));
next_free += len;
+ result = (stringbuf + old_next_free);
+ } else {
+ _nc_warning("Too much data, some is lost");
}
- return (stringbuf + old_next_free);
+ return result;
}
NCURSES_EXPORT(void)
@@ -126,7 +146,8 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
/* copy the string parts to allocated storage, preserving pointers to it */
{
int offsets[MAX_ENTRY_SIZE / 2], useoffsets[MAX_USES];
- int i, n;
+ unsigned i, n;
+ unsigned nuses = ep->nuses;
TERMTYPE *tp = &(ep->tterm);
if (copy_strings) {
@@ -141,7 +162,7 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
}
}
- for (i = 0; i < ep->nuses; i++) {
+ for (i = 0; i < nuses; i++) {
if (ep->uses[i].name == 0) {
ep->uses[i].name = _nc_save_str(ep->uses[i].name);
}
@@ -160,7 +181,7 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
offsets[i] = tp->Strings[i] - stringbuf;
}
- for (i = 0; i < ep->nuses; i++) {
+ for (i = 0; i < nuses; i++) {
if (ep->uses[i].name == 0)
useoffsets[i] = ABSENT_OFFSET;
else
@@ -168,7 +189,7 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
}
if ((tp->str_table = typeMalloc(char, next_free)) == (char *) 0)
- _nc_err_abort("Out of memory");
+ _nc_err_abort(MSG_NO_MEMORY);
(void) memcpy(tp->str_table, stringbuf, next_free);
tp->term_names = tp->str_table + n;
@@ -190,7 +211,7 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
offsets[i] = tp->ext_Names[i] - stringbuf;
}
if ((tp->ext_str_table = typeMalloc(char, length)) == 0)
- _nc_err_abort("Out of memory");
+ _nc_err_abort(MSG_NO_MEMORY);
for (i = 0, length = 0; i < n; i++) {
tp->ext_Names[i] = tp->ext_str_table + length;
strcpy(tp->ext_Names[i], stringbuf + offsets[i]);
@@ -200,7 +221,7 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
}
#endif
- for (i = 0; i < ep->nuses; i++) {
+ for (i = 0; i < nuses; i++) {
if (useoffsets[i] == ABSENT_OFFSET)
ep->uses[i].name = 0;
else
@@ -209,31 +230,34 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
}
NCURSES_EXPORT(void)
-_nc_merge_entry
-(TERMTYPE * const to, TERMTYPE * const from)
+_nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from)
/* merge capabilities from `from' entry into `to' entry */
{
- int i;
+ unsigned i;
#if NCURSES_XNAMES
_nc_align_termtype(to, from);
#endif
for_each_boolean(i, from) {
- int mergebool = from->Booleans[i];
+ if (to->Booleans[i] != (char) CANCELLED_BOOLEAN) {
+ int mergebool = from->Booleans[i];
- if (mergebool == CANCELLED_BOOLEAN)
- to->Booleans[i] = FALSE;
- else if (mergebool == TRUE)
- to->Booleans[i] = mergebool;
+ if (mergebool == CANCELLED_BOOLEAN)
+ to->Booleans[i] = FALSE;
+ else if (mergebool == TRUE)
+ to->Booleans[i] = mergebool;
+ }
}
for_each_number(i, from) {
- int mergenum = from->Numbers[i];
+ if (to->Numbers[i] != CANCELLED_NUMERIC) {
+ int mergenum = from->Numbers[i];
- if (mergenum == CANCELLED_NUMERIC)
- to->Numbers[i] = ABSENT_NUMERIC;
- else if (mergenum != ABSENT_NUMERIC)
- to->Numbers[i] = mergenum;
+ if (mergenum == CANCELLED_NUMERIC)
+ to->Numbers[i] = ABSENT_NUMERIC;
+ else if (mergenum != ABSENT_NUMERIC)
+ to->Numbers[i] = mergenum;
+ }
}
/*
@@ -242,11 +266,24 @@ _nc_merge_entry
* we ever want to deallocate entries.
*/
for_each_string(i, from) {
- char *mergestring = from->Strings[i];
+ if (to->Strings[i] != CANCELLED_STRING) {
+ char *mergestring = from->Strings[i];
- if (mergestring == CANCELLED_STRING)
- to->Strings[i] = ABSENT_STRING;
- else if (mergestring != ABSENT_STRING)
- to->Strings[i] = mergestring;
+ if (mergestring == CANCELLED_STRING)
+ to->Strings[i] = ABSENT_STRING;
+ else if (mergestring != ABSENT_STRING)
+ to->Strings[i] = mergestring;
+ }
+ }
+}
+
+#if NO_LEAKS
+NCURSES_EXPORT(void)
+_nc_alloc_entry_leaks(void)
+{
+ if (stringbuf != 0) {
+ FreeAndNull(stringbuf);
}
+ next_free = 0;
}
+#endif
diff --git a/contrib/ncurses/ncurses/tinfo/alloc_ttype.c b/contrib/ncurses/ncurses/tinfo/alloc_ttype.c
index c13c5d6c29ed..9f31ed3ffab7 100644
--- a/contrib/ncurses/ncurses/tinfo/alloc_ttype.c
+++ b/contrib/ncurses/ncurses/tinfo/alloc_ttype.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2003,2006 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,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1999 *
+ * Author: Thomas E. Dickey <dickey@clark.net> 1999-on *
****************************************************************************/
/*
@@ -43,7 +43,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: alloc_ttype.c,v 1.12 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: alloc_ttype.c,v 1.16 2006/07/08 19:18:38 tom Exp $")
#if NCURSES_XNAMES
/*
@@ -92,15 +92,17 @@ find_name(char **table, int length, char *name)
}
static void
-realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int
- ext_Numbers, int ext_Strings)
+realign_data(TERMTYPE *to, char **ext_Names,
+ int ext_Booleans,
+ int ext_Numbers,
+ int ext_Strings)
{
int n, m, base;
int limit = (to->ext_Booleans + to->ext_Numbers + to->ext_Strings);
if (to->ext_Booleans != ext_Booleans) {
to->num_Booleans += (ext_Booleans - to->ext_Booleans);
- to->Booleans = typeRealloc(char, to->num_Booleans, to->Booleans);
+ to->Booleans = typeRealloc(NCURSES_SBOOL, to->num_Booleans, to->Booleans);
for (n = to->ext_Booleans - 1,
m = ext_Booleans - 1,
base = to->num_Booleans - (m + 1); m >= 0; m--) {
@@ -146,7 +148,7 @@ realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int
* Returns the first index in ext_Names[] for the given token-type
*/
static int
-_nc_first_ext_name(TERMTYPE * tp, int token_type)
+_nc_first_ext_name(TERMTYPE *tp, int token_type)
{
int first;
@@ -171,7 +173,7 @@ _nc_first_ext_name(TERMTYPE * tp, int token_type)
* Returns the last index in ext_Names[] for the given token-type
*/
static int
-_nc_last_ext_name(TERMTYPE * tp, int token_type)
+_nc_last_ext_name(TERMTYPE *tp, int token_type)
{
int last;
@@ -194,7 +196,7 @@ _nc_last_ext_name(TERMTYPE * tp, int token_type)
* Lookup an entry from extended-names, returning -1 if not found
*/
static int
-_nc_find_ext_name(TERMTYPE * tp, char *name, int token_type)
+_nc_find_ext_name(TERMTYPE *tp, char *name, int token_type)
{
unsigned j;
unsigned first = _nc_first_ext_name(tp, token_type);
@@ -213,7 +215,7 @@ _nc_find_ext_name(TERMTYPE * tp, char *name, int token_type)
* (e.g., Booleans[]).
*/
static int
-_nc_ext_data_index(TERMTYPE * tp, int n, int token_type)
+_nc_ext_data_index(TERMTYPE *tp, int n, int token_type)
{
switch (token_type) {
case BOOLEAN:
@@ -236,7 +238,7 @@ _nc_ext_data_index(TERMTYPE * tp, int n, int token_type)
* data.
*/
static bool
-_nc_del_ext_name(TERMTYPE * tp, char *name, int token_type)
+_nc_del_ext_name(TERMTYPE *tp, char *name, int token_type)
{
int j;
int first, last;
@@ -280,7 +282,7 @@ _nc_del_ext_name(TERMTYPE * tp, char *name, int token_type)
* index into the corresponding data array is returned.
*/
static int
-_nc_ins_ext_name(TERMTYPE * tp, char *name, int token_type)
+_nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type)
{
unsigned first = _nc_first_ext_name(tp, token_type);
unsigned last = _nc_last_ext_name(tp, token_type);
@@ -291,7 +293,7 @@ _nc_ins_ext_name(TERMTYPE * tp, char *name, int token_type)
int cmp = strcmp(name, tp->ext_Names[j]);
if (cmp == 0)
/* already present */
- return _nc_ext_data_index(tp, j, token_type);
+ return _nc_ext_data_index(tp, (int) j, token_type);
if (cmp < 0) {
break;
}
@@ -301,13 +303,13 @@ _nc_ins_ext_name(TERMTYPE * tp, char *name, int token_type)
for (k = total - 1; k > j; k--)
tp->ext_Names[k] = tp->ext_Names[k - 1];
tp->ext_Names[j] = name;
- j = _nc_ext_data_index(tp, j, token_type);
+ j = _nc_ext_data_index(tp, (int) j, token_type);
switch (token_type) {
case BOOLEAN:
tp->ext_Booleans += 1;
tp->num_Booleans += 1;
- tp->Booleans = typeRealloc(char, tp->num_Booleans, tp->Booleans);
+ tp->Booleans = typeRealloc(NCURSES_SBOOL, tp->num_Booleans, tp->Booleans);
for (k = tp->num_Booleans - 1; k > j; k--)
tp->Booleans[k] = tp->Booleans[k - 1];
break;
@@ -335,7 +337,7 @@ _nc_ins_ext_name(TERMTYPE * tp, char *name, int token_type)
* cancellation of a name that is inherited from another entry.
*/
static void
-adjust_cancels(TERMTYPE * to, TERMTYPE * from)
+adjust_cancels(TERMTYPE *to, TERMTYPE *from)
{
int first = to->ext_Booleans + to->ext_Numbers;
int last = first + to->ext_Strings;
@@ -371,8 +373,7 @@ adjust_cancels(TERMTYPE * to, TERMTYPE * from)
}
NCURSES_EXPORT(void)
-_nc_align_termtype
-(TERMTYPE * to, TERMTYPE * from)
+_nc_align_termtype(TERMTYPE *to, TERMTYPE *from)
{
int na = NUM_EXT_NAMES(to);
int nb = NUM_EXT_NAMES(from);
@@ -380,6 +381,7 @@ _nc_align_termtype
bool same;
char **ext_Names;
int ext_Booleans, ext_Numbers, ext_Strings;
+ bool used_ext_Names = FALSE;
DEBUG(2, ("align_termtype to(%d:%s), from(%d:%s)", na, to->term_names,
nb, from->term_names));
@@ -443,6 +445,7 @@ _nc_align_termtype
to->ext_Names = ext_Names;
DEBUG(2, ("realigned %d extended names for '%s' (to)",
NUM_EXT_NAMES(to), to->term_names));
+ used_ext_Names = TRUE;
}
if (nb != (ext_Booleans + ext_Numbers + ext_Strings)) {
nb = (ext_Booleans + ext_Numbers + ext_Strings);
@@ -452,18 +455,19 @@ _nc_align_termtype
DEBUG(2, ("realigned %d extended names for '%s' (from)",
NUM_EXT_NAMES(from), from->term_names));
}
+ if (!used_ext_Names)
+ free(ext_Names);
}
}
#endif
NCURSES_EXPORT(void)
-_nc_copy_termtype
-(TERMTYPE * dst, TERMTYPE * src)
+_nc_copy_termtype(TERMTYPE *dst, TERMTYPE *src)
{
- int i;
+ unsigned i;
*dst = *src; /* ...to copy the sizes and string-tables */
- dst->Booleans = typeMalloc(char, NUM_BOOLEANS(dst));
+ dst->Booleans = typeMalloc(NCURSES_SBOOL, NUM_BOOLEANS(dst));
dst->Numbers = typeMalloc(short, NUM_NUMBERS(dst));
dst->Strings = typeMalloc(char *, NUM_STRINGS(dst));
diff --git a/contrib/ncurses/ncurses/tinfo/captoinfo.c b/contrib/ncurses/ncurses/tinfo/captoinfo.c
index bf3116ae24f9..0e3baa845693 100644
--- a/contrib/ncurses/ncurses/tinfo/captoinfo.c
+++ b/contrib/ncurses/ncurses/tinfo/captoinfo.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -39,7 +40,7 @@
*
* There is just one entry point:
*
- * char *_nc_captoinfo(n, s, parametrized)
+ * char *_nc_captoinfo(n, s, parameterized)
*
* Convert value s for termcap string capability named n into terminfo
* format.
@@ -92,7 +93,7 @@
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$Id: captoinfo.c,v 1.41 2001/06/02 22:50:31 skimo Exp $")
+MODULE_ID("$Id: captoinfo.c,v 1.49 2006/12/16 19:16:53 tom Exp $")
#define MAX_PUSHED 16 /* max # args we can push onto the stack */
@@ -115,7 +116,7 @@ init_string(void)
if (my_string == 0)
my_string = typeMalloc(char, my_length = 256);
if (my_string == 0)
- _nc_err_abort("Out of memory");
+ _nc_err_abort(MSG_NO_MEMORY);
*my_string = '\0';
return my_string;
@@ -129,18 +130,18 @@ save_string(char *d, const char *const s)
if (need > my_length) {
my_string = (char *) realloc(my_string, my_length = (need + need));
if (my_string == 0)
- _nc_err_abort("Out of memory");
+ _nc_err_abort(MSG_NO_MEMORY);
d = my_string + have;
}
(void) strcpy(d, s);
return d + strlen(d);
}
-static inline char *
-save_char(char *s, char c)
+static NCURSES_INLINE char *
+save_char(char *s, int c)
{
static char temp[2];
- temp[0] = c;
+ temp[0] = (char) c;
return save_string(s, temp);
}
@@ -272,12 +273,12 @@ getparm(int parm, int n)
* Convert a termcap string to terminfo format.
* 'cap' is the relevant terminfo capability index.
* 's' is the string value of the capability.
- * 'parametrized' tells what type of translations to do:
+ * 'parameterized' tells what type of translations to do:
* % translations if 1
* pad translations if >=0
*/
-char *
-_nc_captoinfo(const char *cap, const char *s, int const parametrized)
+NCURSES_EXPORT(char *)
+_nc_captoinfo(const char *cap, const char *s, int const parameterized)
{
const char *capstart;
@@ -294,7 +295,7 @@ _nc_captoinfo(const char *cap, const char *s, int const parametrized)
capstart = 0;
if (s == 0)
s = "";
- if (parametrized >= 0 && isdigit(UChar(*s)))
+ if (parameterized >= 0 && isdigit(UChar(*s)))
for (capstart = s;; s++)
if (!(isdigit(UChar(*s)) || *s == '*' || *s == '.'))
break;
@@ -303,7 +304,7 @@ _nc_captoinfo(const char *cap, const char *s, int const parametrized)
switch (*s) {
case '%':
s++;
- if (parametrized < 1) {
+ if (parameterized < 1) {
dp = save_char(dp, '%');
break;
}
@@ -464,7 +465,7 @@ _nc_captoinfo(const char *cap, const char *s, int const parametrized)
dp = save_char(dp, '%');
s--;
_nc_warning("unknown %% code %s (%#x) in %s",
- unctrl((chtype) * s), UChar(*s), cap);
+ unctrl((chtype) *s), UChar(*s), cap);
break;
}
break;
@@ -636,8 +637,8 @@ save_tc_inequality(char *bufptr, int c1, int c2)
* Convert a terminfo string to termcap format. Parameters are as in
* _nc_captoinfo().
*/
-char *
-_nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parametrized)
+NCURSES_EXPORT(char *)
+_nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameterized)
{
int seenone = 0, seentwo = 0, saw_m = 0, saw_n = 0;
const char *padding;
@@ -649,11 +650,11 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parametrize
/* we may have to move some trailing mandatory padding up front */
padding = str + strlen(str) - 1;
- if (*padding == '>' && *--padding == '/') {
+ if (padding > str && *padding == '>' && *--padding == '/') {
--padding;
while (isdigit(UChar(*padding)) || *padding == '.' || *padding == '*')
padding--;
- if (*padding == '<' && *--padding == '$')
+ if (padding > str && *padding == '<' && *--padding == '$')
trimmed = padding;
padding += 2;
@@ -678,7 +679,8 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parametrize
--str;
} else if (str[0] == '%' && str[1] == '%') { /* escaped '%' */
bufptr = save_string(bufptr, "%%");
- } else if (*str != '%' || (parametrized < 1)) {
+ ++str;
+ } else if (*str != '%' || (parameterized < 1)) {
bufptr = save_char(bufptr, *str);
} else if (sscanf(str, "%%?%%{%d}%%>%%t%%{%d}%%+%%;", &c1, &c2) == 2) {
str = strchr(str, ';');
@@ -833,4 +835,13 @@ main(int argc, char *argv[])
}
#endif /* MAIN */
-/* captoinfo.c ends here */
+#if NO_LEAKS
+NCURSES_EXPORT(void)
+_nc_captoinfo_leaks(void)
+{
+ if (my_string != 0) {
+ FreeAndNull(my_string);
+ }
+ my_length = 0;
+}
+#endif
diff --git a/contrib/ncurses/ncurses/tinfo/comp_error.c b/contrib/ncurses/ncurses/tinfo/comp_error.c
index e67cb795dd33..015f34886eb1 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_error.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_error.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -40,7 +41,7 @@
#include <tic.h>
-MODULE_ID("$Id: comp_error.c,v 1.23 2001/09/23 00:58:30 tom Exp $")
+MODULE_ID("$Id: comp_error.c,v 1.30 2005/11/26 15:28:47 tom Exp $")
NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings = FALSE;
NCURSES_EXPORT_VAR(int) _nc_curr_line = 0; /* current line # in input */
@@ -49,6 +50,12 @@ NCURSES_EXPORT_VAR(int) _nc_curr_col = 0; /* current column # in input */
static const char *sourcename;
static char *termtype;
+NCURSES_EXPORT(const char *)
+_nc_get_source(void)
+{
+ return sourcename;
+}
+
NCURSES_EXPORT(void)
_nc_set_source(const char *const name)
{
@@ -59,19 +66,28 @@ NCURSES_EXPORT(void)
_nc_set_type(const char *const name)
{
if (termtype == 0)
- termtype = _nc_doalloc(termtype, MAX_NAME_SIZE + 1);
- termtype[0] = '\0';
- if (name)
- strncat(termtype, name, MAX_NAME_SIZE);
+ termtype = typeMalloc(char, MAX_NAME_SIZE + 1);
+ if (termtype != 0) {
+ termtype[0] = '\0';
+ if (name)
+ strncat(termtype, name, MAX_NAME_SIZE);
+ }
}
NCURSES_EXPORT(void)
_nc_get_type(char *name)
{
- strcpy(name, termtype != 0 ? termtype : "");
+#if NO_LEAKS
+ if (name == 0 && termtype != 0) {
+ FreeAndNull(termtype);
+ return;
+ }
+#endif
+ if (name != 0)
+ strcpy(name, termtype != 0 ? termtype : "");
}
-static inline void
+static NCURSES_INLINE void
where_is_problem(void)
{
fprintf(stderr, "\"%s\"", sourcename);
diff --git a/contrib/ncurses/ncurses/tinfo/comp_expand.c b/contrib/ncurses/ncurses/tinfo/comp_expand.c
index 7ba438aff8e2..ef419d84cd2c 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_expand.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_expand.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -35,7 +35,7 @@
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$Id: comp_expand.c,v 1.17 2001/09/22 19:16:52 tom Exp $")
+MODULE_ID("$Id: comp_expand.c,v 1.18 2006/06/17 19:37:14 tom Exp $")
static int
trailing_spaces(const char *src)
@@ -50,8 +50,7 @@ trailing_spaces(const char *src)
#define REALPRINT(s) (UChar(*(s)) < 127 && isprint(UChar(*(s))))
NCURSES_EXPORT(char *)
-_nc_tic_expand
-(const char *srcp, bool tic_format, int numbers)
+_nc_tic_expand(const char *srcp, bool tic_format, int numbers)
{
static char *buffer;
static size_t length;
@@ -62,6 +61,15 @@ _nc_tic_expand
size_t need = (2 + strlen(str)) * 4;
int ch;
+#if NO_LEAKS
+ if (srcp == 0) {
+ if (buffer != 0) {
+ FreeAndNull(buffer);
+ length = 0;
+ }
+ return 0;
+ }
+#endif
if (buffer == 0 || need > length) {
if ((buffer = typeRealloc(char, length = need, buffer)) == 0)
return 0;
diff --git a/contrib/ncurses/ncurses/tinfo/comp_hash.c b/contrib/ncurses/ncurses/tinfo/comp_hash.c
index 9f2ee71041e4..d4d9eaa62e13 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_hash.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_hash.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -37,6 +38,7 @@
*
*/
+#define USE_TERMLIB 1
#include <curses.priv.h>
#include <tic.h>
@@ -48,7 +50,7 @@
#define DEBUG(level, params) /*nothing */
#endif
-MODULE_ID("$Id: comp_hash.c,v 1.25 2001/06/02 22:50:42 skimo Exp $")
+MODULE_ID("$Id: comp_hash.c,v 1.28 2005/08/20 19:58:18 tom Exp $")
static int hash_function(const char *);
@@ -97,12 +99,11 @@ _nc_make_hash_table(struct name_table_entry *table,
* Computes the hashing function on the given string.
*
* The current hash function is the sum of each consectutive pair
- * of characters, taken as two-byte integers, mod Hashtabsize.
+ * of characters, taken as two-byte integers, mod HASHTABSIZE.
*
*/
-static
-int
+static int
hash_function(const char *string)
{
long sum = 0;
@@ -128,8 +129,8 @@ hash_function(const char *string)
#ifndef MAIN_PROGRAM
NCURSES_EXPORT(struct name_table_entry const *)
-_nc_find_entry
-(const char *string, const struct name_table_entry *const *hash_table)
+_nc_find_entry(const char *string,
+ const struct name_table_entry *const *hash_table)
{
int hashvalue;
struct name_table_entry const *ptr;
@@ -159,10 +160,9 @@ _nc_find_entry
*/
NCURSES_EXPORT(struct name_table_entry const *)
-_nc_find_type_entry
-(const char *string,
- int type,
- const struct name_table_entry *table)
+_nc_find_type_entry(const char *string,
+ int type,
+ const struct name_table_entry *table)
{
struct name_table_entry const *ptr;
diff --git a/contrib/ncurses/ncurses/tinfo/comp_parse.c b/contrib/ncurses/ncurses/tinfo/comp_parse.c
index f11843828e09..667b3257f25a 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_parse.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_parse.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,18 +29,19 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
* comp_parse.c -- parser driver loop and use handling.
*
* _nc_read_entry_source(FILE *, literal, bool, bool (*hook)())
- * _nc_resolve_uses(void)
+ * _nc_resolve_uses2(void)
* _nc_free_entries(void)
*
* Use this code by calling _nc_read_entry_source() on as many source
* files as you like (either terminfo or termcap syntax). If you
- * want use-resolution, call _nc_resolve_uses(). To free the list
+ * want use-resolution, call _nc_resolve_uses2(). To free the list
* storage, do _nc_free_entries().
*
*/
@@ -52,8 +53,12 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: comp_parse.c,v 1.50 2001/06/16 17:52:18 tom Exp $")
+MODULE_ID("$Id: comp_parse.c,v 1.63 2006/07/08 18:55:14 tom Exp $")
+static void sanity_check2(TERMTYPE *, bool);
+NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype2) (TERMTYPE *, bool) = sanity_check2;
+
+/* obsolete: 20040705 */
static void sanity_check(TERMTYPE *);
NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype) (TERMTYPE *) = sanity_check;
@@ -81,14 +86,14 @@ NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype) (TERMTYPE *) = sanity_check
NCURSES_EXPORT_VAR(ENTRY *) _nc_head = 0;
NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = 0;
- static void
- enqueue(ENTRY * ep)
+static void
+enqueue(ENTRY * ep)
/* add an entry to the in-core list */
{
ENTRY *newp = _nc_copy_entry(ep);
if (newp == 0)
- _nc_err_abort("Out of memory");
+ _nc_err_abort(MSG_NO_MEMORY);
newp->last = _nc_tail;
_nc_tail = newp;
@@ -102,24 +107,44 @@ NCURSES_EXPORT(void)
_nc_free_entries(ENTRY * headp)
/* free the allocated storage consumed by list entries */
{
- ENTRY *ep, *next;
+ (void) headp; /* unused - _nc_head is altered here! */
- for (ep = headp; ep; ep = next) {
- /*
- * This conditional lets us disconnect storage from the list.
- * To do this, copy an entry out of the list, then null out
- * the string-table member in the original and any use entries
- * it references.
- */
- FreeIfNeeded(ep->tterm.str_table);
+ while (_nc_head != 0) {
+ _nc_free_termtype(&(_nc_head->tterm));
+ }
+}
+
+NCURSES_EXPORT(ENTRY *)
+_nc_delink_entry(ENTRY * headp, TERMTYPE *tterm)
+/* delink the allocated storage for the given list entry */
+{
+ ENTRY *ep, *last;
+
+ for (last = 0, ep = headp; ep != 0; last = ep, ep = ep->next) {
+ if (&(ep->tterm) == tterm) {
+ if (last != 0) {
+ last->next = ep->next;
+ }
+ if (ep == _nc_head) {
+ _nc_head = ep->next;
+ }
+ if (ep == _nc_tail) {
+ _nc_tail = last;
+ }
+ break;
+ }
+ }
+ return ep;
+}
- next = ep->next;
+NCURSES_EXPORT(void)
+_nc_free_entry(ENTRY * headp, TERMTYPE *tterm)
+/* free the allocated storage consumed by the given list entry */
+{
+ ENTRY *ep;
+ if ((ep = _nc_delink_entry(headp, tterm)) != 0) {
free(ep);
- if (ep == _nc_head)
- _nc_head = 0;
- if (ep == _nc_tail)
- _nc_tail = 0;
}
}
@@ -163,7 +188,7 @@ _nc_entry_match(char *n1, char *n2)
****************************************************************************/
NCURSES_EXPORT(void)
-_nc_read_entry_source(FILE * fp, char *buf,
+_nc_read_entry_source(FILE *fp, char *buf,
int literal, bool silent,
bool(*hook) (ENTRY *))
/* slurp all entries in the given file into core */
@@ -184,14 +209,25 @@ _nc_read_entry_source(FILE * fp, char *buf,
_nc_err_abort("terminal names must start with letter or digit");
/*
- * This can be used for immediate compilation of entries with no
- * use references to disk, so as to avoid chewing up a lot of
- * core when the resolution code could fetch entries off disk.
+ * This can be used for immediate compilation of entries with no "use="
+ * references to disk. That avoids consuming a lot of memory when the
+ * resolution code could fetch entries off disk.
*/
- if (hook != NULLHOOK && (*hook) (&thisentry))
+ if (hook != NULLHOOK && (*hook) (&thisentry)) {
immediate++;
- else
+ } else {
enqueue(&thisentry);
+ /*
+ * The enqueued entry is copied with _nc_copy_termtype(), so we can
+ * free some of the data from thisentry, i.e., the arrays.
+ */
+ FreeIfNeeded(thisentry.tterm.Booleans);
+ FreeIfNeeded(thisentry.tterm.Numbers);
+ FreeIfNeeded(thisentry.tterm.Strings);
+#if NCURSES_XNAMES
+ FreeIfNeeded(thisentry.tterm.ext_Names);
+#endif
+ }
}
if (_nc_tail) {
@@ -211,12 +247,12 @@ _nc_read_entry_source(FILE * fp, char *buf,
}
NCURSES_EXPORT(int)
-_nc_resolve_uses(bool fullresolve)
+_nc_resolve_uses2(bool fullresolve, bool literal)
/* try to resolve all use capabilities */
{
ENTRY *qp, *rp, *lastread = 0;
bool keepgoing;
- int i, j, unresolved, total_unresolved, multiples;
+ int i, unresolved, total_unresolved, multiples;
DEBUG(2, ("RESOLUTION BEGINNING"));
@@ -289,7 +325,7 @@ _nc_resolve_uses(bool fullresolve)
rp = typeMalloc(ENTRY, 1);
if (rp == 0)
- _nc_err_abort("Out of memory");
+ _nc_err_abort(MSG_NO_MEMORY);
rp->tterm = thisterm;
rp->nuses = 0;
rp->next = lastread;
@@ -320,8 +356,8 @@ _nc_resolve_uses(bool fullresolve)
DEBUG(2, ("NAME RESOLUTION COMPLETED OK"));
/*
- * OK, at this point all (char *) references in `name' mwmbers
- * have been successfully converred to (ENTRY *) pointers in
+ * OK, at this point all (char *) references in `name' members
+ * have been successfully converted to (ENTRY *) pointers in
* `link' members. Time to do the actual merges.
*/
if (fullresolve) {
@@ -347,10 +383,10 @@ _nc_resolve_uses(bool fullresolve)
}
/*
- * First, make sure there's no garbage in the
- * merge block. as a side effect, copy into
- * the merged entry the name field and string
- * table pointer.
+ * First, make sure there is no garbage in the
+ * merge block. As a side effect, copy into
+ * the merged entry the name field and string
+ * table pointer.
*/
_nc_copy_termtype(&merged, &(qp->tterm));
@@ -373,6 +409,9 @@ _nc_resolve_uses(bool fullresolve)
FreeIfNeeded(qp->tterm.Booleans);
FreeIfNeeded(qp->tterm.Numbers);
FreeIfNeeded(qp->tterm.Strings);
+#if NCURSES_XNAMES
+ FreeIfNeeded(qp->tterm.ext_Names);
+#endif
qp->tterm = merged;
_nc_wrap_entry(qp, TRUE);
@@ -389,26 +428,6 @@ _nc_resolve_uses(bool fullresolve)
(keepgoing);
DEBUG(2, ("MERGES COMPLETED OK"));
-
- /*
- * The exit condition of the loop above is such that all entries
- * must now be resolved. Now handle cancellations. In a resolved
- * entry there should be no cancellation markers.
- */
- for_entry_list(qp) {
- for_each_boolean(j, &(qp->tterm)) {
- if ((int) qp->tterm.Booleans[j] == CANCELLED_BOOLEAN)
- qp->tterm.Booleans[j] = ABSENT_BOOLEAN;
- }
- for_each_number(j, &(qp->tterm)) {
- if (qp->tterm.Numbers[j] == CANCELLED_NUMERIC)
- qp->tterm.Numbers[j] = ABSENT_NUMERIC;
- }
- for_each_string(j, &(qp->tterm)) {
- if (qp->tterm.Strings[j] == CANCELLED_STRING)
- qp->tterm.Strings[j] = ABSENT_STRING;
- }
- }
}
/*
@@ -426,7 +445,7 @@ _nc_resolve_uses(bool fullresolve)
for_entry_list(qp) {
_nc_curr_line = qp->startline;
_nc_set_type(_nc_first_name(qp->tterm.term_names));
- _nc_check_termtype(&qp->tterm);
+ _nc_check_termtype2(&qp->tterm, literal);
}
DEBUG(2, ("SANITY CHECK FINISHED"));
}
@@ -434,6 +453,13 @@ _nc_resolve_uses(bool fullresolve)
return (TRUE);
}
+/* obsolete: 20040705 */
+NCURSES_EXPORT(int)
+_nc_resolve_uses(bool fullresolve)
+{
+ return _nc_resolve_uses2(fullresolve, FALSE);
+}
+
/*
* This bit of legerdemain turns all the terminfo variable names into
* references to locations in the arrays Booleans, Numbers, and Strings ---
@@ -444,7 +470,7 @@ _nc_resolve_uses(bool fullresolve)
#define CUR tp->
static void
-sanity_check(TERMTYPE * tp)
+sanity_check2(TERMTYPE *tp, bool literal)
{
if (!PRESENT(exit_attribute_mode)) {
#ifdef __UNUSED__ /* this casts too wide a net */
@@ -461,22 +487,24 @@ sanity_check(TERMTYPE * tp)
|| PRESENT(enter_reverse_mode)))
_nc_warning("no exit_attribute_mode");
#endif /* __UNUSED__ */
- PAIRED(enter_standout_mode, exit_standout_mode)
- PAIRED(enter_underline_mode, exit_underline_mode)
+ PAIRED(enter_standout_mode, exit_standout_mode);
+ PAIRED(enter_underline_mode, exit_underline_mode);
}
/* we do this check/fix in postprocess_termcap(), but some packagers
* prefer to bypass it...
*/
- if (acs_chars == 0
- && enter_alt_charset_mode != 0
- && exit_alt_charset_mode != 0)
- acs_chars = strdup(VT_ACSC);
+ if (!literal) {
+ if (acs_chars == 0
+ && enter_alt_charset_mode != 0
+ && exit_alt_charset_mode != 0)
+ acs_chars = strdup(VT_ACSC);
+ ANDMISSING(enter_alt_charset_mode, acs_chars);
+ ANDMISSING(exit_alt_charset_mode, acs_chars);
+ }
/* listed in structure-member order of first argument */
PAIRED(enter_alt_charset_mode, exit_alt_charset_mode);
- ANDMISSING(enter_alt_charset_mode, acs_chars);
- ANDMISSING(exit_alt_charset_mode, acs_chars);
ANDMISSING(enter_blink_mode, exit_attribute_mode);
ANDMISSING(enter_bold_mode, exit_attribute_mode);
PAIRED(exit_ca_mode, enter_ca_mode);
@@ -499,3 +527,10 @@ sanity_check(TERMTYPE * tp)
#endif
ANDMISSING(set_color_pair, initialize_pair);
}
+
+/* obsolete: 20040705 */
+static void
+sanity_check(TERMTYPE *tp)
+{
+ sanity_check2(tp, FALSE);
+}
diff --git a/contrib/ncurses/ncurses/tinfo/comp_scan.c b/contrib/ncurses/ncurses/tinfo/comp_scan.c
index 52fb13a7f76e..e937f7eb5ada 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_scan.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_scan.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996 on *
****************************************************************************/
/*
@@ -50,7 +51,7 @@
#include <term_entry.h>
#include <tic.h>
-MODULE_ID("$Id: comp_scan.c,v 1.59 2001/09/23 00:56:29 tom Exp $")
+MODULE_ID("$Id: comp_scan.c,v 1.78 2006/12/16 19:17:01 tom Exp $")
/*
* Maximum length of string capability we'll accept before raising an error.
@@ -84,6 +85,7 @@ _nc_curr_token =
*****************************************************************************/
static bool first_column; /* See 'next_char()' below */
+static bool had_newline;
static char separator; /* capability separator */
static int pushtype; /* type of pushback token */
static char *pushname;
@@ -93,14 +95,196 @@ NCURSES_EXPORT_VAR(bool)
_nc_disable_period = FALSE; /* used by tic -a option */
#endif
-static int last_char(void);
-static int next_char(void);
-static long stream_pos(void);
-static bool end_of_stream(void);
-static void push_back(char c);
+/*****************************************************************************
+ *
+ * Character-stream handling
+ *
+ *****************************************************************************/
+
+#define LEXBUFSIZ 1024
+
+static char *bufptr; /* otherwise, the input buffer pointer */
+static char *bufstart; /* start of buffer so we can compute offsets */
+static FILE *yyin; /* scanner's input file descriptor */
+
+/*
+ * _nc_reset_input()
+ *
+ * Resets the input-reading routines. Used on initialization,
+ * or after a seek has been done. Exactly one argument must be
+ * non-null.
+ */
+
+NCURSES_EXPORT(void)
+_nc_reset_input(FILE *fp, char *buf)
+{
+ pushtype = NO_PUSHBACK;
+ if (pushname != 0)
+ pushname[0] = '\0';
+ yyin = fp;
+ bufstart = bufptr = buf;
+ _nc_curr_file_pos = 0L;
+ if (fp != 0)
+ _nc_curr_line = 0;
+ _nc_curr_col = 0;
+}
+
+/*
+ * int last_char()
+ *
+ * Returns the final nonblank character on the current input buffer
+ */
+static int
+last_char(void)
+{
+ size_t len = strlen(bufptr);
+ while (len--) {
+ if (!isspace(UChar(bufptr[len])))
+ return bufptr[len];
+ }
+ return 0;
+}
+
+/*
+ * int next_char()
+ *
+ * Returns the next character in the input stream. Comments and leading
+ * white space are stripped.
+ *
+ * The global state variable 'firstcolumn' is set TRUE if the character
+ * returned is from the first column of the input line.
+ *
+ * The global variable _nc_curr_line is incremented for each new line.
+ * The global variable _nc_curr_file_pos is set to the file offset of the
+ * beginning of each line.
+ */
+
+static int
+next_char(void)
+{
+ static char *result;
+ static size_t allocated;
+ int the_char;
+
+ if (!yyin) {
+ if (result != 0) {
+ FreeAndNull(result);
+ FreeAndNull(pushname);
+ allocated = 0;
+ }
+ /*
+ * An string with an embedded null will truncate the input. This is
+ * intentional (we don't read binary files here).
+ */
+ if (bufptr == 0 || *bufptr == '\0')
+ return (EOF);
+ if (*bufptr == '\n') {
+ _nc_curr_line++;
+ _nc_curr_col = 0;
+ } else if (*bufptr == '\t') {
+ _nc_curr_col = (_nc_curr_col | 7);
+ }
+ } else if (!bufptr || !*bufptr) {
+ /*
+ * In theory this could be recoded to do its I/O one character at a
+ * time, saving the buffer space. In practice, this turns out to be
+ * quite hard to get completely right. Try it and see. If you
+ * succeed, don't forget to hack push_back() correspondingly.
+ */
+ size_t used;
+ size_t len;
+
+ do {
+ bufstart = 0;
+ used = 0;
+ do {
+ if (used + (LEXBUFSIZ / 4) >= allocated) {
+ allocated += (allocated + LEXBUFSIZ);
+ result = typeRealloc(char, allocated, result);
+ if (result == 0)
+ return (EOF);
+ }
+ if (used == 0)
+ _nc_curr_file_pos = ftell(yyin);
+
+ if (fgets(result + used, (int) (allocated - used), yyin) != 0) {
+ bufstart = result;
+ if (used == 0) {
+ _nc_curr_line++;
+ _nc_curr_col = 0;
+ }
+ } else {
+ if (used != 0)
+ strcat(result, "\n");
+ }
+ if ((bufptr = bufstart) != 0) {
+ used = strlen(bufptr);
+ while (iswhite(*bufptr)) {
+ if (*bufptr == '\t') {
+ _nc_curr_col = (_nc_curr_col | 7) + 1;
+ } else {
+ _nc_curr_col++;
+ }
+ bufptr++;
+ }
+
+ /*
+ * Treat a trailing <cr><lf> the same as a <newline> so we
+ * can read files on OS/2, etc.
+ */
+ if ((len = strlen(bufptr)) > 1) {
+ if (bufptr[len - 1] == '\n'
+ && bufptr[len - 2] == '\r') {
+ len--;
+ bufptr[len - 1] = '\n';
+ bufptr[len] = '\0';
+ }
+ }
+ } else {
+ return (EOF);
+ }
+ } while (bufptr[len - 1] != '\n'); /* complete a line */
+ } while (result[0] == '#'); /* ignore comments */
+ } else if (*bufptr == '\t') {
+ _nc_curr_col = (_nc_curr_col | 7);
+ }
+
+ first_column = (bufptr == bufstart);
+ if (first_column)
+ had_newline = FALSE;
+
+ _nc_curr_col++;
+ the_char = *bufptr++;
+ return UChar(the_char);
+}
+
+static void
+push_back(char c)
+/* push a character back onto the input stream */
+{
+ if (bufptr == bufstart)
+ _nc_syserr_abort("Can't backspace off beginning of line");
+ *--bufptr = c;
+ _nc_curr_col--;
+}
+
+static long
+stream_pos(void)
+/* return our current character position in the input stream */
+{
+ return (yyin ? ftell(yyin) : (bufptr ? bufptr - bufstart : 0));
+}
+
+static bool
+end_of_stream(void)
+/* are we at end of input? */
+{
+ return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
+ ? TRUE : FALSE);
+}
/* Assume we may be looking at a termcap-style continuation */
-static inline int
+static NCURSES_INLINE int
eat_escaped_newline(int ch)
{
if (ch == '\\')
@@ -148,8 +332,11 @@ _nc_get_token(bool silent)
static const char terminfo_punct[] = "@%&*!#";
static char *buffer;
+ char *after_list;
+ char *after_name;
char *numchk;
char *ptr;
+ char *s;
char numbuf[80];
int ch;
int dot_flag = FALSE;
@@ -157,6 +344,10 @@ _nc_get_token(bool silent)
long number;
long token_start;
unsigned found;
+#ifdef TRACE
+ int old_line;
+ int old_col;
+#endif
if (pushtype != NO_PUSHBACK) {
int retval = pushtype;
@@ -173,16 +364,31 @@ _nc_get_token(bool silent)
return (retval);
}
- if (end_of_stream())
+ if (end_of_stream()) {
+ yyin = 0;
+ next_char(); /* frees its allocated memory */
+ if (buffer != 0) {
+ if (_nc_curr_token.tk_name == buffer)
+ _nc_curr_token.tk_name = 0;
+ FreeAndNull(buffer);
+ }
return (EOF);
+ }
start_token:
token_start = stream_pos();
- while ((ch = next_char()) == '\n' || iswhite(ch))
+ while ((ch = next_char()) == '\n' || iswhite(ch)) {
+ if (ch == '\n')
+ had_newline = TRUE;
continue;
+ }
ch = eat_escaped_newline(ch);
+#ifdef TRACE
+ old_line = _nc_curr_line;
+ old_col = _nc_curr_col;
+#endif
if (ch == EOF)
type = EOF;
else {
@@ -208,36 +414,44 @@ _nc_get_token(bool silent)
}
/* have to make some punctuation chars legal for terminfo */
- if (!isalnum(ch)
+ if (!isalnum(UChar(ch))
#if NCURSES_EXT_FUNCS
&& !(ch == '.' && _nc_disable_period)
#endif
&& !strchr(terminfo_punct, (char) ch)) {
if (!silent)
- _nc_warning("Illegal character (expected alphanumeric or %s) - %s",
+ _nc_warning("Illegal character (expected alphanumeric or %s) - '%s'",
terminfo_punct, unctrl((chtype) ch));
_nc_panic_mode(separator);
goto start_token;
}
if (buffer == 0)
- buffer = _nc_doalloc(buffer, MAX_ENTRY_SIZE);
+ buffer = typeMalloc(char, MAX_ENTRY_SIZE);
+#ifdef TRACE
+ old_line = _nc_curr_line;
+ old_col = _nc_curr_col;
+#endif
ptr = buffer;
*(ptr++) = ch;
if (first_column) {
- char *desc;
-
_nc_comment_start = token_start;
_nc_comment_end = _nc_curr_file_pos;
_nc_start_line = _nc_curr_line;
_nc_syntax = ERR;
+ after_name = 0;
+ after_list = 0;
while ((ch = next_char()) != '\n') {
- if (ch == EOF)
- _nc_err_abort("premature EOF");
- else if (ch == ':' && last_char() != ',') {
+ if (ch == EOF) {
+ _nc_err_abort(MSG_NO_INPUTS);
+ } else if (ch == '|') {
+ after_list = ptr;
+ if (after_name == 0)
+ after_name = ptr;
+ } else if (ch == ':' && last_char() != ',') {
_nc_syntax = SYN_TERMCAP;
separator = ':';
break;
@@ -245,14 +459,18 @@ _nc_get_token(bool silent)
_nc_syntax = SYN_TERMINFO;
separator = ',';
/*
- * Fall-through here is not an accident. The idea is that
- * if we see a comma, we figure this is terminfo unless we
- * subsequently run into a colon -- but we don't stop
- * looking for that colon until hitting a newline. This
+ * If we did not see a '|', then we found a name with no
+ * aliases or description.
+ */
+ if (after_name == 0)
+ break;
+ /*
+ * If we see a comma, we assume this is terminfo unless we
+ * subsequently run into a colon. But we don't stop
+ * looking for a colon until hitting a newline. This
* allows commas to be embedded in description fields of
* either syntax.
*/
- /* FALLTHRU */
} else
ch = eat_escaped_newline(ch);
@@ -277,58 +495,62 @@ _nc_get_token(bool silent)
/*
* This is the soonest we have the terminal name fetched. Set up
- * for following warning messages.
+ * for following warning messages. If there's no '|', then there
+ * is no description.
*/
- ptr = strchr(buffer, '|');
- if (ptr == (char *) NULL)
- ptr = buffer + strlen(buffer);
- ch = *ptr;
- *ptr = '\0';
- _nc_set_type(buffer);
- *ptr = ch;
+ if (after_name != 0) {
+ ch = *after_name;
+ *after_name = '\0';
+ _nc_set_type(buffer);
+ *after_name = ch;
+ }
/*
* Compute the boundary between the aliases and the description
* field for syntax-checking purposes.
*/
- desc = strrchr(buffer, '|');
- if (!silent && desc) {
- if (*desc == '\0')
- _nc_warning("empty longname field");
- else if (strchr(desc, ' ') == (char *) NULL)
- _nc_warning("older tic versions may treat the description field as an alias");
+ if (after_list != 0) {
+ if (!silent) {
+ if (*after_list == '\0')
+ _nc_warning("empty longname field");
+ else if (strchr(after_list, ' ') == 0)
+ _nc_warning("older tic versions may treat the description field as an alias");
+ }
+ } else {
+ after_list = buffer + strlen(buffer);
+ DEBUG(1, ("missing description"));
}
- if (!desc)
- desc = buffer + strlen(buffer);
/*
* Whitespace in a name field other than the long name can confuse
* rdist and some termcap tools. Slashes are a no-no. Other
* special characters can be dangerous due to shell expansion.
*/
- for (ptr = buffer; ptr < desc; ptr++) {
- if (isspace(UChar(*ptr))) {
+ for (s = buffer; s < after_list; ++s) {
+ if (isspace(UChar(*s))) {
if (!silent)
_nc_warning("whitespace in name or alias field");
break;
- } else if (*ptr == '/') {
+ } else if (*s == '/') {
if (!silent)
_nc_warning("slashes aren't allowed in names or aliases");
break;
- } else if (strchr("$[]!*?", *ptr)) {
+ } else if (strchr("$[]!*?", *s)) {
if (!silent)
- _nc_warning("dubious character `%c' in name or alias field", *ptr);
+ _nc_warning("dubious character `%c' in name or alias field", *s);
break;
}
}
- ptr = buffer;
-
_nc_curr_token.tk_name = buffer;
type = NAMES;
} else {
+ if (had_newline && _nc_syntax == SYN_TERMCAP) {
+ _nc_warning("Missing backslash before newline");
+ had_newline = FALSE;
+ }
while ((ch = next_char()) != EOF) {
- if (!isalnum(ch)) {
+ if (!isalnum(UChar(ch))) {
if (_nc_syntax == SYN_TERMINFO) {
if (ch != '_')
break;
@@ -393,7 +615,7 @@ _nc_get_token(bool silent)
/* just to get rid of the compiler warning */
type = UNDEF;
if (!silent)
- _nc_warning("Illegal character - %s", unctrl((chtype) ch));
+ _nc_warning("Illegal character - '%s'", unctrl((chtype) ch));
}
} /* end else (first_column == FALSE) */
} /* end else (ch != EOF) */
@@ -404,6 +626,11 @@ _nc_get_token(bool silent)
if (dot_flag == TRUE)
DEBUG(8, ("Commented out "));
+ if (_nc_tracing >= DEBUG_LEVEL(8)) {
+ _tracef("parsed %d.%d to %d.%d",
+ old_line, old_col,
+ _nc_curr_line, _nc_curr_col);
+ }
if (_nc_tracing >= DEBUG_LEVEL(7)) {
switch (type) {
case BOOLEAN:
@@ -448,8 +675,9 @@ _nc_get_token(bool silent)
type = _nc_get_token(silent);
DEBUG(3, ("token: `%s', class %d",
- _nc_curr_token.tk_name != 0 ? _nc_curr_token.tk_name :
- "<null>",
+ ((_nc_curr_token.tk_name != 0)
+ ? _nc_curr_token.tk_name
+ : "<null>"),
type));
return (type);
@@ -474,7 +702,7 @@ _nc_get_token(bool silent)
*
*/
-NCURSES_EXPORT(char)
+NCURSES_EXPORT(int)
_nc_trans_string(char *ptr, char *last)
{
int count = 0;
@@ -492,10 +720,10 @@ _nc_trans_string(char *ptr, char *last)
if (ch == '^' && last_ch != '%') {
ch = c = next_char();
if (c == EOF)
- _nc_err_abort("Premature EOF");
+ _nc_err_abort(MSG_NO_INPUTS);
if (!(is7bits(ch) && isprint(ch))) {
- _nc_warning("Illegal ^ character - %s", unctrl(ch));
+ _nc_warning("Illegal ^ character - '%s'", unctrl(ch));
}
if (ch == '?') {
*(ptr++) = '\177';
@@ -509,14 +737,14 @@ _nc_trans_string(char *ptr, char *last)
} else if (ch == '\\') {
ch = c = next_char();
if (c == EOF)
- _nc_err_abort("Premature EOF");
+ _nc_err_abort(MSG_NO_INPUTS);
if (ch >= '0' && ch <= '7') {
number = ch - '0';
for (i = 0; i < 2; i++) {
ch = c = next_char();
if (c == EOF)
- _nc_err_abort("Premature EOF");
+ _nc_err_abort(MSG_NO_INPUTS);
if (c < '0' || c > '7') {
if (isdigit(c)) {
@@ -590,21 +818,31 @@ _nc_trans_string(char *ptr, char *last)
continue;
default:
- _nc_warning("Illegal character %s in \\ sequence",
+ _nc_warning("Illegal character '%s' in \\ sequence",
unctrl(ch));
+ /* FALLTHRU */
+ case '|':
*(ptr++) = (char) ch;
} /* endswitch (ch) */
} /* endelse (ch < '0' || ch > '7') */
}
/* end else if (ch == '\\') */
else if (ch == '\n' && (_nc_syntax == SYN_TERMINFO)) {
- /* newlines embedded in a terminfo string are ignored */
+ /*
+ * Newlines embedded in a terminfo string are ignored, provided
+ * that the next line begins with whitespace.
+ */
ignored = TRUE;
} else {
*(ptr++) = (char) ch;
}
if (!ignored) {
+ if (_nc_curr_col <= 1) {
+ push_back(ch);
+ ch = '\n';
+ break;
+ }
last_ch = ch;
count++;
}
@@ -639,11 +877,14 @@ _nc_push_token(int tokclass)
*/
pushtype = tokclass;
if (pushname == 0)
- pushname = _nc_doalloc(pushname, MAX_NAME_SIZE + 1);
+ pushname = typeMalloc(char, MAX_NAME_SIZE + 1);
_nc_get_type(pushname);
DEBUG(3, ("pushing token: `%s', class %d",
- _nc_curr_token.tk_name, pushtype));
+ ((_nc_curr_token.tk_name != 0)
+ ? _nc_curr_token.tk_name
+ : "<null>"),
+ pushtype));
}
/*
@@ -663,169 +904,12 @@ _nc_panic_mode(char ch)
}
}
-/*****************************************************************************
- *
- * Character-stream handling
- *
- *****************************************************************************/
-
-#define LEXBUFSIZ 1024
-
-static char *bufptr; /* otherwise, the input buffer pointer */
-static char *bufstart; /* start of buffer so we can compute offsets */
-static FILE *yyin; /* scanner's input file descriptor */
-
-/*
- * _nc_reset_input()
- *
- * Resets the input-reading routines. Used on initialization,
- * or after a seek has been done. Exactly one argument must be
- * non-null.
- */
-
+#if NO_LEAKS
NCURSES_EXPORT(void)
-_nc_reset_input(FILE * fp, char *buf)
-{
- pushtype = NO_PUSHBACK;
- if (pushname != 0)
- pushname[0] = '\0';
- yyin = fp;
- bufstart = bufptr = buf;
- _nc_curr_file_pos = 0L;
- if (fp != 0)
- _nc_curr_line = 0;
- _nc_curr_col = 0;
-}
-
-/*
- * int last_char()
- *
- * Returns the final nonblank character on the current input buffer
- */
-static int
-last_char(void)
+_nc_comp_scan_leaks(void)
{
- size_t len = strlen(bufptr);
- while (len--) {
- if (!isspace(UChar(bufptr[len])))
- return bufptr[len];
- }
- return 0;
-}
-
-/*
- * int next_char()
- *
- * Returns the next character in the input stream. Comments and leading
- * white space are stripped.
- *
- * The global state variable 'firstcolumn' is set TRUE if the character
- * returned is from the first column of the input line.
- *
- * The global variable _nc_curr_line is incremented for each new line.
- * The global variable _nc_curr_file_pos is set to the file offset of the
- * beginning of each line.
- */
-
-static int
-next_char(void)
-{
- if (!yyin) {
- /*
- * An string with an embedded null will truncate the input. This is
- * intentional (we don't read binary files here).
- */
- if (*bufptr == '\0')
- return (EOF);
- if (*bufptr == '\n') {
- _nc_curr_line++;
- _nc_curr_col = 0;
- }
- } else if (!bufptr || !*bufptr) {
- /*
- * In theory this could be recoded to do its I/O one character at a
- * time, saving the buffer space. In practice, this turns out to be
- * quite hard to get completely right. Try it and see. If you
- * succeed, don't forget to hack push_back() correspondingly.
- */
- static char *result;
- static size_t allocated;
- size_t used;
- size_t len;
-
- do {
- bufstart = 0;
- used = 0;
- do {
- if (used + (LEXBUFSIZ / 4) >= allocated) {
- allocated += (allocated + LEXBUFSIZ);
- result = _nc_doalloc(result, allocated);
- if (result == 0)
- return (EOF);
- }
- if (used == 0)
- _nc_curr_file_pos = ftell(yyin);
-
- if (fgets(result + used, allocated - used, yyin) != NULL) {
- bufstart = result;
- if (used == 0) {
- _nc_curr_line++;
- _nc_curr_col = 0;
- }
- } else {
- if (used != 0)
- strcat(result, "\n");
- }
- if ((bufptr = bufstart) != 0) {
- used = strlen(bufptr);
- while (iswhite(*bufptr))
- bufptr++;
-
- /*
- * Treat a trailing <cr><lf> the same as a <newline> so we
- * can read files on OS/2, etc.
- */
- if ((len = strlen(bufptr)) > 1) {
- if (bufptr[len - 1] == '\n'
- && bufptr[len - 2] == '\r') {
- len--;
- bufptr[len - 1] = '\n';
- bufptr[len] = '\0';
- }
- }
- } else {
- return (EOF);
- }
- } while (bufptr[len - 1] != '\n'); /* complete a line */
- } while (result[0] == '#'); /* ignore comments */
+ if (pushname != 0) {
+ FreeAndNull(pushname);
}
-
- first_column = (bufptr == bufstart);
-
- _nc_curr_col++;
- return (*bufptr++);
-}
-
-static void
-push_back(char c)
-/* push a character back onto the input stream */
-{
- if (bufptr == bufstart)
- _nc_syserr_abort("Can't backspace off beginning of line");
- *--bufptr = c;
-}
-
-static long
-stream_pos(void)
-/* return our current character position in the input stream */
-{
- return (yyin ? ftell(yyin) : (bufptr ? bufptr - bufstart : 0));
-}
-
-static bool
-end_of_stream(void)
-/* are we at end of input? */
-{
- return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
- ? TRUE : FALSE);
}
+#endif
diff --git a/contrib/ncurses/ncurses/tinfo/db_iterator.c b/contrib/ncurses/ncurses/tinfo/db_iterator.c
new file mode 100644
index 000000000000..e69aa5e18834
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/db_iterator.c
@@ -0,0 +1,227 @@
+/****************************************************************************
+ * Copyright (c) 2006 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2006 *
+ ****************************************************************************/
+
+/*
+ * Iterators for terminal databases.
+ */
+
+#include <curses.priv.h>
+
+#include <tic.h>
+
+MODULE_ID("$Id: db_iterator.c,v 1.5 2006/12/16 19:06:42 tom Exp $")
+
+static bool have_tic_directory = FALSE;
+static bool keep_tic_directory = FALSE;
+
+/*
+ * Record the "official" location of the terminfo directory, according to
+ * the place where we're writing to, or the normal default, if not.
+ */
+NCURSES_EXPORT(const char *)
+_nc_tic_dir(const char *path)
+{
+ static const char *result = TERMINFO;
+
+ if (!keep_tic_directory) {
+ if (path != 0) {
+ result = path;
+ have_tic_directory = TRUE;
+ } else if (!have_tic_directory && use_terminfo_vars()) {
+ char *envp;
+ if ((envp = getenv("TERMINFO")) != 0)
+ return _nc_tic_dir(envp);
+ }
+ }
+ return result;
+}
+
+/*
+ * Special fix to prevent the terminfo directory from being moved after tic
+ * has chdir'd to it. If we let it be changed, then if $TERMINFO has a
+ * relative path, we'll lose track of the actual directory.
+ */
+NCURSES_EXPORT(void)
+_nc_keep_tic_dir(const char *path)
+{
+ _nc_tic_dir(path);
+ keep_tic_directory = TRUE;
+}
+
+/*
+ * Process the list of :-separated directories, looking for the terminal type.
+ * We don't use strtok because it does not show us empty tokens.
+ */
+
+static char *this_db_list = 0;
+static int size_db_list;
+
+/*
+ * Cleanup.
+ */
+NCURSES_EXPORT(void)
+_nc_last_db(void)
+{
+ if (this_db_list != 0) {
+ FreeAndNull(this_db_list);
+ }
+ size_db_list = 0;
+}
+
+/* The TERMINFO_DIRS value, if defined by the configure script, begins with a
+ * ":", which will be interpreted as TERMINFO.
+ */
+static const char *
+next_list_item(const char *source, int *offset)
+{
+ if (source != 0) {
+ FreeIfNeeded(this_db_list);
+ this_db_list = strdup(source);
+ size_db_list = strlen(source);
+ }
+
+ if (this_db_list != 0 && size_db_list && *offset < size_db_list) {
+ static char system_db[] = TERMINFO;
+ char *result = this_db_list + *offset;
+ char *marker = strchr(result, NCURSES_PATHSEP);
+
+ /*
+ * Put a null on the marker if a separator was found. Set the offset
+ * to the next position after the marker so we can call this function
+ * again, using the data at the offset.
+ */
+ if (marker == 0) {
+ *offset += strlen(result) + 1;
+ marker = result + *offset;
+ } else {
+ *marker++ = 0;
+ *offset = marker - this_db_list;
+ }
+ if (*result == 0 && result != (this_db_list + size_db_list))
+ result = system_db;
+ return result;
+ }
+ return 0;
+}
+
+#define NEXT_DBD(var, offset) next_list_item((*offset == 0) ? var : 0, offset)
+
+/*
+ * This is a simple iterator which allows the caller to step through the
+ * possible locations for a terminfo directory. ncurses uses this to find
+ * terminfo files to read.
+ */
+NCURSES_EXPORT(const char *)
+_nc_next_db(DBDIRS * state, int *offset)
+{
+ const char *result;
+ char *envp;
+
+ while (*state < dbdLAST) {
+ DBDIRS next = (DBDIRS) ((int) (*state) + 1);
+
+ result = 0;
+
+ switch (*state) {
+ case dbdTIC:
+ if (have_tic_directory)
+ result = _nc_tic_dir(0);
+ break;
+#if USE_DATABASE
+ case dbdEnvOnce:
+ if (use_terminfo_vars()) {
+ if ((envp = getenv("TERMINFO")) != 0)
+ result = _nc_tic_dir(envp);
+ }
+ break;
+ case dbdHome:
+ if (use_terminfo_vars()) {
+ result = _nc_home_terminfo();
+ }
+ break;
+ case dbdEnvList:
+ if (use_terminfo_vars()) {
+ if ((result = NEXT_DBD(getenv("TERMINFO_DIRS"), offset)) != 0)
+ next = *state;
+ }
+ break;
+ case dbdCfgList:
+#ifdef TERMINFO_DIRS
+ if ((result = NEXT_DBD(TERMINFO_DIRS, offset)) != 0)
+ next = *state;
+#endif
+ break;
+ case dbdCfgOnce:
+#ifndef TERMINFO_DIRS
+ result = TERMINFO;
+#endif
+ break;
+#endif /* USE_DATABASE */
+#if USE_TERMCAP
+ case dbdEnvOnce2:
+ if (use_terminfo_vars()) {
+ if ((envp = getenv("TERMCAP")) != 0)
+ result = _nc_tic_dir(envp);
+ }
+ break;
+ case dbdEnvList2:
+ if (use_terminfo_vars()) {
+ if ((result = NEXT_DBD(getenv("TERMPATH"), offset)) != 0)
+ next = *state;
+ }
+ break;
+ case dbdCfgList2:
+ if ((result = NEXT_DBD(TERMPATH, offset)) != 0)
+ next = *state;
+ break;
+#endif /* USE_TERMCAP */
+ case dbdLAST:
+ break;
+ }
+ if (*state != next) {
+ *state = next;
+ *offset = 0;
+ _nc_last_db();
+ }
+ if (result != 0) {
+ return result;
+ }
+ }
+ return 0;
+}
+
+NCURSES_EXPORT(void)
+_nc_first_db(DBDIRS * state, int *offset)
+{
+ *state = dbdTIC;
+ *offset = 0;
+}
diff --git a/contrib/ncurses/ncurses/tinfo/doalloc.c b/contrib/ncurses/ncurses/tinfo/doalloc.c
index 634469cdf4ac..fe2a009d19b4 100644
--- a/contrib/ncurses/ncurses/tinfo/doalloc.c
+++ b/contrib/ncurses/ncurses/tinfo/doalloc.c
@@ -39,7 +39,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: doalloc.c,v 1.7 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: doalloc.c,v 1.8 2002/08/31 21:48:11 Philippe.Blain Exp $")
NCURSES_EXPORT(void *)
_nc_doalloc(void *oldp, size_t amount)
@@ -52,7 +52,7 @@ _nc_doalloc(void *oldp, size_t amount)
errno = ENOMEM; /* just in case 'free' reset */
}
} else {
- newp = typeMalloc(char, amount);
+ newp = malloc(amount);
}
return newp;
}
diff --git a/contrib/ncurses/ncurses/tinfo/free_ttype.c b/contrib/ncurses/ncurses/tinfo/free_ttype.c
index df604e41a681..fa0fff1b83fb 100644
--- a/contrib/ncurses/ncurses/tinfo/free_ttype.c
+++ b/contrib/ncurses/ncurses/tinfo/free_ttype.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2005,2006 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,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1999 *
+ * Author: Thomas E. Dickey 1999-on *
****************************************************************************/
/*
@@ -43,13 +43,14 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: free_ttype.c,v 1.7 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: free_ttype.c,v 1.13 2006/06/25 10:46:02 tom Exp $")
NCURSES_EXPORT(void)
-_nc_free_termtype(TERMTYPE * ptr)
+_nc_free_termtype(TERMTYPE *ptr)
{
+ T(("_nc_free_termtype(%s)", ptr->term_names));
+
FreeIfNeeded(ptr->str_table);
- FreeIfNeeded(ptr->term_names);
FreeIfNeeded(ptr->Booleans);
FreeIfNeeded(ptr->Numbers);
FreeIfNeeded(ptr->Strings);
@@ -58,6 +59,7 @@ _nc_free_termtype(TERMTYPE * ptr)
FreeIfNeeded(ptr->ext_Names);
#endif
memset(ptr, 0, sizeof(TERMTYPE));
+ _nc_free_entry(_nc_head, ptr);
}
#if NCURSES_XNAMES
@@ -67,7 +69,9 @@ NCURSES_EXPORT(int)
use_extended_names(bool flag)
{
int oldflag = _nc_user_definable;
+
+ T((T_CALLED("use_extended_names(%d)"), flag));
_nc_user_definable = flag;
- return oldflag;
+ returnBool(oldflag);
}
#endif
diff --git a/contrib/ncurses/ncurses/tinfo/hashed_db.c b/contrib/ncurses/ncurses/tinfo/hashed_db.c
new file mode 100644
index 000000000000..3fc04eae3cca
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/hashed_db.c
@@ -0,0 +1,260 @@
+/****************************************************************************
+ * Copyright (c) 2006 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2006 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+#include <tic.h>
+#include <hashed_db.h>
+
+#if USE_HASHED_DB
+
+MODULE_ID("$Id: hashed_db.c,v 1.13 2006/08/19 19:48:38 tom Exp $")
+
+#if HASHED_DB_API >= 2
+static DBC *cursor;
+#endif
+
+/*
+ * Open the database.
+ */
+NCURSES_EXPORT(DB *)
+_nc_db_open(const char *path, bool modify)
+{
+ DB *result = 0;
+
+#if HASHED_DB_API >= 4
+ db_create(&result, NULL, 0);
+ result->open(result,
+ NULL,
+ path,
+ NULL,
+ DB_HASH,
+ modify ? DB_CREATE : DB_RDONLY,
+ 0644);
+#elif HASHED_DB_API >= 3
+ db_create(&result, NULL, 0);
+ result->open(result,
+ path,
+ NULL,
+ DB_HASH,
+ modify ? DB_CREATE : DB_RDONLY,
+ 0644);
+#elif HASHED_DB_API >= 2
+ int code;
+
+ if ((code = db_open(path,
+ DB_HASH,
+ modify ? DB_CREATE : DB_RDONLY,
+ 0644,
+ (DB_ENV *) 0,
+ (DB_INFO *) 0,
+ &result)) != 0) {
+ T(("cannot open %s: %s", path, strerror(code)));
+ result = 0;
+ } else {
+ T(("opened %s", path));
+ }
+#else
+ result = dbopen(path,
+ modify ? (O_CREAT | O_RDWR) : O_RDONLY,
+ 0644,
+ DB_HASH,
+ NULL);
+ if (result != 0) {
+ T(("opened %s", path));
+ }
+#endif
+ return result;
+}
+
+/*
+ * Close the database. Do not attempt to use the 'db' handle after this call.
+ */
+NCURSES_EXPORT(int)
+_nc_db_close(DB * db)
+{
+ int result;
+
+#if HASHED_DB_API >= 2
+ result = db->close(db, 0);
+#else
+ result = db->close(db);
+#endif
+ return result;
+}
+
+/*
+ * Write a record to the database.
+ *
+ * Returns 0 on success.
+ *
+ * FIXME: the FreeBSD cap_mkdb program assumes the database could have
+ * duplicates. There appears to be no good reason for that (review/fix).
+ */
+NCURSES_EXPORT(int)
+_nc_db_put(DB * db, DBT * key, DBT * data)
+{
+ int result;
+#if HASHED_DB_API >= 2
+ /* remove any pre-existing value, since we do not want duplicates */
+ (void) db->del(db, NULL, key, 0);
+ result = db->put(db, NULL, key, data, DB_NOOVERWRITE);
+#else
+ result = db->put(db, key, data, R_NOOVERWRITE);
+#endif
+ return result;
+}
+
+/*
+ * Read a record from the database.
+ *
+ * Returns 0 on success.
+ */
+NCURSES_EXPORT(int)
+_nc_db_get(DB * db, DBT * key, DBT * data)
+{
+ int result;
+
+ memset(data, 0, sizeof(*data));
+#if HASHED_DB_API >= 2
+ result = db->get(db, NULL, key, data, 0);
+#else
+ result = db->get(db, key, data, 0);
+#endif
+ return result;
+}
+
+/*
+ * Read the first record from the database, ignoring order.
+ *
+ * Returns 0 on success.
+ */
+NCURSES_EXPORT(int)
+_nc_db_first(DB * db, DBT * key, DBT * data)
+{
+ int result;
+
+ memset(key, 0, sizeof(*key));
+ memset(data, 0, sizeof(*data));
+#if HASHED_DB_API >= 2
+ if ((result = db->cursor(db, NULL, &cursor, 0)) == 0) {
+ result = cursor->c_get(cursor, key, data, DB_FIRST);
+ }
+#else
+ result = db->seq(db, key, data, 0);
+#endif
+ return result;
+}
+
+/*
+ * Read the next record from the database, ignoring order.
+ *
+ * Returns 0 on success.
+ */
+NCURSES_EXPORT(int)
+_nc_db_next(DB * db, DBT * key, DBT * data)
+{
+ int result;
+
+#if HASHED_DB_API >= 2
+ (void) db;
+ if (cursor != 0) {
+ result = cursor->c_get(cursor, key, data, DB_NEXT);
+ } else {
+ result = -1;
+ }
+#else
+ result = db->seq(db, key, data, 0);
+#endif
+ return result;
+}
+
+/*
+ * Check if a record is a terminfo index record. Index records are those that
+ * contain only an alias pointing to a list of aliases.
+ */
+NCURSES_EXPORT(bool)
+_nc_db_have_index(DBT * key, DBT * data, char **buffer, int *size)
+{
+ bool result = FALSE;
+ int used = data->size - 1;
+ char *have = (char *) data->data;
+
+ (void) key;
+ if (*have++ == 2) {
+ result = TRUE;
+ }
+ /*
+ * Update params in any case for consistency with _nc_db_have_data().
+ */
+ *buffer = have;
+ *size = used;
+ return result;
+}
+
+/*
+ * Check if a record is the terminfo data record. Ignore index records, e.g.,
+ * those that contain only an alias pointing to a list of aliases.
+ */
+NCURSES_EXPORT(bool)
+_nc_db_have_data(DBT * key, DBT * data, char **buffer, int *size)
+{
+ bool result = FALSE;
+ int used = data->size - 1;
+ char *have = (char *) data->data;
+
+ if (*have++ == 0) {
+ if (data->size > key->size
+ && IS_TIC_MAGIC(have)) {
+ result = TRUE;
+ }
+ }
+ /*
+ * Update params in any case to make it simple to follow a index record
+ * to the data record.
+ */
+ *buffer = have;
+ *size = used;
+ return result;
+}
+
+#else
+
+extern
+NCURSES_EXPORT(void)
+_nc_hashed_db(void);
+
+NCURSES_EXPORT(void)
+_nc_hashed_db(void)
+{
+}
+
+#endif /* USE_HASHED_DB */
diff --git a/contrib/ncurses/ncurses/tinfo/home_terminfo.c b/contrib/ncurses/ncurses/tinfo/home_terminfo.c
index 47b3e382ef7e..ce6576a82f82 100644
--- a/contrib/ncurses/ncurses/tinfo/home_terminfo.c
+++ b/contrib/ncurses/ncurses/tinfo/home_terminfo.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 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,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1998,2000 *
+ * Author: Thomas E. Dickey 1998,2000,2004,2005 *
****************************************************************************/
/*
@@ -37,7 +37,7 @@
#include <curses.priv.h>
#include <tic.h>
-MODULE_ID("$Id: home_terminfo.c,v 1.6 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: home_terminfo.c,v 1.9 2005/07/02 19:43:38 tom Exp $")
#define my_length (strlen(home) + sizeof(PRIVATE_INFO))
@@ -46,6 +46,8 @@ MODULE_ID("$Id: home_terminfo.c,v 1.6 2000/12/10 02:55:07 tom Exp $")
NCURSES_EXPORT(char *)
_nc_home_terminfo(void)
{
+ char *result = 0;
+#ifdef USE_HOME_TERMINFO
char *home;
static char *temp = 0;
@@ -55,11 +57,12 @@ _nc_home_terminfo(void)
&& my_length <= PATH_MAX) {
temp = typeMalloc(char, my_length);
if (temp == 0)
- _nc_err_abort("Out of memory");
+ _nc_err_abort(MSG_NO_MEMORY);
(void) sprintf(temp, PRIVATE_INFO, home);
}
}
- return temp;
+ result = temp;
}
- return 0;
+#endif
+ return result;
}
diff --git a/contrib/ncurses/ncurses/tinfo/init_keytry.c b/contrib/ncurses/ncurses/tinfo/init_keytry.c
index cf840e8e93b3..3461dd4d5e51 100644
--- a/contrib/ncurses/ncurses/tinfo/init_keytry.c
+++ b/contrib/ncurses/ncurses/tinfo/init_keytry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2005,2006 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 *
@@ -28,11 +28,15 @@
#include <curses.priv.h>
-#include <term.h> /* keypad_xmit, keypad_local, meta_on, meta_off */
- /* cursor_visible,cursor_normal,cursor_invisible */
+#include <term.h>
+/* keypad_xmit, keypad_local, meta_on, meta_off */
+/* cursor_visible,cursor_normal,cursor_invisible */
+
#include <tic.h> /* struct tinfo_fkeys */
-MODULE_ID("$Id: init_keytry.c,v 1.5 2000/12/10 02:55:07 tom Exp $")
+#include <term_entry.h>
+
+MODULE_ID("$Id: init_keytry.c,v 1.8 2006/01/21 23:43:28 tom Exp $")
/*
** _nc_init_keytry()
@@ -69,12 +73,38 @@ _nc_init_keytry(void)
* mouse_activate() (which will call keyok()) are first called.
*/
- for (n = 0; _nc_tinfo_fkeys[n].code; n++)
- if (_nc_tinfo_fkeys[n].offset < STRCOUNT)
- _nc_add_to_try(&(SP->_keytry),
- CUR Strings[_nc_tinfo_fkeys[n].offset],
- _nc_tinfo_fkeys[n].code);
+ if (SP != 0) {
+ for (n = 0; _nc_tinfo_fkeys[n].code; n++) {
+ if (_nc_tinfo_fkeys[n].offset < STRCOUNT) {
+ _nc_add_to_try(&(SP->_keytry),
+ CUR Strings[_nc_tinfo_fkeys[n].offset],
+ _nc_tinfo_fkeys[n].code);
+ }
+ }
+#if NCURSES_XNAMES
+ /*
+ * Add any of the extended strings to the tries if their name begins
+ * with 'k', i.e., they follow the convention of other terminfo key
+ * names.
+ */
+ {
+ TERMTYPE *tp = &(SP->_term->type);
+ for (n = STRCOUNT; n < NUM_STRINGS(tp); ++n) {
+ const char *name = ExtStrname(tp, n, strnames);
+ char *value = tp->Strings[n];
+ if (name != 0
+ && *name == 'k'
+ && value != 0
+ && key_defined(value) == 0) {
+ _nc_add_to_try(&(SP->_keytry),
+ value,
+ n - STRCOUNT + KEY_MAX);
+ }
+ }
+ }
+#endif
#ifdef TRACE
- _nc_trace_tries(SP->_keytry);
+ _nc_trace_tries(SP->_keytry);
#endif
+ }
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_acs.c b/contrib/ncurses/ncurses/tinfo/lib_acs.c
index b84d8e262a2f..2719795d9d4f 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_acs.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_acs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +29,13 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
#include <curses.priv.h>
#include <term.h> /* ena_acs, acs_chars */
-MODULE_ID("$Id: lib_acs.c,v 1.21 2001/12/23 00:15:10 tom Exp $")
+MODULE_ID("$Id: lib_acs.c,v 1.30 2006/01/07 21:27:15 tom Exp $")
#if BROKEN_LINKER
NCURSES_EXPORT_VAR(chtype *)
@@ -55,98 +56,120 @@ NCURSES_EXPORT_VAR(chtype) acs_map[ACS_LEN] =
NCURSES_EXPORT(void)
_nc_init_acs(void)
{
+ chtype *fake_map = acs_map;
+ chtype *real_map = SP != 0 ? SP->_acs_map : fake_map;
+ int j;
+
T(("initializing ACS map"));
/*
+ * If we're using this from curses (rather than terminfo), we are storing
+ * the mapping information in the SCREEN struct so we can decide how to
+ * render it.
+ */
+ if (real_map != fake_map) {
+ for (j = 1; j < ACS_LEN; ++j) {
+ real_map[j] = 0;
+ fake_map[j] = A_ALTCHARSET | j;
+ SP->_screen_acs_map[j] = FALSE;
+ }
+ } else {
+ for (j = 1; j < ACS_LEN; ++j) {
+ real_map[j] = 0;
+ }
+ }
+
+ /*
* Initializations for a UNIX-like multi-terminal environment. Use
* ASCII chars and count on the terminfo description to do better.
*/
- ACS_ULCORNER = '+'; /* should be upper left corner */
- ACS_LLCORNER = '+'; /* should be lower left corner */
- ACS_URCORNER = '+'; /* should be upper right corner */
- ACS_LRCORNER = '+'; /* should be lower right corner */
- ACS_RTEE = '+'; /* should be tee pointing left */
- ACS_LTEE = '+'; /* should be tee pointing right */
- ACS_BTEE = '+'; /* should be tee pointing up */
- ACS_TTEE = '+'; /* should be tee pointing down */
- ACS_HLINE = '-'; /* should be horizontal line */
- ACS_VLINE = '|'; /* should be vertical line */
- ACS_PLUS = '+'; /* should be large plus or crossover */
- ACS_S1 = '~'; /* should be scan line 1 */
- ACS_S9 = '_'; /* should be scan line 9 */
- ACS_DIAMOND = '+'; /* should be diamond */
- ACS_CKBOARD = ':'; /* should be checker board (stipple) */
- ACS_DEGREE = '\''; /* should be degree symbol */
- ACS_PLMINUS = '#'; /* should be plus/minus */
- ACS_BULLET = 'o'; /* should be bullet */
- ACS_LARROW = '<'; /* should be arrow pointing left */
- ACS_RARROW = '>'; /* should be arrow pointing right */
- ACS_DARROW = 'v'; /* should be arrow pointing down */
- ACS_UARROW = '^'; /* should be arrow pointing up */
- ACS_BOARD = '#'; /* should be board of squares */
- ACS_LANTERN = '#'; /* should be lantern symbol */
- ACS_BLOCK = '#'; /* should be solid square block */
+ real_map['l'] = '+'; /* should be upper left corner */
+ real_map['m'] = '+'; /* should be lower left corner */
+ real_map['k'] = '+'; /* should be upper right corner */
+ real_map['j'] = '+'; /* should be lower right corner */
+ real_map['u'] = '+'; /* should be tee pointing left */
+ real_map['t'] = '+'; /* should be tee pointing right */
+ real_map['v'] = '+'; /* should be tee pointing up */
+ real_map['w'] = '+'; /* should be tee pointing down */
+ real_map['q'] = '-'; /* should be horizontal line */
+ real_map['x'] = '|'; /* should be vertical line */
+ real_map['n'] = '+'; /* should be large plus or crossover */
+ real_map['o'] = '~'; /* should be scan line 1 */
+ real_map['s'] = '_'; /* should be scan line 9 */
+ real_map['`'] = '+'; /* should be diamond */
+ real_map['a'] = ':'; /* should be checker board (stipple) */
+ real_map['f'] = '\''; /* should be degree symbol */
+ real_map['g'] = '#'; /* should be plus/minus */
+ real_map['~'] = 'o'; /* should be bullet */
+ real_map[','] = '<'; /* should be arrow pointing left */
+ real_map['+'] = '>'; /* should be arrow pointing right */
+ real_map['.'] = 'v'; /* should be arrow pointing down */
+ real_map['-'] = '^'; /* should be arrow pointing up */
+ real_map['h'] = '#'; /* should be board of squares */
+ real_map['i'] = '#'; /* should be lantern symbol */
+ real_map['0'] = '#'; /* should be solid square block */
/* these defaults were invented for ncurses */
- ACS_S3 = '-'; /* should be scan line 3 */
- ACS_S7 = '-'; /* should be scan line 7 */
- ACS_LEQUAL = '<'; /* should be less-than-or-equal-to */
- ACS_GEQUAL = '>'; /* should be greater-than-or-equal-to */
- ACS_PI = '*'; /* should be greek pi */
- ACS_NEQUAL = '!'; /* should be not-equal */
- ACS_STERLING = 'f'; /* should be pound-sterling symbol */
+ real_map['p'] = '-'; /* should be scan line 3 */
+ real_map['r'] = '-'; /* should be scan line 7 */
+ real_map['y'] = '<'; /* should be less-than-or-equal-to */
+ real_map['z'] = '>'; /* should be greater-than-or-equal-to */
+ real_map['{'] = '*'; /* should be greek pi */
+ real_map['|'] = '!'; /* should be not-equal */
+ real_map['}'] = 'f'; /* should be pound-sterling symbol */
+
+#if !USE_WIDEC_SUPPORT
+ if (_nc_unicode_locale() && _nc_locale_breaks_acs()) {
+ acs_chars = NULL;
+ ena_acs = NULL;
+ enter_alt_charset_mode = NULL;
+ exit_alt_charset_mode = NULL;
+ set_attributes = NULL;
+ }
+#endif
if (ena_acs != NULL) {
TPUTS_TRACE("ena_acs");
putp(ena_acs);
}
-#define ALTCHAR(c) ((chtype)(((unsigned char)(c)) | A_ALTCHARSET))
+#if NCURSES_EXT_FUNCS
+ /*
+ * Linux console "supports" the "PC ROM" character set by the coincidence
+ * that smpch/rmpch and smacs/rmacs have the same values. ncurses has
+ * no codepage support (see SCO Merge for an example). Outside of the
+ * values defined in acsc, there are no definitions for the "PC ROM"
+ * character set (assumed by some applications to be codepage 437), but we
+ * allow those applications to use those codepoints.
+ *
+ * test/blue.c uses this feature.
+ */
+#define PCH_KLUDGE(a,b) (a != 0 && b != 0 && !strcmp(a,b))
+ if (PCH_KLUDGE(enter_pc_charset_mode, enter_alt_charset_mode) &&
+ PCH_KLUDGE(exit_pc_charset_mode, exit_alt_charset_mode)) {
+ size_t i;
+ for (i = 1; i < ACS_LEN; ++i) {
+ if (real_map[i] == 0) {
+ real_map[i] = i;
+ if (real_map != fake_map) {
+ if (SP != 0)
+ SP->_screen_acs_map[i] = TRUE;
+ }
+ }
+ }
+ }
+#endif
if (acs_chars != NULL) {
size_t i = 0;
size_t length = strlen(acs_chars);
- while (i < length)
- switch (acs_chars[i]) {
- case 'l':
- case 'm':
- case 'k':
- case 'j':
- case 'u':
- case 't':
- case 'v':
- case 'w':
- case 'q':
- case 'x':
- case 'n':
- case 'o':
- case 's':
- case '`':
- case 'a':
- case 'f':
- case 'g':
- case '~':
- case ',':
- case '+':
- case '.':
- case '-':
- case 'h':
- case 'i':
- case '0':
- case 'p':
- case 'r':
- case 'y':
- case 'z':
- case '{':
- case '|':
- case '}':
- acs_map[(unsigned int) acs_chars[i]] =
- ALTCHAR(acs_chars[i + 1]);
- i++;
- /* FALLTHRU */
- default:
- i++;
- break;
+ while (i + 1 < length) {
+ if (acs_chars[i] != 0 && UChar(acs_chars[i]) < ACS_LEN) {
+ real_map[UChar(acs_chars[i])] = UChar(acs_chars[i + 1]) | A_ALTCHARSET;
+ if (SP != 0)
+ SP->_screen_acs_map[UChar(acs_chars[i])] = TRUE;
}
+ i += 2;
+ }
}
#ifdef TRACE
/* Show the equivalent mapping, noting if it does not match the
@@ -154,14 +177,18 @@ _nc_init_acs(void)
*/
if (_nc_tracing & TRACE_CALLS) {
size_t n, m;
- char show[ACS_LEN + 1];
+ char show[ACS_LEN * 2 + 1];
for (n = 1, m = 0; n < ACS_LEN; n++) {
- if (acs_map[n] != 0) {
+ if (real_map[n] != 0) {
show[m++] = (char) n;
- show[m++] = ChCharOf(acs_map[n]);
+ show[m++] = ChCharOf(real_map[n]);
}
}
show[m] = 0;
+ if (acs_chars == NULL || strcmp(acs_chars, show))
+ _tracef("%s acs_chars %s",
+ (acs_chars == NULL) ? "NULL" : "READ",
+ _nc_visbuf(acs_chars));
_tracef("%s acs_chars %s",
(acs_chars == NULL)
? "NULL"
diff --git a/contrib/ncurses/ncurses/tinfo/lib_cur_term.c b/contrib/ncurses/ncurses/tinfo/lib_cur_term.c
index 8f269e591d0c..8fccc2f88d08 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_cur_term.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_cur_term.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2003 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 <term_entry.h> /* TTY, cur_term */
#include <termcap.h> /* ospeed */
-MODULE_ID("$Id: lib_cur_term.c,v 1.11 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_cur_term.c,v 1.13 2003/12/27 18:21:30 tom Exp $")
NCURSES_EXPORT_VAR(TERMINAL *) cur_term = 0;
@@ -49,11 +49,14 @@ set_curterm(TERMINAL * termp)
{
TERMINAL *oldterm = cur_term;
+ T((T_CALLED("set_curterm(%p)"), termp));
+
if ((cur_term = termp) != 0) {
ospeed = _nc_ospeed(cur_term->_baudrate);
PC = (pad_char != NULL) ? pad_char[0] : 0;
}
- return oldterm;
+ T((T_RETURN("%p"), oldterm));
+ return (oldterm);
}
NCURSES_EXPORT(int)
@@ -63,6 +66,7 @@ del_curterm(TERMINAL * termp)
if (termp != 0) {
_nc_free_termtype(&(termp->type));
+ FreeIfNeeded(termp->_termname);
free(termp);
if (termp == cur_term)
cur_term = 0;
diff --git a/contrib/ncurses/ncurses/tinfo/lib_data.c b/contrib/ncurses/ncurses/tinfo/lib_data.c
index 87d60edf6ed9..34f033a79021 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_data.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_data.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -40,18 +41,15 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_data.c,v 1.16 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_data.c,v 1.17 2005/01/22 17:39:22 tom Exp $")
/*
* OS/2's native linker complains if we don't initialize public data when
* constructing a dll (reported by J.J.G.Ripoll).
*/
-NCURSES_EXPORT_VAR(WINDOW *)
-stdscr = 0;
-NCURSES_EXPORT_VAR(WINDOW *)
-curscr = 0;
-NCURSES_EXPORT_VAR(WINDOW *)
-newscr = 0;
+NCURSES_EXPORT_VAR(WINDOW *) stdscr = 0;
+NCURSES_EXPORT_VAR(WINDOW *) curscr = 0;
+NCURSES_EXPORT_VAR(WINDOW *) newscr = 0;
NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain = 0;
@@ -66,7 +64,7 @@ NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain = 0;
* module coupling that increases the size of the executable.
*/
#if BROKEN_LINKER
- static SCREEN *my_screen;
+static SCREEN *my_screen;
NCURSES_EXPORT(SCREEN *)
_nc_screen(void)
@@ -81,11 +79,11 @@ _nc_alloc_screen(void)
}
NCURSES_EXPORT(void)
-_nc_set_screen(SCREEN * sp)
+_nc_set_screen(SCREEN *sp)
{
my_screen = sp;
}
#else
-NCURSES_EXPORT_VAR(SCREEN *) SP = NULL; /* Some linkers require initialized data... */
+NCURSES_EXPORT_VAR(SCREEN *) SP = NULL; /* Some linkers require initialized data... */
#endif
diff --git a/contrib/ncurses/ncurses/tinfo/lib_has_cap.c b/contrib/ncurses/ncurses/tinfo/lib_has_cap.c
index 6fb7b3a9c8c0..0dc66bd9b918 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_has_cap.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_has_cap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-2003 *
****************************************************************************/
/*
@@ -42,7 +43,7 @@
#include <term.h>
-MODULE_ID("$Id: lib_has_cap.c,v 1.3 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_has_cap.c,v 1.4 2003/10/25 19:43:55 tom Exp $")
NCURSES_EXPORT(bool)
has_ic(void)
diff --git a/contrib/ncurses/ncurses/tinfo/lib_kernel.c b/contrib/ncurses/ncurses/tinfo/lib_kernel.c
index b4d3c7f45aca..89dc1e80ea8e 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_kernel.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_kernel.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2000,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -48,13 +48,13 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_kernel.c,v 1.22 2002/05/11 20:32:18 tom Exp $")
+MODULE_ID("$Id: lib_kernel.c,v 1.24 2004/05/08 17:11:21 tom Exp $")
static int
_nc_vdisable(void)
{
- int value;
-#if defined(_POSIX_VDISABLE) && defined(HAVE_UNISTD_H)
+ int value = -1;
+#if defined(_POSIX_VDISABLE) && HAVE_UNISTD_H
value = _POSIX_VDISABLE;
#endif
#if defined(_PC_VDISABLE)
diff --git a/contrib/ncurses/ncurses/tinfo/lib_napms.c b/contrib/ncurses/ncurses/tinfo/lib_napms.c
index 20537be4dfe0..926afa836db4 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_napms.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_napms.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -36,6 +36,8 @@
*
* The routine napms.
*
+ * (This file was originally written by Eric Raymond; however except for
+ * comments, none of the original code remains - T.Dickey).
*/
#include <curses.priv.h>
@@ -47,7 +49,7 @@
#endif
#endif
-MODULE_ID("$Id: lib_napms.c,v 1.12 2001/12/22 22:20:40 tom Exp $")
+MODULE_ID("$Id: lib_napms.c,v 1.15 2005/04/03 13:58:14 tom Exp $")
NCURSES_EXPORT(int)
napms(int ms)
@@ -56,13 +58,16 @@ napms(int ms)
#if HAVE_NANOSLEEP
{
- struct timespec ts;
- ts.tv_sec = ms / 1000;
- ts.tv_nsec = (ms % 1000) * 1000000;
- nanosleep(&ts, NULL);
+ struct timespec request, remaining;
+ request.tv_sec = ms / 1000;
+ request.tv_nsec = (ms % 1000) * 1000000;
+ while (nanosleep(&request, &remaining) == -1
+ && errno == EINTR) {
+ request = remaining;
+ }
}
#else
- _nc_timed_wait(0, ms, (int *) 0);
+ _nc_timed_wait(0, ms, (int *) 0 EVENTLIST_2nd(0));
#endif
returnCode(OK);
diff --git a/contrib/ncurses/ncurses/tinfo/lib_options.c b/contrib/ncurses/ncurses/tinfo/lib_options.c
index 05bd47685dd6..bdb0b7024d7c 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_options.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_options.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000,2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -42,7 +43,7 @@
#include <term.h>
-MODULE_ID("$Id: lib_options.c,v 1.46 2002/02/02 19:40:54 tom Exp $")
+MODULE_ID("$Id: lib_options.c,v 1.49 2006/03/04 19:28:25 tom Exp $")
NCURSES_EXPORT(int)
idlok(WINDOW *win, bool flag)
@@ -72,7 +73,7 @@ halfdelay(int t)
{
T((T_CALLED("halfdelay(%d)"), t));
- if (t < 1 || t > 255)
+ if (t < 1 || t > 255 || SP == 0)
returnCode(ERR);
cbreak();
@@ -98,7 +99,7 @@ nodelay(WINDOW *win, bool flag)
NCURSES_EXPORT(int)
notimeout(WINDOW *win, bool f)
{
- T((T_CALLED("notimout(%p,%d)"), win, f));
+ T((T_CALLED("notimeout(%p,%d)"), win, f));
if (win) {
win->_notimeout = f;
@@ -133,19 +134,24 @@ keypad(WINDOW *win, bool flag)
NCURSES_EXPORT(int)
meta(WINDOW *win GCC_UNUSED, bool flag)
{
+ int result = ERR;
+
/* Ok, we stay relaxed and don't signal an error if win is NULL */
T((T_CALLED("meta(%p,%d)"), win, flag));
- SP->_use_meta = flag;
-
- if (flag && meta_on) {
- TPUTS_TRACE("meta_on");
- putp(meta_on);
- } else if (!flag && meta_off) {
- TPUTS_TRACE("meta_off");
- putp(meta_off);
+ if (SP != 0) {
+ SP->_use_meta = flag;
+
+ if (flag && meta_on) {
+ TPUTS_TRACE("meta_on");
+ putp(meta_on);
+ } else if (!flag && meta_off) {
+ TPUTS_TRACE("meta_off");
+ putp(meta_off);
+ }
+ result = OK;
}
- returnCode(OK);
+ returnCode(result);
}
/* curs_set() moved here to narrow the kernel interface */
@@ -153,51 +159,56 @@ meta(WINDOW *win GCC_UNUSED, bool flag)
NCURSES_EXPORT(int)
curs_set(int vis)
{
- int cursor = SP->_cursor;
+ int result = ERR;
T((T_CALLED("curs_set(%d)"), vis));
-
- if (vis < 0 || vis > 2)
- returnCode(ERR);
-
- if (vis == cursor)
- returnCode(cursor);
-
- switch (vis) {
- case 2:
- if (cursor_visible) {
- TPUTS_TRACE("cursor_visible");
- putp(cursor_visible);
- } else
- returnCode(ERR);
- break;
- case 1:
- if (cursor_normal) {
- TPUTS_TRACE("cursor_normal");
- putp(cursor_normal);
- } else
- returnCode(ERR);
- break;
- case 0:
- if (cursor_invisible) {
- TPUTS_TRACE("cursor_invisible");
- putp(cursor_invisible);
- } else
- returnCode(ERR);
- break;
+ if (SP != 0 && vis >= 0 && vis <= 2) {
+ int cursor = SP->_cursor;
+
+ if (vis == cursor) {
+ result = cursor;
+ } else {
+ result = (cursor == -1 ? 1 : cursor);
+ switch (vis) {
+ case 2:
+ if (cursor_visible) {
+ TPUTS_TRACE("cursor_visible");
+ putp(cursor_visible);
+ } else
+ result = ERR;
+ break;
+ case 1:
+ if (cursor_normal) {
+ TPUTS_TRACE("cursor_normal");
+ putp(cursor_normal);
+ } else
+ result = ERR;
+ break;
+ case 0:
+ if (cursor_invisible) {
+ TPUTS_TRACE("cursor_invisible");
+ putp(cursor_invisible);
+ } else
+ result = ERR;
+ break;
+ }
+ SP->_cursor = vis;
+ _nc_flush();
+ }
}
- SP->_cursor = vis;
- _nc_flush();
-
- returnCode(cursor == -1 ? 1 : cursor);
+ returnCode(result);
}
NCURSES_EXPORT(int)
typeahead(int fd)
{
T((T_CALLED("typeahead(%d)"), fd));
- SP->_checkfd = fd;
- returnCode(OK);
+ if (SP != 0) {
+ SP->_checkfd = fd;
+ returnCode(OK);
+ } else {
+ returnCode(ERR);
+ }
}
/*
@@ -224,7 +235,7 @@ NCURSES_EXPORT(int)
has_key(int keycode)
{
T((T_CALLED("has_key(%d)"), keycode));
- returnCode(has_key_internal(keycode, SP->_keytry));
+ returnCode(SP != 0 ? has_key_internal(keycode, SP->_keytry) : FALSE);
}
#endif /* NCURSES_EXT_FUNCS */
@@ -248,10 +259,12 @@ _nc_keypad(bool flag)
_nc_flush();
}
- if (flag && !SP->_tried) {
- _nc_init_keytry();
- SP->_tried = TRUE;
+ if (SP != 0) {
+ if (flag && !SP->_tried) {
+ _nc_init_keytry();
+ SP->_tried = TRUE;
+ }
+ SP->_keypad_on = flag;
}
- SP->_keypad_on = flag;
return (OK);
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_print.c b/contrib/ncurses/ncurses/tinfo/lib_print.c
index 01540eacdc14..975b46d85773 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_print.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_print.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2000,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -35,7 +35,7 @@
#include <term.h>
-MODULE_ID("$Id: lib_print.c,v 1.14 2002/03/16 21:45:08 tom Exp $")
+MODULE_ID("$Id: lib_print.c,v 1.16 2006/11/26 00:26:34 tom Exp $")
NCURSES_EXPORT(int)
mcprint(char *data, int len)
@@ -51,7 +51,7 @@ mcprint(char *data, int len)
}
if (prtr_non) {
- switchon = tparm(prtr_non, len);
+ switchon = TPARM_1(prtr_non, len);
onsize = strlen(switchon);
offsize = 0;
} else {
@@ -60,7 +60,8 @@ mcprint(char *data, int len)
offsize = strlen(prtr_off);
}
- if ((mybuf = typeMalloc(char, onsize + len + offsize + 1)) == (char *) 0) {
+ if (switchon == 0
+ || (mybuf = typeMalloc(char, onsize + len + offsize + 1)) == 0) {
errno = ENOMEM;
return (ERR);
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_raw.c b/contrib/ncurses/ncurses/tinfo/lib_raw.c
index 97cf0cbd0249..aa09f52c8c8d 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_raw.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_raw.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 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 *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1998 on *
****************************************************************************/
/*
@@ -48,7 +49,7 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_raw.c,v 1.12 2001/08/04 17:18:38 tom Exp $")
+MODULE_ID("$Id: lib_raw.c,v 1.13 2002/07/06 22:00:45 tom Exp $")
#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
@@ -60,6 +61,9 @@ MODULE_ID("$Id: lib_raw.c,v 1.12 2001/08/04 17:18:38 tom Exp $")
#ifdef __EMX__
#include <io.h>
+#define _nc_setmode(mode) setmode(SP->_ifd, mode)
+#else
+#define _nc_setmode(mode) /* nothing */
#endif
#define COOKED_INPUT (IXON|BRKINT|PARMRK)
@@ -75,162 +79,218 @@ MODULE_ID("$Id: lib_raw.c,v 1.12 2001/08/04 17:18:38 tom Exp $")
NCURSES_EXPORT(int)
raw(void)
{
+ int result = ERR;
+
T((T_CALLED("raw()")));
- if (SP != 0 && cur_term != 0) {
- SP->_raw = TRUE;
- SP->_cbreak = 1;
+ if (SP != 0 && cur_term != 0) {
+ TTY buf;
-#ifdef __EMX__
- setmode(SP->_ifd, O_BINARY);
-#endif
+ BEFORE("raw");
+ _nc_setmode(O_BINARY);
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("raw");
- cur_term->Nttyb.c_lflag &= ~(ICANON | ISIG | IEXTEN);
- cur_term->Nttyb.c_iflag &= ~(COOKED_INPUT);
- cur_term->Nttyb.c_cc[VMIN] = 1;
- cur_term->Nttyb.c_cc[VTIME] = 0;
- AFTER("raw");
+ buf.c_lflag &= ~(ICANON | ISIG | IEXTEN);
+ buf.c_iflag &= ~(COOKED_INPUT);
+ buf.c_cc[VMIN] = 1;
+ buf.c_cc[VTIME] = 0;
#else
- cur_term->Nttyb.sg_flags |= RAW;
+ buf.sg_flags |= RAW;
#endif
- returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
+ if ((result = _nc_set_tty_mode(&buf)) == OK) {
+ SP->_raw = TRUE;
+ SP->_cbreak = 1;
+ cur_term->Nttyb = buf;
+ }
+ AFTER("raw");
}
- returnCode(ERR);
+ returnCode(result);
}
NCURSES_EXPORT(int)
cbreak(void)
{
+ int result = ERR;
+
T((T_CALLED("cbreak()")));
- SP->_cbreak = 1;
+ if (SP != 0 && cur_term != 0) {
+ TTY buf;
-#ifdef __EMX__
- setmode(SP->_ifd, O_BINARY);
-#endif
+ BEFORE("cbreak");
+ _nc_setmode(O_BINARY);
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("cbreak");
- cur_term->Nttyb.c_lflag &= ~ICANON;
- cur_term->Nttyb.c_iflag &= ~ICRNL;
- cur_term->Nttyb.c_lflag |= ISIG;
- cur_term->Nttyb.c_cc[VMIN] = 1;
- cur_term->Nttyb.c_cc[VTIME] = 0;
- AFTER("cbreak");
+ buf.c_lflag &= ~ICANON;
+ buf.c_iflag &= ~ICRNL;
+ buf.c_lflag |= ISIG;
+ buf.c_cc[VMIN] = 1;
+ buf.c_cc[VTIME] = 0;
#else
- cur_term->Nttyb.sg_flags |= CBREAK;
+ buf.sg_flags |= CBREAK;
#endif
- returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
+ if ((result = _nc_set_tty_mode(&buf)) == OK) {
+ SP->_cbreak = 1;
+ cur_term->Nttyb = buf;
+ }
+ AFTER("cbreak");
+ }
+ returnCode(result);
}
+/*
+ * Note:
+ * this implementation may be wrong. See the comment under intrflush().
+ */
NCURSES_EXPORT(void)
qiflush(void)
{
+ int result = ERR;
+
T((T_CALLED("qiflush()")));
- /*
- * Note: this implementation may be wrong. See the comment under
- * intrflush().
- */
+ if (cur_term != 0) {
+ TTY buf;
+ BEFORE("qiflush");
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("qiflush");
- cur_term->Nttyb.c_lflag &= ~(NOFLSH);
- AFTER("qiflush");
- (void) _nc_set_tty_mode(&cur_term->Nttyb);
+ buf.c_lflag &= ~(NOFLSH);
+ result = _nc_set_tty_mode(&buf);
+#else
+ /* FIXME */
#endif
+ if (result == OK)
+ cur_term->Nttyb = buf;
+ AFTER("qiflush");
+ }
returnVoid;
}
NCURSES_EXPORT(int)
noraw(void)
{
+ int result = ERR;
+
T((T_CALLED("noraw()")));
- SP->_raw = FALSE;
- SP->_cbreak = 0;
+ if (SP != 0 && cur_term != 0) {
+ TTY buf;
-#ifdef __EMX__
- setmode(SP->_ifd, O_TEXT);
-#endif
+ BEFORE("noraw");
+ _nc_setmode(O_TEXT);
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("noraw");
- cur_term->Nttyb.c_lflag |= ISIG | ICANON |
- (cur_term->Ottyb.c_lflag & IEXTEN);
- cur_term->Nttyb.c_iflag |= COOKED_INPUT;
- AFTER("noraw");
+ buf.c_lflag |= ISIG | ICANON |
+ (cur_term->Ottyb.c_lflag & IEXTEN);
+ buf.c_iflag |= COOKED_INPUT;
#else
- cur_term->Nttyb.sg_flags &= ~(RAW | CBREAK);
+ buf.sg_flags &= ~(RAW | CBREAK);
#endif
- returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
+ if ((result = _nc_set_tty_mode(&buf)) == OK) {
+ SP->_raw = FALSE;
+ SP->_cbreak = 0;
+ cur_term->Nttyb = buf;
+ }
+ AFTER("noraw");
+ }
+ returnCode(result);
}
NCURSES_EXPORT(int)
nocbreak(void)
{
+ int result = ERR;
+
T((T_CALLED("nocbreak()")));
- SP->_cbreak = 0;
+ if (SP != 0 && cur_term != 0) {
+ TTY buf;
-#ifdef __EMX__
- setmode(SP->_ifd, O_TEXT);
-#endif
+ BEFORE("nocbreak");
+ _nc_setmode(O_TEXT);
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("nocbreak");
- cur_term->Nttyb.c_lflag |= ICANON;
- cur_term->Nttyb.c_iflag |= ICRNL;
- AFTER("nocbreak");
+ buf.c_lflag |= ICANON;
+ buf.c_iflag |= ICRNL;
#else
- cur_term->Nttyb.sg_flags &= ~CBREAK;
+ buf.sg_flags &= ~CBREAK;
#endif
- returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
+ if ((result = _nc_set_tty_mode(&buf)) == OK) {
+ SP->_cbreak = 0;
+ cur_term->Nttyb = buf;
+ }
+ AFTER("nocbreak");
+ }
+ returnCode(result);
}
+/*
+ * Note:
+ * this implementation may be wrong. See the comment under intrflush().
+ */
NCURSES_EXPORT(void)
noqiflush(void)
{
+ int result = ERR;
+
T((T_CALLED("noqiflush()")));
- /*
- * Note: this implementation may be wrong. See the comment under
- * intrflush().
- */
+ if (cur_term != 0) {
+ TTY buf;
+ BEFORE("noqiflush");
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("noqiflush");
- cur_term->Nttyb.c_lflag |= NOFLSH;
- AFTER("noqiflush");
- (void) _nc_set_tty_mode(&cur_term->Nttyb);
+ buf.c_lflag |= NOFLSH;
+ result = _nc_set_tty_mode(&buf);
+#else
+ /* FIXME */
#endif
+ if (result == OK) {
+ cur_term->Nttyb = buf;
+ }
+ AFTER("noqiflush");
+ }
returnVoid;
}
+/*
+ * This call does the same thing as the qiflush()/noqiflush() pair. We know
+ * for certain that SVr3 intrflush() tweaks the NOFLSH bit; on the other hand,
+ * the match (in the SVr4 man pages) between the language describing NOFLSH in
+ * termio(7) and the language describing qiflush()/noqiflush() in
+ * curs_inopts(3x) is too exact to be coincidence.
+ */
NCURSES_EXPORT(int)
intrflush(WINDOW *win GCC_UNUSED, bool flag)
{
+ int result = ERR;
+
T((T_CALLED("intrflush(%d)"), flag));
- /*
- * This call does the same thing as the qiflush()/noqiflush() pair. We
- * know for certain that SVr3 intrflush() tweaks the NOFLSH bit; on the
- * other hand, the match (in the SVr4 man pages) between the language
- * describing NOFLSH in termio(7) and the language describing
- * qiflush()/noqiflush() in curs_inopts(3x) is too exact to be coincidence.
- */
+ if (cur_term != 0) {
+ TTY buf;
+ BEFORE("intrflush");
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("intrflush");
- if (flag)
- cur_term->Nttyb.c_lflag &= ~(NOFLSH);
- else
- cur_term->Nttyb.c_lflag |= (NOFLSH);
- AFTER("intrflush");
- returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
+ if (flag)
+ buf.c_lflag &= ~(NOFLSH);
+ else
+ buf.c_lflag |= (NOFLSH);
+ result = _nc_set_tty_mode(&buf);
#else
- returnCode(ERR);
+ /* FIXME */
#endif
+ if (result == OK) {
+ cur_term->Nttyb = buf;
+ }
+ AFTER("intrflush");
+ }
+ returnCode(result);
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_setup.c b/contrib/ncurses/ncurses/tinfo/lib_setup.c
index 1e49b2b6ce07..350824208830 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_setup.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_setup.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-2003 *
****************************************************************************/
/*
@@ -46,9 +47,13 @@
#define _POSIX_SOURCE
#endif
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$Id: lib_setup.c,v 1.68 2001/12/08 22:14:18 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.95 2006/07/28 22:58:13 tom Exp $")
/****************************************************************************
*
@@ -72,6 +77,10 @@ MODULE_ID("$Id: lib_setup.c,v 1.68 2001/12/08 22:14:18 tom Exp $")
# include <sys/ptem.h>
#endif
+#if HAVE_LANGINFO_CODESET
+#include <langinfo.h>
+#endif
+
/*
* SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS,
* Solaris, IRIX) define TIOCGWINSZ and struct winsize.
@@ -90,9 +99,58 @@ MODULE_ID("$Id: lib_setup.c,v 1.68 2001/12/08 22:14:18 tom Exp $")
# endif
#endif
+NCURSES_EXPORT_VAR(char) ttytype[NAMESIZE] = "";
+NCURSES_EXPORT_VAR(int) LINES = 0;
+NCURSES_EXPORT_VAR(int) COLS = 0;
+NCURSES_EXPORT_VAR(int) TABSIZE = 0;
+
static int _use_env = TRUE;
-static void do_prototype(void);
+#if USE_SIGWINCH
+int
+_nc_handle_sigwinch(int enable)
+{
+ static int have_sigwinch = 0; /* initially no SIGWINCH's */
+ static int can_resizeall = 1; /* initially enabled */
+ SCREEN *scan;
+ int result;
+
+ switch (enable) {
+ default:
+ /* record a SIGWINCH */
+ have_sigwinch = 1;
+ break;
+ case 0:
+ /* temporarily disable the next block */
+ --can_resizeall;
+ break;
+ case 1:
+ /* temporarily enable the next block */
+ ++can_resizeall;
+ break;
+ }
+
+ /*
+ * If we have a pending SIGWINCH, set the flag in each screen.
+ * But do this only if the block is enabled.
+ */
+ if (can_resizeall-- >= 0) { /* test and disable */
+ if (have_sigwinch) {
+ scan = _nc_screen_chain;
+ while (scan) {
+ scan->_sig_winch = TRUE;
+ scan = scan->_next_screen;
+ }
+ have_sigwinch = 0;
+ }
+ }
+ result = can_resizeall + 1; /* reenable (unless disables are nested) */
+ can_resizeall = result;
+
+ return result;
+}
+
+#endif
NCURSES_EXPORT(void)
use_env(bool f)
@@ -102,10 +160,6 @@ use_env(bool f)
returnVoid;
}
-NCURSES_EXPORT_VAR(int) LINES = 0;
-NCURSES_EXPORT_VAR(int) COLS = 0;
-NCURSES_EXPORT_VAR(int) TABSIZE = 0;
-
static void
_nc_get_screensize(int *linep, int *colp)
/* Obtain lines/columns values from the environment and/or terminfo entry */
@@ -113,6 +167,7 @@ _nc_get_screensize(int *linep, int *colp)
/* figure out the size of the screen */
T(("screen size: terminfo lines = %d columns = %d", lines, columns));
+ _nc_handle_sigwinch(0);
if (!_use_env) {
*linep = (int) lines;
*colp = (int) columns;
@@ -159,7 +214,7 @@ _nc_get_screensize(int *linep, int *colp)
* environment variable.
*/
if (*linep <= 0)
- *linep = WINSIZE_ROWS(size);
+ *linep = (SP != 0 && SP->_filtered) ? 1 : WINSIZE_ROWS(size);
if (*colp <= 0)
*colp = WINSIZE_COLS(size);
}
@@ -191,6 +246,7 @@ _nc_get_screensize(int *linep, int *colp)
lines = (short) (*linep);
columns = (short) (*colp);
}
+ _nc_handle_sigwinch(1);
T(("screen size is %dx%d", *linep, *colp));
@@ -199,18 +255,30 @@ _nc_get_screensize(int *linep, int *colp)
else
TABSIZE = 8;
T(("TABSIZE = %d", TABSIZE));
-
}
#if USE