From 01b82453a3d0c6d76d4afc340c07cfc2be4a6b7a Mon Sep 17 00:00:00 2001 From: Rong-En Fan Date: Sat, 20 Jan 2007 08:21:19 +0000 Subject: [PATCH] Remove files that are no longer exist. Approved by: delphij --- contrib/ncurses/Makefile.glibc | 405 -- contrib/ncurses/README.glibc | 5 - contrib/ncurses/c++/Makefile.in | 220 - contrib/ncurses/c++/NEWS | 42 - contrib/ncurses/c++/PROBLEMS | 5 - contrib/ncurses/c++/README-first | 58 - contrib/ncurses/c++/cursesapp.cc | 146 - contrib/ncurses/c++/cursesapp.h | 163 - contrib/ncurses/c++/cursesf.cc | 426 -- contrib/ncurses/c++/cursesf.h | 824 ---- contrib/ncurses/c++/cursesm.cc | 382 -- contrib/ncurses/c++/cursesm.h | 592 --- contrib/ncurses/c++/cursesmain.cc | 57 - contrib/ncurses/c++/cursesp.cc | 129 - contrib/ncurses/c++/cursesp.h | 221 - contrib/ncurses/c++/cursespad.cc | 270 - contrib/ncurses/c++/cursesw.cc | 455 -- contrib/ncurses/c++/cursesw.h | 1397 ------ contrib/ncurses/c++/cursslk.cc | 122 - contrib/ncurses/c++/cursslk.h | 205 - contrib/ncurses/c++/demo.cc | 492 -- contrib/ncurses/c++/edit_cfg.sh | 70 - contrib/ncurses/c++/etip.h.in | 291 -- contrib/ncurses/c++/headers | 39 - contrib/ncurses/c++/internal.h | 49 - contrib/ncurses/c++/modules | 43 - contrib/ncurses/misc/indent.pro | 35 - contrib/ncurses/ncurses/base/lib_insstr.c | 83 - .../ncurses/ncurses/widechar/lib_ins_nwstr.c | 84 - contrib/ncurses/test/Makefile.in | 221 - contrib/ncurses/test/README | 22 - contrib/ncurses/test/blue.c | 429 -- contrib/ncurses/test/bs.6 | 42 - contrib/ncurses/test/bs.c | 1226 ----- contrib/ncurses/test/cardfile.c | 434 -- contrib/ncurses/test/cardfile.dat | 13 - contrib/ncurses/test/configure | 2401 --------- contrib/ncurses/test/configure.in | 327 -- contrib/ncurses/test/ditto.c | 148 - contrib/ncurses/test/dots.c | 140 - contrib/ncurses/test/filter.c | 103 - contrib/ncurses/test/firework.c | 173 - contrib/ncurses/test/firstlast.c | 90 - contrib/ncurses/test/gdc.6 | 22 - contrib/ncurses/test/gdc.c | 315 -- contrib/ncurses/test/hanoi.c | 301 -- contrib/ncurses/test/hashtest.c | 226 - contrib/ncurses/test/keynames.c | 15 - contrib/ncurses/test/knight.c | 700 --- contrib/ncurses/test/lrtest.c | 144 - contrib/ncurses/test/modules | 59 - contrib/ncurses/test/ncurses.c | 4332 ----------------- contrib/ncurses/test/ncurses_tst.hin | 56 - contrib/ncurses/test/newdemo.c | 356 -- contrib/ncurses/test/railroad.c | 242 - contrib/ncurses/test/rain.c | 134 - contrib/ncurses/test/tclock.c | 246 - contrib/ncurses/test/test.priv.h | 212 - contrib/ncurses/test/testaddch.c | 59 - contrib/ncurses/test/testcurs.c | 694 --- contrib/ncurses/test/testscanw.c | 39 - contrib/ncurses/test/tracemunch | 98 - contrib/ncurses/test/view.c | 513 -- contrib/ncurses/test/worm.c | 425 -- contrib/ncurses/test/xmas.c | 1157 ----- 65 files changed, 23424 deletions(-) delete mode 100644 contrib/ncurses/Makefile.glibc delete mode 100644 contrib/ncurses/README.glibc delete mode 100644 contrib/ncurses/c++/Makefile.in delete mode 100644 contrib/ncurses/c++/NEWS delete mode 100644 contrib/ncurses/c++/PROBLEMS delete mode 100644 contrib/ncurses/c++/README-first delete mode 100644 contrib/ncurses/c++/cursesapp.cc delete mode 100644 contrib/ncurses/c++/cursesapp.h delete mode 100644 contrib/ncurses/c++/cursesf.cc delete mode 100644 contrib/ncurses/c++/cursesf.h delete mode 100644 contrib/ncurses/c++/cursesm.cc delete mode 100644 contrib/ncurses/c++/cursesm.h delete mode 100644 contrib/ncurses/c++/cursesmain.cc delete mode 100644 contrib/ncurses/c++/cursesp.cc delete mode 100644 contrib/ncurses/c++/cursesp.h delete mode 100644 contrib/ncurses/c++/cursespad.cc delete mode 100644 contrib/ncurses/c++/cursesw.cc delete mode 100644 contrib/ncurses/c++/cursesw.h delete mode 100644 contrib/ncurses/c++/cursslk.cc delete mode 100644 contrib/ncurses/c++/cursslk.h delete mode 100644 contrib/ncurses/c++/demo.cc delete mode 100755 contrib/ncurses/c++/edit_cfg.sh delete mode 100644 contrib/ncurses/c++/etip.h.in delete mode 100644 contrib/ncurses/c++/headers delete mode 100644 contrib/ncurses/c++/internal.h delete mode 100644 contrib/ncurses/c++/modules delete mode 100644 contrib/ncurses/misc/indent.pro delete mode 100644 contrib/ncurses/ncurses/base/lib_insstr.c delete mode 100644 contrib/ncurses/ncurses/widechar/lib_ins_nwstr.c delete mode 100644 contrib/ncurses/test/Makefile.in delete mode 100644 contrib/ncurses/test/README delete mode 100644 contrib/ncurses/test/blue.c delete mode 100644 contrib/ncurses/test/bs.6 delete mode 100644 contrib/ncurses/test/bs.c delete mode 100644 contrib/ncurses/test/cardfile.c delete mode 100644 contrib/ncurses/test/cardfile.dat delete mode 100755 contrib/ncurses/test/configure delete mode 100644 contrib/ncurses/test/configure.in delete mode 100644 contrib/ncurses/test/ditto.c delete mode 100644 contrib/ncurses/test/dots.c delete mode 100644 contrib/ncurses/test/filter.c delete mode 100644 contrib/ncurses/test/firework.c delete mode 100644 contrib/ncurses/test/firstlast.c delete mode 100644 contrib/ncurses/test/gdc.6 delete mode 100644 contrib/ncurses/test/gdc.c delete mode 100644 contrib/ncurses/test/hanoi.c delete mode 100644 contrib/ncurses/test/hashtest.c delete mode 100644 contrib/ncurses/test/keynames.c delete mode 100644 contrib/ncurses/test/knight.c delete mode 100644 contrib/ncurses/test/lrtest.c delete mode 100644 contrib/ncurses/test/modules delete mode 100644 contrib/ncurses/test/ncurses.c delete mode 100644 contrib/ncurses/test/ncurses_tst.hin delete mode 100644 contrib/ncurses/test/newdemo.c delete mode 100644 contrib/ncurses/test/railroad.c delete mode 100644 contrib/ncurses/test/rain.c delete mode 100644 contrib/ncurses/test/tclock.c delete mode 100644 contrib/ncurses/test/test.priv.h delete mode 100644 contrib/ncurses/test/testaddch.c delete mode 100644 contrib/ncurses/test/testcurs.c delete mode 100644 contrib/ncurses/test/testscanw.c delete mode 100755 contrib/ncurses/test/tracemunch delete mode 100644 contrib/ncurses/test/view.c delete mode 100644 contrib/ncurses/test/worm.c delete mode 100644 contrib/ncurses/test/xmas.c diff --git a/contrib/ncurses/Makefile.glibc b/contrib/ncurses/Makefile.glibc deleted file mode 100644 index 2535e9f3b8e7..000000000000 --- a/contrib/ncurses/Makefile.glibc +++ /dev/null @@ -1,405 +0,0 @@ -# Copyright (C) 1997,1998 Free Software Foundation, Inc. -# This file is part of the GNU C Library. - -# The GNU C Library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. - -# The GNU C Library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. - -# You should have received a copy of the GNU Library General Public -# License along with the GNU C Library; see the file COPYING.LIB. If not, -# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# -# Makefile for ncurses part. -# -subdir := ncurses - -ncurses-version = 4.2 -form-version = $(ncurses-version) -menu-version = $(ncurses-version) -panel-version = $(ncurses-version) - -extras := form menu ncurses panel - -extra-libs = $(extras:%=lib%) -# These libraries will be built in the `others' pass rather than -# the `lib' pass, because they depend on libc.so being built already. -extra-libs-others = $(extra-libs) - -# The sources are found in the appropriate subdir. -subdir-dirs = $(extras) progs test -vpath %.c $(subdir-dirs) -vpath %.h $(subdir-dirs) - -libform-routines = \ - fld_arg \ - fld_attr \ - fld_current \ - fld_def \ - fld_dup \ - fld_ftchoice \ - fld_ftlink \ - fld_info \ - fld_just \ - fld_link \ - fld_max \ - fld_move \ - fld_newftyp \ - fld_opts \ - fld_pad \ - fld_page \ - fld_stat \ - fld_type \ - fld_user \ - frm_cursor \ - frm_data \ - frm_def \ - frm_driver \ - frm_hook \ - frm_opts \ - frm_page \ - frm_post \ - frm_req_name \ - frm_scale \ - frm_sub \ - frm_user \ - frm_win \ - fty_alnum \ - fty_alpha \ - fty_enum \ - fty_int \ - fty_ipv4 \ - fty_num \ - fty_regex - -libncurses-routines = \ - base/define_key \ - base/keybound \ - base/keyok \ - base/lib_addch \ - base/lib_addstr \ - base/lib_beep \ - base/lib_bkgd \ - base/lib_box \ - base/lib_chgat \ - base/lib_clear \ - base/lib_clearok \ - base/lib_clrbot \ - base/lib_clreol \ - base/lib_color \ - base/lib_colorset \ - base/lib_delch \ - base/lib_delwin \ - base/lib_dft_fgbg \ - base/lib_echo \ - base/lib_endwin \ - base/lib_erase \ - base/lib_flash \ - base/lib_freeall \ - base/lib_getch \ - base/lib_getstr \ - base/lib_hline \ - base/lib_immedok \ - base/lib_inchstr \ - base/lib_initscr \ - base/lib_insch \ - base/lib_insdel \ - base/lib_insstr \ - base/lib_instr \ - base/lib_isendwin \ - base/lib_leaveok \ - base/lib_mouse \ - base/lib_move \ - base/lib_mvwin \ - base/lib_newterm \ - base/lib_newwin \ - base/lib_nl \ - base/lib_overlay \ - base/lib_pad \ - base/lib_printw \ - base/lib_redrawln \ - base/lib_refresh \ - base/lib_restart \ - base/lib_scanw \ - base/lib_screen \ - base/lib_scroll \ - base/lib_scrollok \ - base/lib_scrreg \ - base/lib_set_term \ - base/lib_slk \ - base/lib_slkatr_set \ - base/lib_slkatrof \ - base/lib_slkatron \ - base/lib_slkatrset \ - base/lib_slkattr \ - base/lib_slkclear \ - base/lib_slkcolor \ - base/lib_slkinit \ - base/lib_slklab \ - base/lib_slkrefr \ - base/lib_slkset \ - base/lib_slktouch \ - base/lib_touch \ - base/lib_ungetch \ - base/lib_vline \ - base/lib_wattroff \ - base/lib_wattron \ - base/lib_winch \ - base/lib_window \ - base/memmove \ - base/nc_panel \ - base/resizeterm \ - base/safe_sprintf \ - base/sigaction \ - base/tries \ - base/version \ - base/vsscanf \ - base/wresize \ - codes \ - comp_captab \ - expanded \ - fallback \ - lib_gen \ - lib_keyname \ - names \ - tinfo/access \ - tinfo/add_tries \ - tinfo/alloc_entry \ - tinfo/alloc_ttype \ - tinfo/captoinfo \ - tinfo/comp_error \ - tinfo/comp_expand \ - tinfo/comp_hash \ - tinfo/comp_parse \ - tinfo/comp_scan \ - tinfo/doalloc \ - tinfo/free_ttype \ - tinfo/getenv_num \ - tinfo/home_terminfo \ - tinfo/init_keytry \ - tinfo/lib_acs \ - tinfo/lib_baudrate \ - tinfo/lib_cur_term \ - tinfo/lib_data \ - tinfo/lib_has_cap \ - tinfo/lib_kernel \ - tinfo/lib_longname \ - tinfo/lib_napms \ - tinfo/lib_options \ - tinfo/lib_print \ - tinfo/lib_raw \ - tinfo/lib_setup \ - tinfo/lib_termcap \ - tinfo/lib_termname \ - tinfo/lib_tgoto \ - tinfo/lib_ti \ - tinfo/lib_tparm \ - tinfo/lib_tputs \ - tinfo/lib_ttyflags \ - tinfo/name_match \ - tinfo/parse_entry \ - tinfo/read_entry \ - tinfo/read_termcap \ - tinfo/setbuf \ - tinfo/strings \ - tinfo/write_entry \ - trace/lib_trace \ - trace/lib_traceatr \ - trace/lib_tracebits \ - trace/lib_tracechr \ - trace/lib_tracedmp \ - trace/lib_tracemse \ - trace/trace_buf \ - trace/trace_tries \ - trace/trace_xnames \ - trace/varargs \ - trace/visbuf \ - tty/hardscroll \ - tty/hashmap \ - tty/lib_mvcur \ - tty/lib_tstp \ - tty/lib_twait \ - tty/lib_vidattr \ - tty/tty_update \ - unctrl - -libmenu-routines = \ - m_attribs \ - m_cursor \ - m_driver \ - m_format \ - m_global \ - m_hook \ - m_item_cur \ - m_item_nam \ - m_item_new \ - m_item_opt \ - m_item_top \ - m_item_use \ - m_item_val \ - m_item_vis \ - m_items \ - m_new \ - m_opts \ - m_pad \ - m_pattern \ - m_post \ - m_req_name \ - m_scale \ - m_spacing \ - m_sub \ - m_userptr \ - m_win - -libpanel-routines = \ - panel \ - p_above \ - p_below \ - p_bottom \ - p_delete \ - p_hide \ - p_hidden \ - p_move \ - p_new \ - p_replace \ - p_show \ - p_top \ - p_update \ - p_user \ - p_win - -headers = curses.h eti.h form.h menu.h panel.h term.h termcap.h \ - unctrl.h -others = clear infocmp tic toe tput tset -install-bin = $(others) - -clear-objs = clear.o -infocmp-objs = infocmp.o dump_entry.o -tic-objs = tic.o dump_entry.o -toe-objs = toe.o dump_entry.o -tput-objs = tput.o -tset-objs = tset.o dump_entry.o -extra-objs = $(tic-objs) $(toe-objs) $(infocmp-objs) $(clear-objs) \ - $(tput-objs) $(tset-objs) - -test-srcs = blue bs cardfile ditto firework firstlast gdc hanoi hashtest knight \ - lrtest ncurses newdemo rain tclock testaddch testcurs \ - testscanw view worm xmas - -include ../Rules - -ifndef tabsetdir -tabsetdir = $(datadir)/tabset -endif -ifndef inst_tabsetdir -inst_tabsetdir = $(install_root)/$(tabsetdir) -endif - -ifndef terminfodir -terminfodir = $(datadir)/terminfo -endif -ifndef inst_terminfodir -inst_terminfodir = $(install_root)/$(terminfodir) -endif - -ifndef mandir -mandir = $(prefix)/man -endif - -ifndef inst_mandir -inst_mandir = $(install_root)/$(mandir) -endif - -CPPFLAGS += -DTERMINFO='"$(terminfodir)"' -Iinclude -Iform -Incurses \ - -Imenu -Ipanel -Iprogs -Itest - -ifneq ($(strip $(objpfx)),) -CPPFLAGS += -I$(objpfx) -endif - -LDLIBS-tclock = math/libm - -tests: $(test-srcs:%=$(objpfx)%) - -$(objpfx)clear: $(addprefix $(objpfx),$(clear-objs)) -$(objpfx)infocmp: $(addprefix $(objpfx),$(infocmp-objs)) -$(objpfx)tic: $(addprefix $(objpfx),$(tic-objs)) -$(objpfx)toe: $(addprefix $(objpfx),$(toe-objs)) -$(objpfx)tput: $(addprefix $(objpfx),$(tput-objs)) -$(objpfx)tset: $(addprefix $(objpfx),$(tset-objs)) - -ifeq ($(build-shared),yes) -$(others:%=$(objpfx)%): $(objpfx)libncurses.so -else -$(others:%=$(objpfx)%): $(objpfx)libncurses.a -endif - -$(test-srcs:%=$(objpfx)%): $(objpfx)libform.a $(objpfx)libmenu.a \ - $(objpfx)libpanel.a $(objpfx)libncurses.a - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(extras:%=$(objpfx)lib%.so): $(common-objpfx)libc.so - -subdir_install: $(inst_libdir)/libtermcap.a $(inst_libdir)/libcurses.a \ - $(inst_bindir)/reset $(inst_bindir)/captoinfo - -$(inst_libdir)/libtermcap.a $(inst_libdir)/libcurses.a: \ - $(inst_libdir)/libncurses.a - $(make-link) - -$(inst_bindir)/reset: $(inst_bindir)/tset - $(make-link) - -$(inst_bindir)/captoinfo: $(inst_bindir)/tic - $(make-link) - -ifeq (yes,$(build-shared)) -subdir_install: $(inst_libdir)/libtermcap.so $(inst_libdir)/libcurses.so - -$(inst_libdir)/libtermcap.so $(inst_libdir)/libcurses.so: \ - $(inst_libdir)/libncurses.so - $(make-link) -endif - -subdir_install: $(inst_mandir)/man5/terminfo.5 - -$(inst_mandir)/man5/terminfo.5: $(objpfx)terminfo.5 $(wildcard man/*.[0-9]*) - $(make-target-directory) - sh $(edit_man-sh) $(prefix) $(inst_mandir) $(edit_man-sed) $^ - -subdir_install: $(inst_tabsetdir)/std - -$(inst_tabsetdir)/std: \ - $(filter-out misc/tabset/CVS, $(wildcard misc/tabset/*)) - $(make-target-directory) - for f in $^; do \ - echo installing $$f; \ - $(INSTALL_DATA) $$f $(inst_tabsetdir); \ - done - - -ifeq (no,$(cross-compiling)) -subdir_install: $(inst_terminfodir)/v/vt100 - -$(inst_terminfodir)/v/vt100: misc/terminfo.src $(objpfx)tic - $(make-target-directory) - sh $(run_tic-sh) $(common-objpfx) misc $(terminfodir) \ - $(install_root) -endif - -subdir_distclean subdir_realclean: - -rm -f $(addprefix $(objpfx), MKterm.h.awk codes.c \ - comp_captab.c confdefs.h config.log curses.h \ - expanded.c fallback.c hashsize.h keys.tries \ - lib_gen.c lib_keyname.c names.c ncurses_cfg.h \ - nomacros.h parametrized.h term.h termcap.h \ - terminfo.5 termsort.c unctrl.c unctrl.h) diff --git a/contrib/ncurses/README.glibc b/contrib/ncurses/README.glibc deleted file mode 100644 index 7d52269b9997..000000000000 --- a/contrib/ncurses/README.glibc +++ /dev/null @@ -1,5 +0,0 @@ -To compile this as an add-on for glibc, unpack it in the glibc source -tree and put ncurses on the add-on list when you do configure. - -hjl@gnu.ai.mit.edu -03/21/1997 diff --git a/contrib/ncurses/c++/Makefile.in b/contrib/ncurses/c++/Makefile.in deleted file mode 100644 index 9555320e4c6b..000000000000 --- a/contrib/ncurses/c++/Makefile.in +++ /dev/null @@ -1,220 +0,0 @@ -# $Id: Makefile.in,v 1.64 2002/01/19 20:25:31 NIIBE.Yutaka Exp $ -############################################################################## -# Copyright (c) 1998,1999,2000,2001,2002 Free Software Foundation, Inc. # -# # -# Permission is hereby granted, free of charge, to any person obtaining a # -# copy of this software and associated documentation files (the "Software"), # -# to deal in the Software without restriction, including without limitation # -# the rights to use, copy, modify, merge, publish, distribute, distribute # -# with modifications, sublicense, and/or sell copies of the Software, and to # -# permit persons to whom the Software is furnished to do so, subject to the # -# following conditions: # -# # -# The above copyright notice and this permission notice shall be included in # -# all copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # -# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # -# DEALINGS IN THE SOFTWARE. # -# # -# Except as contained in this notice, the name(s) of the above copyright # -# holders shall not be used in advertising or otherwise to promote the sale, # -# use or other dealings in this Software without prior written # -# authorization. # -############################################################################## -# -# Author: Thomas E. Dickey 1996,1997 -# -# Simple makefile for c++ window class demo - -# turn off _all_ suffix rules; we'll generate our own -.SUFFIXES: - -SHELL = /bin/sh - -CF_MFLAGS = @cf_cv_makeflags@ -@SET_MAKE@ -x = @PROG_EXT@ - -MODEL = ../@DFT_OBJ_SUBDIR@ -DESTDIR = @DESTDIR@ -srcdir = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ -libdir = @libdir@ -includedir = @includedir@ - -LIBTOOL = @LIBTOOL@ - -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ - -AR = @AR@ -AR_OPTS = @AR_OPTS@ - -CXX_AR = @CXX_AR@ -CXX_AR_OPTS = @CXX_AR_OPTS@ -RANLIB = @RANLIB@ - -CXX = @CXX@ -CPP = @CPP@ -CXXFLAGS = @CXXFLAGS@ -CXXLIBS = @CXXLIBS@ - -INCDIR = ../include -CPPFLAGS = -I../c++ -I$(INCDIR) -I$(srcdir) -DHAVE_CONFIG_H @CPPFLAGS@ - -CCFLAGS = $(CPPFLAGS) $(CXXFLAGS) - -CFLAGS_LIBTOOL = $(CCFLAGS) -CFLAGS_NORMAL = $(CCFLAGS) -CFLAGS_DEBUG = $(CCFLAGS) @CXX_G_OPT@ -DTRACE -CFLAGS_PROFILE = $(CCFLAGS) -pg -CFLAGS_SHARED = $(CCFLAGS) @CC_SHARED_OPTS@ - -CFLAGS_DEFAULT = $(CFLAGS_@DFT_UPR_MODEL@) - -NCURSES_MAJOR = @NCURSES_MAJOR@ -NCURSES_MINOR = @NCURSES_MINOR@ -REL_VERSION = @cf_cv_rel_version@ -ABI_VERSION = @cf_cv_abi_version@ - -LINK = @LINK_PROGS@ $(LIBTOOL) $(CXX) @CXXLDFLAGS@ - -LIBROOT = ncurses++ - -LIBNAME_LIBTOOL = @LIB_PREFIX@$(LIBROOT)@LIB_SUFFIX@.la -LIBNAME_NORMAL = @LIB_PREFIX@$(LIBROOT)@LIB_SUFFIX@.a -LIBNAME = @LIB_PREFIX@$(LIBROOT)@CXX_LIB_SUFFIX@ - -LINK_FLAGS = @EXTRA_LDFLAGS@ -L../lib -l$(LIBROOT)@LIB_SUFFIX@ - -LINK_LIBTOOL = @EXTRA_LDFLAGS@ -L../lib ../lib/$(LIBNAME) -LINK_NORMAL = $(LINK_FLAGS) -LINK_DEBUG = $(LINK_FLAGS) -LINK_PROFILE = $(LINK_FLAGS) -LINK_SHARED = $(LINK_FLAGS) - -LDFLAGS = @TEST_ARGS@ @LDFLAGS@ \ - @LD_MODEL@ @LIBS@ @EXTRA_LIBS@ @LOCAL_LDFLAGS@ $(CXXLIBS) - -LDFLAGS_LIBTOOL = $(LDFLAGS) -LDFLAGS_NORMAL = $(LDFLAGS) -LDFLAGS_DEBUG = $(LDFLAGS) @CC_G_OPT@ -LDFLAGS_PROFILE = $(LDFLAGS) -pg -LDFLAGS_SHARED = $(LDFLAGS) @LD_SHARED_OPTS@ - -LDFLAGS_DEFAULT = $(LINK_@DFT_UPR_MODEL@) $(LDFLAGS_@DFT_UPR_MODEL@) - -AUTO_SRC = \ - etip.h - -all \ -libs :: $(AUTO_SRC) ../lib/$(LIBNAME) - -all :: demo$x - -sources : $(AUTO_SRC) - -depend : - -# Build a conventional library for installing, since a shared library would -# pull in all of the ncurses libraries (panel, menu, form, ncurses) as direct -# dependencies. -LIB_OBJS = \ - $(MODEL)/cursesf.o \ - $(MODEL)/cursesm.o \ - $(MODEL)/cursesw.o \ - $(MODEL)/cursespad.o \ - $(MODEL)/cursesp.o \ - $(MODEL)/cursslk.o \ - $(MODEL)/cursesapp.o \ - $(MODEL)/cursesmain.o - -../lib/$(LIBNAME_NORMAL) : $(LIB_OBJS) - $(CXX_AR) $(CXX_AR_OPTS) $@ $? - $(RANLIB) $@ - -../lib/$(LIBNAME_LIBTOOL) : $(LIB_OBJS) - cd ../lib && $(LIBTOOL) $(CXX) -o $(LIBNAME) $(LIB_OBJS:.o=.lo) \ - -rpath $(INSTALL_PREFIX)$(libdir) \ - -version-info $(NCURSES_MAJOR):$(NCURSES_MINOR) - -OBJS_DEMO = $(MODEL)/demo.o - -$(MODEL)/demo.o : $(srcdir)/demo.cc \ - $(cursesf_h) $(cursesm_h) $(cursesapp_h) - -demo$x: $(OBJS_DEMO) \ - ../lib/$(LIBNAME) \ - @TEST_DEPS@ - @ECHO_LINK@ $(LINK) -o $@ $(OBJS_DEMO) $(LDFLAGS_DEFAULT) - -etip.h: $(srcdir)/etip.h.in $(srcdir)/edit_cfg.sh - cp $(srcdir)/etip.h.in $@ - sh $(srcdir)/edit_cfg.sh ../include/ncurses_cfg.h $@ - -$(DESTDIR)$(libdir) : - sh $(srcdir)/../mkinstalldirs $@ - -install \ -install.libs:: ../lib/$(LIBNAME) $(DESTDIR)$(libdir) - $(LIBTOOL) $(INSTALL) ../lib/$(LIBNAME) $(DESTDIR)$(libdir)/$(LIBNAME) - -uninstall \ -uninstall.libs:: - -$(LIBTOOL) rm -f $(DESTDIR)$(libdir)/$(LIBNAME) - -mostlyclean :: - -rm -f core tags TAGS *~ *.bak *.i *.ii *.ln *.atac trace - -clean :: mostlyclean - -rm -rf $(MODEL)/SunWS_cache - -$(LIBTOOL) rm -f demo$x $(AUTO_SRC) ../lib/$(LIBNAME) $(LIB_OBJS) $(LIB_OBJS:.o=.lo) $(OBJS_DEMO) - -rm -rf .libs - -distclean :: clean - -rm -f Makefile - -realclean :: distclean - -############################################################################### - -cursesw_h = $(srcdir)/cursesw.h \ - etip.h \ - $(INCDIR)/curses.h - -cursesp_h = $(srcdir)/cursesp.h \ - $(cursesw_h) \ - $(INCDIR)/panel.h - -cursesf_h = $(srcdir)/cursesf.h \ - $(cursesp_h) \ - $(INCDIR)/form.h - -cursesm_h = $(srcdir)/cursesm.h \ - $(cursesp_h) \ - $(INCDIR)/menu.h - -cursslk_h = $(srcdir)/cursslk.h \ - $(cursesw_h) - -cursesapp_h = $(srcdir)/cursesapp.h \ - $(cursslk_h) - -$(INCDIR)/form.h : - cd ../form && $(MAKE) $@ - -$(INCDIR)/menu.h : - cd ../menu && $(MAKE) $@ - -$(INCDIR)/panel.h : - cd ../panel && $(MAKE) $@ - -############################################################################### -# The remainder of this file is automatically generated during configuration -############################################################################### diff --git a/contrib/ncurses/c++/NEWS b/contrib/ncurses/c++/NEWS deleted file mode 100644 index 299292d18a7e..000000000000 --- a/contrib/ncurses/c++/NEWS +++ /dev/null @@ -1,42 +0,0 @@ -This is a log of changes that the ncurses C++ binding has gone -through starting with the integration of menu and forms integration -into the binding. - -990731 + Improve support for pads. A viewport window may now be added to - a pad. It will then be possible to use a builtin panning mechanism - to view the pad. - -970908 + Improve NCursesWindow class: added additional methods to - cover more ncurses functionality. Make refresh() and - noutrefresh() virtual members to allow different implementation - in the NCursesPanel class. - + CAUTION: changed order of parameters in vline() and hline() of - NCursesWindow class. - + Make refresh() in NCursesPanel non-static, it is now a - reimplementation of refresh() in the base class. Added - noutrefresh() to NCursesPanel. - + Added NCursesForm and related classes to support libform - functionality. - + Moved most of configuration related stuff from cursesw.h to - etip.h - + Added NCursesApplication class to support easy configuration - of menu and forms related attributes as well as ripped of - title lines and Soft-Label-Keys for an application. - + Support of Auto-Cleanup for a menus fieldlist. - + Change of return type for current_item() and operator[] for - menus. - + Enhanced demo. -970502 - + Introduced the THROW and THROWS functions/macros to prepare - a smoother transition to real exception handling. - + Exception classes provided in etip.h - + Added the NCursesMenu class to support libmenu functionality. - + The inheritace relation between NCursesWindow and NCursesColorWindow - was kind of brain damage. Monochrome is a special case of colored, so - the relation should be just the opposite. This would allow all - derived classes like NCursesPanel, NCursesMenu or NCursesForm to - have colors. - To resolve that design flaw I put the color functionality into the - NCursesWindow class and it can be switched on by the static member - useColors(). NCursesColorWindow is still there for compatibility - reasons. diff --git a/contrib/ncurses/c++/PROBLEMS b/contrib/ncurses/c++/PROBLEMS deleted file mode 100644 index 81c1ebaf8946..000000000000 --- a/contrib/ncurses/c++/PROBLEMS +++ /dev/null @@ -1,5 +0,0 @@ -This is a list of open problems. This mainly lists known missing pieces -and design flaws. - -1. Testing!!! -2. Better demo program diff --git a/contrib/ncurses/c++/README-first b/contrib/ncurses/c++/README-first deleted file mode 100644 index eb37ac670247..000000000000 --- a/contrib/ncurses/c++/README-first +++ /dev/null @@ -1,58 +0,0 @@ - C++ interface to ncurses routines ------------------------------------------------------------------------ - -This directory contains the source code for several C++ classes which -ease the use of writing ncurses-based programs. The code is derived -from the libg++ CursesWindow class but enhanced for ncurses. - -The classes simplify the use of window specific functions by -encapsulating them in the window object. Function overloading is -used in order to narrow the interface. E.g. you don't have the -distinction between `printw' and `mvprintw' anymore. - -A second benefit is the removal of all #defines which are included in -the curses.h file. This is a steady cause of trouble because many -common identifiers are used. Instead now all #defines are inline -functions which also allows strict type checking of arguments. - -The next enhancement is color support. It was originally provided by a -derived class. This caused some trouble if you think about Panels or -Menus and Forms with colors. We decided to put color support into the -base class so that any derived class may use color support also. -The implementation chosen here is directed to unrestricted use -of mixes of color and monochrome windows. The original NCursesColorWindow -class is maintained for compatibility reasons. - -The last point to mention is the support of other packages that are -distributed with the ncurses package: the panels library, the menu library -and the form library. This support is provided by the NCursesPanel class, -which is also derived from the NCursesWindow class and the NCursesMenu -and NCursesForm classes which are derived from NCursesPanel. This allows -building interfaces with windows. - -Please see the example program for a quick introduction. - -Note that at this point, there is no documentation for these classes. -Hopefully some will be written in the not too distant future. For now, -to find out how to use the classes, read the code and the example program. - -Suggestions for enhancements and contributions of code (and docs) are -welcome. Please let us know which functionality you miss. - - ATTENTION LINUX USERS: There is currently some discussion of - replacing the BSD curses in the Linux libc with ncurses. If - this is done we could perhaps include these classes in the Linux - libg++ replacing the original CursesWindow class (and renaming it - to CursesWindow). This could be done because NCursesWindow can - be made easily to a superset of the CursesWindow class. - - -Original author: - Eric Newton for FSF's libg++ - -Authors of first ncurses based release (NCursesWindow, NCursesPanel): - Ulrich Drepper - and Anatoly Ivasyuk - -Author of this release: - Juergen Pfeifer diff --git a/contrib/ncurses/c++/cursesapp.cc b/contrib/ncurses/c++/cursesapp.cc deleted file mode 100644 index 46cc271db644..000000000000 --- a/contrib/ncurses/c++/cursesapp.cc +++ /dev/null @@ -1,146 +0,0 @@ -// * this is for making emacs happy: -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,1999,2001 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "Software"), 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: Juergen Pfeifer 1997 * - ****************************************************************************/ - -#include "internal.h" -#include "cursesapp.h" - -MODULE_ID("$Id: cursesapp.cc,v 1.8 2001/03/24 21:25:36 tom Exp $") - -void -NCursesApplication::init(bool bColors) { - if (bColors) - NCursesWindow::useColors(); - - if (Root_Window->colors() > 1) { - b_Colors = TRUE; - Root_Window->setcolor(1); - Root_Window->setpalette(COLOR_YELLOW,COLOR_BLUE); - Root_Window->setcolor(2); - Root_Window->setpalette(COLOR_CYAN,COLOR_BLUE); - Root_Window->setcolor(3); - Root_Window->setpalette(COLOR_BLACK,COLOR_BLUE); - Root_Window->setcolor(4); - Root_Window->setpalette(COLOR_BLACK,COLOR_CYAN); - Root_Window->setcolor(5); - Root_Window->setpalette(COLOR_BLUE,COLOR_YELLOW); - Root_Window->setcolor(6); - Root_Window->setpalette(COLOR_BLACK,COLOR_GREEN); - } - else - b_Colors = FALSE; - - Root_Window->bkgd(' '|window_backgrounds()); -} - -NCursesApplication* NCursesApplication::theApp = 0; -NCursesWindow* NCursesApplication::titleWindow = 0; -NCursesApplication::SLK_Link* NCursesApplication::slk_stack = 0; - -NCursesApplication::~NCursesApplication() { - Soft_Label_Key_Set* S; - - delete titleWindow; - while( (S=top()) ) { - pop(); - delete S; - } - delete Root_Window; - ::endwin(); -} - -int NCursesApplication::rinit(NCursesWindow& w) { - titleWindow = &w; - return OK; -} - -void NCursesApplication::push(Soft_Label_Key_Set& S) { - SLK_Link* L = new SLK_Link; - assert(L != 0); - L->prev = slk_stack; - L->SLKs = &S; - slk_stack = L; - if (Root_Window) - S.show(); -} - -bool NCursesApplication::pop() { - if (slk_stack) { - SLK_Link* L = slk_stack; - slk_stack = slk_stack->prev; - delete L; - if (Root_Window && top()) - top()->show(); - } - return (slk_stack ? FALSE : TRUE); -} - -Soft_Label_Key_Set* NCursesApplication::top() const { - if (slk_stack) - return slk_stack->SLKs; - else - return (Soft_Label_Key_Set*)0; -} - -int NCursesApplication::operator()(void) { - bool bColors = b_Colors; - Soft_Label_Key_Set* S; - - int ts = titlesize(); - if (ts>0) - NCursesWindow::ripoffline(ts,rinit); - Soft_Label_Key_Set::Label_Layout fmt = useSLKs(); - if (fmt!=Soft_Label_Key_Set::None) { - S = new Soft_Label_Key_Set(fmt); - assert(S != 0); - init_labels(*S); - } - - Root_Window = new NCursesWindow(::stdscr); - init(bColors); - - if (ts>0) - title(); - if (fmt!=Soft_Label_Key_Set::None) { - push(*S); - } - - return run(); -} - -NCursesApplication::NCursesApplication(bool bColors) { - b_Colors = bColors; - if (theApp) - THROW(new NCursesException("Application object already created.")); - else - theApp = this; -} diff --git a/contrib/ncurses/c++/cursesapp.h b/contrib/ncurses/c++/cursesapp.h deleted file mode 100644 index c897a07dc20d..000000000000 --- a/contrib/ncurses/c++/cursesapp.h +++ /dev/null @@ -1,163 +0,0 @@ -// * This makes emacs happy -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,2000 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: Juergen Pfeifer 1997 * - ****************************************************************************/ - -// $Id: cursesapp.h,v 1.7 2001/03/24 21:41:18 tom Exp $ - -#ifndef NCURSES_CURSESAPP_H_incl -#define NCURSES_CURSESAPP_H_incl - -#include - -class NCURSES_IMPEXP NCursesApplication { -public: - typedef struct _slk_link { // This structure is used to maintain - struct _slk_link* prev; // a stack of SLKs - Soft_Label_Key_Set* SLKs; - } SLK_Link; -private: - static int rinit(NCursesWindow& w); // Internal Init function for title - static NCursesApplication* theApp; // Global ref. to the application - - static SLK_Link* slk_stack; - -protected: - static NCursesWindow* titleWindow; // The Title Window (if any) - - bool b_Colors; // Is this a color application? - NCursesWindow* Root_Window; // This is the stdscr equiv. - - // Initialization of attributes; - // Rewrite this in your derived class if you prefer other settings - virtual void init(bool bColors); - - // The number of lines for the title window. Default is no title window - // You may rewrite this in your derived class - virtual int titlesize() const { - return 0; - } - - // This method is called to put something into the title window initially - // You may rewrite this in your derived class - virtual void title() { - } - - // The layout used for the Soft Label Keys. Default is to have no SLKs. - // You may rewrite this in your derived class - virtual Soft_Label_Key_Set::Label_Layout useSLKs() const { - return Soft_Label_Key_Set::None; - } - - // This method is called to initialize the SLKs. Default is nothing. - // You may rewrite this in your derived class - virtual void init_labels(Soft_Label_Key_Set& S) const { - } - - // Your derived class must implement this method. The return value must - // be the exit value of your application. - virtual int run() = 0; - - - // The constructor is protected, so you may use it in your derived - // class constructor. The argument tells whether or not you want colors. - NCursesApplication(bool wantColors = FALSE); - -public: - virtual ~NCursesApplication(); - - // Get a pointer to the current application object - static NCursesApplication* getApplication() { - return theApp; - } - - // This method runs the application and returns its exit value - int operator()(void); - - // Process the commandline arguments. The default implementation simply - // ignores them. Your derived class may rewrite this. - virtual void handleArgs(int argc, char* argv[]) { - } - - // Does this application use colors? - inline bool useColors() const { - return b_Colors; - } - - // Push the Key Set S onto the SLK Stack. S then becomes the current set - // of Soft Labelled Keys. - void push(Soft_Label_Key_Set& S); - - // Throw away the current set of SLKs and make the previous one the - // new current set. - bool pop(); - - // Retrieve the current set of Soft Labelled Keys. - Soft_Label_Key_Set* top() const; - - // Attributes to use for menu and forms foregrounds - virtual chtype foregrounds() const { - return b_Colors ? COLOR_PAIR(1) : A_BOLD; - } - - // Attributes to use for menu and forms backgrounds - virtual chtype backgrounds() const { - return b_Colors ? COLOR_PAIR(2) : A_NORMAL; - } - - // Attributes to use for inactive (menu) elements - virtual chtype inactives() const { - return b_Colors ? (COLOR_PAIR(3)|A_DIM) : A_DIM; - } - - // Attributes to use for (form) labels and SLKs - virtual chtype labels() const { - return b_Colors ? COLOR_PAIR(4) : A_NORMAL; - } - - // Attributes to use for form backgrounds - virtual chtype dialog_backgrounds() const { - return b_Colors ? COLOR_PAIR(4) : A_NORMAL; - } - - // Attributes to use as default for (form) window backgrounds - virtual chtype window_backgrounds() const { - return b_Colors ? COLOR_PAIR(5) : A_NORMAL; - } - - // Attributes to use for the title window - virtual chtype screen_titles() const { - return b_Colors ? COLOR_PAIR(6) : A_BOLD; - } - -}; - -#endif // NCURSES_CURSESAPP_H_incl diff --git a/contrib/ncurses/c++/cursesf.cc b/contrib/ncurses/c++/cursesf.cc deleted file mode 100644 index f25d2d5ac6c9..000000000000 --- a/contrib/ncurses/c++/cursesf.cc +++ /dev/null @@ -1,426 +0,0 @@ -// * this is for making emacs happy: -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,2001 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "Software"), 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: Juergen Pfeifer 1997 * - ****************************************************************************/ - -#include "internal.h" -#include "cursesf.h" -#include "cursesapp.h" - -MODULE_ID("$Id: cursesf.cc,v 1.14 2001/07/14 20:54:43 juergen Exp $") - -NCursesFormField::~NCursesFormField () { - if (field) - OnError(::free_field (field)); -} - -/* Construct a FIELD* array from an array of NCursesFormField - * objects. - */ -FIELD** -NCursesForm::mapFields(NCursesFormField* nfields[]) { - int fieldCount = 0,lcv; - FIELD** old_fields; - - assert(nfields != 0); - - for (lcv=0; nfields[lcv]->field; ++lcv) - ++fieldCount; - - FIELD** fields = new FIELD*[fieldCount + 1]; - - for (lcv=0;nfields[lcv]->field;++lcv) { - fields[lcv] = nfields[lcv]->field; - } - fields[lcv] = NULL; - - my_fields = nfields; - - if (form && (old_fields = ::form_fields(form))) { - ::set_form_fields(form,(FIELD**)0); - delete[] old_fields; - } - return fields; -} - -void NCursesForm::setDefaultAttributes() { - NCursesApplication* S = NCursesApplication::getApplication(); - - int n = count(); - if (n > 0) { - for(int i=0; ioptions() & (O_EDIT|O_ACTIVE))==(O_EDIT|O_ACTIVE)) { - if (S) { - f->set_foreground(S->foregrounds()); - f->set_background(S->backgrounds()); - } - f->set_pad_character('_'); - } - else { - if (S) - f->set_background(S->labels()); - } - } - } - - if (S) { - bkgd(' '|S->dialog_backgrounds()); - if (sub) - sub->bkgd(' '|S->dialog_backgrounds()); - } -} - -void -NCursesForm::InitForm(NCursesFormField* nfields[], - bool with_frame, - bool autoDelete_Fields) { - int mrows, mcols; - - keypad(TRUE); - meta(TRUE); - - b_framed = with_frame; - b_autoDelete = autoDelete_Fields; - - form = (FORM*)0; - form = ::new_form(mapFields(nfields)); - if (!form) - OnError (E_SYSTEM_ERROR); - - UserHook* hook = new UserHook; - hook->m_user = NULL; - hook->m_back = this; - hook->m_owner = form; - ::set_form_userptr(form,(void*)hook); - - ::set_form_init (form, NCursesForm::frm_init); - ::set_form_term (form, NCursesForm::frm_term); - ::set_field_init (form, NCursesForm::fld_init); - ::set_field_term (form, NCursesForm::fld_term); - - scale(mrows, mcols); - ::set_form_win(form, w); - - if (with_frame) { - if ((mrows > height()-2) || (mcols > width()-2)) - OnError(E_NO_ROOM); - sub = new NCursesWindow(*this,mrows,mcols,1,1,'r'); - ::set_form_sub(form, sub->w); - b_sub_owner = TRUE; - } - else { - sub = (NCursesWindow*)0; - b_sub_owner = FALSE; - } - options_on(O_NL_OVERLOAD); - setDefaultAttributes(); -} - -NCursesForm::~NCursesForm() { - UserHook* hook = (UserHook*)::form_userptr(form); - delete hook; - if (b_sub_owner) { - delete sub; - ::set_form_sub(form,(WINDOW *)0); - } - if (form) { - FIELD** fields = ::form_fields(form); - int cnt = count(); - - OnError(::set_form_fields(form,(FIELD**)0)); - - if (b_autoDelete) { - if (cnt>0) { - for (int i=0; i <= cnt; i++) - delete my_fields[i]; - } - delete[] my_fields; - } - - ::free_form(form); - // It's essential to do this after free_form() - delete[] fields; - } -} - -void -NCursesForm::setSubWindow(NCursesWindow& nsub) { - if (!isDescendant(nsub)) - OnError(E_SYSTEM_ERROR); - else { - if (b_sub_owner) - delete sub; - sub = ⊄ - ::set_form_sub(form,sub->w); - } -} - -/* Internal hook functions. They will route the hook - * calls to virtual methods of the NCursesForm class, - * so in C++ providing a hook is done simply by - * implementing a virtual method in a derived class - */ -void -NCursesForm::frm_init(FORM *f) { - getHook(f)->On_Form_Init(); -} - -void -NCursesForm::frm_term(FORM *f) { - getHook(f)->On_Form_Termination(); -} - -void -NCursesForm::fld_init(FORM *f) { - NCursesForm* F = getHook(f); - F->On_Field_Init (*(F->current_field ())); -} - -void -NCursesForm::fld_term(FORM *f) { - NCursesForm* F = getHook(f); - F->On_Field_Termination (*(F->current_field ())); -} - -void -NCursesForm::On_Form_Init() { -} - -void -NCursesForm::On_Form_Termination() { -} - -void -NCursesForm::On_Field_Init(NCursesFormField& field) { -} - -void -NCursesForm::On_Field_Termination(NCursesFormField& field) { -} - -// call the form driver and do basic error checking. -int -NCursesForm::driver (int c) { - int res = ::form_driver (form, c); - switch (res) { - case E_OK: - case E_REQUEST_DENIED: - case E_INVALID_FIELD: - case E_UNKNOWN_COMMAND: - break; - default: - OnError (res); - } - return (res); -} - -void NCursesForm::On_Request_Denied(int c) const { - ::beep(); -} - -void NCursesForm::On_Invalid_Field(int c) const { - ::beep(); -} - -void NCursesForm::On_Unknown_Command(int c) const { - ::beep(); -} - -static const int CMD_QUIT = MAX_COMMAND + 1; - -NCursesFormField* -NCursesForm::operator()(void) { - int drvCmnd; - int err; - int c; - - post(); - show(); - refresh(); - - while (((drvCmnd = virtualize((c=getKey()))) != CMD_QUIT)) { - switch((err=driver(drvCmnd))) { - case E_REQUEST_DENIED: - On_Request_Denied(c); - break; - case E_INVALID_FIELD: - On_Invalid_Field(c); - break; - case E_UNKNOWN_COMMAND: - On_Unknown_Command(c); - break; - case E_OK: - break; - default: - OnError(err); - } - } - - unpost(); - hide(); - refresh(); - return my_fields[::field_index (::current_field (form))]; -} - -// Provide a default key virtualization. Translate the keyboard -// code c into a form request code. -// The default implementation provides a hopefully straightforward -// mapping for the most common keystrokes and form requests. -int -NCursesForm::virtualize(int c) { - switch(c) { - - case KEY_HOME : return(REQ_FIRST_FIELD); - case KEY_END : return(REQ_LAST_FIELD); - - case KEY_DOWN : return(REQ_DOWN_CHAR); - case KEY_UP : return(REQ_UP_CHAR); - case KEY_LEFT : return(REQ_PREV_CHAR); - case KEY_RIGHT : return(REQ_NEXT_CHAR); - - case KEY_NPAGE : return(REQ_NEXT_PAGE); - case KEY_PPAGE : return(REQ_PREV_PAGE); - - case KEY_BACKSPACE : return(REQ_DEL_PREV); - case KEY_ENTER : return(REQ_NEW_LINE); - case KEY_CLEAR : return(REQ_CLR_FIELD); - - case CTRL('X') : return(CMD_QUIT); // eXit - - case CTRL('F') : return(REQ_NEXT_FIELD); // Forward - case CTRL('B') : return(REQ_PREV_FIELD); // Backward - case CTRL('L') : return(REQ_LEFT_FIELD); // Left - case CTRL('R') : return(REQ_RIGHT_FIELD); // Right - case CTRL('U') : return(REQ_UP_FIELD); // Up - case CTRL('D') : return(REQ_DOWN_FIELD); // Down - - case CTRL('W') : return(REQ_NEXT_WORD); - case CTRL('T') : return(REQ_PREV_WORD); - - case CTRL('A') : return(REQ_BEG_FIELD); - case CTRL('E') : return(REQ_END_FIELD); - - case CTRL('I') : return(REQ_INS_CHAR); - case CTRL('M') : - case CTRL('J') : return(REQ_NEW_LINE); - case CTRL('O') : return(REQ_INS_LINE); - case CTRL('V') : return(REQ_DEL_CHAR); - case CTRL('H') : return(REQ_DEL_PREV); - case CTRL('Y') : return(REQ_DEL_LINE); - case CTRL('G') : return(REQ_DEL_WORD); - case CTRL('K') : return(REQ_CLR_EOF); - - case CTRL('N') : return(REQ_NEXT_CHOICE); - case CTRL('P') : return(REQ_PREV_CHOICE); - - default: - return(c); - } -} -// -// ------------------------------------------------------------------------- -// User Defined Fieldtypes -// ------------------------------------------------------------------------- -// -bool UserDefinedFieldType::fcheck(FIELD *f, const void *u) { - NCursesFormField* F = (NCursesFormField*)u; - assert(F != 0); - UserDefinedFieldType* udf = (UserDefinedFieldType*)(F->fieldtype()); - assert(udf != 0); - return udf->field_check(*F); -} - -bool UserDefinedFieldType::ccheck(int c, const void *u) { - NCursesFormField* F = (NCursesFormField*)u; - assert(F != 0); - UserDefinedFieldType* udf = - (UserDefinedFieldType*)(F->fieldtype()); - assert(udf != 0); - return udf->char_check(c); -} - -void* UserDefinedFieldType::makearg(va_list* va) { - return va_arg(*va,NCursesFormField*); -} - -FIELDTYPE* UserDefinedFieldType::generic_fieldtype = - ::new_fieldtype(UserDefinedFieldType::fcheck, - UserDefinedFieldType::ccheck); - -FIELDTYPE* UserDefinedFieldType_With_Choice::generic_fieldtype_with_choice = - ::new_fieldtype(UserDefinedFieldType::fcheck, - UserDefinedFieldType::ccheck); - -bool UserDefinedFieldType_With_Choice::next_choice(FIELD *f, const void *u) { - NCursesFormField* F = (NCursesFormField*)u; - assert(F != 0); - UserDefinedFieldType_With_Choice* udf = - (UserDefinedFieldType_With_Choice*)(F->fieldtype()); - assert(udf != 0); - return udf->next(*F); -} - -bool UserDefinedFieldType_With_Choice::prev_choice(FIELD *f, const void *u) { - NCursesFormField* F = (NCursesFormField*)u; - assert(F != 0); - UserDefinedFieldType_With_Choice* udf = - (UserDefinedFieldType_With_Choice*)(F->fieldtype()); - assert(udf != 0); - return udf->previous(*F); -} - -class UDF_Init { -private: - int code; - static UDF_Init* I; -public: - UDF_Init() { - code = ::set_fieldtype_arg(UserDefinedFieldType::generic_fieldtype, - UserDefinedFieldType::makearg, - NULL, - NULL); - if (code==E_OK) - code = ::set_fieldtype_arg - (UserDefinedFieldType_With_Choice::generic_fieldtype_with_choice, - UserDefinedFieldType::makearg, - NULL, - NULL); - if (code==E_OK) - code = ::set_fieldtype_choice - (UserDefinedFieldType_With_Choice::generic_fieldtype_with_choice, - UserDefinedFieldType_With_Choice::next_choice, - UserDefinedFieldType_With_Choice::prev_choice); - } -}; - -UDF_Init* UDF_Init::I = new UDF_Init(); - diff --git a/contrib/ncurses/c++/cursesf.h b/contrib/ncurses/c++/cursesf.h deleted file mode 100644 index e3655f202b55..000000000000 --- a/contrib/ncurses/c++/cursesf.h +++ /dev/null @@ -1,824 +0,0 @@ -// * This makes emacs happy -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "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: Juergen Pfeifer 1997 * - ****************************************************************************/ - -// $Id: cursesf.h,v 1.16 2001/07/15 00:02:53 tom Exp $ - -#ifndef NCURSES_CURSESF_H_incl -#define NCURSES_CURSESF_H_incl 1 - -#include -#include - -extern "C" { -# include -} -// -// ------------------------------------------------------------------------- -// The abstract base class for buitin and user defined Fieldtypes. -// ------------------------------------------------------------------------- -// -class NCURSES_IMPEXP NCursesFormField; // forward declaration - -// Class to represent builtin field types as well as C++ written new -// fieldtypes (see classes UserDefineFieldType... -class NCURSES_IMPEXP NCursesFieldType { - friend class NCursesFormField; - -protected: - FIELDTYPE* fieldtype; - - inline void OnError(int err) const THROWS(NCursesFormException) { - if (err!=E_OK) - THROW(new NCursesFormException (err)); - } - - NCursesFieldType(FIELDTYPE *f) : fieldtype(f) { - } - - virtual ~NCursesFieldType() {} - - // Set the fields f fieldtype to this one. - virtual void set(NCursesFormField& f) = 0; - -public: - NCursesFieldType() : fieldtype((FIELDTYPE*)0) { - } -}; - -// -// ------------------------------------------------------------------------- -// The class representing a forms field, wrapping the lowlevel FIELD struct -// ------------------------------------------------------------------------- -// -class NCURSES_IMPEXP NCursesFormField { - friend class NCursesForm; - -protected: - FIELD *field; // lowlevel structure - NCursesFieldType* ftype; // Associated field type - - // Error handler - inline void OnError (int err) const THROWS(NCursesFormException) { - if (err != E_OK) - THROW(new NCursesFormException (err)); - } - -public: - // Create a 'Null' field. Can be used to delimit a field list - NCursesFormField() - : field((FIELD*)0), ftype((NCursesFieldType*)0) { - } - - // Create a new field - NCursesFormField (int rows, - int cols, - int first_row = 0, - int first_col = 0, - int offscreen_rows = 0, - int additional_buffers = 0) - : ftype((NCursesFieldType*)0) { - field = ::new_field(rows,cols,first_row,first_col, - offscreen_rows, additional_buffers); - if (!field) - OnError(errno); - } - - virtual ~NCursesFormField (); - - // Duplicate the field at a new position - inline NCursesFormField* dup(int first_row, int first_col) { - NCursesFormField* f = new NCursesFormField(); - if (!f) - OnError(E_SYSTEM_ERROR); - else { - f->ftype = ftype; - f->field = ::dup_field(field,first_row,first_col); - if (!f->field) - OnError(errno); - } - return f; - } - - // Link the field to a new location - inline NCursesFormField* link(int first_row, int first_col) { - NCursesFormField* f = new NCursesFormField(); - if (!f) - OnError(E_SYSTEM_ERROR); - else { - f->ftype = ftype; - f->field = ::link_field(field,first_row,first_col); - if (!f->field) - OnError(errno); - } - return f; - } - - // Get the lowlevel field representation - inline FIELD* get_field() const { - return field; - } - - // Retrieve info about the field - inline void info(int& rows, int& cols, - int& first_row, int& first_col, - int& offscreen_rows, int& additional_buffers) const { - OnError(::field_info(field, &rows, &cols, - &first_row, &first_col, - &offscreen_rows, &additional_buffers)); - } - - // Retrieve info about the fields dynamic properties. - inline void dynamic_info(int& dynamic_rows, int& dynamic_cols, - int& max_growth) const { - OnError(::dynamic_field_info(field, &dynamic_rows, &dynamic_cols, - &max_growth)); - } - - // For a dynamic field you may set the maximum growth limit. - // A zero means unlimited growth. - inline void set_maximum_growth(int growth = 0) { - OnError(::set_max_field(field,growth)); - } - - // Move the field to a new position - inline void move(int row, int col) { - OnError(::move_field(field,row,col)); - } - - // Mark the field to start a new page - inline void new_page(bool pageFlag = FALSE) { - OnError(::set_new_page(field,pageFlag)); - } - - // Retrieve whether or not the field starts a new page. - inline bool is_new_page() const { - return ::new_page(field); - } - - // Set the justification for the field - inline void set_justification(int just) { - OnError(::set_field_just(field,just)); - } - - // Retrieve the fields justification - inline int justification() const { - return ::field_just(field); - } - // Set the foreground attribute for the field - inline void set_foreground(chtype fore) { - OnError(::set_field_fore(field,fore)); - } - - // Retrieve the fields foreground attribute - inline chtype fore() const { - return ::field_fore(field); - } - - // Set the background attribute for the field - inline void set_background(chtype back) { - OnError(::set_field_back(field,back)); - } - - // Retrieve the fields background attribute - inline chtype back() const { - return ::field_back(field); - } - - // Set the padding character for the field - inline void set_pad_character(int pad) { - OnError(::set_field_pad(field,pad)); - } - - // Retrieve the fields padding character - inline int pad() const { - return ::field_pad(field); - } - - // Switch on the fields options - inline void options_on (Field_Options options) { - OnError (::field_opts_on (field, options)); - } - - // Switch off the fields options - inline void options_off (Field_Options options) { - OnError (::field_opts_off (field, options)); - } - - // Retrieve the fields options - inline Field_Options options () const { - return ::field_opts (field); - } - - // Set the fields options - inline void set_options (Field_Options options) { - OnError (::set_field_opts (field, options)); - } - - // Mark the field as changed - inline void set_changed(bool changeFlag = TRUE) { - OnError(::set_field_status(field,changeFlag)); - } - - // Test whether or not the field is marked as changed - inline bool changed() const { - return ::field_status(field); - } - - // Return the index of the field in the field array of a form - // or -1 if the field is not associated to a form - inline int (index)() const { - return ::field_index(field); - } - - // Store a value in a fields buffer. The default buffer is nr. 0 - inline void set_value(const char *val, int buffer = 0) { - OnError(::set_field_buffer(field,buffer,val)); - } - - // Retrieve the value of a fields buffer. The default buffer is nr. 0 - inline char* value(int buffer = 0) const { - return ::field_buffer(field,buffer); - } - - // Set the validation type of the field. - inline void set_fieldtype(NCursesFieldType& f) { - ftype = &f; - f.set(*this); // A good friend may do that... - } - - // Retrieve the validation type of the field. - inline NCursesFieldType* fieldtype() const { - return ftype; - } - -}; - -// -// ------------------------------------------------------------------------- -// The class representing a form, wrapping the lowlevel FORM struct -// ------------------------------------------------------------------------- -// -class NCURSES_IMPEXP NCursesForm : public NCursesPanel { -protected: - FORM* form; // the lowlevel structure - -private: - NCursesWindow* sub; // the subwindow object - bool b_sub_owner; // is this our own subwindow? - bool b_framed; // has the form a border? - bool b_autoDelete; // Delete fields when deleting form? - - NCursesFormField** my_fields; // The array of fields for this form - - // This structure is used for the form's user data field to link the - // FORM* to the C++ object and to provide extra space for a user pointer. - typedef struct { - void* m_user; // the pointer for the user's data - const NCursesForm* m_back; // backward pointer to C++ object - const FORM* m_owner; - } UserHook; - - // Get the backward pointer to the C++ object from a FORM - static inline NCursesForm* getHook(const FORM *f) { - UserHook* hook = (UserHook*)::form_userptr(f); - assert(hook != 0 && hook->m_owner==f); - return (NCursesForm*)(hook->m_back); - } - - // This are the built-in hook functions in this C++ binding. In C++ we use - // virtual member functions (see below On_..._Init and On_..._Termination) - // to provide this functionality in an object oriented manner. - static void frm_init(FORM *); - static void frm_term(FORM *); - static void fld_init(FORM *); - static void fld_term(FORM *); - - // Calculate FIELD* array for the menu - FIELD** mapFields(NCursesFormField* nfields[]); - -protected: - // internal routines - inline void set_user(void *user) { - UserHook* uptr = (UserHook*)::form_userptr (form); - assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form); - uptr->m_user = user; - } - - inline void *get_user() { - UserHook* uptr = (UserHook*)::form_userptr (form); - assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form); - return uptr->m_user; - } - - void InitForm (NCursesFormField* Fields[], - bool with_frame, - bool autoDeleteFields); - - inline void OnError (int err) const THROWS(NCursesFormException) { - if (err != E_OK) - THROW(new NCursesFormException (err)); - } - - // this wraps the form_driver call. - virtual int driver (int c) ; - - // 'Internal' constructor, builds an object without association to a - // field array. - NCursesForm( int lines, - int cols, - int begin_y = 0, - int begin_x = 0) - : NCursesPanel(lines,cols,begin_y,begin_x), - form ((FORM*)0) { - } - -public: - // Create form for the default panel. - NCursesForm (NCursesFormField* Fields[], - bool with_frame=FALSE, // reserve space for a frame? - bool autoDelete_Fields=FALSE) // do automatic cleanup? - : NCursesPanel() { - InitForm(Fields, with_frame, autoDelete_Fields); - } - - // Create a form in a panel with the given position and size. - NCursesForm (NCursesFormField* Fields[], - int lines, - int cols, - int begin_y, - int begin_x, - bool with_frame=FALSE, // reserve space for a frame? - bool autoDelete_Fields=FALSE) // do automatic cleanup? - : NCursesPanel(lines, cols, begin_y, begin_x) { - InitForm(Fields, with_frame, autoDelete_Fields); - } - - virtual ~NCursesForm(); - - // Set the default attributes for the form - virtual void setDefaultAttributes(); - - // Retrieve current field of the form. - inline NCursesFormField* current_field() const { - return my_fields[::field_index(::current_field(form))]; - } - - // Set the forms subwindow - void setSubWindow(NCursesWindow& sub); - - // Set these fields for the form - inline void setFields(NCursesFormField* Fields[]) { - OnError(::set_form_fields(form,mapFields(Fields))); - } - - // Remove the form from the screen - inline void unpost (void) { - OnError (::unpost_form (form)); - } - - // Post the form to the screen if flag is true, unpost it otherwise - inline void post(bool flag = TRUE) { - OnError (flag ? ::post_form(form) : ::unpost_form (form)); - } - - // Decorations - inline void frame(const char *title=NULL, const char* btitle=NULL) { - if (b_framed) - NCursesPanel::frame(title,btitle); - else - OnError(E_SYSTEM_ERROR); - } - - inline void boldframe(const char *title=NULL, const char* btitle=NULL) { - if (b_framed) - NCursesPanel::boldframe(title,btitle); - else - OnError(E_SYSTEM_ERROR); - } - - inline void label(const char *topLabel, const char *bottomLabel) { - if (b_framed) - NCursesPanel::label(topLabel,bottomLabel); - else - OnError(E_SYSTEM_ERROR); - } - - // ----- - // Hooks - // ----- - - // Called after the form gets repositioned in its window. - // This is especially true if the form is posted. - virtual void On_Form_Init(); - - // Called before the form gets repositioned in its window. - // This is especially true if the form is unposted. - virtual void On_Form_Termination(); - - // Called after the field became the current field - virtual void On_Field_Init(NCursesFormField& field); - - // Called before this field is left as current field. - virtual void On_Field_Termination(NCursesFormField& field); - - // Calculate required window size for the form. - void scale(int& rows, int& cols) const { - OnError(::scale_form(form,&rows,&cols)); - } - - // Retrieve number of fields in the form. - int count() const { - return ::field_count(form); - } - - // Make the page the current page of the form. - void set_page(int page) { - OnError(::set_form_page(form,page)); - } - - // Retrieve current page number - int page() const { - return ::form_page(form); - } - - // Switch on the forms options - inline void options_on (Form_Options options) { - OnError (::form_opts_on (form, options)); - } - - // Switch off the forms options - inline void options_off (Form_Options options) { - OnError (::form_opts_off (form, options)); - } - - // Retrieve the forms options - inline Form_Options options () const { - return ::form_opts (form); - } - - // Set the forms options - inline void set_options (Form_Options options) { - OnError (::set_form_opts (form, options)); - } - - // Are there more data in the current field after the data shown - inline bool data_ahead() const { - return ::data_ahead(form); - } - - // Are there more data in the current field before the data shown - inline bool data_behind() const { - return ::data_behind(form); - } - - // Position the cursor to the current field - inline void position_cursor () { - OnError (::pos_form_cursor (form)); - } - // Set the current field - inline void set_current(NCursesFormField& F) { - OnError (::set_current_field(form, F.field)); - } - - // Provide a default key virtualization. Translate the keyboard - // code c into a form request code. - // The default implementation provides a hopefully straightforward - // mapping for the most common keystrokes and form requests. - virtual int virtualize(int c); - - // Operators - inline NCursesFormField* operator[](int i) const { - if ( (i < 0) || (i >= ::field_count (form)) ) - OnError (E_BAD_ARGUMENT); - return my_fields[i]; - } - - // Perform the menu's operation - // Return the field where you left the form. - virtual NCursesFormField* operator()(void); - - // Exception handlers. The default is a Beep. - virtual void On_Request_Denied(int c) const; - virtual void On_Invalid_Field(int c) const; - virtual void On_Unknown_Command(int c) const; - -}; - -// -// ------------------------------------------------------------------------- -// This is the typical C++ typesafe way to allow to attach -// user data to a field of a form. Its assumed that the user -// data belongs to some class T. Use T as template argument -// to create a UserField. -// ------------------------------------------------------------------------- -template class NCURSES_IMPEXP NCursesUserField : public NCursesFormField -{ -public: - NCursesUserField (int rows, - int cols, - int first_row = 0, - int first_col = 0, - const T* p_UserData = (T*)0, - int offscreen_rows = 0, - int additional_buffers = 0) - : NCursesFormField (rows, cols, - first_row, first_col, - offscreen_rows, additional_buffers) { - if (field) - OnError(::set_field_userptr(field,(void *)p_UserData)); - } - - virtual ~NCursesUserField() {}; - - inline const T* UserData (void) const { - return (const T*)::field_userptr (field); - } - - inline virtual void setUserData(const T* p_UserData) { - if (field) - OnError (::set_field_userptr (field, (void *)p_UserData)); - } -}; -// -// ------------------------------------------------------------------------- -// The same mechanism is used to attach user data to a form -// ------------------------------------------------------------------------- -// -template class NCURSES_IMPEXP NCursesUserForm : public NCursesForm -{ -protected: - // 'Internal' constructor, builds an object without association to a - // field array. - NCursesUserForm( int lines, - int cols, - int begin_y = 0, - int begin_x = 0, - const T* p_UserData = (T*)0) - : NCursesForm(lines,cols,begin_y,begin_x) { - if (form) - set_user ((void *)p_UserData); - } - -public: - NCursesUserForm (NCursesFormField Fields[], - bool with_frame=FALSE, - bool autoDelete_Fields=FALSE) - : NCursesForm (Fields, with_frame, autoDelete_Fields) { - }; - - NCursesUserForm (NCursesFormField Fields[], - const T* p_UserData = (T*)0, - bool with_frame=FALSE, - bool autoDelete_Fields=FALSE) - : NCursesForm (Fields, with_frame, autoDelete_Fields) { - if (form) - set_user ((void *)p_UserData); - }; - - NCursesUserForm (NCursesFormField Fields[], - int lines, - int cols, - int begin_y = 0, - int begin_x = 0, - const T* p_UserData = (T*)0, - bool with_frame=FALSE, - bool autoDelete_Fields=FALSE) - : NCursesForm (Fields, lines, cols, begin_y, begin_x, - with_frame, autoDelete_Fields) { - if (form) - set_user ((void *)p_UserData); - }; - - virtual ~NCursesUserForm() { - }; - - inline T* UserData (void) const { - return (T*)get_user (); - }; - - inline virtual void setUserData (const T* p_UserData) { - if (form) - set_user ((void *)p_UserData); - } - -}; -// -// ------------------------------------------------------------------------- -// Builtin Fieldtypes -// ------------------------------------------------------------------------- -// -class NCURSES_IMPEXP Alpha_Field : public NCursesFieldType { -private: - int min_field_width; - - void set(NCursesFormField& f) { - OnError(::set_field_type(f.get_field(),fieldtype,min_field_width)); - } - -public: - Alpha_Field(int width) - : NCursesFieldType(TYPE_ALPHA), - min_field_width(width) { - } -}; - -class NCURSES_IMPEXP Alphanumeric_Field : public NCursesFieldType { -private: - int min_field_width; - - void set(NCursesFormField& f) { - OnError(::set_field_type(f.get_field(),fieldtype,min_field_width)); - } - -public: - Alphanumeric_Field(int width) - : NCursesFieldType(TYPE_ALNUM), - min_field_width(width) { - } -}; - -class NCURSES_IMPEXP Integer_Field : public NCursesFieldType { -private: - int precision; - long lower_limit, upper_limit; - - void set(NCursesFormField& f) { - OnError(::set_field_type(f.get_field(),fieldtype, - precision,lower_limit,upper_limit)); - } - -public: - Integer_Field(int prec, long low=0L, long high=0L) - : NCursesFieldType(TYPE_INTEGER), - precision(prec), lower_limit(low), upper_limit(high) { - } -}; - -class NCURSES_IMPEXP Numeric_Field : public NCursesFieldType { -private: - int precision; - double lower_limit, upper_limit; - - void set(NCursesFormField& f) { - OnError(::set_field_type(f.get_field(),fieldtype, - precision,lower_limit,upper_limit)); - } - -public: - Numeric_Field(int prec, double low=0.0, double high=0.0) - : NCursesFieldType(TYPE_NUMERIC), - precision(prec), lower_limit(low), upper_limit(high) { - } -}; - -class NCURSES_IMPEXP Regular_Expression_Field : public NCursesFieldType { -private: - char* regex; - - void set(NCursesFormField& f) { - OnError(::set_field_type(f.get_field(),fieldtype,regex)); - } - -public: - Regular_Expression_Field(const char *expr) - : NCursesFieldType(TYPE_REGEXP) { - regex = new char[1 + ::strlen(expr)]; - (::strcpy)(regex,expr); - } - - ~Regular_Expression_Field() { - delete[] regex; - } -}; - -class NCURSES_IMPEXP Enumeration_Field : public NCursesFieldType { -private: - char** list; - int case_sensitive; - int non_unique_matches; - - void set(NCursesFormField& f) { - OnError(::set_field_type(f.get_field(),fieldtype, - list,case_sensitive,non_unique_matches)); - } -public: - Enumeration_Field(char* enums[], - bool case_sens=FALSE, - bool non_unique=FALSE) - : NCursesFieldType(TYPE_ENUM), - list(enums), - case_sensitive(case_sens?-1:0), - non_unique_matches(non_unique?-1:0) { - } -}; - -class NCURSES_IMPEXP IPV4_Address_Field : public NCursesFieldType { -private: - void set(NCursesFormField& f) { - OnError(::set_field_type(f.get_field(),fieldtype)); - } - -public: - IPV4_Address_Field() : NCursesFieldType(TYPE_IPV4) { - } -}; -// -// ------------------------------------------------------------------------- -// Abstract base class for User-Defined Fieldtypes -// ------------------------------------------------------------------------- -// -class NCURSES_IMPEXP UserDefinedFieldType : public NCursesFieldType { - friend class UDF_Init; // Internal helper to set up statics -private: - // For all C++ defined fieldtypes we need only one generic lowlevel - // FIELDTYPE* element. - static FIELDTYPE* generic_fieldtype; - -protected: - // This are the functions required by the low level libforms functions - // to construct a fieldtype. - static bool fcheck(FIELD *, const void*); - static bool ccheck(int c, const void *); - static void* makearg(va_list*); - - void set(NCursesFormField& f) { - OnError(::set_field_type(f.get_field(),fieldtype,&f)); - } - -protected: - // Redefine this function to do a field validation. The argument - // is a reference to the field you should validate. - virtual bool field_check(NCursesFormField& f) = 0; - - // Redefine this function to do a character validation. The argument - // is the character to be validated. - virtual bool char_check (int c) = 0; - -public: - UserDefinedFieldType() : NCursesFieldType(generic_fieldtype) { - } -}; -// -// ------------------------------------------------------------------------- -// Abstract base class for User-Defined Fieldtypes with Choice functions -// ------------------------------------------------------------------------- -// -class NCURSES_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedFieldType { - friend class UDF_Init; // Internal helper to set up statics -private: - // For all C++ defined fieldtypes with choice functions we need only one - // generic lowlevel FIELDTYPE* element. - static FIELDTYPE* generic_fieldtype_with_choice; - - // This are the functions required by the low level libforms functions - // to construct a fieldtype with choice functions. - static bool next_choice(FIELD*, const void *); - static bool prev_choice(FIELD*, const void *); - -protected: - // Redefine this function to do the retrieval of the next choice value. - // The argument is a reference to the field tobe examined. - virtual bool next (NCursesFormField& f) = 0; - - // Redefine this function to do the retrieval of the previous choice value. - // The argument is a reference to the field tobe examined. - virtual bool previous(NCursesFormField& f) = 0; - -public: - UserDefinedFieldType_With_Choice() { - fieldtype = generic_fieldtype_with_choice; - } -}; - -#endif // NCURSES_CURSESF_H_incl - diff --git a/contrib/ncurses/c++/cursesm.cc b/contrib/ncurses/c++/cursesm.cc deleted file mode 100644 index d9b0a63d810b..000000000000 --- a/contrib/ncurses/c++/cursesm.cc +++ /dev/null @@ -1,382 +0,0 @@ -// * this is for making emacs happy: -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,1999,2001 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "Software"), 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: Juergen Pfeifer 1997 * - ****************************************************************************/ - -#include "internal.h" -#include "cursesm.h" -#include "cursesapp.h" - -MODULE_ID("$Id: cursesm.cc,v 1.16 2001/07/14 20:54:43 juergen Exp $") - -NCursesMenuItem::~NCursesMenuItem() { - if (item) - OnError(::free_item(item)); -} - -bool -NCursesMenuItem::action() { - return FALSE; -}; - -NCursesMenuCallbackItem::~NCursesMenuCallbackItem() { -} - -bool -NCursesMenuCallbackItem::action() { - if (p_fct) - return p_fct (*this); - else - return FALSE; -} - -/* Internal hook functions. They will route the hook - * calls to virtual methods of the NCursesMenu class, - * so in C++ providing a hook is done simply by - * implementing a virtual method in a derived class - */ -void -NCursesMenu::mnu_init(MENU *m) { - getHook(m)->On_Menu_Init(); -} - -void -NCursesMenu::mnu_term(MENU *m) { - getHook(m)->On_Menu_Termination(); -} - -void -NCursesMenu::itm_init(MENU *m) { - NCursesMenu* M = getHook(m); - M->On_Item_Init (*(M->current_item ())); -} - -void -NCursesMenu::itm_term(MENU *m) { - NCursesMenu* M = getHook(m); - M->On_Item_Termination (*(M->current_item ())); -} - -/* Construct an ITEM* array from an array of NCursesMenuItem - * objects. - */ -ITEM** -NCursesMenu::mapItems(NCursesMenuItem* nitems[]) { - int itemCount = 0,lcv; - - for (lcv=0; nitems[lcv]->item; ++lcv) - ++itemCount; - - ITEM** items = new ITEM*[itemCount + 1]; - - for (lcv=0;nitems[lcv]->item;++lcv) { - items[lcv] = nitems[lcv]->item; - } - items[lcv] = NULL; - - my_items = nitems; - - if (menu) - delete[] ::menu_items(menu); - return items; -} - -void -NCursesMenu::InitMenu(NCursesMenuItem* nitems[], - bool with_frame, - bool autoDelete_Items) { - int mrows, mcols; - - keypad(TRUE); - meta(TRUE); - - b_framed = with_frame; - b_autoDelete = autoDelete_Items; - - menu = (MENU*)0; - menu = ::new_menu(mapItems(nitems)); - if (!menu) - OnError (E_SYSTEM_ERROR); - - UserHook* hook = new UserHook; - hook->m_user = NULL; - hook->m_back = this; - hook->m_owner = menu; - ::set_menu_userptr(menu,(void*)hook); - - ::set_menu_init (menu, NCursesMenu::mnu_init); - ::set_menu_term (menu, NCursesMenu::mnu_term); - ::set_item_init (menu, NCursesMenu::itm_init); - ::set_item_term (menu, NCursesMenu::itm_term); - - scale(mrows, mcols); - ::set_menu_win(menu, w); - - if (with_frame) { - if ((mrows > height()-2) || (mcols > width()-2)) - OnError(E_NO_ROOM); - sub = new NCursesWindow(*this,mrows,mcols,1,1,'r'); - ::set_menu_sub(menu, sub->w); - b_sub_owner = TRUE; - } - else { - sub = (NCursesWindow*)0; - b_sub_owner = FALSE; - } - setDefaultAttributes(); -} - -void -NCursesMenu::setDefaultAttributes() { - NCursesApplication* S = NCursesApplication::getApplication(); - if (S) { - ::set_menu_fore(menu, S->foregrounds()); - ::set_menu_back(menu, S->backgrounds()); - ::set_menu_grey(menu, S->inactives()); - } -} - -NCursesMenu::~NCursesMenu() { - UserHook* hook = (UserHook*)::menu_userptr(menu); - delete hook; - if (b_sub_owner) { - delete sub; - ::set_menu_sub(menu,(WINDOW *)0); - } - if (menu) { - ITEM** itms = ::menu_items(menu); - int cnt = count(); - - OnError(::set_menu_items(menu,(ITEM**)0)); - - if (b_autoDelete) { - if (cnt>0) { - for (int i=0; i <= cnt; i++) - delete my_items[i]; - } - delete[] my_items; - } - - ::free_menu(menu); - // It's essential to do this after free_menu() - delete[] itms; - } -} - -void -NCursesMenu::setSubWindow(NCursesWindow& nsub) { - if (!isDescendant(nsub)) - OnError(E_SYSTEM_ERROR); - else { - if (b_sub_owner) - delete sub; - sub = ⊄ - ::set_menu_sub(menu,sub->w); - } -} - -bool -NCursesMenu::set_pattern (const char *pat) { - int res = ::set_menu_pattern (menu, pat); - switch(res) { - case E_OK: - break; - case E_NO_MATCH: - return FALSE; - default: - OnError (res); - } - return TRUE; -} - -// call the menu driver and do basic error checking. -int -NCursesMenu::driver (int c) { - int res = ::menu_driver (menu, c); - switch (res) { - case E_OK: - case E_REQUEST_DENIED: - case E_NOT_SELECTABLE: - case E_UNKNOWN_COMMAND: - case E_NO_MATCH: - break; - default: - OnError (res); - } - return (res); -} - -static const int CMD_QUIT = MAX_COMMAND + 1; -static const int CMD_ACTION = MAX_COMMAND + 2; -// -// ------------------------------------------------------------------------- -// Provide a default key virtualization. Translate the keyboard -// code c into a menu request code. -// The default implementation provides a hopefully straightforward -// mapping for the most common keystrokes and menu requests. -// ------------------------------------------------------------------------- -int -NCursesMenu::virtualize(int c) { - switch(c) { - case CTRL('X') : return(CMD_QUIT); // eXit - - case KEY_DOWN : return(REQ_DOWN_ITEM); - case CTRL('N') : return(REQ_NEXT_ITEM); // Next - case KEY_UP : return(REQ_UP_ITEM); - case CTRL('P') : return(REQ_PREV_ITEM); // Previous - - case CTRL('U') : return(REQ_SCR_ULINE); // Up - case CTRL('D') : return(REQ_SCR_DLINE); // Down - case CTRL('F') : return(REQ_SCR_DPAGE); // Forward - case CTRL('B') : return(REQ_SCR_UPAGE); // Backward - - case CTRL('Y') : return(REQ_CLEAR_PATTERN); - case CTRL('H') : return(REQ_BACK_PATTERN); - case CTRL('A') : return(REQ_NEXT_MATCH); - case CTRL('E') : return(REQ_PREV_MATCH); - case CTRL('T') : return(REQ_TOGGLE_ITEM); - - case CTRL('J') : - case CTRL('M') : return(CMD_ACTION); - - case KEY_HOME : return(REQ_FIRST_ITEM); - case KEY_LEFT : return(REQ_LEFT_ITEM); - case KEY_RIGHT : return(REQ_RIGHT_ITEM); - case KEY_END : return(REQ_LAST_ITEM); - case KEY_BACKSPACE : return(REQ_BACK_PATTERN); - case KEY_NPAGE : return(REQ_SCR_DPAGE); - case KEY_PPAGE : return(REQ_SCR_UPAGE); - - default: - return(c); - } -} - -NCursesMenuItem* -NCursesMenu::operator()(void) { - int drvCmnd; - int err; - int c; - bool b_action = FALSE; - - post(); - show(); - refresh(); - - while (!b_action && ((drvCmnd = virtualize((c=getKey()))) != CMD_QUIT)) { - - switch((err=driver(drvCmnd))) { - case E_REQUEST_DENIED: - On_Request_Denied(c); - break; - case E_NOT_SELECTABLE: - On_Not_Selectable(c); - break; - case E_UNKNOWN_COMMAND: - if (drvCmnd == CMD_ACTION) { - if (options() & O_ONEVALUE) { - NCursesMenuItem* itm = current_item(); - assert(itm != 0); - if (itm->options() & O_SELECTABLE) - { - b_action = itm->action(); - refresh(); - } - else - On_Not_Selectable(c); - } - else { - int n = count(); - for(int i=0; ivalue()) { - b_action |= itm->action(); - refresh(); - } - } - } - } else - On_Unknown_Command(c); - break; - case E_NO_MATCH: - On_No_Match(c); - break; - case E_OK: - break; - default: - OnError(err); - } - } - - unpost(); - hide(); - refresh(); - if (options() & O_ONEVALUE) - return my_items[::item_index (::current_item (menu))]; - else - return NULL; -} - -void -NCursesMenu::On_Menu_Init() { -} - -void -NCursesMenu::On_Menu_Termination() { -} - -void -NCursesMenu::On_Item_Init(NCursesMenuItem& item) { -} - -void -NCursesMenu::On_Item_Termination(NCursesMenuItem& item) { -} - -void -NCursesMenu::On_Request_Denied(int c) const { - ::beep(); -} - -void -NCursesMenu::On_Not_Selectable(int c) const { - ::beep(); -} - -void -NCursesMenu::On_No_Match(int c) const { - ::beep(); -} - -void -NCursesMenu::On_Unknown_Command(int c) const { - ::beep(); -} diff --git a/contrib/ncurses/c++/cursesm.h b/contrib/ncurses/c++/cursesm.h deleted file mode 100644 index 541ba038795b..000000000000 --- a/contrib/ncurses/c++/cursesm.h +++ /dev/null @@ -1,592 +0,0 @@ -// * This makes emacs happy -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,1999,2000 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: Juergen Pfeifer 1997 * - ****************************************************************************/ - -// $Id: cursesm.h,v 1.15 2001/03/24 21:41:28 tom Exp $ - -#ifndef NCURSES_CURSESM_H_incl -#define NCURSES_CURSESM_H_incl 1 - -#include - -extern "C" { -# include -} -// -// ------------------------------------------------------------------------- -// This wraps the ITEM type of -// ------------------------------------------------------------------------- -// -class NCURSES_IMPEXP NCursesMenuItem { - friend class NCursesMenu; - -protected: - ITEM *item; - - inline void OnError (int err) const THROWS(NCursesMenuException) { - if (err != E_OK) - THROW(new NCursesMenuException (err)); - } - -public: - NCursesMenuItem (const char* p_name = NULL, - const char* p_descript = NULL ) { - item = p_name ? ::new_item (p_name, p_descript) : (ITEM*)0; - if (p_name && !item) - OnError (E_SYSTEM_ERROR); - } - // Create an item. If you pass both parameters as NULL, a delimiting - // item is constructed which can be used to terminate a list of - // NCursesMenu objects. - - virtual ~NCursesMenuItem (); - // Release the items memory - - inline const char* name () const { - return ::item_name (item); - } - // Name of the item - - inline const char* description () const { - return ::item_description (item); - } - // Description of the item - - inline int (index) (void) const { - return ::item_index (item); - } - // Index of the item in an item array (or -1) - - inline void options_on (Item_Options options) { - OnError (::item_opts_on (item, options)); - } - // Switch on the items options - - inline void options_off (Item_Options options) { - OnError (::item_opts_off (item, options)); - } - // Switch off the item's option - - inline Item_Options options () const { - return ::item_opts (item); - } - // Retrieve the items options - - inline void set_options (Item_Options options) { - OnError (::set_item_opts (item, options)); - } - // Set the items options - - inline void set_value (bool f) { - OnError (::set_item_value (item,f)); - } - // Set/Reset the items selection state - - inline bool value () const { - return ::item_value (item); - } - // Retrieve the items selection state - - inline bool visible () const { - return ::item_visible (item); - } - // Retrieve visibility of the item - - virtual bool action(); - // Perform an action associated with this item; you may use this in an - // user supplied driver for a menu; you may derive from this class and - // overload action() to supply items with different actions. - // If an action returns true, the menu will be exited. The default action - // is to do nothing. -}; - -// Prototype for an items callback function. -typedef bool ITEMCALLBACK(NCursesMenuItem&); - -// If you don't like to create a child class for individual items to -// overload action(), you may use this class and provide a callback -// function pointer for items. -class NCURSES_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem { -private: - ITEMCALLBACK* p_fct; - -public: - NCursesMenuCallbackItem(ITEMCALLBACK* fct = NULL, - const char* p_name = NULL, - const char* p_descript = NULL ) - : NCursesMenuItem (p_name, p_descript), - p_fct (fct) { - } - - virtual ~NCursesMenuCallbackItem(); - - bool action(); -}; -// -// ------------------------------------------------------------------------- -// This wraps the MENU type of -// ------------------------------------------------------------------------- -// -class NCURSES_IMPEXP NCursesMenu : public NCursesPanel { -protected: - MENU *menu; - -private: - NCursesWindow* sub; // the subwindow object - bool b_sub_owner; // is this our own subwindow? - bool b_framed; // has the menu a border? - bool b_autoDelete; // Delete items when deleting menu? - - NCursesMenuItem** my_items; // The array of items for this menu - - // This structure is used for the menu's user data field to link the - // MENU* to the C++ object and to provide extra space for a user pointer. - typedef struct { - void* m_user; // the pointer for the user's data - const NCursesMenu* m_back; // backward pointer to C++ object - const MENU* m_owner; - } UserHook; - - // Get the backward pointer to the C++ object from a MENU - static inline NCursesMenu* getHook(const MENU *m) { - UserHook* hook = (UserHook*)::menu_userptr(m); - assert(hook != 0 && hook->m_owner==m); - return (NCursesMenu*)(hook->m_back); - } - - // This are the built-in hook functions in this C++ binding. In C++ we use - // virtual member functions (see below On_..._Init and On_..._Termination) - // to provide this functionality in an object oriented manner. - static void mnu_init(MENU *); - static void mnu_term(MENU *); - static void itm_init(MENU *); - static void itm_term(MENU *); - - // Calculate ITEM* array for the menu - ITEM** mapItems(NCursesMenuItem* nitems[]); - -protected: - // internal routines - inline void set_user(void *user) { - UserHook* uptr = (UserHook*)::menu_userptr (menu); - assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu); - uptr->m_user = user; - } - - inline void *get_user() { - UserHook* uptr = (UserHook*)::menu_userptr (menu); - assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu); - return uptr->m_user; - } - - void InitMenu (NCursesMenuItem* menu[], - bool with_frame, - bool autoDeleteItems); - - inline void OnError (int err) const THROWS(NCursesMenuException) { - if (err != E_OK) - THROW(new NCursesMenuException (this, err)); - } - - // this wraps the menu_driver call. - virtual int driver (int c) ; - - // 'Internal' constructor to create a menu without association to - // an array of items. - NCursesMenu( int lines, - int cols, - int begin_y = 0, - int begin_x = 0) - : NCursesPanel(lines,cols,begin_y,begin_x), - menu ((MENU*)0) { - } - -public: - // Make a full window size menu - NCursesMenu (NCursesMenuItem* Items[], - bool with_frame=FALSE, // Reserve space for a frame? - bool autoDelete_Items=FALSE) // Autocleanup of Items? - : NCursesPanel() { - InitMenu(Items, with_frame, autoDelete_Items); - } - - // Make a menu with a window of this size. - NCursesMenu (NCursesMenuItem* Items[], - int lines, - int cols, - int begin_y = 0, - int begin_x = 0, - bool with_frame=FALSE, // Reserve space for a frame? - bool autoDelete_Items=FALSE) // Autocleanup of Items? - : NCursesPanel(lines, cols, begin_y, begin_x) { - InitMenu(Items, with_frame, autoDelete_Items); - } - - virtual ~NCursesMenu (); - - // Retrieve the menus subwindow - inline NCursesWindow& subWindow() const { - assert(sub!=NULL); - return *sub; - } - - // Set the menus subwindow - void setSubWindow(NCursesWindow& sub); - - // Set these items for the menu - inline void setItems(NCursesMenuItem* Items[]) { - OnError(::set_menu_items(menu,mapItems(Items))); - } - - // Remove the menu from the screen - inline void unpost (void) { - OnError (::unpost_menu (menu)); - } - - // Post the menu to the screen if flag is true, unpost it otherwise - inline void post(bool flag = TRUE) { - flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu)); - } - - // Get the numer of rows and columns for this menu - inline void scale (int& mrows, int& mcols) const { - OnError (::scale_menu (menu, &mrows, &mcols)); - } - - // Set the format of this menu - inline void set_format(int mrows, int mcols) { - OnError (::set_menu_format(menu, mrows, mcols)); - } - - // Get the format of this menu - inline void menu_format(int& rows,int& cols) { - ::menu_format(menu,&rows,&cols); - } - - // Items of the menu - inline NCursesMenuItem* items() const { - return *my_items; - } - - // Get the number of items in this menu - inline int count() const { - return ::item_count(menu); - } - - // Get the current item (i.e. the one the cursor is located) - inline NCursesMenuItem* current_item() const { - return my_items[::item_index(::current_item(menu))]; - } - - // Get the marker string - inline const char* mark() const { - return ::menu_mark(menu); - } - - // Set the marker string - inline void set_mark(const char *mark) { - OnError (::set_menu_mark (menu, mark)); - } - - // Get the name of the request code c - inline static const char* request_name(int c) { - return ::menu_request_name(c); - } - - // Get the current pattern - inline char* pattern() const { - return ::menu_pattern(menu); - } - - // true if there is a pattern match, false otherwise. - bool set_pattern (const char *pat); - - // set the default attributes for the menu - // i.e. set fore, back and grey attribute - virtual void setDefaultAttributes(); - - // Get the menus background attributes - inline chtype back() const { - return ::menu_back(menu); - } - - // Get the menus foreground attributes - inline chtype fore() const { - return ::menu_fore(menu); - } - - // Get the menus grey attributes (used for unselectable items) - inline chtype grey() const { - return ::menu_grey(menu); - } - - // Set the menus background attributes - inline chtype set_background(chtype a) { - return ::set_menu_back(menu,a); - } - - // Set the menus foreground attributes - inline chtype set_foreground(chtype a) { - return ::set_menu_fore(menu,a); - } - - // Set the menus grey attributes (used for unselectable items) - inline chtype set_grey(chtype a) { - return ::set_menu_grey(menu,a); - } - - inline void options_on (Menu_Options opts) { - OnError (::menu_opts_on (menu,opts)); - } - - inline void options_off(Menu_Options opts) { - OnError (::menu_opts_off(menu,opts)); - } - - inline Menu_Options options() const { - return ::menu_opts(menu); - } - - inline void set_options (Menu_Options opts) { - OnError (::set_menu_opts (menu,opts)); - } - - inline int pad() const { - return ::menu_pad(menu); - } - - inline void set_pad (int padch) { - OnError (::set_menu_pad (menu, padch)); - } - - // Position the cursor to the current item - inline void position_cursor () const { - OnError (::pos_menu_cursor (menu)); - } - - // Set the current item - inline void set_current(NCursesMenuItem& I) { - OnError (::set_current_item(menu, I.item)); - } - - // Get the current top row of the menu - inline int top_row (void) const { - return ::top_row (menu); - } - - // Set the current top row of the menu - inline void set_top_row (int row) { - OnError (::set_top_row (menu, row)); - } - - // spacing control - // Set the spacing for the menu - inline void setSpacing(int spc_description, - int spc_rows, - int spc_columns) { - OnError(::set_menu_spacing(menu, - spc_description, - spc_rows, - spc_columns)); - } - - // Get the spacing info for the menu - inline void Spacing(int& spc_description, - int& spc_rows, - int& spc_columns) const { - OnError(::menu_spacing(menu, - &spc_description, - &spc_rows, - &spc_columns)); - } - - // Decorations - inline void frame(const char *title=NULL, const char* btitle=NULL) { - if (b_framed) - NCursesPanel::frame(title,btitle); - else - OnError(E_SYSTEM_ERROR); - } - - inline void boldframe(const char *title=NULL, const char* btitle=NULL) { - if (b_framed) - NCursesPanel::boldframe(title,btitle); - else - OnError(E_SYSTEM_ERROR); - } - - inline void label(const char *topLabel, const char *bottomLabel) { - if (b_framed) - NCursesPanel::label(topLabel,bottomLabel); - else - OnError(E_SYSTEM_ERROR); - } - - // ----- - // Hooks - // ----- - - // Called after the menu gets repositioned in its window. - // This is especially true if the menu is posted. - virtual void On_Menu_Init(); - - // Called before the menu gets repositioned in its window. - // This is especially true if the menu is unposted. - virtual void On_Menu_Termination(); - - // Called after the item became the current item - virtual void On_Item_Init(NCursesMenuItem& item); - - // Called before this item is left as current item. - virtual void On_Item_Termination(NCursesMenuItem& item); - - // Provide a default key virtualization. Translate the keyboard - // code c into a menu request code. - // The default implementation provides a hopefully straightforward - // mapping for the most common keystrokes and menu requests. - virtual int virtualize(int c); - - - // Operators - inline NCursesMenuItem* operator[](int i) const { - if ( (i < 0) || (i >= ::item_count (menu)) ) - OnError (E_BAD_ARGUMENT); - return (my_items[i]); - } - - // Perform the menu's operation - // Return the item where you left the selection mark for a single - // selection menu, or NULL for a multivalued menu. - virtual NCursesMenuItem* operator()(void); - - // -------------------- - // Exception handlers - // Called by operator() - // -------------------- - - // Called if the request is denied - virtual void On_Request_Denied(int c) const; - - // Called if the item is not selectable - virtual void On_Not_Selectable(int c) const; - - // Called if pattern doesn't match - virtual void On_No_Match(int c) const; - - // Called if the command is unknown - virtual void On_Unknown_Command(int c) const; - -}; -// -// ------------------------------------------------------------------------- -// This is the typical C++ typesafe way to allow to attach -// user data to an item of a menu. Its assumed that the user -// data belongs to some class T. Use T as template argument -// to create a UserItem. -// ------------------------------------------------------------------------- -// -template class NCURSES_IMPEXP NCursesUserItem : public NCursesMenuItem -{ -public: - NCursesUserItem (const char* p_name, - const char* p_descript = NULL, - const T* p_UserData = (T*)0) - : NCursesMenuItem (p_name, p_descript) { - if (item) - OnError (::set_item_userptr (item, (void *)p_UserData)); - }; - - virtual ~NCursesUserItem() {}; - - inline const T* UserData (void) const { - return (const T*)::item_userptr (item); - }; - - inline virtual void setUserData(const T* p_UserData) { - if (item) - OnError (::set_item_userptr (item, (void *)p_UserData)); - } -}; -// -// ------------------------------------------------------------------------- -// The same mechanism is used to attach user data to a menu -// ------------------------------------------------------------------------- -// -template class NCURSES_IMPEXP NCursesUserMenu : public NCursesMenu -{ -protected: - NCursesUserMenu( int lines, - int cols, - int begin_y = 0, - int begin_x = 0, - const T* p_UserData = (T*)0) - : NCursesMenu(lines,cols,begin_y,begin_x) { - if (menu) - set_user ((void *)p_UserData); - } - -public: - NCursesUserMenu (NCursesMenuItem Items[], - const T* p_UserData = (T*)0, - bool with_frame=FALSE, - bool autoDelete_Items=FALSE) - : NCursesMenu (Items, with_frame, autoDelete_Items) { - if (menu) - set_user ((void *)p_UserData); - }; - - NCursesUserMenu (NCursesMenuItem Items[], - int lines, - int cols, - int begin_y = 0, - int begin_x = 0, - const T* p_UserData = (T*)0, - bool with_frame=FALSE) - : NCursesMenu (Items, lines, cols, begin_y, begin_x, with_frame) { - if (menu) - set_user ((void *)p_UserData); - }; - - virtual ~NCursesUserMenu() { - }; - - inline T* UserData (void) const { - return (T*)get_user (); - }; - - inline virtual void setUserData (const T* p_UserData) { - if (menu) - set_user ((void *)p_UserData); - } -}; - -#endif // NCURSES_CURSESM_H_incl diff --git a/contrib/ncurses/c++/cursesmain.cc b/contrib/ncurses/c++/cursesmain.cc deleted file mode 100644 index 6b34b52044ab..000000000000 --- a/contrib/ncurses/c++/cursesmain.cc +++ /dev/null @@ -1,57 +0,0 @@ -// * this is for making emacs happy: -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,2001 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "Software"), 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: Juergen Pfeifer 1997 * - ****************************************************************************/ - -#include "internal.h" -#include "cursesapp.h" - -MODULE_ID("$Id: cursesmain.cc,v 1.8 2001/07/14 20:54:43 juergen Exp $") - -/* This is the default implementation of main() for a NCursesApplication. - * You only have to instantiate a static NCursesApplication object in your - * main application source file and link this module with your application. - */ -int main(int argc, char* argv[]) -{ - NCursesApplication* A = NCursesApplication::getApplication(); - if (!A) - return(1); - else { - int res; - - A->handleArgs(argc,argv); - ::endwin(); - res = (*A)(); - ::endwin(); - return(res); - } -} diff --git a/contrib/ncurses/c++/cursesp.cc b/contrib/ncurses/c++/cursesp.cc deleted file mode 100644 index 7fb5e51778ef..000000000000 --- a/contrib/ncurses/c++/cursesp.cc +++ /dev/null @@ -1,129 +0,0 @@ -// * this is for making emacs happy: -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "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: Juergen Pfeifer 1993,1997 * - ****************************************************************************/ - -#include "internal.h" -#include "cursesp.h" -#include - -MODULE_ID("$Id: cursesp.cc,v 1.19 2001/07/14 20:54:43 juergen Exp $") - -NCursesPanel* NCursesPanel::dummy = (NCursesPanel*)0; - -void NCursesPanel::init() { - p = ::new_panel(w); - if (!p) - OnError(ERR); - - UserHook* hook = new UserHook; - hook->m_user = NULL; - hook->m_back = this; - hook->m_owner = p; - ::set_panel_userptr(p, (void *)hook); -} - -NCursesPanel::~NCursesPanel() { - UserHook* hook = (UserHook*)::panel_userptr(p); - assert(hook != 0 && hook->m_back==this && hook->m_owner==p); - delete hook; - ::del_panel(p); - ::update_panels(); -} - -void -NCursesPanel::redraw() { - PANEL *pan; - - pan = ::panel_above(NULL); - while (pan) { - ::touchwin(panel_window(pan)); - pan = ::panel_above(pan); - } - ::update_panels(); - ::doupdate(); -} - -int -NCursesPanel::refresh() { - ::update_panels(); - return ::doupdate(); -} - -int -NCursesPanel::noutrefresh() { - ::update_panels(); - return OK; -} - -void -NCursesPanel::boldframe(const char *title, const char* btitle) { - standout(); - frame(title, btitle); - standend(); -} - -void -NCursesPanel::frame(const char *title,const char *btitle) { - int err = OK; - if (!title && !btitle) { - err = box(); - } - else { - err = box(); - if (err==OK) - label(title,btitle); - } - OnError(err); -} - -void -NCursesPanel::label(const char *tLabel, const char *bLabel) { - if (tLabel) - centertext(0,tLabel); - if (bLabel) - centertext(maxy(),bLabel); -} - -void -NCursesPanel::centertext(int row,const char *label) { - if (label) { - int x = (maxx() - ::strlen(label)) / 2; - if (x<0) - x=0; - OnError(addstr(row, x, label, width())); - } -} - -int -NCursesPanel::getKey(void) { - return getch(); -} diff --git a/contrib/ncurses/c++/cursesp.h b/contrib/ncurses/c++/cursesp.h deleted file mode 100644 index 1a656f5464ad..000000000000 --- a/contrib/ncurses/c++/cursesp.h +++ /dev/null @@ -1,221 +0,0 @@ -// * This makes emacs happy -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "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: Juergen Pfeifer 1997 * - ****************************************************************************/ - -#ifndef NCURSES_CURSESP_H_incl -#define NCURSES_CURSESP_H_incl 1 - -// $Id: cursesp.h,v 1.15 2001/07/14 20:56:18 juergen Exp $ - -#include - -extern "C" { -# include -} - -class NCURSES_IMPEXP NCursesPanel : public NCursesWindow { -protected: - PANEL *p; - static NCursesPanel *dummy; - -private: - // This structure is used for the panel's user data field to link the - // PANEL* to the C++ object and to provide extra space for a user pointer. - typedef struct { - void* m_user; // the pointer for the user's data - const NCursesPanel* m_back; // backward pointer to C++ object - const PANEL* m_owner; // the panel itself - } UserHook; - - void init(); // Initialize the panel object - -protected: - void set_user(void *user) { - UserHook* uptr = (UserHook*)::panel_userptr (p); - assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==p); - uptr->m_user = user; - } - // Set the user pointer of the panel. - - void *get_user() { - UserHook* uptr = (UserHook*)::panel_userptr (p); - assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==p); - return uptr->m_user; - } - - void OnError (int err) const THROWS((NCursesPanelException)) { - if (err==ERR) - THROW(new NCursesPanelException (this, err)); - } - // If err is equal to the curses error indicator ERR, an error handler - // is called. - - // Get a keystroke. Default implementation calls getch() - virtual int getKey(void); - -public: - NCursesPanel(int lines, - int cols, - int begin_y = 0, - int begin_x = 0) - : NCursesWindow(lines,cols,begin_y,begin_x) { - init(); - } - // Create a panel with this size starting at the requested position. - - NCursesPanel() : NCursesWindow(::stdscr) { init(); } - // This constructor creates the default Panel associated with the - // ::stdscr window - - virtual ~NCursesPanel(); - - // basic manipulation - inline void hide() { - OnError (::hide_panel(p)); - } - // Hide the panel. It stays in the stack but becomes invisible. - - inline void show() { - OnError (::show_panel(p)); - } - // Show the panel, i.e. make it visible. - - inline void top() { - OnError (::top_panel(p)); - } - // Make this panel the top panel in the stack. - - inline void bottom() { - OnError (::bottom_panel(p)); - } - // Make this panel the bottom panel in the stack. - // N.B.: The panel associated with ::stdscr is always on the bottom. So - // actually bottom() makes the panel the first above ::stdscr. - - virtual int mvwin(int y, int x) { - OnError(::move_panel(p, y, x)); - return OK; - } - - inline bool hidden() const { - return (::panel_hidden (p) ? TRUE : FALSE); - } - // Return TRUE if the panel is hidden, FALSE otherwise. - -/* The functions panel_above() and panel_below() are not reflected in - the NCursesPanel class. The reason for this is, that we cannot - assume that a panel retrieved by those operations is one wrapped - by a C++ class. Although this situation might be handled, we also - need a reverse mapping from PANEL to NCursesPanel which needs some - redesign of the low level stuff. At the moment, we define them in the - interface but they will always produce an error. */ - inline NCursesPanel& above() const { - OnError(ERR); - return *dummy; - } - - inline NCursesPanel& below() const { - OnError(ERR); - return *dummy; - } - - // Those two are rewrites of the corresponding virtual members of - // NCursesWindow - virtual int refresh(); - // Propagate all panel changes to the virtual screen and update the - // physical screen. - - virtual int noutrefresh(); - // Propagate all panel changes to the virtual screen. - - static void redraw(); - // Redraw all panels. - - // decorations - virtual void frame(const char* title=NULL, - const char* btitle=NULL); - // Put a frame around the panel and put the title centered in the top line - // and btitle in the bottom line. - - virtual void boldframe(const char* title=NULL, - const char* btitle=NULL); - // Same as frame(), but use highlighted attributes. - - virtual void label(const char* topLabel, - const char* bottomLabel); - // Put the title centered in the top line and btitle in the bottom line. - - virtual void centertext(int row,const char* label); - // Put the label text centered in the specified row. -}; - -/* We use templates to provide a typesafe mechanism to associate - * user data with a panel. A NCursesUserPanel is a panel - * associated with some user data of type T. - */ -template class NCursesUserPanel : public NCursesPanel -{ -public: - NCursesUserPanel (int lines, - int cols, - int begin_y = 0, - int begin_x = 0, - const T* p_UserData = (T*)0) - : NCursesPanel (lines, cols, begin_y, begin_x) { - if (p) - set_user ((void *)p_UserData); - }; - // This creates an user panel of the requested size with associated - // user data pointed to by p_UserData. - - NCursesUserPanel(const T* p_UserData = (T*)0) : NCursesPanel() { - if (p) - set_user((void *)p_UserData); - }; - // This creates an user panel associated with the ::stdscr and user data - // pointed to by p_UserData. - - virtual ~NCursesUserPanel() {}; - - T* UserData (void) const { - return (T*)get_user (); - }; - // Retrieve the user data associated with the panel. - - virtual void setUserData (const T* p_UserData) { - if (p) - set_user ((void *)p_UserData); - } - // Associate the user panel with the user data pointed to by p_UserData. -}; - -#endif // NCURSES_CURSESP_H_incl diff --git a/contrib/ncurses/c++/cursespad.cc b/contrib/ncurses/c++/cursespad.cc deleted file mode 100644 index 64795120ebb7..000000000000 --- a/contrib/ncurses/c++/cursespad.cc +++ /dev/null @@ -1,270 +0,0 @@ -// * this is for making emacs happy: -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1999,2001 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "Software"), 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: Juergen Pfeifer 1999 * - ****************************************************************************/ - -#include "internal.h" -#include "etip.h" -#include "cursesw.h" - -MODULE_ID("$Id: cursespad.cc,v 1.4 2001/03/24 21:25:57 tom Exp $") - -NCursesPad::NCursesPad(int lines, int cols) - : NCursesWindow(), - viewWin((NCursesWindow*)0), - viewSub((NCursesWindow*)0), - h_gridsize(0), v_gridsize(0), - min_row(0), min_col(0) -{ - w = ::newpad(lines,cols); - if ((WINDOW*)0==w) { - count--; - err_handler("Cannot construct window"); - } - alloced = TRUE; -} - - -int NCursesPad::driver (int key) { - // Default implementation - switch(key) { - case KEY_UP: - // ======= - return REQ_PAD_UP; - case KEY_DOWN: - // ========= - return REQ_PAD_DOWN; - case KEY_LEFT: - // ========= - return REQ_PAD_LEFT; - case KEY_RIGHT: - // ========== - return REQ_PAD_RIGHT; - case KEY_EXIT: - // ========= - case CTRL('X'): - // ========== - return REQ_PAD_EXIT; - - default: return(key); - } -} - - -void NCursesPad::operator()(void) { - NCursesWindow* W = Win(); - - if ((NCursesWindow*)0 != W) { - int Width = W->width(); - int Height = W->height(); - - int req = REQ_PAD_REFRESH; - - W->keypad(TRUE); - W->meta(TRUE); - refresh(); - - do { - bool changed = FALSE; - - switch (req) { - case REQ_PAD_REFRESH: - // ================ - changed = TRUE; - break; - case REQ_PAD_LEFT: - // ============= - if (min_col > 0) { - changed = TRUE; - if (min_col < h_gridsize) - min_col = 0; - else - min_col -= h_gridsize; - } - else - OnNavigationError(req); - break; - case REQ_PAD_RIGHT: - // ============== - if (min_col < (width() - Width - 1)) { - changed = TRUE; - if (min_col > (width() - Width - h_gridsize - 1)) - min_col = width() - Width - 1; - else - min_col += h_gridsize; - } - else - OnNavigationError(req); - break; - case REQ_PAD_UP: - // =========== - if (min_row > 0) { - changed = TRUE; - if (min_row < v_gridsize) - min_row = 0; - else - min_row -= v_gridsize; - } - else - OnNavigationError(req); - break; - case REQ_PAD_DOWN: - // ============= - if (min_row < (height() - Height - 1)) { - changed = TRUE; - if (min_row > (height() - Height - v_gridsize - 1)) - min_row = height() - Height - 1; - else - min_row += v_gridsize; - } - else - OnNavigationError(req); - break; - - default: - OnUnknownOperation(req); - } - - if (changed) { - noutrefresh(); - W->syncup(); - OnOperation(req); - viewWin->refresh(); - } - } while( (req=driver(W->getch())) != REQ_PAD_EXIT ); - } -} - - -int NCursesPad::refresh() { - int res = noutrefresh(); - if (res==OK && ((NCursesWindow*)0 != viewWin)) { - res = (viewWin->refresh()); - } - return(res); -} - -int NCursesPad::noutrefresh() { - int res = OK; - NCursesWindow* W = Win(); - if ((NCursesWindow*)0 != W) { - res = copywin(*W,min_row,min_col, - 0,0,W->maxy(),W->maxx(), - FALSE); - if (res==OK) { - W->syncup(); - res = viewWin->noutrefresh(); - } - } - return (res); -} - -void NCursesPad::setWindow(NCursesWindow& view, - int v_grid NCURSES_PARAM_INIT(1), - int h_grid NCURSES_PARAM_INIT(1)) -{ - viewWin = &view; - min_row = min_col = 0; - if (h_grid <=0 || v_grid <= 0) - err_handler("Illegal Gridsize"); - else { - h_gridsize = h_grid; - v_gridsize = v_grid; - } -} - -void NCursesPad::setSubWindow(NCursesWindow& sub) -{ - if ((NCursesWindow*)0 == viewWin) - err_handler("Pad has no viewport"); - if (!viewWin->isDescendant(sub)) - THROW(new NCursesException("NCursesFramePad", E_SYSTEM_ERROR)); - viewSub = ⊂ -} - -void NCursesFramedPad::OnOperation(int pad_req) { - NCursesWindow* W = Win(); - NCursesWindow* Win = getWindow(); - - if (((NCursesWindow*)0 != W) && ((NCursesWindow*)0 != Win)) { - int Width = W->width(); - int Height = W->height(); - int i, row, col, h_len, v_len; - - h_len = (Width*Width + width() - 1)/width(); - if (h_len==0) - h_len = 1; - if (h_len > Width) - h_len = Width; - - v_len = (Height*Height + height() - 1)/height(); - if (v_len==0) - v_len = 1; - if (v_len > Height) - v_len = Height; - - col = (min_col * Width + width() - 1) / width(); - if (col + h_len > Width) - col = Width - h_len; - - row = (min_row * Height + height() - 1) / height(); - if (row + v_len > Height) - row = Height - v_len; - - Win->vline(1,Width+1,Height); - Win->attron(A_REVERSE); - if (v_len>=2) { - Win->addch(row+1,Width+1,ACS_UARROW); - for(i=2;iaddch(row+i,Width+1,' '); - Win->addch(row+v_len,Width+1,ACS_DARROW); - } - else { - for(i=1;i<=v_len;i++) - Win->addch(row+i,Width+1,' '); - } - Win->attroff(A_REVERSE); - - Win->hline(Height+1,1,Width); - Win->attron(A_REVERSE); - if (h_len >= 2) { - Win->addch(Height+1,col+1,ACS_LARROW); - for(i=2;iaddch(Height+1,col+i,' '); - Win->addch(Height+1,col+h_len,ACS_RARROW); - } - else { - for(i=1;i<=h_len;i++) - Win->addch(Height+1,col+i,' '); - } - Win->attroff(A_REVERSE); - } -} diff --git a/contrib/ncurses/c++/cursesw.cc b/contrib/ncurses/c++/cursesw.cc deleted file mode 100644 index fb6bd8b1fed8..000000000000 --- a/contrib/ncurses/c++/cursesw.cc +++ /dev/null @@ -1,455 +0,0 @@ -// * this is for making emacs happy: -*-Mode: C++;-*- - -/* - Copyright (C) 1989 Free Software Foundation - written by Eric Newton (newton@rocky.oswego.edu) - - This file is part of the GNU C++ Library. This library is free - software; you can redistribute it and/or modify it under the terms of - the GNU Library General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. This library is distributed in the hope - that it will be useful, but WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - modified by Ulrich Drepper (drepper@karlsruhe.gmd.de) - and Anatoly Ivasyuk (anatoly@nick.csh.rit.edu) - - modified by Juergen Pfeifer (juergen.pfeifer@gmx.net) -*/ - -#include "internal.h" -#include "cursesw.h" - -MODULE_ID("$Id: cursesw.cc,v 1.24 2001/12/08 21:02:33 tom Exp $") - -#define COLORS_NEED_INITIALIZATION -1 -#define COLORS_NOT_INITIALIZED 0 -#define COLORS_MONOCHROME 1 -#define COLORS_ARE_REALLY_THERE 2 - -// declare static variables for the class -long NCursesWindow::count = 0L; -bool NCursesWindow::b_initialized = FALSE; - -/* - * The ncurses library has a fallback for vsscanf(), which may work... - */ -#if !(USE_STRSTREAM_VSCAN || USE_STRSTREAM_VSCAN_CAST) -# undef USE_STDIO_VSCAN -# define USE_STDIO_VSCAN 1 -#endif - -#if defined(__GNUG__) -# ifndef _IO_va_list -# define _IO_va_list char * -# endif -#endif - -int -NCursesWindow::scanw(const char* fmt, ...) -{ - int result = ERR; - char buf[BUFSIZ]; - - if (::wgetnstr(w, buf, sizeof(buf)) != ERR) { - va_list args; - va_start(args, fmt); -#if USE_STDIO_VSCAN - if (::vsscanf(buf, fmt, args) != -1) - result = OK; -#elif USE_STRSTREAM_VSCAN /* powerpc, os390 */ - strstreambuf ss(buf, sizeof(buf)); - if (ss.vscan(fmt, args) != -1) - result = OK; -#elif USE_STRSTREAM_VSCAN_CAST /* pre-gcc 3.0 */ - strstreambuf ss(buf, sizeof(buf)); - if (ss.vscan(fmt, (_IO_va_list)args) != -1) - result = OK; -#endif - va_end(args); - } - return result; -} - - -int -NCursesWindow::scanw(int y, int x, const char* fmt, ...) -{ - int result = ERR; - char buf[BUFSIZ]; - - if (::wmove(w, y, x) != ERR) { - if (::wgetnstr(w, buf, sizeof(buf)) != ERR) { - va_list args; - va_start(args, fmt); -#if USE_STDIO_VSCAN - if (::vsscanf(buf, fmt, args) != -1) - result = OK; -#elif USE_STRSTREAM_VSCAN /* powerpc, os390 */ - strstreambuf ss(buf, sizeof(buf)); - if (ss.vscan(fmt, args) != -1) - result = OK; -#elif USE_STRSTREAM_VSCAN_CAST /* pre-gcc 3.0 */ - strstreambuf ss(buf, sizeof(buf)); - if (ss.vscan(fmt, (_IO_va_list)args) != -1) - result = OK; -#endif - va_end(args); - } - } - return result; -} - - -int -NCursesWindow::printw(const char * fmt, ...) -{ - va_list args; - va_start(args, fmt); - char buf[BUFSIZ]; - ::vsprintf(buf, fmt, args); - va_end(args); - return waddstr(w, buf); -} - - -int -NCursesWindow::printw(int y, int x, const char * fmt, ...) -{ - va_list args; - va_start(args, fmt); - int result = ::wmove(w, y, x); - if (result == OK) { - char buf[BUFSIZ]; - ::vsprintf(buf, fmt, args); - result = waddstr(w, buf); - } - va_end(args); - return result; -} - - -void -NCursesWindow::init(void) -{ - leaveok(0); - keypad(1); - meta(1); -} - -void -NCursesWindow::err_handler(const char *msg) const THROWS(NCursesException) -{ - THROW(new NCursesException(msg)); -} - -void -NCursesWindow::initialize() { - if (!b_initialized) { - ::initscr(); - b_initialized = TRUE; - if (colorInitialized==COLORS_NEED_INITIALIZATION) { - colorInitialized=COLORS_NOT_INITIALIZED; - useColors(); - } - ::noecho(); - ::cbreak(); - } -} - -NCursesWindow::NCursesWindow() { - initialize(); - - w = (WINDOW *)0; - init(); - alloced = FALSE; - subwins = par = sib = 0; - count++; -} - -NCursesWindow::NCursesWindow(int lines, int cols, int begin_y, int begin_x) -{ - initialize(); - - w = ::newwin(lines, cols, begin_y, begin_x); - if (w == 0) { - err_handler("Cannot construct window"); - } - init(); - - alloced = TRUE; - subwins = par = sib = 0; - count++; -} - -NCursesWindow::NCursesWindow(WINDOW* &window) -{ - initialize(); - - w = window; - init(); - alloced = FALSE; - subwins = par = sib = 0; - count++; -} - -NCursesWindow::NCursesWindow(NCursesWindow& win, int l, int c, - int begin_y, int begin_x, char absrel) -{ - initialize(); - if (absrel == 'a') { // absolute origin - begin_y -= win.begy(); - begin_x -= win.begx(); - } - - // Even though we treat subwindows as a tree, the standard curses - // library needs the `subwin' call to link to the parent in - // order to correctly perform refreshes, etc. - // Friendly enough, this also works for pads. - w = ::derwin(win.w, l, c, begin_y, begin_x); - if (w == 0) { - err_handler("Cannot construct subwindow"); - } - - par = &win; - sib = win.subwins; - win.subwins = this; - subwins = 0; - alloced = TRUE; - count++; -} - -NCursesWindow::NCursesWindow(NCursesWindow& win, - bool do_box NCURSES_PARAM_INIT(TRUE)) -{ - initialize(); - w = :: derwin(win.w,win.height()-2,win.width()-2,1,1); - if (w == 0) { - err_handler("Cannot construct subwindow"); - } - - par = &win; - sib = win.subwins; - win.subwins = this; - subwins = 0; - alloced = TRUE; - count++; - - if (do_box) { - win.box(); - win.touchwin(); - } -} - -NCursesWindow NCursesWindow::Clone() { - WINDOW *d = ::dupwin(w); - NCursesWindow W(d); - W.subwins = subwins; - W.sib = sib; - W.par = par; - W.alloced = alloced; - return W; -} - -typedef int (*RIPOFFINIT)(NCursesWindow&); -static RIPOFFINIT R_INIT[5]; // There can't be more -static int r_init_idx = 0; -static RIPOFFINIT* prip = R_INIT; - -extern "C" int _nc_ripoffline(int,int (*init)(WINDOW*,int)); - -NCursesWindow::NCursesWindow(WINDOW *win, int cols) { - initialize(); - w = win; - assert((w->_maxx+1)==cols); - alloced = FALSE; - subwins = par = sib = 0; -} - -int NCursesWindow::ripoff_init(WINDOW *w, int cols) -{ - int res = ERR; - - RIPOFFINIT init = *prip++; - if (init) { - NCursesWindow* W = new NCursesWindow(w,cols); - res = init(*W); - } - return res; -} - -int NCursesWindow::ripoffline(int ripoff_lines, - int (*init)(NCursesWindow& win)) { - int code = ::_nc_ripoffline(ripoff_lines,ripoff_init); - if (code==OK && init && ripoff_lines) { - R_INIT[r_init_idx++] = init; - } - return code; -} - -bool -NCursesWindow::isDescendant(NCursesWindow& win) { - for (NCursesWindow* p = subwins; p != NULL; p = p->sib) { - if (p==&win) - return TRUE; - else { - if (p->isDescendant(win)) - return TRUE; - } - } - return FALSE; -} - -void -NCursesWindow::kill_subwindows() -{ - for (NCursesWindow* p = subwins; p != 0; p = p->sib) { - p->kill_subwindows(); - if (p->alloced) { - if (p->w != 0) - ::delwin(p->w); - p->alloced = FALSE; - } - p->w = 0; // cause a run-time error if anyone attempts to use... - } -} - - -NCursesWindow::~NCursesWindow() -{ - kill_subwindows(); - - if (par != 0) { // Snip us from the parent's list of subwindows. - NCursesWindow * win = par->subwins; - NCursesWindow * trail = 0; - for (;;) { - if (win == 0) - break; - else if (win == this) { - if (trail != 0) - trail->sib = win->sib; - else - par->subwins = win->sib; - break; - } else { - trail = win; - win = win->sib; - } - } - } - - if (alloced && w != 0) - ::delwin(w); - - if (alloced) { - --count; - if (count == 0) { - ::endwin(); - } - else if (count < 0) { // cannot happen! - err_handler("Too many windows destroyed"); - } - } -} - -// --------------------------------------------------------------------- -// Color stuff -// -int NCursesWindow::colorInitialized = COLORS_NOT_INITIALIZED; - -void -NCursesWindow::useColors(void) -{ - if (colorInitialized == COLORS_NOT_INITIALIZED) { - if (b_initialized) { - if (::has_colors()) { - ::start_color(); - colorInitialized = COLORS_ARE_REALLY_THERE; - } - else - colorInitialized = COLORS_MONOCHROME; - } - else - colorInitialized = COLORS_NEED_INITIALIZATION; - } -} - -short -NCursesWindow::getcolor(int getback) const -{ - short fore, back; - - if (colorInitialized==COLORS_ARE_REALLY_THERE) { - if (::pair_content((short)PAIR_NUMBER(w->_attrs), &fore, &back)) - err_handler("Can't get color pair"); - } - else { - // Monochrome means white on black - back = COLOR_BLACK; - fore = COLOR_WHITE; - } - return getback ? back : fore; -} - -int NCursesWindow::NumberOfColors() -{ - if (colorInitialized==COLORS_ARE_REALLY_THERE) - return COLORS; - else - return 1; // monochrome (actually there are two ;-) -} - -short -NCursesWindow::getcolor() const -{ - if (colorInitialized==COLORS_ARE_REALLY_THERE) - return PAIR_NUMBER(w->_attrs); - else - return 0; // we only have pair zero -} - -int -NCursesWindow::setpalette(short fore, short back, short pair) -{ - if (colorInitialized==COLORS_ARE_REALLY_THERE) - return ::init_pair(pair, fore, back); - else - return OK; -} - -int -NCursesWindow::setpalette(short fore, short back) -{ - if (colorInitialized==COLORS_ARE_REALLY_THERE) - return setpalette(fore, back, (short)PAIR_NUMBER(w->_attrs)); - else - return OK; -} - - -int -NCursesWindow::setcolor(short pair) -{ - if (colorInitialized==COLORS_ARE_REALLY_THERE) { - if ((pair < 1) || (pair > COLOR_PAIRS)) - err_handler("Can't set color pair"); - - attroff(A_COLOR); - attrset(COLOR_PAIR(pair)); - } - return OK; -} - -#if HAVE_HAS_KEY -extern "C" int _nc_has_mouse(void); - -bool NCursesWindow::has_mouse() const { - return ((::has_key(KEY_MOUSE) || ::_nc_has_mouse()) - ? TRUE : FALSE); -} -#endif diff --git a/contrib/ncurses/c++/cursesw.h b/contrib/ncurses/c++/cursesw.h deleted file mode 100644 index 5383399de4fe..000000000000 --- a/contrib/ncurses/c++/cursesw.h +++ /dev/null @@ -1,1397 +0,0 @@ -// * This makes emacs happy -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "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. * - ****************************************************************************/ - -#ifndef NCURSES_CURSESW_H_incl -#define NCURSES_CURSESW_H_incl 1 - -// $Id: cursesw.h,v 1.28 2001/07/15 01:17:56 tom Exp $ - -#include -#include -#include - -#if HAVE_STRSTREAM_H && (USE_STRSTREAM_VSCAN||USE_STRSTREAM_VSCAN_CAST) -#include -#endif - -extern "C" { -# include -} - -/* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro. - Undefine it here, because NCursesWindow uses lines as a method. */ -#undef lines - -/* "Convert" macros to inlines. We'll define it as another symbol to avoid - * conflict with library symbols. - */ -#undef UNDEF -#define UNDEF(name) CUR_ ##name - -#ifdef addch -inline int UNDEF(addch)(chtype ch) { return addch(ch); } -#undef addch -#define addch UNDEF(addch) -#endif - -#ifdef echochar -inline int UNDEF(echochar)(chtype ch) { return echochar(ch); } -#undef echochar -#define echochar UNDEF(echochar) -#endif - -#ifdef insdelln -inline int UNDEF(insdelln)(int n) { return insdelln(n); } -#undef insdelln -#define insdelln UNDEF(insdelln) -#endif - -#ifdef addstr -/* The (char*) cast is to hack around missing const's */ -inline int UNDEF(addstr)(const char * str) { return addstr((char*)str); } -#undef addstr -#define addstr UNDEF(addstr) -#endif - -#ifdef attron -inline int UNDEF(attron)(chtype at) { return attron(at); } -#undef attron -#define attron UNDEF(attron) -#endif - -#ifdef attroff -inline int UNDEF(attroff)(chtype at) { return attroff(at); } -#undef attroff -#define attroff UNDEF(attroff) -#endif - -#ifdef attrset -inline chtype UNDEF(attrset)(chtype at) { return attrset(at); } -#undef attrset -#define attrset UNDEF(attrset) -#endif - -#ifdef color_set -inline chtype UNDEF(color_set)(short p,void* opts) { return color_set(p,opts); } -#undef color_set -#define color_set UNDEF(color_set) -#endif - -#ifdef border -inline int UNDEF(border)(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br) -{ return border(ls,rs,ts,bs,tl,tr,bl,br); } -#undef border -#define border UNDEF(border) -#endif - -#ifdef box -inline int UNDEF(box)(WINDOW *win, int v, int h) { return box(win, v, h); } -#undef box -#define box UNDEF(box) -#endif - -#ifdef mvwhline -inline int UNDEF(mvwhline)(WINDOW *win,int y,int x,chtype c,int n) { - return mvwhline(win,y,x,c,n); } -#undef mvwhline -#define mvwhline UNDEF(mvwhline) -#endif - -#ifdef mvwvline -inline int UNDEF(mvwvline)(WINDOW *win,int y,int x,chtype c,int n) { - return mvwvline(win,y,x,c,n); } -#undef mvwvline -#define mvwvline UNDEF(mvwvline) -#endif - -#ifdef clear -inline int UNDEF(clear)() { return clear(); } -#undef clear -#define clear UNDEF(clear) -#endif - -#ifdef clearok -inline int UNDEF(clearok)(WINDOW* win, bool bf) { return clearok(win, bf); } -#undef clearok -#define clearok UNDEF(clearok) -#else -extern "C" NCURSES_IMPEXP int NCURSES_API clearok(WINDOW*, bool); -#endif - -#ifdef clrtobot -inline int UNDEF(clrtobot)() { return clrtobot(); } -#undef clrtobot -#define clrtobot UNDEF(clrtobot) -#endif - -#ifdef clrtoeol -inline int UNDEF(clrtoeol)() { return clrtoeol(); } -#undef clrtoeol -#define clrtoeol UNDEF(clrtoeol) -#endif - -#ifdef delch -inline int UNDEF(delch)() { return delch(); } -#undef delch -#define delch UNDEF(delch) -#endif - -#ifdef deleteln -inline int UNDEF(deleteln)() { return deleteln(); } -#undef deleteln -#define deleteln UNDEF(deleteln) -#endif - -#ifdef erase -inline int UNDEF(erase)() { return erase(); } -#undef erase -#define erase UNDEF(erase) -#endif - -#ifdef flushok -inline int UNDEF(flushok)(WINDOW* _win, bool _bf) { - return flushok(_win, _bf); } -#undef flushok -#define flushok UNDEF(flushok) -#else -#define _no_flushok -#endif - -#ifdef getch -inline int UNDEF(getch)() { return getch(); } -#undef getch -#define getch UNDEF(getch) -#endif - -#ifdef getstr -inline int UNDEF(getstr)(char *_str) { return getstr(_str); } -#undef getstr -#define getstr UNDEF(getstr) -#endif - -#ifdef instr -inline int UNDEF(instr)(char *_str) { return instr(_str); } -#undef instr -#define instr UNDEF(instr) -#endif - -#ifdef innstr -inline int UNDEF(innstr)(char *_str, int n) { return innstr(_str,n); } -#undef innstr -#define innstr UNDEF(innstr) -#endif - -#ifdef mvwinnstr -inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) { - return mvwinnstr(win,y,x,_str,n); } -#undef mvwinnstr -#define mvwinnstr UNDEF(mvwinnstr) -#endif - -#ifdef mvinnstr -inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) { - return mvinnstr(y,x,_str,n); } -#undef mvinnstr -#define mvinnstr UNDEF(mvinnstr) -#endif - -#ifdef winsstr -inline int UNDEF(winsstr)(WINDOW *w, const char *_str) { - return winsstr(w,_str); } -#undef winsstr -#define winsstr UNDEF(winsstr) -#endif - -#ifdef mvwinsstr -inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x, const char *_str) { - return mvwinsstr(w,y,x,_str); } -#undef mvwinsstr -#define mvwinsstr UNDEF(mvwinsstr) -#endif - -#ifdef insstr -inline int UNDEF(insstr)(const char *_str) { - return insstr(_str); } -#undef insstr -#define insstr UNDEF(insstr) -#endif - -#ifdef mvinsstr -inline int UNDEF(mvinsstr)(int y, int x,const char *_str) { - return mvinsstr(y,x,_str); } -#undef mvinsstr -#define mvinsstr UNDEF(mvinsstr) -#endif - -#ifdef insnstr -inline int UNDEF(insnstr)(const char *_str, int n) { - return insnstr(_str,n); } -#undef insnstr -#define insnstr UNDEF(insnstr) -#endif - -#ifdef mvwinsnstr -inline int UNDEF(mvwinsnstr)(WINDOW *w, int y, int x,const char *_str, int n) { - return mvwinsnstr(w,y,x,_str,n); } -#undef mvwinsnstr -#define mvwinsnstr UNDEF(mvwinsnstr) -#endif - -#ifdef mvinsnstr -inline int UNDEF(mvinsnstr)(int y, int x,const char *_str, int n) { - return mvinsnstr(y,x,_str,n); } -#undef mvinsnstr -#define mvinsnstr UNDEF(mvinsnstr) -#endif - -#ifdef getnstr -inline int UNDEF(getnstr)(char *_str, int n) { return getnstr(_str,n); } -#undef getnstr -#define getnstr UNDEF(getnstr) -#endif - -#ifdef getyx -inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) { - getyx(win, y, x); } -#undef getyx -#define getyx UNDEF(getyx) -#endif - -#ifdef getbegyx -inline void UNDEF(getbegyx)(WINDOW* win, int& y, int& x) { getbegyx(win, y, x); } -#undef getbegyx -#define getbegyx UNDEF(getbegyx) -#endif - -#ifdef getmaxyx -inline void UNDEF(getmaxyx)(WINDOW* win, int& y, int& x) { getmaxyx(win, y, x); } -#undef getmaxyx -#define getmaxyx UNDEF(getmaxyx) -#endif - -#ifdef hline -inline int UNDEF(hline)(chtype ch, int n) { return hline(ch, n); } -#undef hline -#define hline UNDEF(hline) -#endif - -#ifdef inch -inline chtype UNDEF(inch)() { return inch(); } -#undef inch -#define inch UNDEF(inch) -#endif - -#ifdef insch -inline int UNDEF(insch)(char c) { return insch(c); } -#undef insch -#define insch UNDEF(insch) -#endif - -#ifdef insertln -inline int UNDEF(insertln)() { return insertln(); } -#undef insertln -#define insertln UNDEF(insertln) -#endif - -#ifdef leaveok -inline int UNDEF(leaveok)(WINDOW* win, bool bf) { return leaveok(win, bf); } -#undef leaveok -#define leaveok UNDEF(leaveok) -#else -extern "C" NCURSES_IMPEXP int NCURSES_API leaveok(WINDOW* win, bool bf); -#endif - -#ifdef move -inline int UNDEF(move)(int x, int y) { return move(x, y); } -#undef move -#define move UNDEF(move) -#endif - -#ifdef refresh -inline int UNDEF(refresh)() { return refresh(); } -#undef refresh -#define refresh UNDEF(refresh) -#endif - -#ifdef redrawwin -inline int UNDEF(redrawwin)(WINDOW *win) { return redrawwin(win); } -#undef redrawwin -#define redrawwin UNDEF(redrawwin) -#endif - -#ifdef scrl -inline int UNDEF(scrl)(int l) { return scrl(l); } -#undef scrl -#define scrl UNDEF(scrl) -#endif - -#ifdef scroll -inline int UNDEF(scroll)(WINDOW *win) { return scroll(win); } -#undef scroll -#define scroll UNDEF(scroll) -#endif - -#ifdef scrollok -inline int UNDEF(scrollok)(WINDOW* win, bool bf) { return scrollok(win, bf); } -#undef scrollok -#define scrollok UNDEF(scrollok) -#else -#if defined(__NCURSES_H) -extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, bool); -#else -extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, char); -#endif -#endif - -#ifdef setscrreg -inline int UNDEF(setscrreg)(int t, int b) { return setscrreg(t, b); } -#undef setscrreg -#define setscrreg UNDEF(setscrreg) -#endif - -#ifdef standend -inline int UNDEF(standend)() { return standend(); } -#undef standend -#define standend UNDEF(standend) -#endif - -#ifdef standout -inline int UNDEF(standout)() { return standout(); } -#undef standout -#define standout UNDEF(standout) -#endif - -#ifdef subpad -inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x) -{ return derwin(p,l,c,y,x); } -#undef subpad -#define subpad UNDEF(subpad) -#endif - -#ifdef timeout -inline void UNDEF(timeout)(int delay) { timeout(delay); } -#undef timeout -#define timeout UNDEF(timeout) -#endif - -#ifdef touchline -inline int UNDEF(touchline)(WINDOW *win, int s, int c) -{ return touchline(win,s,c); } -#undef touchline -#define touchline UNDEF(touchline) -#endif - -#ifdef touchwin -inline int UNDEF(touchwin)(WINDOW *win) { return touchwin(win); } -#undef touchwin -#define touchwin UNDEF(touchwin) -#endif - -#ifdef untouchwin -inline int UNDEF(untouchwin)(WINDOW *win) { return untouchwin(win); } -#undef untouchwin -#define untouchwin UNDEF(untouchwin) -#endif - -#ifdef vline -inline int UNDEF(vline)(chtype ch, int n) { return vline(ch, n); } -#undef vline -#define vline UNDEF(vline) -#endif - -#ifdef waddstr -inline int UNDEF(waddstr)(WINDOW *win, char *str) { return waddstr(win, str); } -#undef waddstr -#define waddstr UNDEF(waddstr) -#endif - -#ifdef waddchstr -inline int UNDEF(waddchstr)(WINDOW *win, chtype *at) { return waddchstr(win, at); } -#undef waddchstr -#define waddchstr UNDEF(waddchstr) -#endif - -#ifdef wstandend -inline int UNDEF(wstandend)(WINDOW *win) { return wstandend(win); } -#undef wstandend -#define wstandend UNDEF(wstandend) -#endif - -#ifdef wstandout -inline int UNDEF(wstandout)(WINDOW *win) { return wstandout(win); } -#undef wstandout -#define wstandout UNDEF(wstandout) -#endif - - -#ifdef wattroff -inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); } -#undef wattroff -#define wattroff UNDEF(wattroff) -#endif - -#ifdef chgat -inline int UNDEF(chgat)(int n,attr_t attr, short color, const void *opts) { - return chgat(n,attr,color,opts); } -#undef chgat -#define chgat UNDEF(chgat) -#endif - -#ifdef mvchgat -inline int UNDEF(mvchgat)(int y, int x, int n, - attr_t attr, short color, const void *opts) { - return mvchgat(y,x,n,attr,color,opts); } -#undef mvchgat -#define mvchgat UNDEF(mvchgat) -#endif - -#ifdef mvwchgat -inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n, - attr_t attr, short color, const void *opts) { - return mvwchgat(win,y,x,n,attr,color,opts); } -#undef mvwchgat -#define mvwchgat UNDEF(mvwchgat) -#endif - -#ifdef wattrset -inline int UNDEF(wattrset)(WINDOW *win, int att) { return wattrset(win, att); } -#undef wattrset -#define wattrset UNDEF(wattrset) -#endif - -#ifdef winch -inline chtype UNDEF(winch)(const WINDOW* win) { return winch(win); } -#undef winch -#define winch UNDEF(winch) -#endif - -#ifdef mvwaddch -inline int UNDEF(mvwaddch)(WINDOW *win, int y, int x, const chtype ch) -{ return mvwaddch(win, y, x, ch); } -#undef mvwaddch -#define mvwaddch UNDEF(mvwaddch) -#endif - -#ifdef mvwaddchnstr -inline int UNDEF(mvwaddchnstr)(WINDOW *win, int y, int x, chtype *str, int n) -{ return mvwaddchnstr(win, y, x, str, n); } -#undef mvwaddchnstr -#define mvwaddchnstr UNDEF(mvwaddchnstr) -#endif - -#ifdef mvwaddchstr -inline int UNDEF(mvwaddchstr)(WINDOW *win, int y, int x, chtype *str) -{ return mvwaddchstr(win, y, x, str); } -#undef mvwaddchstr -#define mvwaddchstr UNDEF(mvwaddchstr) -#endif - -#ifdef addnstr -inline int UNDEF(addnstr)(const char *str, int n) -{ return addnstr((char*)str, n); } -#undef addnstr -#define addnstr UNDEF(addnstr) -#endif - -#ifdef mvwaddnstr -inline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n) -{ return mvwaddnstr(win, y, x, (char*)str, n); } -#undef mvwaddnstr -#define mvwaddnstr UNDEF(mvwaddnstr) -#endif - -#ifdef mvwaddstr -inline int UNDEF(mvwaddstr)(WINDOW *win, int y, int x, const char * str) -{ return mvwaddstr(win, y, x, (char*)str); } -#undef mvwaddstr -#define mvwaddstr UNDEF(mvwaddstr) -#endif - -#ifdef mvwdelch -inline int UNDEF(mvwdelch)(WINDOW *win, int y, int x) -{ return mvwdelch(win, y, x); } -#undef mvwdelch -#define mvwdelch UNDEF(mvwdelch) -#endif - -#ifdef mvwgetch -inline int UNDEF(mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);} -#undef mvwgetch -#define mvwgetch UNDEF(mvwgetch) -#endif - -#ifdef mvwgetstr -inline int UNDEF(mvwgetstr)(WINDOW *win, int y, int x, char *str) -{return mvwgetstr(win,y,x, str);} -#undef mvwgetstr -#define mvwgetstr UNDEF(mvwgetstr) -#endif - -#ifdef mvwgetnstr -inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n) -{return mvwgetnstr(win,y,x, str,n);} -#undef mvwgetnstr -#define mvwgetnstr UNDEF(mvwgetnstr) -#endif - -#ifdef mvwinch -inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) { - return mvwinch(win, y, x);} -#undef mvwinch -#define mvwinch UNDEF(mvwinch) -#endif - -#ifdef mvwinsch -inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, char c) -{ return mvwinsch(win, y, x, c); } -#undef mvwinsch -#define mvwinsch UNDEF(mvwinsch) -#endif - -#ifdef mvaddch -inline int UNDEF(mvaddch)(int y, int x, chtype ch) -{ return mvaddch(y, x, ch); } -#undef mvaddch -#define mvaddch UNDEF(mvaddch) -#endif - -#ifdef mvaddnstr -inline int UNDEF(mvaddnstr)(int y, int x, const char *str, int n) -{ return mvaddnstr(y, x, (char*)str, n); } -#undef mvaddnstr -#define mvaddnstr UNDEF(mvaddnstr) -#endif - -#ifdef mvaddstr -inline int UNDEF(mvaddstr)(int y, int x, const char * str) -{ return mvaddstr(y, x, (char*)str); } -#undef mvaddstr -#define mvaddstr UNDEF(mvaddstr) -#endif - -#ifdef mvdelch -inline int UNDEF(mvdelch)(int y, int x) { return mvdelch(y, x);} -#undef mvdelch -#define mvdelch UNDEF(mvdelch) -#endif - -#ifdef mvgetch -inline int UNDEF(mvgetch)(int y, int x) { return mvgetch(y, x);} -#undef mvgetch -#define mvgetch UNDEF(mvgetch) -#endif - -#ifdef mvgetstr -inline int UNDEF(mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);} -#undef mvgetstr -#define mvgetstr UNDEF(mvgetstr) -#endif - -#ifdef mvgetnstr -inline int UNDEF(mvgetnstr)(int y, int x, char *str, int n) { - return mvgetnstr(y, x, str,n);} -#undef mvgetnstr -#define mvgetnstr UNDEF(mvgetnstr) -#endif - -#ifdef mvinch -inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);} -#undef mvinch -#define mvinch UNDEF(mvinch) -#endif - -#ifdef mvinsch -inline int UNDEF(mvinsch)(int y, int x, char c) -{ return mvinsch(y, x, c); } -#undef mvinsch -#define mvinsch UNDEF(mvinsch) -#endif - -#ifdef napms -inline void UNDEF(napms)(unsigned long x) { napms(x); } -#undef napms -#define napms UNDEF(napms) -#endif - -#ifdef fixterm -inline int UNDEF(fixterm)(void) { return fixterm(); } -#undef fixterm -#define fixterm UNDEF(fixterm) -#endif - -#ifdef resetterm -inline int UNDEF(resetterm)(void) { return resetterm(); } -#undef resetterm -#define resetterm UNDEF(resetterm) -#endif - -#ifdef saveterm -inline int UNDEF(saveterm)(void) { return saveterm(); } -#undef saveterm -#define saveterm UNDEF(saveterm) -#endif - -#ifdef crmode -inline int UNDEF(crmode)(void) { return crmode(); } -#undef crmode -#define crmode UNDEF(crmode) -#endif - -#ifdef nocrmode -inline int UNDEF(nocrmode)(void) { return nocrmode(); } -#undef nocrmode -#define nocrmode UNDEF(nocrmode) -#endif - -#ifdef getbkgd -inline chtype UNDEF(getbkgd)(const WINDOW *win) { return getbkgd(win); } -#undef getbkgd -#define getbkgd UNDEF(getbkgd) -#endif - -#ifdef bkgd -inline int UNDEF(bkgd)(chtype ch) { return bkgd(ch); } -#undef bkgd -#define bkgd UNDEF(bkgd) -#endif - -#ifdef bkgdset -inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); } -#undef bkgdset -#define bkgdset UNDEF(bkgdset) -#endif - -/* - * - * C++ class for windows. - * - * - */ - -class NCURSES_IMPEXP NCursesWindow -{ - friend class NCursesMenu; - friend class NCursesForm; - -private: - static bool b_initialized; - static void initialize(); - static int ripoff_init(WINDOW *,int); - - void init(); - - short getcolor(int getback) const; - - static int setpalette(short fore, short back, short pair); - static int colorInitialized; - - // This private constructor is only used during the initialization - // of windows generated by ripoffline() calls. - NCursesWindow(WINDOW* win, int cols); - -protected: - void err_handler(const char *) const THROWS(NCursesException); - // Signal an error with the given message text. - - static long count; // count of all active windows: - // We rely on the c++ promise that - // all otherwise uninitialized - // static class vars are set to 0 - - WINDOW* w; // the curses WINDOW - - bool alloced; // TRUE if we own the WINDOW - - NCursesWindow* par; // parent, if subwindow - NCursesWindow* subwins; // head of subwindows list - NCursesWindow* sib; // next subwindow of parent - - void kill_subwindows(); // disable all subwindows - // Destroy all subwindows. - - /* Only for use by derived classes. They are then in charge to - fill the member variables correctly. */ - NCursesWindow(); - -public: - NCursesWindow(WINDOW* &window); // useful only for stdscr - - NCursesWindow(int lines, // number of lines - int cols, // number of columns - int begin_y, // line origin - int begin_x); // col origin - - NCursesWindow(NCursesWindow& par,// parent window - int lines, // number of lines - int cols, // number of columns - int begin_y, // absolute or relative - int begin_x, // origins: - char absrel = 'a');// if `a', begin_y & begin_x are - // absolute screen pos, else if `r', they are relative to par origin - - NCursesWindow(NCursesWindow& par,// parent window - bool do_box = TRUE); - // this is the very common case that we want to create the subwindow that - // is two lines and two columns smaller and begins at (1,1). - // We may automatically request the box around it. - - virtual ~NCursesWindow(); - - NCursesWindow Clone(); - // Make an exact copy of the window. - - // Initialization. - static void useColors(void); - // Call this routine very early if you want to have colors. - - static int ripoffline(int ripoff_lines, - int (*init)(NCursesWindow& win)); - // This function is used to generate a window of ripped-of lines. - // If the argument is positive, lines are removed from the top, if it - // is negative lines are removed from the bottom. This enhances the - // lowlevel ripoffline() function because it uses the internal - // implementation that allows to remove more than just a single line. - // This function must be called before any other ncurses function. The - // creation of the window is deferred until ncurses gets initialized. - // The initialization function is then called. - - // ------------------------------------------------------------------------- - // terminal status - // ------------------------------------------------------------------------- - int lines() const { initialize(); return LINES; } - // Number of lines on terminal, *not* window - - int cols() const { initialize(); return COLS; } - // Number of cols on terminal, *not* window - - int tabsize() const { initialize(); return TABSIZE; } - // Size of a tab on terminal, *not* window - - static int NumberOfColors(); - // Number of available colors - - int colors() const { return NumberOfColors(); } - // Number of available colors - - // ------------------------------------------------------------------------- - // window status - // ------------------------------------------------------------------------- - int height() const { return maxy() + 1; } - // Number of lines in this window - - int width() const { return maxx() + 1; } - // Number of columns in this window - - int begx() const { return w->_begx; } - // Column of top left corner relative to stdscr - - int begy() const { return w->_begy; } - // Line of top left corner relative to stdscr - - int maxx() const { return w->_maxx; } - // Largest x coord in window - - int maxy() const { return w->_maxy; } - // Largest y coord in window - - short getcolor() const; - // Actual color pair - - short foreground() const { return getcolor(0); } - // Actual foreground color - - short background() const { return getcolor(1); } - // Actual background color - - int setpalette(short fore, short back); - // Set color palette entry - - int setcolor(short pair); - // Set actually used palette entry - - // ------------------------------------------------------------------------- - // window positioning - // ------------------------------------------------------------------------- - virtual int mvwin(int begin_y, int begin_x) { - return ::mvwin(w,begin_y,begin_x); } - // Move window to new position with the new position as top left corner. - // This is virtual because it is redefined in NCursesPanel. - - // ------------------------------------------------------------------------- - // coordinate positioning - // ------------------------------------------------------------------------- - int move(int y, int x) { return ::wmove(w, y, x); } - // Move cursor the this position - - void getyx(int& y, int& x) const { ::getyx(w, y, x); } - // Get current position of the cursor - - int mvcur(int oldrow, int oldcol, int newrow, int newcol) const { - return ::mvcur(oldrow, oldcol, newrow, newcol); } - // Perform lowlevel cursor motion that takes effect immediately. - - // ------------------------------------------------------------------------- - // input - // ------------------------------------------------------------------------- - int getch() { return ::wgetch(w); } - // Get a keystroke from the window. - - int getch(int y, int x) { return ::mvwgetch(w,y,x); } - // Move cursor to position and get a keystroke from the window - - int getstr(char* str, int n=-1) { - return ::wgetnstr(w, str,n); } - // Read a series of characters into str until a newline or carriage return - // is received. Read at most n characters. If n is negative, the limit is - // ignored. - - int getstr(int y, int x, char* str, int n=-1) { - return ::mvwgetnstr(w,y,x,str,n); } - // Move the cursor to the requested position and then perform the getstr() - // as described above. - - int instr(char *s, int n=-1) { return ::winnstr(w,s,n); } - // Get a string of characters from the window into the buffer s. Retrieve - // at most n characters, if n is negative retrieve all characters up to the - // end of the current line. Attributes are stripped from the characters. - - int instr(int y, int x, char *s, int n=-1) { - return ::mvwinnstr(w,y,x,s,n); } - // Move the cursor to the requested position and then perform the instr() - // as described above. - - int scanw(const char* fmt, ...) - // Perform a scanw function from the window. -#if __GNUG__ >= 2 - __attribute__ ((format (scanf, 2, 3))); -#else - ; -#endif - - int scanw(int y, int x, const char* fmt, ...) - // Move the cursor to the requested position and then perform a scanw - // from the window. -#if __GNUG__ >= 2 - __attribute__ ((format (scanf, 4, 5))); -#else - ; -#endif - - // ------------------------------------------------------------------------- - // output - // ------------------------------------------------------------------------- - int addch(const chtype ch) { return ::waddch(w, ch); } - // Put attributed character to the window. - - int addch(int y, int x, const chtype ch) { - return ::mvwaddch(w,y,x,ch); } - // Move cursor to the requested position and then put attributed character - // to the window. - - int echochar(const chtype ch) { return ::wechochar(w,ch); } - // Put attributed character to the window and refresh it immediately. - - int addstr(const char* str, int n=-1) { - return ::waddnstr(w, (char*)str,n); } - // Write the string str to the window, stop writing if the terminating - // NUL or the limit n is reached. If n is negative, it is ignored. - - int addstr(int y, int x, const char * str, int n=-1) { - return ::mvwaddnstr(w,y,x,(char*)str,n); } - // Move the cursor to the requested position and then perform the addstr - // as described above. - - int printw(const char* fmt, ...) - // Do a formatted print to the window. -#if (__GNUG__ >= 2) && !defined(printf) - __attribute__ ((format (printf, 2, 3))); -#else - ; -#endif - - int printw(int y, int x, const char * fmt, ...) - // Move the cursor and then do a formatted print to the window. -#if (__GNUG__ >= 2) && !defined(printf) - __attribute__ ((format (printf, 4, 5))); -#else - ; -#endif - - chtype inch() const { return ::winch(w); } - // Retrieve attributed character under the current cursor position. - - chtype inch(int y, int x) { return ::mvwinch(w,y,x); } - // Move cursor to requested position and then retrieve attributed character - // at this position. - - int insch(chtype ch) { return ::winsch(w, ch); } - // Insert attributed character into the window before current cursor - // position. - - int insch(int y, int x, chtype ch) { - return ::mvwinsch(w,y,x,(char)ch); } - // Move cursor to requested position and then insert the attributed - // character before that position. - - int insertln() { return ::winsdelln(w,1); } - // Insert an empty line above the current line. - - int insdelln(int n=1) { return ::winsdelln(w,n); } - // If n>0 insert that many lines above the current line. If n<0 delete - // that many lines beginning with the current line. - - int insstr(const char *s, int n=-1) { - return ::winsnstr(w,s,n); } - // Insert the string into the window before the current cursor position. - // Insert stops at end of string or when the limit n is reached. If n is - // negative, it is ignored. - - int insstr(int y, int x, const char *s, int n=-1) { - return ::mvwinsnstr(w,y,x,s,n); } - // Move the cursor to the requested position and then perform the insstr() - // as described above. - - int attron (chtype at) { return ::wattron (w, at); } - // Switch on the window attributes; - - int attroff(chtype at) { return ::wattroff(w, (int) at); } - // Switch off the window attributes; - - int attrset(chtype at) { return ::wattrset(w, (int) at); } - // Set the window attributes; - - int color_set(short color_pair_number, void* opts=NULL) { - return ::wcolor_set(w, color_pair_number, opts); } - // Set the window color attribute; - - int chgat(int n,attr_t attr, short color, const void *opts=NULL) { - return ::wchgat(w,n,attr,color,opts); } - // Change the attributes of the next n characters in the current line. If - // n is negative or greater than the number of remaining characters in the - // line, the attributes will be changed up to the end of the line. - - int chgat(int y, int x, - int n,attr_t attr, short color, const void *opts=NULL) { - return ::mvwchgat(w,y,x,n,attr,color,opts); } - // Move the cursor to the requested position and then perform chgat() as - // described above. - - // ------------------------------------------------------------------------- - // background - // ------------------------------------------------------------------------- - chtype getbkgd() const { return ::getbkgd(w); } - // Get current background setting. - - int bkgd(const chtype ch) { return ::wbkgd(w,ch); } - // Set the background property and apply it to the window. - - void bkgdset(chtype ch) { ::wbkgdset(w,ch); } - // Set the background property. - - // ------------------------------------------------------------------------- - // borders - // ------------------------------------------------------------------------- - int box(chtype vert=0, chtype hor=0) { - return ::wborder(w, vert, vert, hor, hor, 0, 0 ,0, 0); } - // Draw a box around the window with the given vertical and horizontal - // drawing characters. If you specify a zero as character, curses will try - // to find a "nice" character. - - int border(chtype left=0, chtype right=0, - chtype top =0, chtype bottom=0, - chtype top_left =0, chtype top_right=0, - chtype bottom_left =0, chtype bottom_right=0) { - return ::wborder(w,left,right,top,bottom,top_left,top_right, - bottom_left,bottom_right); } - // Draw a border around the window with the given characters for the - // various parts of the border. If you pass zero for a character, curses - // will try to find "nice" characters. - - // ------------------------------------------------------------------------- - // lines and boxes - // ------------------------------------------------------------------------- - int hline(int len, chtype ch=0) { return ::whline(w, ch, len); } - // Draw a horizontal line of len characters with the given character. If - // you pass zero for the character, curses will try to find a "nice" one. - - int hline(int y, int x, int len, chtype ch=0) { - return ::mvwhline(w,y,x,ch,len); } - // Move the cursor to the requested position and then draw a horizontal line. - - int vline(int len, chtype ch=0) { return ::wvline(w, ch, len); } - // Draw a vertical line of len characters with the given character. If - // you pass zero for the character, curses will try to find a "nice" one. - - int vline(int y, int x, int len, chtype ch=0) { - return ::mvwvline(w,y,x,ch,len); } - // Move the cursor to the requested position and then draw a vertical line. - - // ------------------------------------------------------------------------- - // erasure - // ------------------------------------------------------------------------- - int erase() { return ::werase(w); } - // Erase the window. - - int clear() { return ::wclear(w); } - // Clear the window. - - int clearok(bool bf) { return ::clearok(w, bf); } - // Set/Reset the clear flag. If set, the next refresh() will clear the - // screen. - - int clrtobot() { return ::wclrtobot(w); } - // Clear to the end of the window. - - int clrtoeol() { return ::wclrtoeol(w); } - // Clear to the end of the line. - - int delch() { return ::wdelch(w); } - // Delete character under the cursor. - - int delch(int y, int x) { return ::mvwdelch(w,y,x); } - // Move cursor to requested position and delete the character under the - // cursor. - - int deleteln() { return ::winsdelln(w,-1); } - // Delete the current line. - - // ------------------------------------------------------------------------- - // screen control - // ------------------------------------------------------------------------- - int scroll(int amount=1) { return ::wscrl(w,amount); } - // Scroll amount lines. If amount is positive, scroll up, otherwise - // scroll down. - - int scrollok(bool bf) { return ::scrollok(w, bf); } - // If bf is TRUE, window scrolls if cursor is moved off the bottom - // edge of the window or a scrolling region, otherwise the cursor is left - // at the bottom line. - - int setscrreg(int from, int to) { - return ::wsetscrreg(w,from,to); } - // Define a soft scrolling region. - - int idlok(bool bf) { return ::idlok(w, bf); } - // If bf is TRUE, use insert/delete line hardware support if possible. - // Otherwise do it in software. - - - void idcok(bool bf) { ::idcok(w, bf); } - // If bf is TRUE, use insert/delete character hardware support if possible. - // Otherwise do it in software. - - int touchwin() { return ::wtouchln(w,0,height(),1); } - // Mark the whole window as modified. - - int untouchwin() { return ::wtouchln(w,0,height(),0); } - // Mark the whole window as unmodified. - - int touchln(int s, int cnt, bool changed=TRUE) { - return ::wtouchln(w,s,cnt,(int)(changed?1:0)); } - // Mark cnt lines beginning from line s as changed or unchanged, depending - // on the value of the changed flag. - - bool is_linetouched(int line) const { - return (::is_linetouched(w,line) ? TRUE:FALSE); } - // Return TRUE if line is marked as changed, FALSE otherwise - - bool is_wintouched() const { - return (::is_wintouched(w) ? TRUE:FALSE); } - // Return TRUE if window is marked as changed, FALSE otherwise - - int leaveok(bool bf) { return ::leaveok(w, bf); } - // If bf is TRUE, curses will leave the cursor after an update whereever - // it is after the update. - - int redrawln(int from, int n) { return ::wredrawln(w,from,n); } - // Redraw n lines starting from the requested line - - int redrawwin() { return ::wredrawln(w,0,height()); } - // Redraw the whole window - - int doupdate() { return ::doupdate(); } - // Do all outputs to make the physical screen looking like the virtual one - - void syncdown() { ::wsyncdown(w); } - // Propagate the changes down to all descendant windows - - void syncup() { ::wsyncup(w); } - // Propagate the changes up in the hierarchy - - void cursyncup() { ::wcursyncup(w); } - // Position the cursor in all ancestor windows corresponding to our setting - - int syncok(bool bf) { return ::syncok(w,bf); } - // If called with bf=TRUE, syncup() is called whenever the window is changed - -#ifndef _no_flushok - int flushok(bool bf) { return ::flushok(w, bf); } -#endif - - void immedok(bool bf) { ::immedok(w,bf); } - // If called with bf=TRUE, any change in the window will cause an - // automatic immediate refresh() - - int keypad(bool bf) { return ::keypad(w, bf); } - // If called with bf=TRUE, the application will interpret function keys. - - int meta(bool bf) { return ::meta(w,bf); } - // If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise - // 7-Bit characters are generated. - - int standout() { return ::wstandout(w); } - // Enable "standout" attributes - - int standend() { return ::wstandend(w); } - // Disable "standout" attributes - - // ------------------------------------------------------------------------- - // The next two are virtual, because we redefine them in the - // NCursesPanel class. - // ------------------------------------------------------------------------- - virtual int refresh() { return ::wrefresh(w); } - // Propagate the changes in this window to the virtual screen and call - // doupdate(). This is redefined in NCursesPanel. - - virtual int noutrefresh() { return ::wnoutrefresh(w); } - // Propagate the changes in this window to the virtual screen. This is - // redefined in NCursesPanel. - - // ------------------------------------------------------------------------- - // multiple window control - // ------------------------------------------------------------------------- - int overlay(NCursesWindow& win) { - return ::overlay(w, win.w); } - // Overlay this window over win. - - int overwrite(NCursesWindow& win) { - return ::overwrite(w, win.w); } - // Overwrite win with this window. - - int copywin(NCursesWindow& win, - int sminrow, int smincol, - int dminrow, int dmincol, - int dmaxrow, int dmaxcol, bool overlay=TRUE) { - return ::copywin(w,win.w,sminrow,smincol,dminrow,dmincol, - dmaxrow,dmaxcol,(int)(overlay?1:0)); } - // Overlay or overwrite the rectangle in win given by dminrow,dmincol, - // dmaxrow,dmaxcol with the rectangle in this window beginning at - // sminrow,smincol. - - // ------------------------------------------------------------------------- - // Mouse related - // ------------------------------------------------------------------------- - bool has_mouse() const; - // Return TRUE if terminal supports a mouse, FALSE otherwise - - // ------------------------------------------------------------------------- - // traversal support - // ------------------------------------------------------------------------- - NCursesWindow* child() { return subwins; } - // Get the first child window. - - NCursesWindow* sibling() { return sib; } - // Get the next child of my parent. - - NCursesWindow* parent() { return par; } - // Get my parent. - - bool isDescendant(NCursesWindow& win); - // Return TRUE if win is a descendant of this. -}; - -// ------------------------------------------------------------------------- -// We leave this here for compatibility reasons. -// ------------------------------------------------------------------------- -class NCURSES_IMPEXP NCursesColorWindow : public NCursesWindow { -public: - NCursesColorWindow(WINDOW* &window) // useful only for stdscr - : NCursesWindow(window) { - useColors(); } - - NCursesColorWindow(int lines, // number of lines - int cols, // number of columns - int begin_y, // line origin - int begin_x) // col origin - : NCursesWindow(lines,cols,begin_y,begin_x) { - useColors(); } - - NCursesColorWindow(NCursesWindow& par,// parent window - int lines, // number of lines - int cols, // number of columns - int begin_y, // absolute or relative - int begin_x, // origins: - char absrel = 'a') // if `a', by & bx are - : NCursesWindow(par,lines,cols, // absolute screen pos, - begin_y,begin_x, // else if `r', they are - absrel ) { // relative to par origin - useColors(); } -}; - -// These enum definitions really belong inside the NCursesPad class, but only -// recent compilers support that feature. - - typedef enum { - REQ_PAD_REFRESH = KEY_MAX + 1, - REQ_PAD_UP, - REQ_PAD_DOWN, - REQ_PAD_LEFT, - REQ_PAD_RIGHT, - REQ_PAD_EXIT - } Pad_Request; - - const Pad_Request PAD_LOW = REQ_PAD_REFRESH; // lowest op-code - const Pad_Request PAD_HIGH = REQ_PAD_EXIT; // highest op-code - -// ------------------------------------------------------------------------- -// Pad Support. We allow an association of a pad with a "real" window -// through which the pad may be viewed. -// ------------------------------------------------------------------------- -class NCURSES_IMPEXP NCursesPad : public NCursesWindow { -private: - NCursesWindow* viewWin; // the "viewport" window - NCursesWindow* viewSub; // the "viewport" subwindow - - int h_gridsize, v_gridsize; - -protected: - int min_row, min_col; // top left row/col of the pads display area - - NCursesWindow* Win(void) const { - // Get the window into which the pad should be copied (if any) - return (viewSub?viewSub:(viewWin?viewWin:0)); - } - - NCursesWindow* getWindow(void) const { - return viewWin; - } - - NCursesWindow* getSubWindow(void) const { - return viewSub; - } - - virtual int driver (int key); // Virtualize keystroke key - // The driver translates the keystroke c into an Pad_Request - - virtual void OnUnknownOperation(int pad_req) { - ::beep(); - } - // This is called if the driver returns an unknown op-code - - virtual void OnNavigationError(int pad_req) { - ::beep(); - } - // This is called if a navigation request couldn't be satisfied - - virtual void OnOperation(int pad_req) { - }; - // OnOperation is called if a Pad_Operation was executed and just before - // the refresh() operation is done. - -public: - NCursesPad(int lines, int cols); - // create a pad with the given size - - virtual ~NCursesPad() {} - - int echochar(const chtype ch) { return ::pechochar(w,ch); } - // Put the attributed character onto the pad and immediately do a - // prefresh(). - - int refresh(); - // If a viewport is defined the pad is displayed in this window, otherwise - // this is a noop. - - int refresh(int pminrow, int pmincol, - int sminrow, int smincol, - int smaxrow, int smaxcol) { - return ::prefresh(w,pminrow,pmincol, - sminrow,smincol,smaxrow,smaxcol); - } - // The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle - // on the screen. refresh copies a rectangle of this size beginning - // with top left corner pminrow,pmincol onto the screen and calls doupdate(). - - int noutrefresh(); - // If a viewport is defined the pad is displayed in this window, otherwise - // this is a noop. - - int noutrefresh(int pminrow, int pmincol, - int sminrow, int smincol, - int smaxrow, int smaxcol) { - return ::pnoutrefresh(w,pminrow,pmincol, - sminrow,smincol,smaxrow,smaxcol); - } - // Does the same as refresh() but without calling doupdate(). - - virtual void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1); - // Add the window "view" as viewing window to the pad. - - virtual void setSubWindow(NCursesWindow& sub); - // Use the subwindow "sub" of the viewport window for the actual viewing. - // The full viewport window is usually used to provide some decorations - // like frames, titles etc. - - virtual void operator() (void); - // Perform Pad's operation -}; - -// A FramedPad is constructed always with a viewport window. This viewport -// will be framed (by a box() command) and the interior of the box is the -// viewport subwindow. On the frame we display scrollbar sliders. -class NCURSES_IMPEXP NCursesFramedPad : public NCursesPad { -protected: - virtual void OnOperation(int pad_req); - -public: - NCursesFramedPad(NCursesWindow& win, int lines, int cols, - int v_grid = 1, int h_grid = 1) - : NCursesPad(lines,cols) { - NCursesPad::setWindow(win,v_grid,h_grid); - NCursesPad::setSubWindow(*(new NCursesWindow(win))); - } - // Construct the FramedPad with the given Window win as viewport. - - virtual ~NCursesFramedPad() { - delete getSubWindow(); - } - - void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) { - err_handler("Operation not allowed"); - } - // Disable this call; the viewport is already defined - - void setSubWindow(NCursesWindow& sub) { - err_handler("Operation not allowed"); - } - // Disable this call; the viewport subwindow is already defined - -}; - -#endif // NCURSES_CURSESW_H_incl diff --git a/contrib/ncurses/c++/cursslk.cc b/contrib/ncurses/c++/cursslk.cc deleted file mode 100644 index c0c372b04939..000000000000 --- a/contrib/ncurses/c++/cursslk.cc +++ /dev/null @@ -1,122 +0,0 @@ -// * this is for making emacs happy: -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "Software"), 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: Juergen Pfeifer 1997 * - ****************************************************************************/ - -#include "internal.h" -#include "cursslk.h" -#include "cursesapp.h" -#include - -MODULE_ID("$Id: cursslk.cc,v 1.9 2001/03/24 20:04:15 tom Exp $") - -void Soft_Label_Key_Set::Soft_Label_Key::operator=(char *text) { - delete[] label; - label = new char[1 + ::strlen(text)]; - (::strcpy)(label,text); -} - -long Soft_Label_Key_Set::count = 0L; -int Soft_Label_Key_Set::num_labels = 0; - -Soft_Label_Key_Set::Label_Layout - Soft_Label_Key_Set::format = None; - -void Soft_Label_Key_Set::init() { - slk_array = new Soft_Label_Key[num_labels]; - for(int i=0; i < num_labels; i++) { - slk_array[i].num = i+1; - } - b_attrInit = FALSE; -} - -Soft_Label_Key_Set::Soft_Label_Key_Set() { - if (format==None) - Error("No default SLK layout"); - init(); -} - -Soft_Label_Key_Set::Soft_Label_Key_Set(Soft_Label_Key_Set::Label_Layout fmt) { - if (fmt==None) - Error("Invalid SLK Layout"); - if (count++==0) { - format = fmt; - if (ERR == ::slk_init((int)fmt)) - Error("slk_init"); - num_labels = (fmt>=PC_Style?12:8); - } - else if (fmt!=format) - Error("All SLKs must have same layout"); - init(); -} - -Soft_Label_Key_Set::~Soft_Label_Key_Set() { - if (!::isendwin()) - clear(); - delete[] slk_array; - count--; -} - -Soft_Label_Key_Set::Soft_Label_Key& Soft_Label_Key_Set::operator[](int i) { - if (i<1 || i>num_labels) - Error("Invalid Label index"); - return slk_array[i-1]; -} - -void Soft_Label_Key_Set::activate_label(int i, bool bf) { - if (!b_attrInit) { - NCursesApplication* A = NCursesApplication::getApplication(); - if (A) attrset(A->labels()); - b_attrInit = TRUE; - } - Soft_Label_Key& K = (*this)[i]; - if (ERR==::slk_set(K.num,bf?K.label:"",K.format)) - Error("slk_set"); - noutrefresh(); -} - -void Soft_Label_Key_Set::activate_labels(bool bf) { - if (!b_attrInit) { - NCursesApplication* A = NCursesApplication::getApplication(); - if (A) attrset(A->labels()); - b_attrInit = TRUE; - } - for(int i=1; i <= num_labels; i++) { - Soft_Label_Key& K = (*this)[i]; - if (ERR==::slk_set(K.num,bf?K.label:"",K.format)) - Error("slk_set"); - } - if (bf) - restore(); - else - clear(); - noutrefresh(); -} diff --git a/contrib/ncurses/c++/cursslk.h b/contrib/ncurses/c++/cursslk.h deleted file mode 100644 index 79fa9936fa94..000000000000 --- a/contrib/ncurses/c++/cursslk.h +++ /dev/null @@ -1,205 +0,0 @@ -// * this is for making emacs happy: -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,2000 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: Juergen Pfeifer 1997 * - ****************************************************************************/ - -// $Id: cursslk.h,v 1.7 2001/03/24 21:41:47 tom Exp $ - -#ifndef NCURSES_CURSSLK_H_incl -#define NCURSES_CURSSLK_H_incl - -#include - -class NCURSES_IMPEXP Soft_Label_Key_Set { -public: - // This inner class represents the attributes of a Soft Label Key (SLK) - class NCURSES_IMPEXP Soft_Label_Key { - friend class Soft_Label_Key_Set; - public: - typedef enum { Left=0, Center=1, Right=2 } Justification; - - private: - char *label; // The Text of the Label - Justification format; // The Justification - int num; // The number of the Label - - Soft_Label_Key() : label((char*)0),format(Left),num(-1) { - } - - virtual ~Soft_Label_Key() { - delete[] label; - }; - - public: - // Set the text of the Label - void operator=(char *text); - - // Set the Justification of the Label - inline void operator=(Justification just) { - format = just; - } - - // Retrieve the text of the label - inline char* operator()(void) const { - return label; - } - }; - -public: - typedef enum { - None = -1, - Three_Two_Three = 0, - Four_Four = 1, - PC_Style = 2, - PC_Style_With_Index = 3 - } Label_Layout; - -private: - static long NCURSES_IMPEXP count; // Number of Key Sets - static Label_Layout NCURSES_IMPEXP format; // Layout of the Key Sets - static int NCURSES_IMPEXP num_labels; // Number Of Labels in Key Sets - bool NCURSES_IMPEXP b_attrInit; // Are attributes initialized - - Soft_Label_Key *slk_array; // The array of SLK's - - // Init the Key Set - void init(); - - // Activate or Deactivate Label# i, Label counting starts with 1! - void activate_label(int i, bool bf=TRUE); - - // Activate of Deactivate all Labels - void activate_labels(bool bf); - -protected: - inline void Error (const char* msg) const THROWS(NCursesException) { - THROW(new NCursesException (msg)); - } - - // Remove SLK's from screen - void clear() { - if (ERR==::slk_clear()) - Error("slk_clear"); - } - - // Restore them - void restore() { - if (ERR==::slk_restore()) - Error("slk_restore"); - } - -public: - - // Construct a Key Set, use the most comfortable layout as default. - // You must create a Soft_Label_Key_Set before you create any object of - // the NCursesWindow, NCursesPanel or derived classes. (Actually before - // ::initscr() is called). - Soft_Label_Key_Set(Label_Layout fmt); - - // This constructor assumes, that you already constructed a Key Set - // with a layout by the constructor above. This layout will be reused. - NCURSES_IMPEXP Soft_Label_Key_Set(); - - virtual ~Soft_Label_Key_Set(); - - // Get Label# i. Label counting starts with 1! - NCURSES_IMPEXP Soft_Label_Key& operator[](int i); - - // Retrieve number of Labels - inline int labels() const { return num_labels; } - - // Refresh the SLK portion of the screen - inline void refresh() { - if (ERR==::slk_refresh()) - Error("slk_refresh"); - } - - // Mark the SLK portion of the screen for refresh, defer actual refresh - // until next update call. - inline void noutrefresh() { - if (ERR==::slk_noutrefresh()) - Error("slk_noutrefresh"); - } - - // Mark the whole SLK portion of the screen as modified - inline void touch() { - if (ERR==::slk_touch()) - Error("slk_touch"); - } - - // Activate Label# i - inline void show(int i) { - activate_label(i,FALSE); - activate_label(i,TRUE); - } - - // Hide Label# i - inline void hide(int i) { - activate_label(i,FALSE); - } - - // Show all Labels - inline void show() { - activate_labels(FALSE); - activate_labels(TRUE); - } - - // Hide all Labels - inline void hide() { - activate_labels(FALSE); - } - - inline void attron(attr_t attrs) { - if (ERR==::slk_attron(attrs)) - Error("slk_attron"); - } - - inline void attroff(attr_t attrs) { - if (ERR==::slk_attroff(attrs)) - Error("slk_attroff"); - } - - inline void attrset(attr_t attrs) { - if (ERR==::slk_attrset(attrs)) - Error("slk_attrset"); - } - - inline void color(short color_pair_number) { - if (ERR==::slk_color(color_pair_number)) - Error("slk_color"); - } - - inline attr_t attr() const { - return ::slk_attr(); - } -}; - -#endif // NCURSES_CURSSLK_H_incl diff --git a/contrib/ncurses/c++/demo.cc b/contrib/ncurses/c++/demo.cc deleted file mode 100644 index 56573cdd0d7d..000000000000 --- a/contrib/ncurses/c++/demo.cc +++ /dev/null @@ -1,492 +0,0 @@ -/* - * Silly demo program for the NCursesPanel class. - * - * written by Anatoly Ivasyuk (anatoly@nick.csh.rit.edu) - * - * Demo code for NCursesMenu and NCursesForm written by - * Juergen Pfeifer - * - * $Id: demo.cc,v 1.21 2001/07/15 01:15:26 tom Exp $ - */ - -#include "cursesapp.h" -#include "cursesm.h" -#include "cursesf.h" - -#if HAVE_LIBC_H -# include -#endif - -extern "C" unsigned int sleep(unsigned int); - -#undef index // needed for NeXT - -// -// ------------------------------------------------------------------------- -// -class SillyDemo -{ - public: - void run(int sleeptime) { - - NCursesPanel *std = new NCursesPanel(); - - // Make a few small demo panels - - NCursesPanel *u = new NCursesPanel(8,20,12,4); - NCursesPanel *v = new NCursesPanel(8,20,10,6); - NCursesPanel *w = new NCursesPanel(8,20,8,8); - NCursesPanel *x = new NCursesPanel(8,20,6,10); - NCursesPanel *y = new NCursesPanel(8,20,4,12); - NCursesPanel *z = new NCursesPanel(8,30,2,14); - - // Draw something on the main screen, so we can see what happens - // when panels get moved or deleted. - - std->box(); - std->move(std->height()/2,1); - std->hline(std->width()-2); - std->move(1,std->width()/2); - std->vline(std->height()-2); - std->addch(0,std->width()/2,ACS_TTEE); - std->addch(std->height()-1,std->width()/2,ACS_BTEE); - std->addch(std->height()/2,0,ACS_LTEE); - std->addch(std->height()/2,std->width()-1,ACS_RTEE); - std->addch(std->height()/2,std->width()/2,ACS_PLUS); - - // Draw frames with titles around panels so that we can see where - // the panels are located. - u->boldframe("Win U"); - v->frame("Win V"); - w->boldframe("Win W"); - x->frame("Win X"); - y->boldframe("Win Y"); - z->frame("Win Z"); - if (NCursesApplication::getApplication()->useColors()) { - u->bkgd(' '|COLOR_PAIR(1)); - w->bkgd(' '|COLOR_PAIR(1)); - y->bkgd(' '|COLOR_PAIR(1)); - v->bkgd(' '|COLOR_PAIR(2)); - x->bkgd(' '|COLOR_PAIR(2)); - z->bkgd(' '|COLOR_PAIR(2)); - } - - // A refresh to any valid panel updates all panels and refreshes - // the screen. Using std is just convenient - We know it's always - // valid until the end of the program. - - std->refresh(); - sleep(sleeptime); - - // Show what happens when panels are deleted and moved. - - sleep(sleeptime); - delete u; - std->refresh(); - - sleep(sleeptime); - delete z; - std->refresh(); - - sleep(sleeptime); - delete v; - std->refresh(); - - // show how it looks when a panel moves - sleep(sleeptime); - y->mvwin(5,30); - std->refresh(); - - sleep(sleeptime); - delete y; - std->refresh(); - - // show how it looks when you raise a panel - sleep(sleeptime); - w->top(); - std->refresh(); - - sleep(sleeptime); - delete w; - std->refresh(); - - sleep(sleeptime); - delete x; - - std->clear(); - std->refresh(); - - // Don't forget to clean up the main screen. Since this is the - // last thing using NCursesWindow, this has the effect of - // shutting down ncurses and restoring the terminal state. - - sleep(sleeptime); - delete std; - } -}; - -class UserData -{ -private: - int u; -public: - UserData(int x) : u(x) {} - int sleeptime() const { return u; } -}; -// -// ------------------------------------------------------------------------- -// -template class MyAction : public NCursesUserItem -{ -public: - MyAction (const char* p_name, - const T* p_UserData) - : NCursesUserItem(p_name, (const char*)0, p_UserData) - {}; - - ~MyAction() {} - - bool action() { - SillyDemo a; - a.run(NCursesUserItem::UserData()->sleeptime()); - return FALSE; - } -}; - -class QuitItem : public NCursesMenuItem -{ -public: - QuitItem() : NCursesMenuItem("Quit") { - } - - bool action() { - return TRUE; - } -}; -// -// ------------------------------------------------------------------------- -// -class Label : public NCursesFormField -{ -public: - Label(const char* title, - int row, int col) - : NCursesFormField(1,(int)::strlen(title),row,col) { - set_value(title); - options_off(O_EDIT|O_ACTIVE); - } -}; -// -// ------------------------------------------------------------------------- -// -class MyFieldType : public UserDefinedFieldType { -private: - int chk; -protected: - bool field_check(NCursesFormField& f) { - return TRUE; - } - bool char_check(int c) { - return (c==chk?TRUE:FALSE); - } -public: - MyFieldType(int x) : chk(x) { - } -}; -// -// ------------------------------------------------------------------------- -// -class TestForm : public NCursesForm -{ -private: - NCursesFormField** F; - MyFieldType* mft; - Integer_Field *ift; - Enumeration_Field *eft; - - static char *weekdays[]; - -public: - TestForm() : NCursesForm(13,51,(lines()-15)/2,(cols()-53)/2) { - - F = new NCursesFormField*[10]; - mft = new MyFieldType('X'); - ift = new Integer_Field(0,1,10); - eft = new Enumeration_Field(weekdays); - - F[0] = new Label("Demo Entry Form",0,16); - F[1] = new Label("Weekday Enum",2,1); - F[2] = new Label("Number(1-10)",2,21); - F[3] = new Label("Only 'X'",2,35); - F[4] = new Label("Multiline Field (Dynamic and Scrollable)",5,1); - F[5] = new NCursesFormField(1,18,3,1); - F[6] = new NCursesFormField(1,12,3,21); - F[7] = new NCursesFormField(1,12,3,35); - F[8] = new NCursesFormField(4,46,6,1,2); - F[9] = new NCursesFormField(); - - InitForm(F,TRUE,TRUE); - boldframe(); - - F[5]->set_fieldtype(*eft); - F[6]->set_fieldtype(*ift); - - F[7]->set_fieldtype(*mft); - F[7]->set_maximum_growth(20); // max. 20 characters - F[7]->options_off(O_STATIC); // make field dynamic - - F[8]->set_maximum_growth(10); // max. 10 lines - F[8]->options_off(O_STATIC); // make field dynamic - } - - ~TestForm() { - delete mft; - delete ift; - delete eft; - } -}; - -char* TestForm::weekdays[] = { - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", - "Friday", "Saturday", (char *)0 }; -// -// ------------------------------------------------------------------------- -// -class FormAction : public NCursesMenuItem -{ -public: - FormAction(const char *s) : NCursesMenuItem(s) { - } - - bool action() { - TestForm F; - Soft_Label_Key_Set* S = new Soft_Label_Key_Set; - for(int i=1; i <= S->labels(); i++) { - char buf[5]; - ::sprintf(buf,"Frm%02d",i); - (*S)[i] = buf; // Text - (*S)[i] = Soft_Label_Key_Set::Soft_Label_Key::Left; // Justification - } - NCursesApplication::getApplication()->push(*S); - F(); - NCursesApplication::getApplication()->pop(); - return FALSE; - } -}; -// -// ------------------------------------------------------------------------- -// -class PadAction : public NCursesMenuItem -{ -public: - PadAction(const char* s) : NCursesMenuItem(s) { - } - - bool action() { - const int GRIDSIZE = 3; - const int PADSIZE = 200; - unsigned gridcount = 0; - - NCursesPanel std; - NCursesPanel P(std.lines()-2,std.cols()-2,1,1); - NCursesFramedPad FP(P,PADSIZE,PADSIZE); - - for (int i=0; i < PADSIZE; i++) { - for (int j=0; j < PADSIZE; j++) { - if (i % GRIDSIZE == 0 && j % GRIDSIZE == 0) { - if (i==0 || j==0) - FP.addch('+'); - else - FP.addch((chtype)('A' + (gridcount++ % 26))); - } - else if (i % GRIDSIZE == 0) - FP.addch('-'); - else if (j % GRIDSIZE == 0) - FP.addch('|'); - else - FP.addch(' '); - } - } - - P.label("Pad Demo",NULL); - FP(); - P.clear(); - return FALSE; - } -}; - -// -// ------------------------------------------------------------------------- -// -class PassiveItem : public NCursesMenuItem { -public: - PassiveItem(const char* text) : NCursesMenuItem(text) { - options_off(O_SELECTABLE); - } -}; - -// -// ------------------------------------------------------------------------- -// -class ScanAction : public NCursesMenuItem -{ -public: - ScanAction(const char* s) : NCursesMenuItem(s) { - } - - bool action() { - NCursesPanel *std = new NCursesPanel(); - - NCursesPanel *w = new NCursesPanel(std->lines() - 2, std->cols() - 2, 1, 1); - w->box(); - w->refresh(); - - NCursesPanel *s = new NCursesPanel(w->lines() - 6, w->cols() - 6, 3, 3); - s->scrollok(TRUE); - ::echo(); - - s->printw("Enter decimal integers. The running total will be shown\n"); - int value = -1; - int result = 0; - while (value != 0) { - value = 0; - s->scanw("%d", &value); - if (value != 0) { - s->printw("%d: ", result += value); - } - s->refresh(); - } - s->printw("\nPress any key to continue..."); - s->getch(); - - delete s; - delete w; - delete std; - ::noecho(); - return FALSE; - } -}; - -// -// ------------------------------------------------------------------------- -// -class MyMenu : public NCursesMenu -{ -private: - NCursesPanel* P; - NCursesMenuItem** I; - UserData *u; - #define n_items 7 - -public: - MyMenu () - : NCursesMenu (n_items+2, 8, (lines()-10)/2, (cols()-10)/2) - { - u = new UserData(1); - I = new NCursesMenuItem*[1+n_items]; - I[0] = new PassiveItem("One"); - I[1] = new PassiveItem("Two"); - I[2] = new MyAction ("Silly", u); - I[3] = new FormAction("Form"); - I[4] = new PadAction("Pad"); - I[5] = new ScanAction("Scan"); - I[6] = new QuitItem(); - I[7] = new NCursesMenuItem(); // Terminating empty item - - InitMenu(I,TRUE,TRUE); - - P = new NCursesPanel(1,n_items,LINES-1,1); - boldframe("Demo","Silly"); - P->show(); - } - - ~MyMenu() - { - P->hide(); - delete P; - delete u; - } - - virtual void On_Menu_Init() - { - NCursesWindow W(::stdscr); - P->move(0,0); - P->clrtoeol(); - for(int i=1; i<=count(); i++) - P->addch('0' + i); - P->bkgd(W.getbkgd()); - refresh(); - } - - virtual void On_Menu_Termination() - { - P->move(0,0); - P->clrtoeol(); - refresh(); - } - - virtual void On_Item_Init(NCursesMenuItem& item) - { - P->move(0,item.index()); - P->attron(A_REVERSE); - P->printw("%1d",1+item.index()); - P->attroff(A_REVERSE); - refresh(); - } - - virtual void On_Item_Termination(NCursesMenuItem& item) - { - P->move(0,item.index()); - P->attroff(A_REVERSE); - P->printw("%1d",1+item.index()); - refresh(); - } -}; -// -// ------------------------------------------------------------------------- -// -class TestApplication : public NCursesApplication { -protected: - int titlesize() const { return 1; } - void title(); - Soft_Label_Key_Set::Label_Layout useSLKs() const { - return Soft_Label_Key_Set::PC_Style_With_Index; - } - void init_labels(Soft_Label_Key_Set& S) const; - -public: - TestApplication() : NCursesApplication(TRUE) { - } - - int run(); -}; - -void TestApplication::init_labels(Soft_Label_Key_Set& S) const { - for(int i=1; i <= S.labels(); i++) { - char buf[5]; - ::sprintf(buf,"Key%02d",i); - S[i] = buf; // Text - S[i] = Soft_Label_Key_Set::Soft_Label_Key::Left; // Justification - } -} - -void TestApplication::title() { - const char * const title = "Simple C++ Binding Demo"; - const int len = ::strlen(title); - - titleWindow->bkgd(screen_titles()); - titleWindow->addstr(0,(titleWindow->cols()-len)/2,title); - titleWindow->noutrefresh(); -} - - -int TestApplication::run() { - MyMenu M; - M(); - return 0; -} - -// -// ------------------------------------------------------------------------- -// -static TestApplication Demo; diff --git a/contrib/ncurses/c++/edit_cfg.sh b/contrib/ncurses/c++/edit_cfg.sh deleted file mode 100755 index e0c182257d54..000000000000 --- a/contrib/ncurses/c++/edit_cfg.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -# $Id: edit_cfg.sh,v 1.12 2001/12/08 20:44:59 tom Exp $ -############################################################################## -# Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. # -# # -# Permission is hereby granted, free of charge, to any person obtaining a # -# copy of this software and associated documentation files (the "Software"), # -# 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 1997 -# -# Edit the default value of the etip.h file based on the autoconf-generated -# values: -# -# $1 = ncurses_cfg.h -# $2 = etip.h -# -echo "substituting autoconf'd values from $1 into $2" -for name in \ - CPP_HAS_PARAM_INIT \ - ETIP_NEEDS_MATH_EXCEPTION \ - ETIP_NEEDS_MATH_H \ - HAVE_BUILTIN_H \ - HAVE_GPP_BUILTIN_H \ - HAVE_GXX_BUILTIN_H \ - HAVE_STRSTREAM_H \ - HAVE_TYPEINFO \ - HAVE_VALUES_H \ - USE_STRSTREAM_VSCAN \ - USE_STRSTREAM_VSCAN_CAST -do - mv $2 $2.bak - if ( grep "[ ]$name[ ]1" $1 2>&1 >/dev/null) - then - value=1 - sed -e 's/define '$name'.*$/define '$name' 1/' $2.bak >$2 - else - value=0 - sed -e 's/define '$name'.*$/define '$name' 0/' $2.bak >$2 - fi - if (cmp -s $2 $2.bak) - then - echo '... '$name $value - mv $2.bak $2 - else - echo '... '$name $value - rm -f $2.bak - fi -done diff --git a/contrib/ncurses/c++/etip.h.in b/contrib/ncurses/c++/etip.h.in deleted file mode 100644 index 85e4df211c0f..000000000000 --- a/contrib/ncurses/c++/etip.h.in +++ /dev/null @@ -1,291 +0,0 @@ -// * This makes emacs happy -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "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: Juergen Pfeifer 1997 * - ****************************************************************************/ - -// $Id: etip.h.in,v 1.22 2001/12/08 21:26:49 tom Exp $ - -#ifndef NCURSES_ETIP_H_incl -#define NCURSES_ETIP_H_incl 1 - -// These are substituted at configure/build time -#ifndef HAVE_BUILTIN_H -#define HAVE_BUILTIN_H 0 -#endif - -#ifndef HAVE_GXX_BUILTIN_H -#define HAVE_GXX_BUILTIN_H 0 -#endif - -#ifndef HAVE_GPP_BUILTIN_H -#define HAVE_GPP_BUILTIN_H 0 -#endif - -#ifndef HAVE_STRSTREAM_H -#define HAVE_STRSTREAM_H 0 -#endif - -#ifndef HAVE_TYPEINFO -#define HAVE_TYPEINFO 0 -#endif - -#ifndef HAVE_VALUES_H -#define HAVE_VALUES_H 0 -#endif - -#ifndef ETIP_NEEDS_MATH_H -#define ETIP_NEEDS_MATH_H 0 -#endif - -#ifndef ETIP_NEEDS_MATH_EXCEPTION -#define ETIP_NEEDS_MATH_EXCEPTION 0 -#endif - -#ifndef CPP_HAS_PARAM_INIT -#define CPP_HAS_PARAM_INIT 0 -#endif - -#ifndef USE_STRSTREAM_VSCAN -#define USE_STRSTREAM_VSCAN 0 -#endif - -#ifndef USE_STRSTREAM_VSCAN_CAST -#define USE_STRSTREAM_VSCAN_CAST 0 -#endif - -#ifdef __GNUG__ -# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8)) -# if HAVE_TYPEINFO -# include -# endif -# endif -#endif - -#if defined(__GNUG__) -# if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H -# if ETIP_NEEDS_MATH_H -# if ETIP_NEEDS_MATH_EXCEPTION -# undef exception -# define exception math_exception -# endif -# include -# endif -# undef exception -# define exception builtin_exception -# if HAVE_GPP_BUILTIN_H -# include -# elif HAVE_GXX_BUILTIN_H -# include -# else -# include -# endif -# undef exception -# endif -#elif defined (__SUNPRO_CC) -# include -# include -#else -# include -#endif - -#include - -extern "C" { -#if HAVE_VALUES_H -# include -#endif - -#include -#include -#include -} - -// Language features -#if CPP_HAS_PARAM_INIT -#define NCURSES_PARAM_INIT(value) = value -#else -#define NCURSES_PARAM_INIT(value) /*nothing*/ -#endif - -// Forward Declarations -class NCURSES_IMPEXP NCursesPanel; -class NCURSES_IMPEXP NCursesMenu; -class NCURSES_IMPEXP NCursesForm; - -class NCURSES_IMPEXP NCursesException -{ -public: - const char *message; - int errorno; - - NCursesException (const char* msg, int err) - : message(msg), errorno (err) - {}; - - NCursesException (const char* msg) - : message(msg), errorno (E_SYSTEM_ERROR) - {}; - - virtual const char *classname() const { - return "NCursesWindow"; - } -}; - -class NCURSES_IMPEXP NCursesPanelException : public NCursesException -{ -public: - const NCursesPanel* p; - - NCursesPanelException (const char *msg, int err) : - NCursesException (msg, err), - p ((NCursesPanel*)0) - {}; - - NCursesPanelException (const NCursesPanel* panel, - const char *msg, - int err) : - NCursesException (msg, err), - p (panel) - {}; - - NCursesPanelException (int err) : - NCursesException ("panel library error", err), - p ((NCursesPanel*)0) - {}; - - NCursesPanelException (const NCursesPanel* panel, - int err) : - NCursesException ("panel library error", err), - p (panel) - {}; - - virtual const char *classname() const { - return "NCursesPanel"; - } - -}; - -class NCURSES_IMPEXP NCursesMenuException : public NCursesException -{ -public: - const NCursesMenu* m; - - NCursesMenuException (const char *msg, int err) : - NCursesException (msg, err), - m ((NCursesMenu *)0) - {}; - - NCursesMenuException (const NCursesMenu* menu, - const char *msg, - int err) : - NCursesException (msg, err), - m (menu) - {}; - - NCursesMenuException (int err) : - NCursesException ("menu library error", err), - m ((NCursesMenu *)0) - {}; - - NCursesMenuException (const NCursesMenu* menu, - int err) : - NCursesException ("menu library error", err), - m (menu) - {}; - - virtual const char *classname() const { - return "NCursesMenu"; - } - -}; - -class NCURSES_IMPEXP NCursesFormException : public NCursesException -{ -public: - const NCursesForm* f; - - NCursesFormException (const char *msg, int err) : - NCursesException (msg, err), - f ((NCursesForm*)0) - {}; - - NCursesFormException (const NCursesForm* form, - const char *msg, - int err) : - NCursesException (msg, err), - f (form) - {}; - - NCursesFormException (int err) : - NCursesException ("form library error", err), - f ((NCursesForm*)0) - {}; - - NCursesFormException (const NCursesForm* form, - int err) : - NCursesException ("form library error", err), - f (form) - {}; - - virtual const char *classname() const { - return "NCursesForm"; - } - -}; - -#if !(defined(__GNUG__)||defined(__SUNPRO_CC)) -# include - extern "C" void exit(int); -#endif - -inline void THROW(const NCursesException *e) { -#if defined(__GNUG__) -# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8)) - (*lib_error_handler)(e?e->classname():"",e?e->message:""); -#else - throw *e; -#endif -#elif defined(__SUNPRO_CC) -# if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5) - genericerror(1, ((e != 0) ? (char *)(e->message) : "")); -#else - throw *e; -#endif -#else - if (e) - cerr << e->message << endl; - exit(0); -#endif -} - -#define THROWS(s) - -#endif // NCURSES_ETIP_H_incl diff --git a/contrib/ncurses/c++/headers b/contrib/ncurses/c++/headers deleted file mode 100644 index 3470386adf02..000000000000 --- a/contrib/ncurses/c++/headers +++ /dev/null @@ -1,39 +0,0 @@ -# C++ headers -# $Id: headers,v 1.2 1998/02/11 12:13:40 tom Exp $ -############################################################################## -# Copyright (c) 1998 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 1997 -# -$(srcdir)/cursesapp.h -$(srcdir)/cursesf.h -$(srcdir)/cursesm.h -$(srcdir)/cursesp.h -$(srcdir)/cursesw.h -$(srcdir)/cursslk.h -etip.h diff --git a/contrib/ncurses/c++/internal.h b/contrib/ncurses/c++/internal.h deleted file mode 100644 index 6009027c929a..000000000000 --- a/contrib/ncurses/c++/internal.h +++ /dev/null @@ -1,49 +0,0 @@ -// * This makes emacs happy -*-Mode: C++;-*- -/**************************************************************************** - * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "Software"), 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: Juergen Pfeifer 1997 * - ****************************************************************************/ - -// $Id: internal.h,v 1.8 2001/03/24 21:36:17 tom Exp $ - -#ifndef NCURSES_CPLUS_INTERNAL_H -#define NCURSES_CPLUS_INTERNAL_H 1 - -#include - -#if USE_RCS_IDS -#define MODULE_ID(id) static const char Ident[] = id; -#else -#define MODULE_ID(id) /*nothing*/ -#endif - -#define CTRL(x) ((x) & 0x1f) - -#endif // NCURSES_CPLUS_INTERNAL_H diff --git a/contrib/ncurses/c++/modules b/contrib/ncurses/c++/modules deleted file mode 100644 index 0709805847d2..000000000000 --- a/contrib/ncurses/c++/modules +++ /dev/null @@ -1,43 +0,0 @@ -# Program modules -# $Id: modules,v 1.6 1999/07/31 09:46:54 juergen Exp $ -############################################################################## -# Copyright (c) 1998 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 1995,1997 -# - -@ base -cursesf c++ $(srcdir) $(cursesf_h) $(cursesapp_h) -cursesm c++ $(srcdir) $(cursesm_h) $(cursesapp_h) -cursesp c++ $(srcdir) $(cursesp_h) -cursesw c++ $(srcdir) $(cursesw_h) -cursespad c++ $(srcdir) $(cursesw_h) -cursslk c++ $(srcdir) $(cursslk_h) $(cursesapp_h) -cursesapp c++ $(srcdir) $(cursesapp_h) -cursesmain c++ $(srcdir) $(cursesapp_h) -demo c++ $(srcdir) $(cursesf_h) $(cursesm_h) $(cursesapp_h) diff --git a/contrib/ncurses/misc/indent.pro b/contrib/ncurses/misc/indent.pro deleted file mode 100644 index 14cf385a1cf7..000000000000 --- a/contrib/ncurses/misc/indent.pro +++ /dev/null @@ -1,35 +0,0 @@ -/* Use this with indent 2.0 (2.1 is not acceptable, since it has more bugs) */ -/* indent 4 columns */ --i4 -/* tab stops every 8 columns */ --ts8 -/* cuddle 'else' */ --ce -/* force blank lines after procedure body */ --bap -/* do not force newline after comma in declaration */ --nbc -/* do not force blank line after declarations */ --nbad -/* format braces inline */ --br -/* do not line up parentheses */ --lp -/* put the type of a procedure on the line before its name */ --psl -/* do not insert a space between procedure name and '(' */ --npcs -/* leave preprocessor space */ --lps -/* swallow optional blank lines */ --sob -/* continuation indent of 0 spaces */ --ci0 -/* force space before semicolon on same line */ --ss - -/* for vile */ --T size_t --T LINE --T BUFFER --T WINDOW diff --git a/contrib/ncurses/ncurses/base/lib_insstr.c b/contrib/ncurses/ncurses/base/lib_insstr.c deleted file mode 100644 index a16ab13e4d88..000000000000 --- a/contrib/ncurses/ncurses/base/lib_insstr.c +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** - * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "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: Zeyd M. Ben-Halim 1992,1995 * - * and: Eric S. Raymond * - ****************************************************************************/ - -/* -** lib_insstr.c -** -** The routine winsnstr(). -** -*/ - -#include -#include - -MODULE_ID("$Id: lib_insstr.c,v 1.19 2001/06/09 23:43:02 skimo Exp $") - -NCURSES_EXPORT(int) -winsnstr(WINDOW *win, const char *s, int n) -{ - 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_visbuf(s), n)); - - if (win && str) { - oy = win->_cury; - ox = win->_curx; - for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) { - if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b') { - NCURSES_CH_T wch; - SetChar2(wch, *cp); - _nc_waddch_nosync(win, wch); - } else if (is7bits(*cp) && iscntrl(*cp)) { - winsch(win, ' ' + (chtype) (*cp)); - winsch(win, (chtype) '^'); - win->_curx += 2; - } else { - winsch(win, (chtype) (*cp)); - win->_curx++; - } - if (win->_curx > win->_maxx) - win->_curx = win->_maxx; - } - - win->_curx = ox; - win->_cury = oy; - _nc_synchook(win); - code = OK; - } - returnCode(code); -} diff --git a/contrib/ncurses/ncurses/widechar/lib_ins_nwstr.c b/contrib/ncurses/ncurses/widechar/lib_ins_nwstr.c deleted file mode 100644 index 8302b8b52276..000000000000 --- a/contrib/ncurses/ncurses/widechar/lib_ins_nwstr.c +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** - * Copyright (c) 2002 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "Software"), to deal in the Software without restriction, including * - * without limitation the rights to use, copy, modify, merge, publish, * - * distribute, distribute with modifications, sublicense, and/or sell * - * copies of the Software, and to permit persons to whom the Software is * - * furnished to do so, subject to the following conditions: * - * * - * The above copyright notice and this permission notice shall be included * - * in all copies or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * - * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * * - * Except as contained in this notice, the name(s) of the above copyright * - * holders shall not be used in advertising or otherwise to promote the * - * sale, use or other dealings in this Software without prior written * - * authorization. * - ****************************************************************************/ - -/**************************************************************************** - * Author: Thomas Dickey 2002 * - ****************************************************************************/ - -/* -** lib_ins_nwstr.c -** -** The routine wins_nwstr(). -** -*/ - -#include -#include - -MODULE_ID("$Id: lib_ins_nwstr.c,v 1.2 2002/03/10 22:43:12 tom Exp $") - -NCURSES_EXPORT(int) -wins_nwstr(WINDOW *win, const wchar_t * wstr, int n) -{ - int code = ERR; - NCURSES_SIZE_T oy; - NCURSES_SIZE_T ox; - const wchar_t *cp; - - T((T_CALLED("wins_nwstr(%p,%s,%d)"), win, _nc_viswbuf(wstr), n)); - - if (win != 0 - && wstr != 0 - && wcwidth(*wstr) > 0) { - code = OK; - if (n < 1) - n = wcslen(wstr); - oy = win->_cury; - ox = win->_curx; - for (cp = wstr; *cp && ((cp - wstr) < n); cp++) { - NCURSES_CH_T wch; - SetChar2(wch, *cp); - if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b') { - _nc_waddch_nosync(win, wch); - } else if (is7bits(*cp) && iscntrl(*cp)) { - winsch(win, ' ' + (chtype) (*cp)); - winsch(win, (chtype) '^'); - win->_curx += 2; - } else if (wins_wch(win, &wch) == ERR - || win->_curx > win->_maxx) { - break; - } - } - - win->_curx = ox; - win->_cury = oy; - _nc_synchook(win); - code = OK; - } - returnCode(code); -} diff --git a/contrib/ncurses/test/Makefile.in b/contrib/ncurses/test/Makefile.in deleted file mode 100644 index 833b57f7a091..000000000000 --- a/contrib/ncurses/test/Makefile.in +++ /dev/null @@ -1,221 +0,0 @@ -# $Id: Makefile.in,v 1.63 2002/02/03 00:54:10 china Exp $ -############################################################################## -# Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. # -# # -# Permission is hereby granted, free of charge, to any person obtaining a # -# copy of this software and associated documentation files (the "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 1996,1997,1998 -# -# Makefile for ncurses tests. - -# turn off _all_ suffix rules; we'll generate our own -.SUFFIXES: - -SHELL = /bin/sh - -x = @PROG_EXT@ - -MODEL = ../@DFT_OBJ_SUBDIR@ -srcdir = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ -libdir = @libdir@ -includedir = @includedir@ - -LIBTOOL = @LIBTOOL@ - -CC = @CC@ -CPP = @CPP@ - -CFLAGS = @CFLAGS@ -CPPFLAGS = -I../test -I$(srcdir) @CPPFLAGS@ -DHAVE_CONFIG_H - -CCFLAGS = $(CPPFLAGS) $(CFLAGS) - -CFLAGS_LIBTOOL = $(CCFLAGS) -CFLAGS_NORMAL = $(CCFLAGS) -CFLAGS_DEBUG = $(CCFLAGS) @CC_G_OPT@ -DTRACE -CFLAGS_PROFILE = $(CCFLAGS) -pg -CFLAGS_SHARED = $(CCFLAGS) @CC_SHARED_OPTS@ - -CFLAGS_DEFAULT = $(CFLAGS_@DFT_UPR_MODEL@) - -REL_VERSION = @cf_cv_rel_version@ -ABI_VERSION = @cf_cv_abi_version@ -LOCAL_LIBS = @TEST_DEPS@ -MATH_LIB = @MATH_LIB@ - -LD = @LD@ -LINK = @LINK_TESTS@ $(LIBTOOL) $(CC) $(CFLAGS) - -LDFLAGS = @LD_MODEL@ @TEST_ARGS@ @LIBS@ @EXTRA_LIBS@ @LOCAL_LDFLAGS@ @LDFLAGS@ - -LDFLAGS_LIBTOOL = $(LDFLAGS) -LDFLAGS_NORMAL = $(LDFLAGS) -LDFLAGS_DEBUG = $(LDFLAGS) @CC_G_OPT@ -LDFLAGS_PROFILE = $(LDFLAGS) -pg -LDFLAGS_SHARED = $(LDFLAGS) @LD_SHARED_OPTS@ - -LDFLAGS_DEFAULT = $(LDFLAGS_@DFT_UPR_MODEL@) - -LINT = @LINT@ -LINT_OPTS = @LINT_OPTS@ -LINT_LIBS = -lform -lmenu -lpanel -lncurses @LIBS@ - -TESTS = \ - blue$x \ - bs$x \ - cardfile$x \ - ditto$x \ - dots$x \ - filter$x \ - firework$x \ - firstlast$x \ - gdc$x \ - hanoi$x \ - hashtest$x \ - keynames$x \ - knight$x \ - lrtest$x \ - ncurses$x \ - newdemo$x \ - rain$x \ - railroad$x \ - tclock$x \ - testaddch$x \ - testcurs$x \ - testscanw$x \ - view$x \ - worm$x \ - xmas$x - -all: $(TESTS) - -sources: - -blue$x: $(MODEL)/blue.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/blue.o $(LDFLAGS_DEFAULT) - -bs$x: $(MODEL)/bs.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/bs.o $(LDFLAGS_DEFAULT) - -cardfile$x: $(MODEL)/cardfile.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/cardfile.o $(LDFLAGS_DEFAULT) - -ditto$x: $(MODEL)/ditto.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/ditto.o $(LDFLAGS_DEFAULT) - -dots$x: $(MODEL)/dots.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/dots.o $(LDFLAGS_DEFAULT) - -filter$x: $(MODEL)/filter.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/filter.o $(LDFLAGS_DEFAULT) - -firework$x: $(MODEL)/firework.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/firework.o $(LDFLAGS_DEFAULT) - -firstlast$x: $(MODEL)/firstlast.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/firstlast.o $(LDFLAGS_DEFAULT) - -gdc$x: $(MODEL)/gdc.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/gdc.o $(LDFLAGS_DEFAULT) - -hanoi$x: $(MODEL)/hanoi.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/hanoi.o $(LDFLAGS_DEFAULT) - -hashtest$x: $(MODEL)/hashtest.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/hashtest.o $(LDFLAGS_DEFAULT) - -keynames$x: $(MODEL)/keynames.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/keynames.o $(LDFLAGS_DEFAULT) - -knight$x: $(MODEL)/knight.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/knight.o $(LDFLAGS_DEFAULT) - -lrtest$x: $(MODEL)/lrtest.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/lrtest.o $(LDFLAGS_DEFAULT) - -ncurses$x: $(MODEL)/ncurses.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/ncurses.o $(LDFLAGS_DEFAULT) - -newdemo$x: $(MODEL)/newdemo.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/newdemo.o $(LDFLAGS_DEFAULT) - -rain$x: $(MODEL)/rain.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/rain.o $(LDFLAGS_DEFAULT) - -railroad$x: $(MODEL)/railroad.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/railroad.o $(LDFLAGS_DEFAULT) - -tclock$x: $(MODEL)/tclock.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/tclock.o $(LDFLAGS_DEFAULT) $(MATH_LIB) - -testaddch$x: $(MODEL)/testaddch.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testaddch.o $(LDFLAGS_DEFAULT) - -testcurs$x: $(MODEL)/testcurs.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testcurs.o $(LDFLAGS_DEFAULT) - -testscanw$x: $(MODEL)/testscanw.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testscanw.o $(LDFLAGS_DEFAULT) - -view$x: $(MODEL)/view.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/view.o $(LDFLAGS_DEFAULT) - -worm$x: $(MODEL)/worm.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/worm.o $(LDFLAGS_DEFAULT) - -xmas$x: $(MODEL)/xmas.o $(LOCAL_LIBS) - @ECHO_LINK@ $(LINK) -o $@ $(MODEL)/xmas.o $(LDFLAGS_DEFAULT) - -libs \ -install \ -install.libs \ -install.test: - -uninstall: -uninstall.libs: -uninstall.test: - -mostlyclean :: - -rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace - -clean :: mostlyclean - -rm -rf *.o screendump *.lis $(TESTS) .libs - -distclean :: clean - -rm -f Makefile ncurses_cfg.h config.* - -realclean :: distclean - -lint: - sh -c 'for N in $(TESTS); do echo LINT:$$N; $(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/$$N.c $(LINT_LIBS); done' - -# Use this to get a list of test-programs for the standalone configure script. -echo_tests : - @echo "$(TESTS)" -echo_suffix : - @echo "$x" diff --git a/contrib/ncurses/test/README b/contrib/ncurses/test/README deleted file mode 100644 index cd1767a179b2..000000000000 --- a/contrib/ncurses/test/README +++ /dev/null @@ -1,22 +0,0 @@ -The programs in this directory are designed to test your newest toy :-) -Check the sources for any further details. - -blue - Blue Moon, a nifty solitaire (uses color) -bs.c - the game of Battleships (uses color) -firework.c - multi-colored fireworks (uses color) -gdc.c - Great Digital Clock (uses color) -hanoi.c - the game of hanoi (uses color essentially) -knight.c - the game of Knight's Tour (uses color) -lrtest.c - test of access to the lower-right corner -ncurses.c - multi-test program (uses color) -newdemo.c - another test from PDCurses (uses color) -rain.c - rain drops keep falling on my head... -tclock.c - analog/digital clock -testcurs.c - a test from the PDCurses people (uses color) -worm.c - worms run all over your screen (uses color) -xmas.c - Xmas greeting card - -The bs and knight games demonstrate processing of mouse events under xterm. -This directory also contains: - -tracemunch - Perl script to crunch trace scripts to make them easier to read diff --git a/contrib/ncurses/test/blue.c b/contrib/ncurses/test/blue.c deleted file mode 100644 index 5daba2e61387..000000000000 --- a/contrib/ncurses/test/blue.c +++ /dev/null @@ -1,429 +0,0 @@ -/***************************************************************************** - * * - * B l u e M o o n * - * ================= * - * V2.2 * - * A patience game by T.A.Lister * - * Integral screen support by Eric S. Raymond * - * * - *****************************************************************************/ - -/* - * Compile this with the command `cc -O blue.c -lcurses -o blue'. For best - * results, use the ncurses(3) library. On non-Intel machines, SVr4 curses is - * just as good. - * - * $Id: blue.c,v 1.23 2002/04/06 23:05:16 tom Exp $ - */ - -#include - -#include - -#define NOCARD (-1) - -#define ACE 0 -#define KING 12 -#define SUIT_LENGTH 13 - -#define HEARTS 0 -#define SPADES 1 -#define DIAMONDS 2 -#define CLUBS 3 -#define NSUITS 4 - -#define GRID_WIDTH 14 /* 13+1 */ -#define GRID_LENGTH 56 /* 4*(13+1) */ -#define PACK_SIZE 52 - -#define BASEROW 1 -#define PROMPTROW 11 - -#define RED_ON_WHITE 1 -#define BLACK_ON_WHITE 2 -#define BLUE_ON_WHITE 3 - -static RETSIGTYPE die(int onsig) GCC_NORETURN; - -static int deck_size = PACK_SIZE; /* initial deck */ -static int deck[PACK_SIZE]; - -static int grid[GRID_LENGTH]; /* card layout grid */ -static int freeptr[4]; /* free card space pointers */ - -static int deal_number = 0; - -static chtype ranks[SUIT_LENGTH][2] = -{ - {' ', 'A'}, - {' ', '2'}, - {' ', '3'}, - {' ', '4'}, - {' ', '5'}, - {' ', '6'}, - {' ', '7'}, - {' ', '8'}, - {' ', '9'}, - {'1', '0'}, - {' ', 'J'}, - {' ', 'Q'}, - {' ', 'K'} -}; - -/* Please note, that this is a bad example. - Color values should not be or'ed in. This - only works, because the characters used here - are plain and have no color attribute themselves. */ -#ifdef COLOR_PAIR -#define OR_COLORS(value,pair) ((value) | COLOR_PAIR(pair)) -#else -#define OR_COLORS(value,pair) (value) -#endif - -#define PC_COLORS(value,pair) (OR_COLORS(value,pair) | A_ALTCHARSET) - -static chtype letters[4] = -{ - OR_COLORS('h', RED_ON_WHITE), /* hearts */ - OR_COLORS('s', BLACK_ON_WHITE), /* spades */ - OR_COLORS('d', RED_ON_WHITE), /* diamonds */ - OR_COLORS('c', BLACK_ON_WHITE), /* clubs */ -}; - -#if defined(__i386__) -static chtype glyphs[] = -{ - PC_COLORS('\003', RED_ON_WHITE), /* hearts */ - PC_COLORS('\006', BLACK_ON_WHITE), /* spades */ - PC_COLORS('\004', RED_ON_WHITE), /* diamonds */ - PC_COLORS('\005', BLACK_ON_WHITE), /* clubs */ -}; -#endif /* __i386__ */ - -static chtype *suits = letters; /* this may change to glyphs below */ - -static RETSIGTYPE -die(int onsig) -{ - (void) signal(onsig, SIG_IGN); - endwin(); - ExitProgram(EXIT_SUCCESS); -} - -static void -init_vars(void) -{ - int i; - - deck_size = PACK_SIZE; - for (i = 0; i < PACK_SIZE; i++) - deck[i] = i; - for (i = 0; i < 4; i++) - freeptr[i] = i * GRID_WIDTH; -} - -static void -shuffle(int size) -{ - int i, j, numswaps, swapnum, temp; - - numswaps = size * 10; /* an arbitrary figure */ - - for (swapnum = 0; swapnum < numswaps; swapnum++) { - i = rand() % size; - j = rand() % size; - temp = deck[i]; - deck[i] = deck[j]; - deck[j] = temp; - } -} - -static void -deal_cards(void) -{ - int ptr, card = 0, value, csuit, crank, suit, aces[4]; - - for (suit = HEARTS; suit <= CLUBS; suit++) { - ptr = freeptr[suit]; - grid[ptr++] = NOCARD; /* 1st card space is blank */ - while ((ptr % GRID_WIDTH) != 0) { - value = deck[card++]; - crank = value % SUIT_LENGTH; - csuit = value / SUIT_LENGTH; - if (crank == ACE) - aces[csuit] = ptr; - grid[ptr++] = value; - } - } - - if (deal_number == 1) /* shift the aces down to the 1st column */ - for (suit = HEARTS; suit <= CLUBS; suit++) { - grid[suit * GRID_WIDTH] = suit * SUIT_LENGTH; - grid[aces[suit]] = NOCARD; - freeptr[suit] = aces[suit]; - } -} - -static void -printcard(int value) -{ - (void) addch(' '); - if (value == NOCARD) - (void) addstr(" "); - else { - addch(ranks[value % SUIT_LENGTH][0] | COLOR_PAIR(BLUE_ON_WHITE)); - addch(ranks[value % SUIT_LENGTH][1] | COLOR_PAIR(BLUE_ON_WHITE)); - addch(suits[value / SUIT_LENGTH]); - } - (void) addch(' '); -} - -static void -display_cards(int deal) -{ - int row, card; - - clear(); - (void) printw( - "Blue Moon 2.1 - by Tim Lister & Eric Raymond - Deal %d.\n", - deal); - for (row = HEARTS; row <= CLUBS; row++) { - move(BASEROW + row + row + 2, 1); - for (card = 0; card < GRID_WIDTH; card++) - printcard(grid[row * GRID_WIDTH + card]); - } - - move(PROMPTROW + 2, 0); - refresh(); -#define P(x) (void)printw("%s\n", x) - P(" This 52-card solitaire starts with the entire deck shuffled and dealt"); - P("out in four rows. The aces are then moved to the left end of the layout,"); - P("making 4 initial free spaces. You may move to a space only the card that"); - P("matches the left neighbor in suit, and is one greater in rank. Kings are"); - P("high, so no cards may be placed to their right (they create dead spaces)."); - P(" When no moves can be made, cards still out of sequence are reshuffled"); - P("and dealt face up after the ends of the partial sequences, leaving a card"); - P("space after each sequence, so that each row looks like a partial sequence"); - P("followed by a space, followed by enough cards to make a row of 14. "); - P(" A moment's reflection will show that this game cannot take more than 13"); - P("deals. A good score is 1-3 deals, 4-7 is average, 8 or more is poor. "); -#undef P - refresh(); -} - -static int -find(int card) -{ - int i; - - if ((card < 0) || (card >= PACK_SIZE)) - return (NOCARD); - for (i = 0; i < GRID_LENGTH; i++) - if (grid[i] == card) - return i; - return (NOCARD); -} - -static void -movecard(int src, int dst) -{ - grid[dst] = grid[src]; - grid[src] = NOCARD; - - move(BASEROW + (dst / GRID_WIDTH) * 2 + 2, (dst % GRID_WIDTH) * 5 + 1); - printcard(grid[dst]); - - move(BASEROW + (src / GRID_WIDTH) * 2 + 2, (src % GRID_WIDTH) * 5 + 1); - printcard(grid[src]); - - refresh(); -} - -static void -play_game(void) -{ - int dead = 0, i, j; - char c; - int selection[4], card; - - while (dead < 4) { - dead = 0; - for (i = 0; i < 4; i++) { - card = grid[freeptr[i] - 1]; - - if (((card % SUIT_LENGTH) == KING) - || - (card == NOCARD)) - selection[i] = NOCARD; - else - selection[i] = find(card + 1); - - if (selection[i] == NOCARD) - dead++; - }; - - if (dead < 4) { - char live[NSUITS + 1], *lp = live; - - for (i = 0; i < 4; i++) { - if (selection[i] != NOCARD) { - move(BASEROW + (selection[i] / GRID_WIDTH) * 2 + 3, - (selection[i] % GRID_WIDTH) * 5); - (void) printw(" %c ", *lp++ = 'a' + i); - } - }; - *lp = '\0'; - - if (strlen(live) == 1) { - move(PROMPTROW, 0); - (void) printw( - "Making forced moves... "); - refresh(); - (void) sleep(1); - c = live[0]; - } else { - char buf[BUFSIZ]; - - (void) sprintf(buf, - "Type [%s] to move, r to redraw, q or INTR to quit: ", - live); - - do { - move(PROMPTROW, 0); - (void) addstr(buf); - move(PROMPTROW, (int) strlen(buf)); - clrtoeol(); - (void) addch(' '); - } while - (((c = getch()) < 'a' || c > 'd') && (c != 'r') && (c != 'q')); - } - - for (j = 0; j < 4; j++) - if (selection[j] != NOCARD) { - move(BASEROW + (selection[j] / GRID_WIDTH) * 2 + 3, - (selection[j] % GRID_WIDTH) * 5); - (void) printw(" "); - } - - if (c == 'r') - display_cards(deal_number); - else if (c == 'q') - die(SIGINT); - else { - i = c - 'a'; - if (selection[i] == NOCARD) - beep(); - else { - movecard(selection[i], freeptr[i]); - freeptr[i] = selection[i]; - } - } - } - } - - move(PROMPTROW, 0); - standout(); - (void) printw("Finished deal %d - type any character to continue...", deal_number); - standend(); - (void) getch(); -} - -static int -collect_discards(void) -{ - int row, col, cardno = 0, finish, gridno; - - for (row = HEARTS; row <= CLUBS; row++) { - finish = 0; - for (col = 1; col < GRID_WIDTH; col++) { - gridno = row * GRID_WIDTH + col; - - if ((grid[gridno] != (grid[gridno - 1] + 1)) && (finish == 0)) { - finish = 1; - freeptr[row] = gridno; - }; - - if ((finish != 0) && (grid[gridno] != NOCARD)) - deck[cardno++] = grid[gridno]; - } - } - return cardno; -} - -static void -game_finished(int deal) -{ - clear(); - (void) printw("You finished the game in %d deals. This is ", deal); - standout(); - if (deal < 2) - (void) addstr("excellent"); - else if (deal < 4) - (void) addstr("good"); - else if (deal < 8) - (void) addstr("average"); - else - (void) addstr("poor"); - standend(); - (void) addstr(". "); - refresh(); -} - -int -main(int argc, char *argv[]) -{ - (void) signal(SIGINT, die); - initscr(); - - /* - * We use COLOR_GREEN because COLOR_BLACK is wired to the wrong thing. - */ - start_color(); - init_pair(RED_ON_WHITE, COLOR_RED, COLOR_WHITE); - init_pair(BLUE_ON_WHITE, COLOR_BLUE, COLOR_WHITE); - init_pair(BLACK_ON_WHITE, COLOR_BLACK, COLOR_WHITE); - -#ifndef COLOR_PAIR - letters[0] = OR_COLORS('h', RED_ON_WHITE); /* hearts */ - letters[1] = OR_COLORS('s', BLACK_ON_WHITE); /* spades */ - letters[2] = OR_COLORS('d', RED_ON_WHITE); /* diamonds */ - letters[3] = OR_COLORS('c', BLACK_ON_WHITE); /* clubs */ -#if defined(__i386__) && defined(A_ALTCHARSET) - glyphs[0] = PC_COLORS('\003', RED_ON_WHITE); /* hearts */ - glyphs[1] = PC_COLORS('\006', BLACK_ON_WHITE); /* spades */ - glyphs[2] = PC_COLORS('\004', RED_ON_WHITE); /* diamonds */ - glyphs[3] = PC_COLORS('\005', BLACK_ON_WHITE); /* clubs */ -#endif -#endif - -#if defined(__i386__) && defined(A_ALTCHARSET) - if (tigetstr("smpch")) - suits = glyphs; -#endif /* __i386__ && A_ALTCHARSET */ - - cbreak(); - - if (argc == 2) - srand((unsigned) atoi(argv[1])); - else - srand((unsigned) time((time_t *) 0)); - - init_vars(); - - do { - deal_number++; - shuffle(deck_size); - deal_cards(); - display_cards(deal_number); - play_game(); - } - while - ((deck_size = collect_discards()) != 0); - - game_finished(deal_number); - - die(SIGINT); - /*NOTREACHED */ -} - -/* blue.c ends here */ diff --git a/contrib/ncurses/test/bs.6 b/contrib/ncurses/test/bs.6 deleted file mode 100644 index 38cfe82a9811..000000000000 --- a/contrib/ncurses/test/bs.6 +++ /dev/null @@ -1,42 +0,0 @@ -.TH BATTLESHIPS 6 "Aug 23, 1989" -.SH NAME -bs \- battleships game -.SH SYNOPSIS -battle [ -b | -s ] [ -c ] -.SH DESCRIPTION -This program allows you to play the familiar Battleships game against the -computer on a 10x10 board. The interface is visual and largely -self-explanatory; you place your ships and pick your shots by moving the -cursor around the `sea' with the rogue/hack motion keys hjklyubn. -.PP -Note that when selecting a ship to place, you must type the capital letter -(these are, after all, capital ships). During ship placement, the `r' command -may be used to ignore the current position and randomly place your currently -selected ship. The `R' command will place all remaining ships randomly. The ^L -command (form feed, ASCII 12) will force a screen redraw). -.PP -The command-line arguments control game modes. - -.nf - -b selects a `blitz' variant - -s selects a `salvo' variant - -c permits ships to be placed adjacently -.fi - -The `blitz' variant allows a side to shoot for as long as it continues to -score hits. -.PP -The `salvo' game allows a player one shot per turn for each of his/her ships -still afloat. This puts a premium scoring hits early and knocking out some -ships and also makes much harder the situation where you face a superior force -with only your PT-boat. -.PP -Normally, ships must be separated by at least one square of open water. The --c option disables this check and allows them to close-pack. -.PP -The algorithm the computer uses once it has found a ship to sink is provably -optimal. The dispersion criterion for the random-fire algorithm may not be. -.SH AUTHORS -Originally written by one Bruce Holloway in 1986. Salvo mode added by Chuck A. -DeGaul (cbosgd!cad). Visual user interface, `closepack' option, code rewrite -and manual page by Eric S. Raymond August 1989. diff --git a/contrib/ncurses/test/bs.c b/contrib/ncurses/test/bs.c deleted file mode 100644 index 2d3a7fb2f055..000000000000 --- a/contrib/ncurses/test/bs.c +++ /dev/null @@ -1,1226 +0,0 @@ -/* - * bs.c - original author: Bruce Holloway - * salvo option by: Chuck A DeGaul - * with improved user interface, autoconfiguration and code cleanup - * by Eric S. Raymond - * v1.2 with color support and minor portability fixes, November 1990 - * v2.0 featuring strict ANSI/POSIX conformance, November 1993. - * v2.1 with ncurses mouse support, September 1995 - * - * $Id: bs.c,v 1.35 2002/04/06 23:10:12 tom Exp $ - */ - -#include -#include -#include - -#include - -#ifndef SIGIOT -#define SIGIOT SIGABRT -#endif - -static int getcoord(int); - -/* - * Constants for tuning the random-fire algorithm. It prefers moves that - * diagonal-stripe the board with a stripe separation of srchstep. If - * no such preferred moves are found, srchstep is decremented. - */ -#define BEGINSTEP 3 /* initial value of srchstep */ - -/* miscellaneous constants */ -#define SHIPTYPES 5 -#define OTHER (1-turn) -#define PLAYER 0 -#define COMPUTER 1 -#define MARK_HIT 'H' -#define MARK_MISS 'o' -#define CTRLC '\003' /* used as terminate command */ -#define FF '\014' /* used as redraw command */ - -/* coordinate handling */ -#define BWIDTH 10 -#define BDEPTH 10 - -/* display symbols */ -#define SHOWHIT '*' -#define SHOWSPLASH ' ' -#define IS_SHIP(c) (isupper(UChar(c)) ? TRUE : FALSE) - -/* how to position us on player board */ -#define PYBASE 3 -#define PXBASE 3 -#define PY(y) (PYBASE + (y)) -#define PX(x) (PXBASE + (x)*3) -#define pgoto(y, x) (void)move(PY(y), PX(x)) - -/* how to position us on cpu board */ -#define CYBASE 3 -#define CXBASE 48 -#define CY(y) (CYBASE + (y)) -#define CX(x) (CXBASE + (x)*3) -#define CYINV(y) ((y) - CYBASE) -#define CXINV(x) (((x) - CXBASE) / 3) -#define cgoto(y, x) (void)move(CY(y), CX(x)) - -#define ONBOARD(x, y) (x >= 0 && x < BWIDTH && y >= 0 && y < BDEPTH) - -/* other board locations */ -#define COLWIDTH 80 -#define PROMPTLINE 21 /* prompt line */ -#define SYBASE CYBASE + BDEPTH + 3 /* move key diagram */ -#define SXBASE 63 -#define MYBASE SYBASE - 1 /* diagram caption */ -#define MXBASE 64 -#define HYBASE SYBASE - 1 /* help area */ -#define HXBASE 0 - -/* this will need to be changed if BWIDTH changes */ -static char numbers[] = " 0 1 2 3 4 5 6 7 8 9"; - -static char carrier[] = "Aircraft Carrier"; -static char battle[] = "Battleship"; -static char sub[] = "Submarine"; -static char destroy[] = "Destroyer"; -static char ptboat[] = "PT Boat"; - -static char name[40]; -static char dftname[] = "stranger"; - -/* direction constants */ -#define E 0 -#define SE 1 -#define S 2 -#define SW 3 -#define W 4 -#define NW 5 -#define N 6 -#define NE 7 -static int xincr[8] = -{1, 1, 0, -1, -1, -1, 0, 1}; -static int yincr[8] = -{0, 1, 1, 1, 0, -1, -1, -1}; - -/* current ship position and direction */ -static int curx = (BWIDTH / 2); -static int cury = (BDEPTH / 2); - -typedef struct { - char *name; /* name of the ship type */ - int hits; /* how many times has this ship been hit? */ - char symbol; /* symbol for game purposes */ - int length; /* length of ship */ - int x, y; /* coordinates of ship start point */ - int dir; /* direction of `bow' */ - bool placed; /* has it been placed on the board? */ -} ship_t; - -static bool checkplace(int b, ship_t * ss, int vis); - -#define SHIPIT(name, symbol, length) { name, 0, symbol, length, 0,0, 0, FALSE } - -static ship_t plyship[SHIPTYPES] = -{ - SHIPIT(carrier, 'A', 5), - SHIPIT(battle, 'B', 4), - SHIPIT(destroy, 'D', 3), - SHIPIT(sub, 'S', 3), - SHIPIT(ptboat, 'P', 2), -}; - -static ship_t cpuship[SHIPTYPES] = -{ - SHIPIT(carrier, 'A', 5), - SHIPIT(battle, 'B', 4), - SHIPIT(destroy, 'D', 3), - SHIPIT(sub, 'S', 3), - SHIPIT(ptboat, 'P', 2), -}; - -/* "Hits" board, and main board. */ -static char hits[2][BWIDTH][BDEPTH]; -static char board[2][BWIDTH][BDEPTH]; - -static int turn; /* 0=player, 1=computer */ -static int plywon = 0, cpuwon = 0; /* How many games has each won? */ - -static int salvo, blitz, closepack; - -#define PR (void)addstr - -static RETSIGTYPE uninitgame(int sig) GCC_NORETURN; - -static RETSIGTYPE uninitgame(int sig GCC_UNUSED) -/* end the game, either normally or due to signal */ -{ - clear(); - (void) refresh(); - (void) reset_shell_mode(); - (void) echo(); - (void) endwin(); - ExitProgram(sig ? EXIT_FAILURE : EXIT_SUCCESS); -} - -static void -announceopts(void) -/* announce which game options are enabled */ -{ - if (salvo || blitz || closepack) { - (void) printw("Playing optional game ("); - if (salvo) - (void) printw("salvo, "); - else - (void) printw("nosalvo, "); - if (blitz) - (void) printw("blitz "); - else - (void) printw("noblitz, "); - if (closepack) - (void) printw("closepack)"); - else - (void) printw("noclosepack)"); - } else - (void) printw( - "Playing standard game (noblitz, nosalvo, noclosepack)"); -} - -static void -intro(void) -{ - char *tmpname; - - srand((unsigned) (time(0L) + getpid())); /* Kick the random number generator */ - - (void) signal(SIGINT, uninitgame); - (void) signal(SIGINT, uninitgame); - (void) signal(SIGIOT, uninitgame); /* for assert(3) */ - if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) - (void) signal(SIGQUIT, uninitgame); - - if ((tmpname = getlogin()) != 0) { - (void) strcpy(name, tmpname); - name[0] = toupper(name[0]); - } else - (void) strcpy(name, dftname); - - (void) initscr(); - keypad(stdscr, TRUE); - (void) def_prog_mode(); - (void) nonl(); - (void) cbreak(); - (void) noecho(); - -#ifdef PENGUIN - (void) clear(); - (void) mvaddstr(4, 29, "Welcome to Battleship!"); - (void) move(8, 0); - PR(" \\\n"); - PR(" \\ \\ \\\n"); - PR(" \\ \\ \\ \\ \\_____________\n"); - PR(" \\ \\ \\_____________ \\ \\/ |\n"); - PR(" \\ \\/ \\ \\/ |\n"); - PR(" \\/ \\_____/ |__\n"); - PR(" ________________/ |\n"); - PR(" \\ S.S. Penguin |\n"); - PR(" \\ /\n"); - PR(" \\___________________________________________________/\n"); - - (void) mvaddstr(22, 27, "Hit any key to continue..."); - (void) refresh(); - (void) getch(); -#endif /* PENGUIN */ - -#ifdef A_COLOR - start_color(); - - init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); - init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK); - init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK); - init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK); - init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK); - init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); - init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK); - init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK); -#endif /* A_COLOR */ - -#ifdef NCURSES_MOUSE_VERSION - (void) mousemask(BUTTON1_CLICKED, (mmask_t *) NULL); -#endif /* NCURSES_MOUSE_VERSION */ -} - -/* VARARGS1 */ -static void -prompt(int n, NCURSES_CONST char *f, const char *s) -/* print a message at the prompt line */ -{ - (void) move(PROMPTLINE + n, 0); - (void) clrtoeol(); - (void) printw(f, s); - (void) refresh(); -} - -static void -error(NCURSES_CONST char *s) -{ - (void) move(PROMPTLINE + 2, 0); - (void) clrtoeol(); - if (s) { - (void) addstr(s); - (void) beep(); - } -} - -static void -placeship(int b, ship_t * ss, int vis) -{ - int l; - - for (l = 0; l < ss->length; ++l) { - int newx = ss->x + l * xincr[ss->dir]; - int newy = ss->y + l * yincr[ss->dir]; - - board[b][newx][newy] = ss->symbol; - if (vis) { - pgoto(newy, newx); - (void) addch((chtype) ss->symbol); - } - } - ss->hits = 0; -} - -static int -rnd(int n) -{ - return (((rand() & 0x7FFF) % n)); -} - -static void -randomplace(int b, ship_t * ss) -/* generate a valid random ship placement into px,py */ -{ - - do { - ss->dir = rnd(2) ? E : S; - ss->x = rnd(BWIDTH - (ss->dir == E ? ss->length : 0)); - ss->y = rnd(BDEPTH - (ss->dir == S ? ss->length : 0)); - } while - (!checkplace(b, ss, FALSE)); -} - -static void -initgame(void) -{ - int i, j, unplaced; - ship_t *ss; - - (void) clear(); - (void) mvaddstr(0, 35, "BATTLESHIPS"); - (void) move(PROMPTLINE + 2, 0); - announceopts(); - - memset(board, 0, sizeof(char) * BWIDTH * BDEPTH * 2); - memset(hits, 0, sizeof(char) * BWIDTH * BDEPTH * 2); - for (i = 0; i < SHIPTYPES; i++) { - ss = cpuship + i; - - ss->x = - ss->y = - ss->dir = - ss->hits = 0; - ss->placed = FALSE; - - ss = plyship + i; - - ss->x = - ss->y = - ss->dir = - ss->hits = 0; - ss->placed = FALSE; - } - - /* draw empty boards */ - (void) mvaddstr(PYBASE - 2, PXBASE + 5, "Main Board"); - (void) mvaddstr(PYBASE - 1, PXBASE - 3, numbers); - for (i = 0; i < BDEPTH; ++i) { - (void) mvaddch(PYBASE + i, PXBASE - 3, (chtype) (i + 'A')); -#ifdef A_COLOR - if (has_colors()) - attron(COLOR_PAIR(COLOR_BLUE)); -#endif /* A_COLOR */ - (void) addch(' '); - for (j = 0; j < BWIDTH; j++) - (void) addstr(" . "); -#ifdef A_COLOR - attrset(0); -#endif /* A_COLOR */ - (void) addch(' '); - (void) addch((chtype) (i + 'A')); - } - (void) mvaddstr(PYBASE + BDEPTH, PXBASE - 3, numbers); - (void) mvaddstr(CYBASE - 2, CXBASE + 7, "Hit/Miss Board"); - (void) mvaddstr(CYBASE - 1, CXBASE - 3, numbers); - for (i = 0; i < BDEPTH; ++i) { - (void) mvaddch(CYBASE + i, CXBASE - 3, (chtype) (i + 'A')); -#ifdef A_COLOR - if (has_colors()) - attron(COLOR_PAIR(COLOR_BLUE)); -#endif /* A_COLOR */ - (void) addch(' '); - for (j = 0; j < BWIDTH; j++) - (void) addstr(" . "); -#ifdef A_COLOR - attrset(0); -#endif /* A_COLOR */ - (void) addch(' '); - (void) addch((chtype) (i + 'A')); - } - - (void) mvaddstr(CYBASE + BDEPTH, CXBASE - 3, numbers); - - (void) mvprintw(HYBASE, HXBASE, - "To position your ships: move the cursor to a spot, then"); - (void) mvprintw(HYBASE + 1, HXBASE, - "type the first letter of a ship type to select it, then"); - (void) mvprintw(HYBASE + 2, HXBASE, - "type a direction ([hjkl] or [4862]), indicating how the"); - (void) mvprintw(HYBASE + 3, HXBASE, - "ship should be pointed. You may also type a ship letter"); - (void) mvprintw(HYBASE + 4, HXBASE, - "followed by `r' to position it randomly, or type `R' to"); - (void) mvprintw(HYBASE + 5, HXBASE, - "place all remaining ships randomly."); - - (void) mvaddstr(MYBASE, MXBASE, "Aiming keys:"); - (void) mvaddstr(SYBASE, SXBASE, "y k u 7 8 9"); - (void) mvaddstr(SYBASE + 1, SXBASE, " \\|/ \\|/ "); - (void) mvaddstr(SYBASE + 2, SXBASE, "h-+-l 4-+-6"); - (void) mvaddstr(SYBASE + 3, SXBASE, " /|\\ /|\\ "); - (void) mvaddstr(SYBASE + 4, SXBASE, "b j n 1 2 3"); - - /* have the computer place ships */ - for (ss = cpuship; ss < cpuship + SHIPTYPES; ss++) { - randomplace(COMPUTER, ss); - placeship(COMPUTER, ss, FALSE); - } - - ss = (ship_t *) NULL; - do { - char c, docked[SHIPTYPES + 2], *cp = docked; - - /* figure which ships still wait to be placed */ - *cp++ = 'R'; - for (i = 0; i < SHIPTYPES; i++) - if (!plyship[i].placed) - *cp++ = plyship[i].symbol; - *cp = '\0'; - - /* get a command letter */ - prompt(1, "Type one of [%s] to pick a ship.", docked + 1); - do { - c = getcoord(PLAYER); - } while - (!strchr(docked, c)); - - if (c == 'R') - (void) ungetch('R'); - else { - /* map that into the corresponding symbol */ - for (ss = plyship; ss < plyship + SHIPTYPES; ss++) - if (ss->symbol == c) - break; - - prompt(1, "Type one of [hjklrR] to place your %s.", ss->name); - pgoto(cury, curx); - } - - do { - c = getch(); - } while - (!strchr("hjklrR", c) || c == FF); - - if (c == FF) { - (void) clearok(stdscr, TRUE); - (void) refresh(); - } else if (c == 'r') { - prompt(1, "Random-placing your %s", ss->name); - randomplace(PLAYER, ss); - placeship(PLAYER, ss, TRUE); - error((char *) NULL); - ss->placed = TRUE; - } else if (c == 'R') { - prompt(1, "Placing the rest of your fleet at random...", ""); - for (ss = plyship; ss < plyship + SHIPTYPES; ss++) - if (!ss->placed) { - randomplace(PLAYER, ss); - placeship(PLAYER, ss, TRUE); - ss->placed = TRUE; - } - error((char *) NULL); - } else if (strchr("hjkl8462", c)) { - ss->x = curx; - ss->y = cury; - - switch (c) { - case 'k': - case '8': - ss->dir = N; - break; - case 'j': - case '2': - ss->dir = S; - break; - case 'h': - case '4': - ss->dir = W; - break; - case 'l': - case '6': - ss->dir = E; - break; - } - - if (checkplace(PLAYER, ss, TRUE)) { - placeship(PLAYER, ss, TRUE); - error((char *) NULL); - ss->placed = TRUE; - } - } - - for (unplaced = i = 0; i < SHIPTYPES; i++) - unplaced += !plyship[i].placed; - } while - (unplaced); - - turn = rnd(2); - - (void) mvprintw(HYBASE, HXBASE, - "To fire, move the cursor to your chosen aiming point "); - (void) mvprintw(HYBASE + 1, HXBASE, - "and strike any key other than a motion key. "); - (void) mvprintw(HYBASE + 2, HXBASE, - " "); - (void) mvprintw(HYBASE + 3, HXBASE, - " "); - (void) mvprintw(HYBASE + 4, HXBASE, - " "); - (void) mvprintw(HYBASE + 5, HXBASE, - " "); - - (void) prompt(0, "Press any key to start...", ""); - (void) getch(); -} - -static int -getcoord(int atcpu) -{ - int ny, nx, c; - - if (atcpu) - cgoto(cury, curx); - else - pgoto(cury, curx); - (void) refresh(); - for (;;) { - if (atcpu) { - (void) mvprintw(CYBASE + BDEPTH + 1, CXBASE + 11, "(%d, %c)", - curx, 'A' + cury); - cgoto(cury, curx); - } else { - (void) mvprintw(PYBASE + BDEPTH + 1, PXBASE + 11, "(%d, %c)", - curx, 'A' + cury); - pgoto(cury, curx); - } - - switch (c = getch()) { - case 'k': - case '8': - case KEY_UP: - ny = cury + BDEPTH - 1; - nx = curx; - break; - case 'j': - case '2': - case KEY_DOWN: - ny = cury + 1; - nx = curx; - break; - case 'h': - case '4': - case KEY_LEFT: - ny = cury; - nx = curx + BWIDTH - 1; - break; - case 'l': - case '6': - case KEY_RIGHT: - ny = cury; - nx = curx + 1; - break; - case 'y': - case '7': - case KEY_A1: - ny = cury + BDEPTH - 1; - nx = curx + BWIDTH - 1; - break; - case 'b': - case '1': - case KEY_C1: - ny = cury + 1; - nx = curx + BWIDTH - 1; - break; - case 'u': - case '9': - case KEY_A3: - ny = cury + BDEPTH - 1; - nx = curx + 1; - break; - case 'n': - case '3': - case KEY_C3: - ny = cury + 1; - nx = curx + 1; - break; - case FF: - nx = curx; - ny = cury; - (void) clearok(stdscr, TRUE); - (void) refresh(); - break; -#ifdef NCURSES_MOUSE_VERSION - case KEY_MOUSE: - { - MEVENT myevent; - - getmouse(&myevent); - if (atcpu - && myevent.y >= CY(0) && myevent.y <= CY(BDEPTH) - && myevent.x >= CX(0) && myevent.x <= CX(BDEPTH)) { - curx = CXINV(myevent.x); - cury = CYINV(myevent.y); - return (' '); - } else { - beep(); - continue; - } - } - /* no fall through */ -#endif /* NCURSES_MOUSE_VERSION */ - - default: - if (atcpu) - (void) mvaddstr(CYBASE + BDEPTH + 1, CXBASE + 11, " "); - else - (void) mvaddstr(PYBASE + BDEPTH + 1, PXBASE + 11, " "); - return (c); - } - - curx = nx % BWIDTH; - cury = ny % BDEPTH; - } -} - -static bool -collidecheck(int b, int y, int x) -/* is this location on the selected zboard adjacent to a ship? */ -{ - bool collide; - - /* anything on the square */ - if ((collide = IS_SHIP(board[b][x][y])) != FALSE) - return (collide); - - /* anything on the neighbors */ - if (!closepack) { - int i; - - for (i = 0; i < 8; i++) { - int xend, yend; - - yend = y + yincr[i]; - xend = x + xincr[i]; - if (ONBOARD(xend, yend) - && IS_SHIP(board[b][xend][yend])) { - collide = TRUE; - break; - } - } - } - return (collide); -} - -static bool -checkplace(int b, ship_t * ss, int vis) -{ - int l, xend, yend; - - /* first, check for board edges */ - xend = ss->x + (ss->length - 1) * xincr[ss->dir]; - yend = ss->y + (ss->length - 1) * yincr[ss->dir]; - if (!ONBOARD(xend, yend)) { - if (vis) - switch (rnd(3)) { - case 0: - error("Ship is hanging from the edge of the world"); - break; - case 1: - error("Try fitting it on the board"); - break; - case 2: - error("Figure I won't find it if you put it there?"); - break; - } - return (FALSE); - } - - for (l = 0; l < ss->length; ++l) { - if (collidecheck(b, ss->y + l * yincr[ss->dir], ss->x + l * xincr[ss->dir])) { - if (vis) - switch (rnd(3)) { - case 0: - error("There's already a ship there"); - break; - case 1: - error("Collision alert! Aaaaaagh!"); - break; - case 2: - error("Er, Admiral, what about the other ship?"); - break; - } - return (FALSE); - } - } - return (TRUE); -} - -static int -awinna(void) -{ - int i, j; - ship_t *ss; - - for (i = 0; i < 2; ++i) { - ss = (i) ? cpuship : plyship; - for (j = 0; j < SHIPTYPES; ++j, ++ss) - if (ss->length > ss->hits) - break; - if (j == SHIPTYPES) - return (OTHER); - } - return (-1); -} - -static ship_t * -hitship(int x, int y) -/* register a hit on the targeted ship */ -{ - ship_t *sb, *ss; - char sym; - int oldx, oldy; - - getyx(stdscr, oldy, oldx); - sb = (turn) ? plyship : cpuship; - if ((sym = board[OTHER][x][y]) == 0) - return ((ship_t *) NULL); - for (ss = sb; ss < sb + SHIPTYPES; ++ss) - if (ss->symbol == sym) { - if (++ss->hits < ss->length) /* still afloat? */ - return ((ship_t *) NULL); - else { /* sunk! */ - int i, j; - - if (!closepack) - for (j = -1; j <= 1; j++) { - int bx = ss->x + j * xincr[(ss->dir + 2) % 8]; - int by = ss->y + j * yincr[(ss->dir + 2) % 8]; - - for (i = -1; i <= ss->length; ++i) { - int x1, y1; - - x1 = bx + i * xincr[ss->dir]; - y1 = by + i * yincr[ss->dir]; - if (ONBOARD(x1, y1)) { - hits[turn][x1][y1] = MARK_MISS; - if (turn % 2 == PLAYER) { - cgoto(y1, x1); -#ifdef A_COLOR - if (has_colors()) - attron(COLOR_PAIR(COLOR_GREEN)); -#endif /* A_COLOR */ - (void) addch(MARK_MISS); -#ifdef A_COLOR - attrset(0); -#endif /* A_COLOR */ - } else { - pgoto(y1, x1); - (void) addch(SHOWSPLASH); - } - } - } - } - - for (i = 0; i < ss->length; ++i) { - int x1 = ss->x + i * xincr[ss->dir]; - int y1 = ss->y + i * yincr[ss->dir]; - - hits[turn][x1][y1] = ss->symbol; - if (turn % 2 == PLAYER) { - cgoto(y1, x1); - (void) addch((chtype) (ss->symbol)); - } else { - pgoto(y1, x1); -#ifdef A_COLOR - if (has_colors()) - attron(COLOR_PAIR(COLOR_RED)); -#endif /* A_COLOR */ - (void) addch(SHOWHIT); -#ifdef A_COLOR - attrset(0); -#endif /* A_COLOR */ - } - } - - (void) move(oldy, oldx); - return (ss); - } - } - (void) move(oldy, oldx); - return ((ship_t *) NULL); -} - -static bool -plyturn(void) -{ - ship_t *ss; - bool hit; - NCURSES_CONST char *m = NULL; - - prompt(1, "Where do you want to shoot? ", ""); - for (;;) { - (void) getcoord(COMPUTER); - if (hits[PLAYER][curx][cury]) { - prompt(1, "You shelled this spot already! Try again.", ""); - beep(); - } else - break; - } - hit = IS_SHIP(board[COMPUTER][curx][cury]); - hits[PLAYER][curx][cury] = (hit ? MARK_HIT : MARK_MISS); - cgoto(cury, curx); -#ifdef A_COLOR - if (has_colors()) { - if (hit) - attron(COLOR_PAIR(COLOR_RED)); - else - attron(COLOR_PAIR(COLOR_GREEN)); - } -#endif /* A_COLOR */ - (void) addch((chtype) hits[PLAYER][curx][cury]); -#ifdef A_COLOR - attrset(0); -#endif /* A_COLOR */ - - prompt(1, "You %s.", hit ? "scored a hit" : "missed"); - if (hit && (ss = hitship(curx, cury))) { - switch (rnd(5)) { - case 0: - m = " You sank my %s!"; - break; - case 1: - m = " I have this sinking feeling about my %s...."; - break; - case 2: - m = " My %s has gone to Davy Jones's locker!"; - break; - case 3: - m = " Glub, glub -- my %s is headed for the bottom!"; - break; - case 4: - m = " You'll pick up survivors from my %s, I hope...!"; - break; - } - (void) printw(m, ss->name); - (void) beep(); - return (awinna() == -1); - } - return (hit); -} - -static int -sgetc(const char *s) -{ - const char *s1; - int ch; - - (void) refresh(); - for (;;) { - ch = getch(); - if (islower(ch)) - ch = toupper(ch); - if (ch == CTRLC) - uninitgame(0); - for (s1 = s; *s1 && ch != *s1; ++s1) - continue; - if (*s1) { - (void) addch((chtype) ch); - (void) refresh(); - return (ch); - } - } -} - -static void -randomfire(int *px, int *py) -/* random-fire routine -- implements simple diagonal-striping strategy */ -{ - static int turncount = 0; - static int srchstep = BEGINSTEP; - static int huntoffs; /* Offset on search strategy */ - int ypossible[BWIDTH * BDEPTH], xpossible[BWIDTH * BDEPTH], nposs; - int ypreferred[BWIDTH * BDEPTH], xpreferred[BWIDTH * BDEPTH], npref; - int x, y, i; - - if (turncount++ == 0) - huntoffs = rnd(srchstep); - - /* first, list all possible moves */ - nposs = npref = 0; - for (x = 0; x < BWIDTH; x++) - for (y = 0; y < BDEPTH; y++) - if (!hits[COMPUTER][x][y]) { - xpossible[nposs] = x; - ypossible[nposs] = y; - nposs++; - if (((x + huntoffs) % srchstep) != (y % srchstep)) { - xpreferred[npref] = x; - ypreferred[npref] = y; - npref++; - } - } - - if (npref) { - i = rnd(npref); - - *px = xpreferred[i]; - *py = ypreferred[i]; - } else if (nposs) { - i = rnd(nposs); - - *px = xpossible[i]; - *py = ypossible[i]; - - if (srchstep > 1) - --srchstep; - } else { - error("No moves possible?? Help!"); - ExitProgram(EXIT_FAILURE); - /*NOTREACHED */ - } -} - -#define S_MISS 0 -#define S_HIT 1 -#define S_SUNK -1 - -static int -cpufire(int x, int y) -/* fire away at given location */ -{ - bool hit, sunk; - ship_t *ss = NULL; - - hits[COMPUTER][x][y] = (hit = (board[PLAYER][x][y])) ? MARK_HIT : MARK_MISS; - (void) mvprintw(PROMPTLINE, 0, - "I shoot at %c%d. I %s!", y + 'A', x, hit ? "hit" : - "miss"); - if ((sunk = (hit && (ss = hitship(x, y)))) != 0) - (void) printw(" I've sunk your %s", ss->name); - (void) clrtoeol(); - - pgoto(y, x); -#ifdef A_COLOR - if (has_colors()) { - if (hit) - attron(COLOR_PAIR(COLOR_RED)); - else - attron(COLOR_PAIR(COLOR_GREEN)); - } -#endif /* A_COLOR */ - (void) addch((chtype) (hit ? SHOWHIT : SHOWSPLASH)); -#ifdef A_COLOR - attrset(0); -#endif /* A_COLOR */ - - return ((hit ? (sunk ? S_SUNK : S_HIT) : S_MISS) ? TRUE : FALSE); -} - -/* - * This code implements a fairly irregular FSM, so please forgive the rampant - * unstructuredness below. The five labels are states which need to be held - * between computer turns. - */ -static bool -cputurn(void) -{ -#define POSSIBLE(x, y) (ONBOARD(x, y) && !hits[COMPUTER][x][y]) -#define RANDOM_FIRE 0 -#define RANDOM_HIT 1 -#define HUNT_DIRECT 2 -#define FIRST_PASS 3 -#define REVERSE_JUMP 4 -#define SECOND_PASS 5 - static int next = RANDOM_FIRE; - static bool used[4]; - static ship_t ts; - int navail, x, y, d, n; - int hit = S_MISS; - - switch (next) { - case RANDOM_FIRE: /* last shot was random and missed */ - refire: - randomfire(&x, &y); - if (!(hit = cpufire(x, y))) - next = RANDOM_FIRE; - else { - ts.x = x; - ts.y = y; - ts.hits = 1; - next = (hit == S_SUNK) ? RANDOM_FIRE : RANDOM_HIT; - } - break; - - case RANDOM_HIT: /* last shot was random and hit */ - used[E / 2] = used[S / 2] = used[W / 2] = used[N / 2] = FALSE; - /* FALLTHROUGH */ - - case HUNT_DIRECT: /* last shot hit, we're looking for ship's long axis */ - for (d = navail = 0; d < 4; d++) { - x = ts.x + xincr[d * 2]; - y = ts.y + yincr[d * 2]; - if (!used[d] && POSSIBLE(x, y)) - navail++; - else - used[d] = TRUE; - } - if (navail == 0) /* no valid places for shots adjacent... */ - goto refire; /* ...so we must random-fire */ - else { - for (d = 0, n = rnd(navail) + 1; n; n--) - while (used[d]) - d++; - - assert(d <= 4); - - used[d] = FALSE; - x = ts.x + xincr[d * 2]; - y = ts.y + yincr[d * 2]; - - assert(POSSIBLE(x, y)); - - if (!(hit = cpufire(x, y))) - next = HUNT_DIRECT; - else { - ts.x = x; - ts.y = y; - ts.dir = d * 2; - ts.hits++; - next = (hit == S_SUNK) ? RANDOM_FIRE : FIRST_PASS; - } - } - break; - - case FIRST_PASS: /* we have a start and a direction now */ - x = ts.x + xincr[ts.dir]; - y = ts.y + yincr[ts.dir]; - if (POSSIBLE(x, y) && (hit = cpufire(x, y))) { - ts.x = x; - ts.y = y; - ts.hits++; - next = (hit == S_SUNK) ? RANDOM_FIRE : FIRST_PASS; - } else - next = REVERSE_JUMP; - break; - - case REVERSE_JUMP: /* nail down the ship's other end */ - d = ts.dir + 4; - x = ts.x + ts.hits * xincr[d]; - y = ts.y + ts.hits * yincr[d]; - if (POSSIBLE(x, y) && (hit = cpufire(x, y))) { - ts.x = x; - ts.y = y; - ts.dir = d; - ts.hits++; - next = (hit == S_SUNK) ? RANDOM_FIRE : SECOND_PASS; - } else - next = RANDOM_FIRE; - break; - - case SECOND_PASS: /* kill squares not caught on first pass */ - x = ts.x + xincr[ts.dir]; - y = ts.y + yincr[ts.dir]; - if (POSSIBLE(x, y) && (hit = cpufire(x, y))) { - ts.x = x; - ts.y = y; - ts.hits++; - next = (hit == S_SUNK) ? RANDOM_FIRE : SECOND_PASS; - break; - } else - next = RANDOM_FIRE; - break; - } - - /* check for continuation and/or winner */ - if (salvo) { - (void) refresh(); - (void) sleep(1); - } - if (awinna() != -1) - return (FALSE); - -#ifdef DEBUG - (void) mvprintw(PROMPTLINE + 2, 0, - "New state %d, x=%d, y=%d, d=%d", - next, x, y, d); -#endif /* DEBUG */ - return ((hit) ? TRUE : FALSE); -} - -static int -playagain(void) -{ - int j; - ship_t *ss; - - for (ss = cpuship; ss < cpuship + SHIPTYPES; ss++) - for (j = 0; j < ss->length; j++) { - cgoto(ss->y + j * yincr[ss->dir], ss->x + j * xincr[ss->dir]); - (void) addch((chtype) ss->symbol); - } - - if (awinna()) - ++cpuwon; - else - ++plywon; - j = 18 + strlen(name); - if (plywon >= 10) - ++j; - if (cpuwon >= 10) - ++j; - (void) mvprintw(1, (COLWIDTH - j) / 2, - "%s: %d Computer: %d", name, plywon, cpuwon); - - prompt(2, (awinna())? "Want to be humiliated again, %s [yn]? " - : "Going to give me a chance for revenge, %s [yn]? ", name); - return (sgetc("YN") == 'Y'); -} - -static void -do_options(int c, char *op[]) -{ - register int i; - - if (c > 1) { - for (i = 1; i < c; i++) { - switch (op[i][0]) { - default: - case '?': - (void) fprintf(stderr, "Usage: battle [-s | -b] [-c]\n"); - (void) fprintf(stderr, "\tWhere the options are:\n"); - (void) fprintf(stderr, "\t-s : play a salvo game\n"); - (void) fprintf(stderr, "\t-b : play a blitz game\n"); - (void) fprintf(stderr, "\t-c : ships may be adjacent\n"); - ExitProgram(EXIT_FAILURE); - break; - case '-': - switch (op[i][1]) { - case 'b': - blitz = 1; - if (salvo == 1) { - (void) fprintf(stderr, - "Bad Arg: -b and -s are mutually exclusive\n"); - ExitProgram(EXIT_FAILURE); - } - break; - case 's': - salvo = 1; - if (blitz == 1) { - (void) fprintf(stderr, - "Bad Arg: -s and -b are mutually exclusive\n"); - ExitProgram(EXIT_FAILURE); - } - break; - case 'c': - closepack = 1; - break; - default: - (void) fprintf(stderr, - "Bad arg: type \"%s ?\" for usage message\n", - op[0]); - ExitProgram(EXIT_FAILURE); - } - } - } - } -} - -static int -scount(int who) -{ - register int i, shots; - register ship_t *sp; - - if (who) - sp = cpuship; /* count cpu shots */ - else - sp = plyship; /* count player shots */ - - for (i = 0, shots = 0; i < SHIPTYPES; i++, sp++) { - if (sp->hits >= sp->length) - continue; /* dead ship */ - else - shots++; - } - return (shots); -} - -int -main(int argc, char *argv[]) -{ - do_options(argc, argv); - - intro(); - do { - initgame(); - while (awinna() == -1) { - if (!blitz) { - if (!salvo) { - if (turn) - (void) cputurn(); - else - (void) plyturn(); - } else { - register int i; - - i = scount(turn); - while (i--) { - if (turn) { - if (cputurn() && awinna() != -1) - i = 0; - } else { - if (plyturn() && awinna() != -1) - i = 0; - } - } - } - } else - while (turn ? cputurn() : plyturn()) - continue; - turn = OTHER; - } - } while - (playagain()); - uninitgame(0); - /*NOTREACHED */ -} - -/* bs.c ends here */ diff --git a/contrib/ncurses/test/cardfile.c b/contrib/ncurses/test/cardfile.c deleted file mode 100644 index 8edbd1e4fa0f..000000000000 --- a/contrib/ncurses/test/cardfile.c +++ /dev/null @@ -1,434 +0,0 @@ -/**************************************************************************** - * Copyright (c) 1999-2001,2002 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "Software"), 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 1999 - * - * $Id: cardfile.c,v 1.11 2002/04/06 23:12:50 tom Exp $ - * - * File format: text beginning in column 1 is a title; other text forms the content. - */ - -#include - -#if HAVE_FORM_H && HAVE_PANEL_H && HAVE_LIBFORM && HAVE_LIBPANEL - -#include -#include - -#include - -#define VISIBLE_CARDS 10 -#define OFFSET_CARD 2 - -#ifndef CTRL -#define CTRL(x) ((x) & 0x1f) -#endif - -typedef struct _card { - struct _card *link; - PANEL *panel; - FORM *form; - char *title; - char *content; -} CARD; - -static CARD *all_cards; -static char default_name[] = "cardfile.dat"; - -#if !HAVE_STRDUP -#define strdup my_strdup -static char * -strdup(char *s) -{ - char *p = (char *) malloc(strlen(s) + 1); - if (p) - strcpy(p, s); - return (p); -} -#endif /* not HAVE_STRDUP */ - -static const char * -skip(const char *buffer) -{ - while (isspace(UChar(*buffer))) - buffer++; - return buffer; -} - -static void -trim(char *buffer) -{ - unsigned n = strlen(buffer); - while (n-- && isspace(UChar(buffer[n]))) - buffer[n] = 0; -} - -/*******************************************************************************/ - -static CARD * -add_title(const char *title) -{ - CARD *card, *p, *q; - - for (p = all_cards, q = 0; p != 0; q = p, p = p->link) { - int cmp = strcmp(p->title, title); - if (cmp == 0) - return p; - if (cmp > 0) - break; - } - - card = (CARD *) calloc(1, sizeof(CARD)); - card->title = strdup(title); - card->content = strdup(""); - - if (q == 0) { - card->link = all_cards; - all_cards = card; - } else { - card->link = q->link; - q->link = card; - } - - return card; -} - -static void -add_content(CARD * card, const char *content) -{ - unsigned total, offset; - - content = skip(content); - if ((total = strlen(content)) != 0) { - if ((offset = strlen(card->content)) != 0) { - total += 1 + offset; - card->content = (char *) realloc(card->content, total + 1); - strcpy(card->content + offset++, " "); - } else { - card->content = (char *) malloc(total + 1); - } - strcpy(card->content + offset, content); - } -} - -static CARD * -new_card(void) -{ - CARD *card = add_title(""); - add_content(card, ""); - return card; -} - -static CARD * -find_card(char *title) -{ - CARD *card; - - for (card = all_cards; card != 0; card = card->link) - if (!strcmp(card->title, title)) - break; - - return card; -} - -static void -read_data(char *fname) -{ - FILE *fp; - CARD *card = 0; - char buffer[BUFSIZ]; - - if ((fp = fopen(fname, "r")) != 0) { - while (fgets(buffer, sizeof(buffer), fp)) { - trim(buffer); - if (isspace(UChar(*buffer))) { - if (card == 0) - card = add_title(""); - add_content(card, buffer); - } else if ((card = find_card(buffer)) == 0) { - card = add_title(buffer); - } - } - fclose(fp); - } -} - -/*******************************************************************************/ - -static void -write_data(const char *fname) -{ - FILE *fp; - CARD *p = 0; - int n; - - if (!strcmp(fname, default_name)) - fname = "cardfile.out"; - - if ((fp = fopen(fname, "w")) != 0) { - for (p = all_cards; p != 0; p = p->link) { - FIELD **f = form_fields(p->form); - for (n = 0; f[n] != 0; n++) { - char *s = field_buffer(f[n], 0); - if (s != 0 - && (s = strdup(s)) != 0) { - trim(s); - fprintf(fp, "%s%s\n", n ? "\t" : "", s); - free(s); - } - } - } - fclose(fp); - } -} - -/*******************************************************************************/ - -/* - * Count the cards - */ -static int -count_cards(void) -{ - CARD *p; - int count = 0; - - for (p = all_cards; p != 0; p = p->link) - count++; - - return count; -} - -/* - * Shuffle the panels to keep them in a natural hierarchy. - */ -static void -order_cards(CARD * first, int depth) -{ - if (first) { - if (depth && first->link) - order_cards(first->link, depth - 1); - top_panel(first->panel); - } -} - -/* - * Return the next card in the list - */ -static CARD * -next_card(CARD * now) -{ - if (now->link) - now = now->link; - return now; -} - -/* - * Return the previous card in the list - */ -static CARD * -prev_card(CARD * now) -{ - CARD *p; - for (p = all_cards; p != 0; p = p->link) - if (p->link == now) - return p; - return now; -} - -/*******************************************************************************/ - -static int -form_virtualize(WINDOW *w) -{ - int c = wgetch(w); - - switch (c) { - case CTRL('W'): - return (MAX_FORM_COMMAND + 4); - case CTRL('N'): - return (MAX_FORM_COMMAND + 3); - case CTRL('P'): - return (MAX_FORM_COMMAND + 2); - case CTRL('Q'): - case 033: - return (MAX_FORM_COMMAND + 1); - - case KEY_BACKSPACE: - return (REQ_DEL_PREV); - case KEY_DC: - return (REQ_DEL_CHAR); - case KEY_LEFT: - return (REQ_LEFT_CHAR); - case KEY_RIGHT: - return (REQ_RIGHT_CHAR); - - case KEY_DOWN: - case KEY_NEXT: - return (REQ_NEXT_FIELD); - case KEY_UP: - case KEY_PREVIOUS: - return (REQ_PREV_FIELD); - - default: - return (c); - } -} - -/*******************************************************************************/ - -static void -cardfile(char *fname) -{ - WINDOW *win; - CARD *p; - CARD *top_card; - int visible_cards = count_cards(); - int panel_wide = COLS - (visible_cards * OFFSET_CARD); - int panel_high = LINES - (visible_cards * OFFSET_CARD) - 5; - int form_wide = panel_wide - 2; - int form_high = panel_high - 2; - int x = (visible_cards - 1) * OFFSET_CARD; - int y = 0; - int ch; - int finished = FALSE; - - move(LINES - 3, 0); - addstr("^Q/ESC -- exit form ^W -- writes data to file\n"); - addstr("^N -- go to next card ^P -- go to previous card\n"); - addstr("Arrow keys move left/right within a field, up/down between fields"); - - /* make a panel for each CARD */ - for (p = all_cards; p != 0; p = p->link) { - FIELD **f = (FIELD **) calloc(3, sizeof(FIELD *)); - - win = newwin(panel_high, panel_wide, x, y); - keypad(win, TRUE); - p->panel = new_panel(win); - box(win, 0, 0); - - /* ...and a form in each panel */ - f[0] = new_field(1, form_wide, 0, 0, 0, 0); - set_field_back(f[0], A_REVERSE); - set_field_buffer(f[0], 0, p->title); - - f[1] = new_field(form_high - 1, form_wide, 1, 0, 0, 0); - set_field_buffer(f[1], 0, p->content); - set_field_just(f[1], JUSTIFY_LEFT); - - f[2] = 0; - - p->form = new_form(f); - set_form_win(p->form, win); - set_form_sub(p->form, derwin(win, form_high, form_wide, 1, 1)); - post_form(p->form); - - x -= OFFSET_CARD; - y += OFFSET_CARD; - } - - order_cards(top_card = all_cards, visible_cards); - - while (!finished) { - update_panels(); - doupdate(); - - switch (form_driver(top_card->form, ch = - form_virtualize(panel_window(top_card->panel)))) { - case E_OK: - break; - case E_UNKNOWN_COMMAND: - switch (ch) { - case MAX_FORM_COMMAND + 1: - finished = TRUE; - break; - case MAX_FORM_COMMAND + 2: - top_card = prev_card(top_card); - order_cards(top_card, visible_cards); - break; - case MAX_FORM_COMMAND + 3: - top_card = next_card(top_card); - order_cards(top_card, visible_cards); - break; - case MAX_FORM_COMMAND + 4: - write_data(fname); - break; -#ifdef KEY_RESIZE - case KEY_RESIZE: - flash(); - break; -#endif - default: - beep(); - break; - } - break; - default: - flash(); - break; - } - } -} - -/*******************************************************************************/ - -int -main(int argc, char *argv[]) -{ - int n; - - initscr(); - cbreak(); - noecho(); - - if (argc > 1) { - for (n = 1; n < argc; n++) - read_data(argv[n]); - if (count_cards() == 0) - new_card(); - cardfile(argv[1]); - } else { - read_data(default_name); - if (count_cards() == 0) - new_card(); - cardfile(default_name); - } - - endwin(); - - ExitProgram(EXIT_SUCCESS); -} -#else -int -main(void) -{ - printf("This program requires the curses form and panel libraries\n"); - ExitProgram(EXIT_FAILURE); -} -#endif diff --git a/contrib/ncurses/test/cardfile.dat b/contrib/ncurses/test/cardfile.dat deleted file mode 100644 index deb4b76a7d85..000000000000 --- a/contrib/ncurses/test/cardfile.dat +++ /dev/null @@ -1,13 +0,0 @@ -title 1 - Some text for title1 - and some more text -title 2 - The quicker brown fox ran all over the lazy dog. -put a card before the first two - This is an example of a simple cardfile. -show a fourth card - The fourth card - has a large amount of data, - more than the other cards. - At least, that is what I thought it should do, since I want to see how well - the forms package handles justification. diff --git a/contrib/ncurses/test/configure b/contrib/ncurses/test/configure deleted file mode 100755 index 8d44c2bb41d4..000000000000 --- a/contrib/ncurses/test/configure +++ /dev/null @@ -1,2401 +0,0 @@ -#! /bin/sh - -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13.20000819 -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= -ac_default_prefix=/usr/local -# Any additions from configure.in: - -# Initialize some variables set by options. -# The variables have the same names as the options, with -# dashes changed to underlines. -build=NONE -cache_file=./config.cache -exec_prefix=NONE -host=NONE -no_create= -nonopt=NONE -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -target=NONE -verbose= -x_includes=NONE -x_libraries=NONE -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -# Initialize some other variables. -subdirs= -MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -ac_max_here_lines=12 - -ac_prev= -for ac_option -do - - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case "$ac_option" in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build="$ac_optarg" ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir="$ac_optarg" ;; - - -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; - - -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "enable_${ac_feature}='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] - --bindir=DIR user executables in DIR [EPREFIX/bin] - --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] - --libexecdir=DIR program executables in DIR [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data in DIR - [PREFIX/share] - --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data in DIR - [PREFIX/com] - --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] - --libdir=DIR object code libraries in DIR [EPREFIX/lib] - --includedir=DIR C header files in DIR [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] - --infodir=DIR info documentation in DIR [PREFIX/info] - --mandir=DIR man documentation in DIR [PREFIX/man] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM - run sed PROGRAM on installed program names -EOF - cat << EOF -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR -EOF -cat <&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "with_${ac_package}='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; - - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } - ;; - - *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" - ;; - - esac -done - -if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 - -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg -do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; - esac -done - -# NLS nuisances. -# Only set these to C if already set. These must not be set unconditionally -# because not all systems understand e.g. LANG=C (notably SCO). -# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! -# Non-C LC_CTYPE values break the ctype check. -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 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=ncurses.c - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } - else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } - fi -fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` - -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file -else - echo "creating cache $cache_file" - > $cache_file -fi - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -ac_exeext= -ac_objext=o -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - - - - -# Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:533: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:563: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_prog_rejected=no - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - break - fi - done - IFS="$ac_save_ifs" -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# -gt 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - set dummy "$ac_dir/$ac_word" "$@" - shift - ac_cv_prog_CC="$@" - fi -fi -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - if test -z "$CC"; then - case "`uname -s`" in - *win32* | *WIN32*) - # Extract the first word of "cl", so it can be a program name with args. -set dummy cl; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:614: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="cl" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - ;; - esac - fi - test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } -fi - -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:646: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -cat > conftest.$ac_ext << EOF - -#line 657 "configure" -#include "confdefs.h" - -main(){return(0);} -EOF -if { (eval echo configure:662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - ac_cv_prog_cc_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cc_cross=no - else - ac_cv_prog_cc_cross=yes - fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cc_works=no -fi -rm -fr conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 -if test $ac_cv_prog_cc_works = no; then - { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:688: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 -cross_compiling=$ac_cv_prog_cc_cross - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:693: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes -else - ac_cv_prog_gcc=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 - -if test $ac_cv_prog_gcc = yes; then - GCC=yes -else - GCC= -fi - -ac_test_CFLAGS="${CFLAGS+set}" -ac_save_CFLAGS="$CFLAGS" -CFLAGS= -echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:721: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then - ac_cv_prog_cc_g=yes -else - ac_cv_prog_cc_g=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 -if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi - - -CC_G_OPT="-g" -CC_SHARED_OPTS=unknown -CPPFLAGS="$CPPFLAGS" -DFT_DEP_SUFFIX="" -DFT_OBJ_SUBDIR=`pwd|sed -e's:.*/::'` -DFT_UPR_MODEL="NORMAL" -ECHO_LINK='@ echo linking $@ ... ;' -EXTRA_LIBS="" -LD="ld" -LDFLAGS_SHARED="" -LD_MODEL="" -LD_SHARED_OPTS="" -LIBTOOL="" -LIB_NAME=curses -LIB_PREFIX="-l" -LINK_TESTS="" -LINT=lint -LINT_OPTS="" -LOCAL_LDFLAGS="" -MATH_LIB="-lm" -PROG_EXT="" -TEST_ARGS="" -TEST_DEPS="" -cf_cv_abi_version="" -cf_cv_rel_version="" - - -# Check whether --with-5lib or --without-5lib was given. -if test "${with_5lib+set}" = set; then - withval="$with_5lib" - LIBS="-L/usr/5lib $LIBS" - CPPFLAGS="$CPPFLAGS -I/usr/5include" -fi - - - - -# Check whether --with-ncursesw or --without-ncursesw was given. -if test "${with_ncursesw+set}" = set; then - withval="$with_ncursesw" - - cat >> confdefs.h <<\EOF -#define _GNU_SOURCE 1 -EOF - - cat >> confdefs.h <<\EOF -#define _XOPEN_SOURCE_EXTENDED 1 -EOF - - echo $ac_n "checking for initscr""... $ac_c" 1>&6 -echo "configure:803: checking for initscr" >&5 -if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char initscr(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_initscr) || defined (__stub___initscr) -choke me -#else -initscr(); -#endif - -; return 0; } -EOF -if { (eval echo configure:831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_initscr=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_initscr=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'initscr`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 - - echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6 -echo "configure:850: checking for Gpm_Open in -lgpm" >&5 -ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lgpm $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo gpm | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <&6 -fi - - LIB_NAME=ncursesw - echo $ac_n "checking for putwc""... $ac_c" 1>&6 -echo "configure:898: checking for putwc" >&5 -if eval "test \"`echo '$''{'ac_cv_func_putwc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char putwc(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_putwc) || defined (__stub___putwc) -choke me -#else -putwc(); -#endif - -; return 0; } -EOF -if { (eval echo configure:926: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_putwc=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_putwc=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'putwc`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 - -echo $ac_n "checking for putwc in libutf8""... $ac_c" 1>&6 -echo "configure:945: checking for putwc in libutf8" >&5 -if eval "test \"`echo '$''{'cf_cv_libutf8'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - - cf_save_LIBS="$LIBS" - LIBS="-lutf8 $LIBS" -cat > conftest.$ac_ext < -int main() { -putwc(0,0); -; return 0; } -EOF -if { (eval echo configure:961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - cf_cv_libutf8=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cf_cv_libutf8=no -fi -rm -f conftest* - LIBS="$cf_save_LIBS" - -fi - -echo "$ac_t""$cf_cv_libutf8" 1>&6 - -if test "$cf_cv_libutf8" = yes ; then - cat >> confdefs.h <<\EOF -#define HAVE_LIBUTF8_H 1 -EOF - - LIBS="-lutf8 $LIBS" -fi - -fi - - for p in $HOME /usr/local /usr - do - if test -f $p/include/ncursesw/curses.h - then - CPPFLAGS="$CPPFLAGS -I$p/include/ncursesw" - test $p != /usr && CPPFLAGS="$CPPFLAGS -I$p/include" - test $p != /usr && LIBS="-L$p/lib $LIBS" - break - elif test $p != /usr - then - if test -f $p/include/curses.h - then - CPPFLAGS="$CPPFLAGS -I$p/include" - LIBS="-L$p/lib $LIBS" - break - fi - fi - done - -fi - -fi - - - -# Check whether --with-ncurses or --without-ncurses was given. -if test "${with_ncurses+set}" = set; then - withval="$with_ncurses" - echo $ac_n "checking for initscr""... $ac_c" 1>&6 -echo "configure:1016: checking for initscr" >&5 -if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char initscr(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_initscr) || defined (__stub___initscr) -choke me -#else -initscr(); -#endif - -; return 0; } -EOF -if { (eval echo configure:1044: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_initscr=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_initscr=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'initscr`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 - - echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6 -echo "configure:1063: checking for Gpm_Open in -lgpm" >&5 -ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lgpm $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo gpm | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <&6 -fi - - LIB_NAME=ncurses - for p in $HOME /usr/local /usr - do - if test -f $p/include/ncurses/curses.h - then - CPPFLAGS="$CPPFLAGS -I$p/include/ncurses" - test $p != /usr && CPPFLAGS="$CPPFLAGS -I$p/include" - test $p != /usr && LIBS="-L$p/lib $LIBS" - break - elif test $p != /usr - then - if test -f $p/include/curses.h - then - CPPFLAGS="$CPPFLAGS -I$p/include" - LIBS="-L$p/lib $LIBS" - break - fi - fi - done - -fi - -fi - - - - -echo $ac_n "checking for initscr""... $ac_c" 1>&6 -echo "configure:1137: checking for initscr" >&5 -if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char initscr(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_initscr) || defined (__stub___initscr) -choke me -#else -initscr(); -#endif - -; return 0; } -EOF -if { (eval echo configure:1165: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_initscr=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_initscr=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'initscr`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 - -echo $ac_n "checking for initscr in -l$LIB_NAME""... $ac_c" 1>&6 -echo "configure:1184: checking for initscr in -l$LIB_NAME" >&5 -ac_lib_var=`echo $LIB_NAME'_'initscr | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-l$LIB_NAME $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo $LIB_NAME | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <&6 -fi - -fi - -echo $ac_n "checking for form_driver in -lform""... $ac_c" 1>&6 -echo "configure:1233: checking for form_driver in -lform" >&5 -ac_lib_var=`echo form'_'form_driver | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lform $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo form | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <&6 -fi - -echo $ac_n "checking for menu_driver in -lmenu""... $ac_c" 1>&6 -echo "configure:1280: checking for menu_driver in -lmenu" >&5 -ac_lib_var=`echo menu'_'menu_driver | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lmenu $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo menu | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <&6 -fi - -echo $ac_n "checking for new_panel in -lpanel""... $ac_c" 1>&6 -echo "configure:1327: checking for new_panel in -lpanel" >&5 -ac_lib_var=`echo panel'_'new_panel | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lpanel $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo panel | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <&6 -fi - - -echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:1375: checking return type of signal handlers" >&5 -if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#include -#ifdef signal -#undef signal -#endif -#ifdef __cplusplus -extern "C" void (*signal (int, void (*)(int)))(int); -#else -void (*signal ()) (); -#endif - -int main() { -int i; -; return 0; } -EOF -if { (eval echo configure:1397: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_type_signal=void -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_type_signal=int -fi -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_type_signal" 1>&6 -cat >> confdefs.h <&6 -echo "configure:1417: checking how to run the C preprocessor" >&5 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1438: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1455: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -nologo -E" - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1472: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* -fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" -fi - CPP="$ac_cv_prog_CPP" -else - ac_cv_prog_CPP="$CPP" -fi -echo "$ac_t""$CPP" 1>&6 - -echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1497: checking for ANSI C header files" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#include -#include -#include -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1510: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - ac_cv_header_stdc=yes -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "memchr" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -if test "$cross_compiling" = yes; then - : -else - cat > conftest.$ac_ext < -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } - -EOF -if { (eval echo configure:1577: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_header_stdc=no -fi -rm -fr conftest* -fi - -fi -fi - -echo "$ac_t""$ac_cv_header_stdc" 1>&6 -if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF -#define STDC_HEADERS 1 -EOF - -fi - -echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:1601: checking whether time.h and sys/time.h may both be included" >&5 -if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#include -#include -int main() { -struct tm *tp; -; return 0; } -EOF -if { (eval echo configure:1615: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_header_time=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_time=no -fi -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_header_time" 1>&6 -if test $ac_cv_header_time = yes; then - cat >> confdefs.h <<\EOF -#define TIME_WITH_SYS_TIME 1 -EOF - -fi - -for ac_hdr in \ -form.h \ -getopt.h \ -locale.h \ -menu.h \ -nc_alloc.h \ -nomacros.h \ -panel.h \ -sys/ioctl.h \ -sys/select.h \ -sys/time.h \ -termios.h \ -unistd.h \ - -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1652: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1662: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 -fi -done - - -for ac_func in \ -getnstr \ -gettimeofday \ -napms \ -resize_term \ -resizeterm \ -strdup \ -use_default_colors \ -vsscanf \ -wresize \ - -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1702: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:1730: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 -fi -done - - -echo $ac_n "checking for function curses_version""... $ac_c" 1>&6 -echo "configure:1756: checking for function curses_version" >&5 -if eval "test \"`echo '$''{'cf_cv_func_curses_version'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - -if test "$cross_compiling" = yes; then - cf_cv_func_curses_version=unknown -else - cat > conftest.$ac_ext < -int main() -{ - char temp[1024]; - sprintf(temp, "%s\n", curses_version()); - exit(0); -} - -EOF -if { (eval echo configure:1777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - cf_cv_func_curses_version=yes - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - cf_cv_func_curses_version=no - -fi -rm -fr conftest* -fi - -rm -f core -fi - -echo "$ac_t""$cf_cv_func_curses_version" 1>&6 -test "$cf_cv_func_curses_version" = yes && cat >> confdefs.h <<\EOF -#define HAVE_CURSES_VERSION 1 -EOF - - -echo $ac_n "checking for alternate character set array""... $ac_c" 1>&6 -echo "configure:1801: checking for alternate character set array" >&5 -if eval "test \"`echo '$''{'cf_cv_curses_acs_map'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - -cf_cv_curses_acs_map=unknown -for name in acs_map _acs_map __acs_map _nc_acs_map -do -cat > conftest.$ac_ext < - -int main() { - -$name['k'] = ACS_PLUS - -; return 0; } -EOF -if { (eval echo configure:1821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - cf_cv_curses_acs_map=$name; break -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -done - -fi - -echo "$ac_t""$cf_cv_curses_acs_map" 1>&6 - -test "$cf_cv_curses_acs_map" != unknown && cat >> confdefs.h <&6 -echo "configure:1841: checking for wide alternate character set array" >&5 -if eval "test \"`echo '$''{'cf_cv_curses_wacs_map'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - -cf_cv_curses_wacs_map=unknown -for name in wacs_map _wacs_map __wacs_map _nc_wacs -do -cat > conftest.$ac_ext < - -int main() { - -$name['k'] = *WACS_PLUS - -; return 0; } -EOF -if { (eval echo configure:1864: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - cf_cv_curses_wacs_map=$name; break -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -done - -fi - -echo "$ac_t""$cf_cv_curses_wacs_map" 1>&6 - -test "$cf_cv_curses_wacs_map" != unknown && cat >> confdefs.h <&6 -echo "configure:1887: checking for type attr_t in curses.h" >&5 -cat > conftest.$ac_ext < -int main() { - -attr_t foo - -; return 0; } -EOF -if { (eval echo configure:1902: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - cf_result=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cf_result=no -fi -rm -f conftest* -echo "$ac_t""$cf_result" 1>&6 -if test $cf_result = yes ; then - -cf_result=`echo "have_type_attr_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` - - cat >> confdefs.h <> confdefs.h <&6 -echo "configure:1930: checking for type mbstate_t in curses.h" >&5 -cat > conftest.$ac_ext < -int main() { - -mbstate_t foo - -; return 0; } -EOF -if { (eval echo configure:1945: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - cf_result=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cf_result=no -fi -rm -f conftest* -echo "$ac_t""$cf_result" 1>&6 -if test $cf_result = yes ; then - -cf_result=`echo "have_type_mbstate_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` - - cat >> confdefs.h <> confdefs.h <&6 -echo "configure:1974: checking if sys/time.h works with sys/select.h" >&5 -if eval "test \"`echo '$''{'cf_cv_sys_time_select'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - -cat > conftest.$ac_ext < -#ifdef HAVE_SYS_TIME_H -#include -#endif -#ifdef HAVE_SYS_SELECT_H -#include -#endif - -int main() { - -; return 0; } -EOF -if { (eval echo configure:1995: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - cf_cv_sys_time_select=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cf_cv_sys_time_select=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$cf_cv_sys_time_select" 1>&6 -test "$cf_cv_sys_time_select" = yes && cat >> confdefs.h <<\EOF -#define HAVE_SYS_TIME_SELECT 1 -EOF - - - -trap '' 1 2 15 -cat > confcache <<\EOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. -# -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. -# -EOF -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -(set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote substitution - # turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - -e "s/'/'\\\\''/g" \ - -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' - ;; - esac >> confcache -if cmp -s $cache_file confcache; then - : -else - if test -w $cache_file; then - echo "updating cache $cache_file" - cat confcache > $cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' -fi - -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - -DEFS=-DHAVE_CONFIG_H - -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} - -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS </dev/null | sed 1q`: -# -# $0 $ac_configure_args -# -# Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. - -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option -do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.13.20000819" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac -done - -ac_given_srcdir=$srcdir - -trap 'rm -fr `echo "Makefile ncurses_cfg.h:ncurses_tst.hin" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 -EOF -cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF -$ac_vpsub -$extrasub -s%@SHELL@%$SHELL%g -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@FFLAGS@%$FFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@bindir@%$bindir%g -s%@sbindir@%$sbindir%g -s%@libexecdir@%$libexecdir%g -s%@datadir@%$datadir%g -s%@sysconfdir@%$sysconfdir%g -s%@sharedstatedir@%$sharedstatedir%g -s%@localstatedir@%$localstatedir%g -s%@libdir@%$libdir%g -s%@includedir@%$includedir%g -s%@oldincludedir@%$oldincludedir%g -s%@infodir@%$infodir%g -s%@mandir@%$mandir%g -s%@CC@%$CC%g -s%@CC_G_OPT@%$CC_G_OPT%g -s%@CC_SHARED_OPTS@%$CC_SHARED_OPTS%g -s%@DFT_DEP_SUFFIX@%$DFT_DEP_SUFFIX%g -s%@DFT_OBJ_SUBDIR@%$DFT_OBJ_SUBDIR%g -s%@DFT_UPR_MODEL@%$DFT_UPR_MODEL%g -s%@ECHO_LINK@%$ECHO_LINK%g -s%@EXTRA_LIBS@%$EXTRA_LIBS%g -s%@LD@%$LD%g -s%@LDFLAGS_SHARED@%$LDFLAGS_SHARED%g -s%@LD_MODEL@%$LD_MODEL%g -s%@LD_SHARED_OPTS@%$LD_SHARED_OPTS%g -s%@LIBTOOL@%$LIBTOOL%g -s%@LIB_NAME@%$LIB_NAME%g -s%@LIB_PREFIX@%$LIB_PREFIX%g -s%@LINK_TESTS@%$LINK_TESTS%g -s%@LINT@%$LINT%g -s%@LINT_OPTS@%$LINT_OPTS%g -s%@LOCAL_LDFLAGS@%$LOCAL_LDFLAGS%g -s%@MATH_LIB@%$MATH_LIB%g -s%@PROG_EXT@%$PROG_EXT%g -s%@TEST_ARGS@%$TEST_ARGS%g -s%@TEST_DEPS@%$TEST_DEPS%g -s%@cf_cv_abi_version@%$cf_cv_abi_version%g -s%@cf_cv_rel_version@%$cf_cv_rel_version%g -s%@CPP@%$CPP%g - -CEOF -EOF - -cat >> $CONFIG_STATUS <<\EOF - -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file - else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file - fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file - else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" - else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" - fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` - fi -done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat -fi -EOF - -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* - -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' -ac_dC='\3' -ac_dD='%g' -# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". -ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='\([ ]\)%\1#\2define\3' -ac_uC=' ' -ac_uD='\4%g' -# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_eB='$%\1#\2define\3' -ac_eC=' ' -ac_eD='%g' - -if test "${CONFIG_HEADERS+set}" != set; then -EOF -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -fi -for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - echo creating $ac_file - - rm -f conftest.frag conftest.in conftest.out - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - cat $ac_file_inputs > conftest.in - -EOF - - -# Transform confdefs.h into a list of #define's. We won't use it as a sed -# script, but as data to insert where we see @DEFS@. We expect AC_SAVE_DEFS to -# be either 'cat' or 'sort'. -sort confdefs.h >conftest.vals - -# Break up conftest.vals because some shells have a limit on -# the size of here documents, and old seds have small limits too. - -rm -f conftest.tail -echo ' rm -f conftest.frag' >> $CONFIG_STATUS -while : -do - ac_lines=`grep -c . conftest.vals` - # grep -c gives empty output for an empty file on some AIX systems. - if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi - # Write chunks of a limited-size here document to conftest.frag. - echo ' cat >> conftest.frag <> $CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS - echo 'CEOF' >> $CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail - rm -f conftest.vals - mv conftest.tail conftest.vals -done -rm -f conftest.vals - -# Run sed to substitute the contents of conftest.frag into conftest.in at the -# marker @DEFS@. -echo ' cat >> conftest.edit < conftest.out -rm -f conftest.in -mv conftest.out conftest.in -rm -f conftest.edit conftest.frag -' >> $CONFIG_STATUS - - -cat >> $CONFIG_STATUS <<\EOF - rm -f conftest.frag conftest.h - echo "/* $ac_file. Generated automatically by configure. */" > conftest.h - cat conftest.in >> conftest.h - rm -f conftest.in - if cmp -s $ac_file conftest.h 2>/dev/null; then - echo "$ac_file is unchanged" - rm -f conftest.h - else - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - fi - rm -f $ac_file - mv conftest.h $ac_file - fi -fi; done - -EOF -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -# Extra commands, if any - - cat >>Makefile <>Makefile <],[putwc(0,0);], - [cf_cv_libutf8=yes], - [cf_cv_libutf8=no]) - LIBS="$cf_save_LIBS" -]) - -if test "$cf_cv_libutf8" = yes ; then - AC_DEFINE(HAVE_LIBUTF8_H) - LIBS="-lutf8 $LIBS" -fi -])dnl - -dnl --------------------------------------------------------------------------- -dnl NcursesW, installed in conventional location -AC_ARG_WITH(ncursesw, - [ --with-ncursesw use wide ncurses-libraries (installed)], - [ - AC_DEFINE(_GNU_SOURCE) - AC_DEFINE(_XOPEN_SOURCE_EXTENDED) - AC_CHECK_FUNC(initscr,,[ - AC_CHECK_LIB(gpm,Gpm_Open) - LIB_NAME=ncursesw - AC_CHECK_FUNC(putwc,,[CF_LIBUTF8]) - for p in $HOME /usr/local /usr - do - if test -f $p/include/ncursesw/curses.h - then - CPPFLAGS="$CPPFLAGS -I$p/include/ncursesw" - test $p != /usr && CPPFLAGS="$CPPFLAGS -I$p/include" - test $p != /usr && LIBS="-L$p/lib $LIBS" - break - elif test $p != /usr - then - if test -f $p/include/curses.h - then - CPPFLAGS="$CPPFLAGS -I$p/include" - LIBS="-L$p/lib $LIBS" - break - fi - fi - done - ],[test -d /usr/ccs/lib && LIBS="-L/usr/ccs/lib $LIBS"])]) - -dnl Ncurses, installed in conventional location -AC_ARG_WITH(ncurses, - [ --with-ncurses use ncurses-libraries (installed)], - [AC_CHECK_FUNC(initscr,,[ - AC_CHECK_LIB(gpm,Gpm_Open) - LIB_NAME=ncurses - for p in $HOME /usr/local /usr - do - if test -f $p/include/ncurses/curses.h - then - CPPFLAGS="$CPPFLAGS -I$p/include/ncurses" - test $p != /usr && CPPFLAGS="$CPPFLAGS -I$p/include" - test $p != /usr && LIBS="-L$p/lib $LIBS" - break - elif test $p != /usr - then - if test -f $p/include/curses.h - then - CPPFLAGS="$CPPFLAGS -I$p/include" - LIBS="-L$p/lib $LIBS" - break - fi - fi - done - ],[test -d /usr/ccs/lib && LIBS="-L/usr/ccs/lib $LIBS"])]) - -dnl If we've not specified a library, assume we're using sysvr4 libraries -dnl installed conventionally (e.g., SunOS 5.x - solaris). - -dnl Autoconf builds up the $LIBS in reverse order - -AC_CHECK_FUNC(initscr,,[ -AC_CHECK_LIB($LIB_NAME,initscr)]) -AC_CHECK_LIB(form,form_driver) -AC_CHECK_LIB(menu,menu_driver) -AC_CHECK_LIB(panel,new_panel) - -AC_TYPE_SIGNAL - -AC_STDC_HEADERS -AC_HEADER_TIME -AC_CHECK_HEADERS( \ -form.h \ -getopt.h \ -locale.h \ -menu.h \ -nc_alloc.h \ -nomacros.h \ -panel.h \ -sys/ioctl.h \ -sys/select.h \ -sys/time.h \ -termios.h \ -unistd.h \ -) - -AC_CHECK_FUNCS( \ -getnstr \ -gettimeofday \ -napms \ -resize_term \ -resizeterm \ -strdup \ -use_default_colors \ -vsscanf \ -wresize \ -) - -dnl --------------------------------------------------------------------------- -dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS. -dnl It's a character string "SVR4", not documented. -AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[ -AC_TRY_RUN([ -#include -int main() -{ - char temp[1024]; - sprintf(temp, "%s\n", curses_version()); - exit(0); -}] -,[cf_cv_func_curses_version=yes] -,[cf_cv_func_curses_version=no] -,[cf_cv_func_curses_version=unknown]) -rm -f core]) -test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION) - -dnl --------------------------------------------------------------------------- -dnl Check for likely values of acs_map[]: -AC_CACHE_CHECK(for alternate character set array, cf_cv_curses_acs_map,[ -cf_cv_curses_acs_map=unknown -for name in acs_map _acs_map __acs_map _nc_acs_map -do -AC_TRY_LINK([ -#include -],[ -$name['k'] = ACS_PLUS -],[cf_cv_curses_acs_map=$name; break]) -done -]) - -test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map) - -dnl --------------------------------------------------------------------------- -dnl Check for likely values of wacs_map[]: -AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[ -cf_cv_curses_wacs_map=unknown -for name in wacs_map _wacs_map __wacs_map _nc_wacs -do -AC_TRY_LINK([ -#ifndef _XOPEN_SOURCE_EXTENDED -#define _XOPEN_SOURCE_EXTENDED -#endif -#include -],[ -$name['k'] = *WACS_PLUS -],[cf_cv_curses_wacs_map=$name; break]) -done -]) - -test "$cf_cv_curses_wacs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_WACS_ARRAY,$cf_cv_curses_wacs_map) - -dnl --------------------------------------------------------------------------- -dnl Make an uppercase version of a variable -dnl $1=uppercase($2) -AC_DEFUN([CF_UPPER], -[ -$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` -])dnl - -dnl --------------------------------------------------------------------------- -dnl Check if curses.h defines the given type -AC_DEFUN([CF_CURSES_TYPE], -[ -AC_MSG_CHECKING(for type $1 in curses.h) -AC_TRY_COMPILE([ -#ifndef _XOPEN_SOURCE_EXTENDED -#define _XOPEN_SOURCE_EXTENDED -#endif -#include ],[ -$1 foo -],cf_result=yes,cf_result=no) -AC_MSG_RESULT($cf_result) -if test $cf_result = yes ; then - CF_UPPER(cf_result,have_type_$1) - AC_DEFINE_UNQUOTED($cf_result) -else - AC_DEFINE_UNQUOTED($1,$2) -fi -])dnl - -CF_CURSES_TYPE(attr_t,long) -CF_CURSES_TYPE(mbstate_t,long) - -dnl --------------------------------------------------------------------------- -dnl Check if we can include with ; this breaks on -dnl older SCO configurations. -dnl [CF_SYS_TIME_SELECT] - -AC_MSG_CHECKING(if sys/time.h works with sys/select.h) -AC_CACHE_VAL(cf_cv_sys_time_select,[ -AC_TRY_COMPILE([ -#include -#ifdef HAVE_SYS_TIME_H -#include -#endif -#ifdef HAVE_SYS_SELECT_H -#include -#endif -],[],[cf_cv_sys_time_select=yes], - [cf_cv_sys_time_select=no]) - ]) -AC_MSG_RESULT($cf_cv_sys_time_select) -test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT) - -dnl --------------------------------------------------------------------------- - -AC_OUTPUT(Makefile,[ - cat >>Makefile <>Makefile < 1998 - * - * $Id: ditto.c,v 1.4 2001/09/15 21:53:37 tom Exp $ - * - * The program illustrates how to set up multiple screens from a single - * program. Invoke the program by specifying another terminal on the same - * machine by specifying its device, e.g., - * ditto /dev/ttyp1 - */ -#include -#include -#include - -typedef struct { - FILE *input; - FILE *output; - SCREEN *screen; -} DITTO; - -static void -failed(const char *s) -{ - perror(s); - ExitProgram(EXIT_FAILURE); -} - -static void -usage(void) -{ - fprintf(stderr, "usage: ditto [terminal1 ...]\n"); - ExitProgram(EXIT_FAILURE); -} - -static FILE * -open_tty(char *path) -{ - FILE *fp; - struct stat sb; - - if (stat(path, &sb) < 0) - failed(path); - if ((sb.st_mode & S_IFMT) != S_IFCHR) { - errno = ENOTTY; - failed(path); - } - fp = fopen(path, "a+"); - if (fp == 0) - failed(path); - printf("opened %s\n", path); - return fp; -} - -int -main( - int argc GCC_UNUSED, - char *argv[]GCC_UNUSED) -{ - int j; - int active_tty = 0; - DITTO *data; - - if (argc <= 1) - usage(); - - if ((data = (DITTO *) calloc(argc, sizeof(DITTO))) == 0) - failed("calloc data"); - - data[0].input = stdin; - data[0].output = stdout; - for (j = 1; j < argc; j++) { - data[j].input = - data[j].output = open_tty(argv[j]); - } - - /* - * If we got this far, we have open connection(s) to the terminal(s). - * Set up the screens. - */ - for (j = 0; j < argc; j++) { - active_tty++; - data[j].screen = newterm( - (char *) 0, /* assume $TERM is the same */ - data[j].output, - data[j].input); - if (data[j].screen == 0) - failed("newterm"); - cbreak(); - noecho(); - scrollok(stdscr, TRUE); - } - - /* - * Loop, reading characters from any of the inputs and writing to all - * of the screens. - */ - for (;;) { - int ch; - set_term(data[0].screen); - ch = getch(); - if (ch == ERR) - continue; - if (ch == 4) - break; - for (j = 0; j < argc; j++) { - set_term(data[j].screen); - addch(ch); - refresh(); - } - } - - /* - * Cleanup and exit - */ - for (j = argc - 1; j >= 0; j--) { - set_term(data[j].screen); - endwin(); - } - ExitProgram(EXIT_SUCCESS); -} diff --git a/contrib/ncurses/test/dots.c b/contrib/ncurses/test/dots.c deleted file mode 100644 index 2e0190fc61bb..000000000000 --- a/contrib/ncurses/test/dots.c +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** - * Copyright (c) 1999-2001,2002 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "Software"), 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 1999 - * - * $Id: dots.c,v 1.8 2002/04/06 21:33:42 tom Exp $ - * - * A simple demo of the terminfo interface. - */ -#include - -#include - -#define valid(s) ((s != 0) && s != (char *)-1) - -static bool interrupted = FALSE; - -static int -outc(int c) -{ - if (interrupted) { - char tmp = c; - write(STDOUT_FILENO, &tmp, 1); - } else { - putc(c, stdout); - } - return 0; -} - -static bool -outs(char *s) -{ - if (valid(s)) { - tputs(s, 1, outc); - return TRUE; - } - return FALSE; -} - -static void -cleanup(void) -{ - outs(exit_attribute_mode); - if (!outs(orig_colors)) - outs(orig_pair); - outs(clear_screen); - outs(cursor_normal); -} - -static void -onsig(int n GCC_UNUSED) -{ - interrupted = TRUE; - cleanup(); - ExitProgram(EXIT_FAILURE); -} - -static float -ranf(void) -{ - long r = (rand() & 077777); - return ((float) r / 32768.); -} - -int -main( - int argc GCC_UNUSED, - char *argv[]GCC_UNUSED) -{ - int x, y, z, j, p; - float r; - float c; - - for (j = SIGHUP; j <= SIGTERM; j++) - if (signal(j, SIG_IGN) != SIG_IGN) - signal(j, onsig); - - srand(time(0)); - setupterm((char *) 0, 1, (int *) 0); - outs(clear_screen); - outs(cursor_invisible); - if (max_colors > 1) { - if (!valid(set_a_foreground) - || !valid(set_a_background) - || (!valid(orig_colors) && !valid(orig_pair))) - max_colors = -1; - } - - r = (float) (lines - 4); - c = (float) (columns - 4); - - for (;;) { - x = (int) (c * ranf()) + 2; - y = (int) (r * ranf()) + 2; - p = (ranf() > 0.9) ? '*' : ' '; - - tputs(tparm3(cursor_address, y, x), 1, outc); - if (max_colors > 0) { - z = (int) (ranf() * max_colors); - if (ranf() > 0.01) { - tputs(tparm2(set_a_foreground, z), 1, outc); - } else { - tputs(tparm2(set_a_background, z), 1, outc); - } - } else if (valid(exit_attribute_mode) - && valid(enter_reverse_mode)) { - if (ranf() <= 0.01) - outs((ranf() > 0.6) ? enter_reverse_mode : - exit_attribute_mode); - } - outc(p); - fflush(stdout); - } -} diff --git a/contrib/ncurses/test/filter.c b/contrib/ncurses/test/filter.c deleted file mode 100644 index c3ea3c1882b2..000000000000 --- a/contrib/ncurses/test/filter.c +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** - * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "Software"), to deal in the Software without restriction, including * - * without limitation the rights to use, copy, modify, merge, publish, * - * distribute, distribute with modifications, sublicense, and/or sell * - * copies of the Software, and to permit persons to whom the Software is * - * furnished to do so, subject to the following conditions: * - * * - * The above copyright notice and this permission notice shall be included * - * in all copies or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * - * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * * - * Except as contained in this notice, the name(s) of the above copyright * - * holders shall not be used in advertising or otherwise to promote the * - * sale, use or other dealings in this Software without prior written * - * authorization. * - ****************************************************************************/ - -/* - * Author: Thomas E. Dickey 1998 - * - * $Id: filter.c,v 1.7 2002/03/23 23:02:15 tom Exp $ - */ -#include - -/* - * An example of the 'filter()' function in ncurses, this program prompts - * for commands and executes them (like a command shell). It illustrates - * how ncurses can be used to implement programs that are not full-screen. - * - * Ncurses differs slightly from SVr4 curses. The latter does not flush its - * state when exiting program mode, so the attributes on the command lines of - * this program 'bleed' onto the executed commands. Rather than use the - * reset_shell_mode() and reset_prog_mode() functions, we could invoke endwin() - * and refresh(), but that does not work any better. - */ - -static int -new_command(char *buffer, int length, attr_t underline) -{ - int code; - - attron(A_BOLD); - printw("Command: "); - attron(underline); - code = getnstr(buffer, length); - attroff(underline); - attroff(A_BOLD); - printw("\n"); - - return code; -} - -int -main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) -{ - char buffer[80]; - attr_t underline; - - filter(); - (void) newterm((char *) 0, stdout, stdin); - cbreak(); - keypad(stdscr, TRUE); - - if (has_colors()) { - int background = COLOR_BLACK; - start_color(); -#if HAVE_USE_DEFAULT_COLORS - if (use_default_colors() != ERR) - background = -1; -#endif - init_pair(1, COLOR_CYAN, background); - underline = COLOR_PAIR(1); - } else { - underline = A_UNDERLINE; - } - - while (new_command(buffer, sizeof(buffer) - 1, underline) != ERR - && strlen(buffer) != 0) { - reset_shell_mode(); - printf("\n"); - fflush(stdout); - system(buffer); - reset_prog_mode(); - touchwin(stdscr); - erase(); - refresh(); - } - printw("done"); - refresh(); - endwin(); - ExitProgram(EXIT_SUCCESS); -} diff --git a/contrib/ncurses/test/firework.c b/contrib/ncurses/test/firework.c deleted file mode 100644 index 3d84c4399139..000000000000 --- a/contrib/ncurses/test/firework.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * $Id: firework.c,v 1.20 2002/03/23 21:41:42 tom Exp $ - */ -#include - -#include - -static int my_bg = COLOR_BLACK; - -static void -cleanup(void) -{ - curs_set(1); - endwin(); -} - -static RETSIGTYPE -onsig(int n GCC_UNUSED) -{ - cleanup(); - ExitProgram(EXIT_FAILURE); -} - -static void -showit(void) -{ - int ch; - napms(120); - if ((ch = getch()) != ERR) { -#ifdef KEY_RESIZE - if (ch == KEY_RESIZE) { - erase(); - } else -#endif - if (ch == 'q') { - cleanup(); - ExitProgram(EXIT_SUCCESS); - } else if (ch == 's') { - nodelay(stdscr, FALSE); - } else if (ch == ' ') { - nodelay(stdscr, TRUE); - } - } -} - -static -int -get_colour(chtype * bold) -{ - int attr; - attr = (rand() % 16) + 1; - - *bold = A_NORMAL; - if (attr > 8) { - *bold = A_BOLD; - attr &= 7; - } - return (attr); -} - -static -void -explode(int row, int col) -{ - chtype bold; - erase(); - mvprintw(row, col, "-"); - showit(); - - init_pair(1, get_colour(&bold), my_bg); - attrset(COLOR_PAIR(1) | bold); - mvprintw(row - 1, col - 1, " - "); - mvprintw(row + 0, col - 1, "-+-"); - mvprintw(row + 1, col - 1, " - "); - showit(); - - init_pair(1, get_colour(&bold), my_bg); - attrset(COLOR_PAIR(1) | bold); - mvprintw(row - 2, col - 2, " --- "); - mvprintw(row - 1, col - 2, "-+++-"); - mvprintw(row + 0, col - 2, "-+#+-"); - mvprintw(row + 1, col - 2, "-+++-"); - mvprintw(row + 2, col - 2, " --- "); - showit(); - - init_pair(1, get_colour(&bold), my_bg); - attrset(COLOR_PAIR(1) | bold); - mvprintw(row - 2, col - 2, " +++ "); - mvprintw(row - 1, col - 2, "++#++"); - mvprintw(row + 0, col - 2, "+# #+"); - mvprintw(row + 1, col - 2, "++#++"); - mvprintw(row + 2, col - 2, " +++ "); - showit(); - - init_pair(1, get_colour(&bold), my_bg); - attrset(COLOR_PAIR(1) | bold); - mvprintw(row - 2, col - 2, " # "); - mvprintw(row - 1, col - 2, "## ##"); - mvprintw(row + 0, col - 2, "# #"); - mvprintw(row + 1, col - 2, "## ##"); - mvprintw(row + 2, col - 2, " # "); - showit(); - - init_pair(1, get_colour(&bold), my_bg); - attrset(COLOR_PAIR(1) | bold); - mvprintw(row - 2, col - 2, " # # "); - mvprintw(row - 1, col - 2, "# #"); - mvprintw(row + 0, col - 2, " "); - mvprintw(row + 1, col - 2, "# #"); - mvprintw(row + 2, col - 2, " # # "); - showit(); -} - -int -main( - int argc GCC_UNUSED, - char *argv[]GCC_UNUSED) -{ - int j; - int start, end, row, diff, flag = 0, direction; - unsigned seed; - - for (j = SIGHUP; j <= SIGTERM; j++) - if (signal(j, SIG_IGN) != SIG_IGN) - signal(j, onsig); - - initscr(); - noecho(); - cbreak(); - keypad(stdscr, TRUE); - nodelay(stdscr, TRUE); - - if (has_colors()) { - start_color(); -#if HAVE_USE_DEFAULT_COLORS - if (use_default_colors() == OK) - my_bg = -1; -#endif - } - curs_set(0); - - seed = time((time_t *) 0); - srand(seed); - for (;;) { - do { - start = rand() % (COLS - 3); - end = rand() % (COLS - 3); - start = (start < 2) ? 2 : start; - end = (end < 2) ? 2 : end; - direction = (start > end) ? -1 : 1; - diff = abs(start - end); - } while (diff < 2 || diff >= LINES - 2); - attrset(A_NORMAL); - for (row = 0; row < diff; row++) { - mvprintw(LINES - row, start + (row * direction), - (direction < 0) ? "\\" : "/"); - if (flag++) { - showit(); - erase(); - flag = 0; - } - } - if (flag++) { - showit(); - flag = 0; - } - seed = time((time_t *) 0); - srand(seed); - explode(LINES - row, start + (diff * direction)); - erase(); - showit(); - } -} diff --git a/contrib/ncurses/test/firstlast.c b/contrib/ncurses/test/firstlast.c deleted file mode 100644 index 6a79a33fbfb1..000000000000 --- a/contrib/ncurses/test/firstlast.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This test was written by Alexander V. Lukyanov to demonstrate difference - * between ncurses 4.1 and SVR4 curses - * - * $Id: firstlast.c,v 1.3 2001/09/15 21:46:34 tom Exp $ - */ - -#include - -static void -fill(WINDOW *w, const char *str) -{ - const char *s; - for (;;) { - for (s = str; *s; s++) { - if (waddch(w, *s) == ERR) { - wmove(w, 0, 0); - return; - } - } - } -} - -int -main( - int argc GCC_UNUSED, - char *argv[]GCC_UNUSED) -{ - WINDOW *large, *small; - initscr(); - noecho(); - - large = newwin(20, 60, 2, 10); - small = newwin(10, 30, 7, 25); - - /* test 1 - addch */ - fill(large, "LargeWindow"); - - refresh(); - wrefresh(large); - wrefresh(small); - - mvwaddstr(small, 5, 5, " Test String "); - wrefresh(small); - getch(); - - touchwin(large); - wrefresh(large); - - mvwaddstr(small, 5, 5, " Test <***************> String "); - wrefresh(small); - - /* DIFFERENCE! */ - getch(); - - /* test 2: erase */ - erase(); - refresh(); - getch(); - - /* test 3: clrtoeol */ - werase(small); - wrefresh(small); - touchwin(large); - wrefresh(large); - wmove(small, 5, 0); - waddstr(small, " clrtoeol>"); - wclrtoeol(small); - wrefresh(small); - - /* DIFFERENCE! */ ; - getch(); - - /* test 4: clrtobot */ - werase(small); - wrefresh(small); - touchwin(large); - wrefresh(large); - wmove(small, 5, 3); - waddstr(small, " clrtobot>"); - wclrtobot(small); - wrefresh(small); - - /* DIFFERENCE! */ - getch(); - - endwin(); - - ExitProgram(EXIT_SUCCESS); -} diff --git a/contrib/ncurses/test/gdc.6 b/contrib/ncurses/test/gdc.6 deleted file mode 100644 index 7fa60de9edf8..000000000000 --- a/contrib/ncurses/test/gdc.6 +++ /dev/null @@ -1,22 +0,0 @@ -.TH GDC 6 -.SH NAME -gdc \- grand digital clock (curses) -.SH SYNOPSIS -.B gdc -[-s] [ -.I n -] -.SH DESCRIPTION -.I Gdc -runs a digital clock made of reverse-video blanks on a curses -compatible VDU screen. With an optional numeric argument -.I n -it stops after -.I n -seconds (default never). -The optional -.B -s -flag makes digits scroll as they change. In this curses mode implementation, -the scrolling option has trouble keeping up. -.SH AUTHOR -Amos Shapir, modified for curses by John Lupien. diff --git a/contrib/ncurses/test/gdc.c b/contrib/ncurses/test/gdc.c deleted file mode 100644 index 8b37b1e4452c..000000000000 --- a/contrib/ncurses/test/gdc.c +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Grand digital clock for curses compatible terminals - * Usage: gdc [-s] [n] -- run for n seconds (default infinity) - * Flags: -s: scroll - * - * modified 10-18-89 for curses (jrl) - * 10-18-89 added signal handling - * - * $Id: gdc.c,v 1.21 2002/03/23 22:17:24 tom Exp $ - */ - -#include - -#include - -#define YBASE 10 -#define XBASE 10 -#define XLENGTH 54 -#define YDEPTH 5 - -static short disp[11] = -{ - 075557, 011111, 071747, 071717, 055711, - 074717, 074757, 071111, 075757, 075717, 002020 -}; -static long older[6], next[6], newer[6], mask; - -static int sigtermed = 0; -static bool redirected = FALSE; -static bool hascolor = FALSE; - -static RETSIGTYPE -sighndl(int signo) -{ - signal(signo, sighndl); - sigtermed = signo; - if (redirected) { - endwin(); - ExitProgram(EXIT_FAILURE); - } -} - -static void -drawbox(void) -{ - chtype bottom[XLENGTH + 1]; - int n; - - if (hascolor) - attrset(COLOR_PAIR(3)); - - mvaddch(YBASE - 1, XBASE - 1, ACS_ULCORNER); - hline(ACS_HLINE, XLENGTH); - mvaddch(YBASE - 1, XBASE + XLENGTH, ACS_URCORNER); - - mvaddch(YBASE + YDEPTH, XBASE - 1, ACS_LLCORNER); - mvinchnstr(YBASE + YDEPTH, XBASE, bottom, XLENGTH); - for (n = 0; n < XLENGTH; n++) - bottom[n] = ACS_HLINE | (bottom[n] & (A_ATTRIBUTES | A_COLOR)); - mvaddchnstr(YBASE + YDEPTH, XBASE, bottom, XLENGTH); - mvaddch(YBASE + YDEPTH, XBASE + XLENGTH, ACS_LRCORNER); - - move(YBASE, XBASE - 1); - vline(ACS_VLINE, YDEPTH); - - move(YBASE, XBASE + XLENGTH); - vline(ACS_VLINE, YDEPTH); - - if (hascolor) - attrset(COLOR_PAIR(2)); -} - -static void -standt(int on) -{ - if (on) { - if (hascolor) { - attron(COLOR_PAIR(1)); - } else { - attron(A_STANDOUT); - } - } else { - if (hascolor) { - attron(COLOR_PAIR(2)); - } else { - attroff(A_STANDOUT); - } - } -} - -static void -set(int t, int n) -{ - int i, m; - - m = 7 << n; - for (i = 0; i < 5; i++) { - next[i] |= ((disp[t] >> ((4 - i) * 3)) & 07) << n; - mask |= (next[i] ^ older[i]) & m; - } - if (mask & m) - mask |= m; -} - -static void -usage(void) -{ - static const char *msg[] = - { - "Usage: gdc [options] [count]" - ,"" - ,"Options:" - ," -n redirect input to /dev/null" - ," -s scroll each number into place, rather than flipping" - ,"" - ,"If you specify a count, gdc runs for that number of seconds" - }; - unsigned j; - for (j = 0; j < SIZEOF(msg); j++) - fprintf(stderr, "%s\n", msg[j]); - ExitProgram(EXIT_FAILURE); -} - -int -main(int argc, char *argv[]) -{ - time_t now; - struct tm *tm; - long t, a; - int i, j, s, k; - int count = 0; - FILE *ofp = stdout; - FILE *ifp = stdin; - bool scrol = FALSE; - - signal(SIGINT, sighndl); - signal(SIGTERM, sighndl); - signal(SIGKILL, sighndl); - - while ((k = getopt(argc, argv, "sn")) != EOF) { - switch (k) { - case 's': - scrol = TRUE; - break; - case 'n': - ifp = fopen("/dev/null", "r"); - redirected = TRUE; - break; - default: - usage(); - } - } - if (optind < argc) { - count = atoi(argv[optind++]); - } - if (optind < argc) - usage(); - - if (redirected) { - char *name = getenv("TERM"); - if (name == 0 - || newterm(name, ofp, ifp) == 0) { - fprintf(stderr, "cannot open terminal\n"); - ExitProgram(EXIT_FAILURE); - } - - } else { - initscr(); - } - cbreak(); - noecho(); - nodelay(stdscr, 1); - curs_set(0); - - hascolor = has_colors(); - - if (hascolor) { - int bg = COLOR_BLACK; - start_color(); -#if HAVE_USE_DEFAULT_COLORS - if (use_default_colors() == OK) - bg = -1; -#endif - init_pair(1, COLOR_BLACK, COLOR_RED); - init_pair(2, COLOR_RED, bg); - init_pair(3, COLOR_WHITE, bg); - attrset(COLOR_PAIR(2)); - } - - restart: - for (j = 0; j < 5; j++) - older[j] = newer[j] = next[j] = 0; - - clear(); - drawbox(); - - do { - char buf[30]; - - time(&now); - tm = localtime(&now); - - mask = 0; - set(tm->tm_sec % 10, 0); - set(tm->tm_sec / 10, 4); - set(tm->tm_min % 10, 10); - set(tm->tm_min / 10, 14); - set(tm->tm_hour % 10, 20); - set(tm->tm_hour / 10, 24); - set(10, 7); - set(10, 17); - - for (k = 0; k < 6; k++) { - if (scrol) { - for (i = 0; i < 5; i++) - newer[i] = (newer[i] & ~mask) | (newer[i + 1] & mask); - newer[5] = (newer[5] & ~mask) | (next[k] & mask); - } else - newer[k] = (newer[k] & ~mask) | (next[k] & mask); - next[k] = 0; - for (s = 1; s >= 0; s--) { - standt(s); - for (i = 0; i < 6; i++) { - if ((a = (newer[i] ^ older[i]) & (s ? newer : older)[i]) - != 0) { - for (j = 0, t = 1 << 26; t; t >>= 1, j++) { - if (a & t) { - if (!(a & (t << 1))) { - move(YBASE + i, XBASE + 2 * j); - } - addstr(" "); - } - } - } - if (!s) { - older[i] = newer[i]; - } - } - if (!s) { - if (scrol) - drawbox(); - refresh(); - /* - * If we're scrolling, space out the refreshes to fake - * movement. That's 7 frames, or 6 intervals, which would - * be 166 msec if we spread it out over a second. It looks - * better (but will well on a slow terminal, e.g., less - * than 9600bd) to squeeze that into a half-second, and use - * half of 170 msec to ensure that the program doesn't eat - * a lot of time when asking what time it is, at the top of - * this loop -TD - */ - if (scrol) - napms(85); - } - } - } - - /* this depends on the detailed format of ctime(3) */ - (void) strcpy(buf, ctime(&now)); - (void) strcpy(buf + 10, buf + 19); - mvaddstr(16, 30, buf); - - move(6, 0); - drawbox(); - refresh(); - - /* - * If we're not scrolling, wait 1000 msec (1 sec). Use napms() rather - * than sleep() because the latter does odd things on some systems, - * e.g., suspending output as well. - */ - if (scrol) - napms(500); - else - napms(1000); - - /* - * This is a safe way to check if we're interrupted - making the signal - * handler set a flag that we can check. Since we're running - * nodelay(), the wgetch() call returns immediately, and in particular - * will return an error if interrupted. This works only if we can - * read from the input, of course. - */ - switch (wgetch(stdscr)) { - case 'q': - count = 1; - break; - case 's': - nodelay(stdscr, FALSE); - break; - case ' ': - nodelay(stdscr, TRUE); - break; -#ifdef KEY_RESIZE - case KEY_RESIZE: -#endif - case '?': - goto restart; - case ERR: - if (sigtermed) { - standend(); - endwin(); - fprintf(stderr, "gdc terminated by signal %d\n", sigtermed); - ExitProgram(EXIT_FAILURE); - } - /* FALLTHRU */ - default: - continue; - } - } while (--count); - standend(); - endwin(); - ExitProgram(EXIT_SUCCESS); -} diff --git a/contrib/ncurses/test/hanoi.c b/contrib/ncurses/test/hanoi.c deleted file mode 100644 index ef09514e08e4..000000000000 --- a/contrib/ncurses/test/hanoi.c +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Name: Towers of Hanoi. - * - * Desc: - * This is a playable copy of towers of hanoi. - * Its sole purpose is to demonstrate my Amiga Curses package. - * This program should compile on any system that has Curses. - * 'hanoi' will give a manual game with 7 playing pieces. - * 'hanoi n' will give a manual game with n playing pieces. - * 'hanoi n a' will give an auto solved game with n playing pieces. - * - * Author: Simon J Raybould (sie@fulcrum.bt.co.uk). - * (This version has been slightly modified by the ncurses maintainers.) - * - * Date: 05.Nov.90 - * - * $Id: hanoi.c,v 1.23 2002/03/24 00:40:01 tom Exp $ - */ - -#include - -#define NPEGS 3 /* This is not configurable !! */ -#define MINTILES 3 -#define MAXTILES 9 -#define DEFAULTTILES 7 -#define TOPLINE 6 -#define BASELINE 16 -#define STATUSLINE (LINES-3) -#define LEFTPEG 19 -#define MIDPEG 39 -#define RIGHTPEG 59 - -#define LENTOIND(x) (((x)-1)/2) -#define OTHER(a,b) (3-((a)+(b))) - -struct Peg { - size_t Length[MAXTILES]; - int Count; -}; - -static struct Peg Pegs[NPEGS]; -static int PegPos[] = -{LEFTPEG, MIDPEG, RIGHTPEG}; -static int TileColour[] = -{ - COLOR_GREEN, /* Length 3 */ - COLOR_MAGENTA, /* Length 5 */ - COLOR_RED, /* Length 7 */ - COLOR_BLUE, /* Length 9 */ - COLOR_CYAN, /* Length 11 */ - COLOR_YELLOW, /* Length 13 */ - COLOR_GREEN, /* Length 15 */ - COLOR_MAGENTA, /* Length 17 */ - COLOR_RED, /* Length 19 */ -}; -static int NMoves = 0; - -static void InitTiles(int NTiles); -static void DisplayTiles(void); -static void MakeMove(int From, int To); -static void AutoMove(int From, int To, int Num); -static void Usage(void); -static int Solved(int NumTiles); -static int GetMove(int *From, int *To); -static int InvalidMove(int From, int To); - -int -main(int argc, char **argv) -{ - int NTiles, FromCol, ToCol; - bool AutoFlag = 0; - - switch (argc) { - case 1: - NTiles = DEFAULTTILES; - break; - case 2: - NTiles = atoi(argv[1]); - if (NTiles > MAXTILES || NTiles < MINTILES) { - fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES); - ExitProgram(EXIT_FAILURE); - } - break; - case 3: - if (strcmp(argv[2], "a")) { - Usage(); - ExitProgram(EXIT_FAILURE); - } - NTiles = atoi(argv[1]); - if (NTiles > MAXTILES || NTiles < MINTILES) { - fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES); - ExitProgram(EXIT_FAILURE); - } - AutoFlag = TRUE; - break; - default: - Usage(); - ExitProgram(EXIT_FAILURE); - } -#ifdef TRACE - trace(TRACE_MAXIMUM); -#endif - initscr(); - if (has_colors()) { - int i; - int bg = COLOR_BLACK; - start_color(); -#if HAVE_USE_DEFAULT_COLORS - if (use_default_colors() == OK) - bg = -1; -#endif - for (i = 0; i < 9; i++) - init_pair(i + 1, bg, TileColour[i]); - } - cbreak(); - if (LINES < 24) { - endwin(); - fprintf(stderr, "Min screen length 24 lines\n"); - ExitProgram(EXIT_FAILURE); - } - if (AutoFlag) { - curs_set(0); - leaveok(stdscr, TRUE); /* Attempt to remove cursor */ - } - InitTiles(NTiles); - DisplayTiles(); - if (AutoFlag) { - do { - noecho(); - AutoMove(0, 2, NTiles); - } while (!Solved(NTiles)); - sleep(2); - } else { - echo(); - for (;;) { - if (GetMove(&FromCol, &ToCol)) - break; - if (InvalidMove(FromCol, ToCol)) { - mvaddstr(STATUSLINE, 0, "Invalid Move !!"); - refresh(); - beep(); - continue; - } - MakeMove(FromCol, ToCol); - if (Solved(NTiles)) { - mvprintw(STATUSLINE, 0, - "Well Done !! You did it in %d moves", NMoves); - refresh(); - sleep(5); - break; - } - } - } - endwin(); - ExitProgram(EXIT_SUCCESS); -} - -static int -InvalidMove(int From, int To) -{ - if (From >= NPEGS) - return TRUE; - if (From < 0) - return TRUE; - if (To >= NPEGS) - return TRUE; - if (To < 0) - return TRUE; - if (From == To) - return TRUE; - if (!Pegs[From].Count) - return TRUE; - if (Pegs[To].Count && - Pegs[From].Length[Pegs[From].Count - 1] > - Pegs[To].Length[Pegs[To].Count - 1]) - return TRUE; - return FALSE; -} - -static void -InitTiles(int NTiles) -{ - int Size, SlotNo; - - for (Size = NTiles * 2 + 1, SlotNo = 0; Size >= 3; Size -= 2) - Pegs[0].Length[SlotNo++] = Size; - - Pegs[0].Count = NTiles; - Pegs[1].Count = 0; - Pegs[2].Count = 0; -} - -static void -DisplayTiles(void) -{ - int Line, peg, SlotNo; - char TileBuf[BUFSIZ]; - - erase(); - mvaddstr(1, 24, "T O W E R S O F H A N O I"); - mvaddstr(3, 34, "SJR 1990"); - mvprintw(19, 5, "Moves : %d", NMoves); - attrset(A_REVERSE); - mvaddstr(BASELINE, 8, - " "); - - for (Line = TOPLINE; Line < BASELINE; Line++) { - mvaddch(Line, LEFTPEG, ' '); - mvaddch(Line, MIDPEG, ' '); - mvaddch(Line, RIGHTPEG, ' '); - } - mvaddch(BASELINE, LEFTPEG, '1'); - mvaddch(BASELINE, MIDPEG, '2'); - mvaddch(BASELINE, RIGHTPEG, '3'); - attrset(A_NORMAL); - - /* Draw tiles */ - for (peg = 0; peg < NPEGS; peg++) { - for (SlotNo = 0; SlotNo < Pegs[peg].Count; SlotNo++) { - memset(TileBuf, ' ', Pegs[peg].Length[SlotNo]); - TileBuf[Pegs[peg].Length[SlotNo]] = '\0'; - if (has_colors()) - attrset(COLOR_PAIR(LENTOIND(Pegs[peg].Length[SlotNo]))); - else - attrset(A_REVERSE); - mvaddstr(BASELINE - (SlotNo + 1), - (int) (PegPos[peg] - Pegs[peg].Length[SlotNo] / 2), - TileBuf); - } - } - attrset(A_NORMAL); - refresh(); -} - -static int -GetMove(int *From, int *To) -{ - mvaddstr(STATUSLINE, 0, "Next move ('q' to quit) from "); - clrtoeol(); - refresh(); - if ((*From = getch()) == 'q') - return TRUE; - *From -= ('0' + 1); - addstr(" to "); - clrtoeol(); - refresh(); - - if ((*To = getch()) == 'q') - return TRUE; - *To -= ('0' + 1); - refresh(); - napms(500); - - move(STATUSLINE, 0); - clrtoeol(); - refresh(); - return FALSE; -} - -static void -MakeMove(int From, int To) -{ - Pegs[From].Count--; - Pegs[To].Length[Pegs[To].Count] = Pegs[From].Length[Pegs[From].Count]; - Pegs[To].Count++; - NMoves++; - DisplayTiles(); -} - -static void -AutoMove(int From, int To, int Num) -{ - if (Num == 1) { - MakeMove(From, To); - napms(500); - return; - } - AutoMove(From, OTHER(From, To), Num - 1); - MakeMove(From, To); - napms(500); - AutoMove(OTHER(From, To), To, Num - 1); -} - -static int -Solved(int NumTiles) -{ - int i; - - for (i = 1; i < NPEGS; i++) - if (Pegs[i].Count == NumTiles) - return TRUE; - return FALSE; -} - -static void -Usage(void) -{ - fprintf(stderr, "Usage: hanoi [] [a]\n"); - fprintf(stderr, - "The 'a' option causes the tower to be solved automatically\n"); -} diff --git a/contrib/ncurses/test/hashtest.c b/contrib/ncurses/test/hashtest.c deleted file mode 100644 index 9ddb07cb7430..000000000000 --- a/contrib/ncurses/test/hashtest.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * hashtest.c -- test hash mapping - * - * Generate timing statistics for vertical-motion optimization. - * - * $Id: hashtest.c,v 1.21 2002/03/23 22:17:24 tom Exp $ - */ - -#ifdef TRACE -#define Trace(p) _tracef p -#define USE_TRACE 1 -#else -#define Trace(p) /* nothing */ -#define USE_TRACE 0 -#endif - -#include - -#include - -#define LO_CHAR ' ' -#define HI_CHAR '~' - -static bool continuous = FALSE; -static bool reverse_loops = FALSE; -static bool single_step = FALSE; -static bool extend_corner = FALSE; -static int foot_lines = 0; -static int head_lines = 0; - -static void -cleanup(void) -{ - move(LINES - 1, 0); - clrtoeol(); - refresh(); - endwin(); -} - -static RETSIGTYPE -finish(int sig GCC_UNUSED) -{ - cleanup(); - ExitProgram(EXIT_FAILURE); -} - -static void -genlines(int base) -{ - int i, j; - -#if USE_TRACE - if (base == 'a') - Trace(("Resetting screen")); - else - Trace(("Painting `%c' screen", base)); -#endif - - /* Do this so writes to lower-right corner don't cause a spurious - * scrolling operation. This _shouldn't_ break the scrolling - * optimization, since that's computed in the refresh() call. - */ - scrollok(stdscr, FALSE); - - move(0, 0); - for (i = 0; i < head_lines; i++) - for (j = 0; j < COLS; j++) - addch((j % 8 == 0) ? ('A' + j / 8) : '-'); - - move(head_lines, 0); - for (i = head_lines; i < LINES - foot_lines; i++) { - int c = (base - LO_CHAR + i) % (HI_CHAR - LO_CHAR + 1) + LO_CHAR; - int hi = (extend_corner || (i < LINES - 1)) ? COLS : COLS - 1; - for (j = 0; j < hi; j++) - addch(c); - } - - for (i = LINES - foot_lines; i < LINES; i++) { - move(i, 0); - for (j = 0; j < (extend_corner ? COLS : COLS - 1); j++) - addch((j % 8 == 0) ? ('A' + j / 8) : '-'); - } - - scrollok(stdscr, TRUE); - if (single_step) { - move(LINES - 1, 0); - getch(); - } else - refresh(); -} - -static void -one_cycle(int ch) -{ - if (continuous) { - genlines(ch); - } else if (ch != 'a') { - genlines('a'); - genlines(ch); - } -} - -static void -run_test(bool optimized GCC_UNUSED) -{ - char ch; - int lo = continuous ? LO_CHAR : 'a' - LINES; - int hi = continuous ? HI_CHAR : 'a' + LINES; - - if (lo < LO_CHAR) - lo = LO_CHAR; - if (hi > HI_CHAR) - hi = HI_CHAR; - -#if defined(TRACE) || defined(NCURSES_TEST) - if (optimized) { - Trace(("With hash mapping")); - _nc_optimize_enable |= OPTIMIZE_HASHMAP; - } else { - Trace(("Without hash mapping")); - _nc_optimize_enable &= ~OPTIMIZE_HASHMAP; - } -#endif - - if (reverse_loops) - for (ch = hi; ch >= lo; ch--) - one_cycle(ch); - else - for (ch = lo; ch <= hi; ch++) - one_cycle(ch); -} - -static void -usage(void) -{ - static const char *const tbl[] = - { - "Usage: hashtest [options]" - ,"" - ,"Options:" - ," -c continuous (don't reset between refresh's)" - ," -f num leave 'num' lines constant for footer" - ," -h num leave 'num' lines constant for header" - ," -l num repeat test 'num' times" - ," -n test the normal optimizer" - ," -o test the hashed optimizer" - ," -r reverse the loops" - ," -s single-step" - ," -x assume lower-right corner extension" - }; - size_t n; - - for (n = 0; n < SIZEOF(tbl); n++) - fprintf(stderr, "%s\n", tbl[n]); - ExitProgram(EXIT_FAILURE); -} - -int -main(int argc, char *argv[]) -{ - int c; - int test_loops = 1; - int test_normal = FALSE; - int test_optimize = FALSE; - - while ((c = getopt(argc, argv, "cf:h:l:norsx")) != EOF) { - switch (c) { - case 'c': - continuous = TRUE; - break; - case 'f': - foot_lines = atoi(optarg); - break; - case 'h': - head_lines = atoi(optarg); - break; - case 'l': - test_loops = atoi(optarg); - break; - case 'n': - test_normal = TRUE; - break; - case 'o': - test_optimize = TRUE; - break; - case 'r': - reverse_loops = TRUE; - break; - case 's': - single_step = TRUE; - break; - case 'x': - extend_corner = TRUE; - break; - default: - usage(); - } - } - if (!test_normal && !test_optimize) { - test_normal = TRUE; - test_optimize = TRUE; - } -#if USE_TRACE - trace(TRACE_TIMES); -#endif - - (void) signal(SIGINT, finish); /* arrange interrupts to terminate */ - - (void) initscr(); /* initialize the curses library */ - keypad(stdscr, TRUE); /* enable keyboard mapping */ - (void) nonl(); /* tell curses not to do NL->CR/NL on output */ - (void) cbreak(); /* take input chars one at a time, no wait for \n */ - (void) noecho(); /* don't echo input */ - scrollok(stdscr, TRUE); - - while (test_loops-- > 0) { - if (test_normal) - run_test(FALSE); - if (test_optimize) - run_test(TRUE); - } - - cleanup(); /* we're done */ - ExitProgram(EXIT_SUCCESS); -} -/* hashtest.c ends here */ diff --git a/contrib/ncurses/test/keynames.c b/contrib/ncurses/test/keynames.c deleted file mode 100644 index c2056ec4e7bb..000000000000 --- a/contrib/ncurses/test/keynames.c +++ /dev/null @@ -1,15 +0,0 @@ -/* - * $Id: keynames.c,v 1.3 2001/09/15 21:46:34 tom Exp $ - */ - -#include - -int -main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) -{ - int n; - for (n = -1; n < 512; n++) { - printf("%d(%5o):%s\n", n, n, keyname(n)); - } - ExitProgram(EXIT_SUCCESS); -} diff --git a/contrib/ncurses/test/knight.c b/contrib/ncurses/test/knight.c deleted file mode 100644 index 469d25e355f9..000000000000 --- a/contrib/ncurses/test/knight.c +++ /dev/null @@ -1,700 +0,0 @@ -/* - * Knight's Tour - a brain game - * - * The original of this game was anonymous. It had an unbelievably bogus - * interface, you actually had to enter square coordinates! Redesign by - * Eric S. Raymond July 22 1995. Mouse support - * added September 20th 1995. - * - * $Id: knight.c,v 1.24 2002/03/23 22:17:24 tom Exp $ - */ - -#include - -#include - -/* board size */ -#define BDEPTH 8 -#define BWIDTH 8 - -/* where to start the instructions */ -#define INSTRY 2 -#define INSTRX 35 - -/* corner of board */ -#define BOARDY 2 -#define BOARDX 0 - -/* notification line */ -#define NOTIFYY 21 - -/* virtual color values */ -#define TRAIL_COLOR 1 -#define PLUS_COLOR 2 -#define MINUS_COLOR 3 - -#define CX(x) (2 + 4 * (x)) -#define CY(y) (1 + 2 * (y)) -#define cellmove(y, x) wmove(boardwin, CY(y), CX(x)) -#define CXINV(x) (((x) - 1) / 4) -#define CYINV(y) (((y) - 2) / 2) - -typedef struct { - short x, y; -} cell; - -static WINDOW *boardwin; /* the board window */ -static WINDOW *helpwin; /* the help window */ -static WINDOW *msgwin; /* the message window */ -static cell history[BDEPTH * BWIDTH + 1]; /* choice history */ -static chtype minus = '-'; /* possible-move character */ -static chtype oldch; -static chtype plus = '+'; /* cursor hot-spot character */ -static chtype trail = '#'; /* trail character */ -static int movecount; /* count of moves so far */ -static int trialcount; /* count of trials so far */ -static short board[BDEPTH][BWIDTH]; /* the squares */ -/* *INDENT-OFF* */ -static const struct { - int y; - int x; -} offsets[] = { - { 2, 1 }, - { 1, 2 }, - { -1, 2 }, - { -2, 1 }, - { -2, -1 }, - { -1, -2 }, - { 1, -2 }, - { 2, -1 }, -}; -/* *INDENT-ON* */ - -static void -init_program(void) -{ - srand((unsigned) getpid()); - initscr(); - cbreak(); /* immediate char return */ - noecho(); /* no immediate echo */ - boardwin = newwin(BDEPTH * 2 + 1, BWIDTH * 4 + 1, BOARDY, BOARDX); - helpwin = newwin(0, 0, INSTRY, INSTRX); - msgwin = newwin(1, INSTRX - 1, NOTIFYY, 0); - scrollok(msgwin, TRUE); - keypad(boardwin, TRUE); - - if (has_colors()) { - int bg = COLOR_BLACK; - - start_color(); -#if HAVE_USE_DEFAULT_COLORS - if (use_default_colors() == OK) - bg = -1; -#endif - - (void) init_pair(TRAIL_COLOR, COLOR_CYAN, bg); - (void) init_pair(PLUS_COLOR, COLOR_RED, bg); - (void) init_pair(MINUS_COLOR, COLOR_GREEN, bg); - - trail |= COLOR_PAIR(TRAIL_COLOR); - plus |= COLOR_PAIR(PLUS_COLOR); - minus |= COLOR_PAIR(MINUS_COLOR); - } -#ifdef NCURSES_MOUSE_VERSION - (void) mousemask(BUTTON1_CLICKED, (mmask_t *) NULL); -#endif /* NCURSES_MOUSE_VERSION */ - - oldch = minus; -} - -static void -help1(void) -/* game explanation -- initial help screen */ -{ - (void) waddstr(helpwin, "Knight's move is a solitaire puzzle. Your\n"); - (void) waddstr(helpwin, "objective is to visit each square of the \n"); - (void) waddstr(helpwin, "chessboard exactly once by making knight's\n"); - (void) waddstr(helpwin, "moves (one square right or left followed \n"); - (void) waddstr(helpwin, "by two squares up or down, or two squares \n"); - (void) waddstr(helpwin, "right or left followed by one square up or\n"); - (void) waddstr(helpwin, "down). You may start anywhere.\n\n"); - - (void) waddstr(helpwin, "Use arrow keys to move the cursor around.\n"); - (void) waddstr(helpwin, "When you want to move your knight to the \n"); - (void) waddstr(helpwin, "cursor location, press or Enter.\n"); - (void) waddstr(helpwin, "Illegal moves will be rejected with an \n"); - (void) waddstr(helpwin, "audible beep.\n\n"); - (void) waddstr(helpwin, "The program will detect if you solve the\n"); - (void) waddstr(helpwin, "puzzle; also inform you when you run out\n"); - (void) waddstr(helpwin, "of legal moves.\n\n"); - - (void) mvwaddstr(helpwin, NOTIFYY - INSTRY, 0, - "Press `?' to go to keystroke help."); -} - -static void -help2(void) -/* keystroke help screen */ -{ - (void) waddstr(helpwin, "Possible moves are shown with `-'.\n\n"); - - (void) waddstr(helpwin, "You can move around with the arrow keys or\n"); - (void) waddstr(helpwin, "with the rogue/hack movement keys. Other\n"); - (void) waddstr(helpwin, "commands allow you to undo moves or redraw.\n"); - (void) waddstr(helpwin, "Your mouse may work; try left-button to\n"); - (void) waddstr(helpwin, "move to the square under the pointer.\n\n"); - - (void) waddstr(helpwin, "x,q -- exit y k u 7 8 9\n"); - (void) waddstr(helpwin, "r -- redraw screen \\|/ \\|/ \n"); - (void) waddstr(helpwin, "bksp -- undo move h-+-l 4-+-6\n"); - (void) waddstr(helpwin, "a -- autojump /|\\ /|\\ \n"); - (void) waddstr(helpwin, " b j n 1 2 3\n"); - - (void) waddstr(helpwin, "\nYou can place your knight on the selected\n"); - (void) waddstr(helpwin, "square with spacebar, Enter, or the keypad\n"); - (void) waddstr(helpwin, "center key. Use F/B to review the path.\n"); - - (void) mvwaddstr(helpwin, NOTIFYY - INSTRY, 0, - "Press `?' to go to game explanation"); -} - -static void -show_help(bool * keyhelp) -{ - werase(helpwin); - if (*keyhelp) { - help1(); - *keyhelp = FALSE; - } else { - help2(); - *keyhelp = TRUE; - } - wrefresh(helpwin); -} - -static bool -chksqr(int r1, int c1) -{ - if ((r1 < 0) || (r1 > BDEPTH - 1)) - return (FALSE); - if ((c1 < 0) || (c1 > BWIDTH - 1)) - return (FALSE); - return ((!board[r1][c1]) ? TRUE : FALSE); -} - -static bool -chkmoves(int rw, int col) -/* check to see if valid moves are available */ -{ - unsigned n; - - for (n = 0; n < SIZEOF(offsets); n++) - if (chksqr(rw + offsets[n].y, col + offsets[n].x)) - return (TRUE); - return (FALSE); -} - -static void -dosquares(void) -{ - int i, j; - - mvaddstr(0, 20, "KNIGHT'S MOVE -- a logical solitaire"); - - move(BOARDY, BOARDX); - waddch(boardwin, ACS_ULCORNER); - for (j = 0; j < 7; j++) { - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_TTEE); - } - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_URCORNER); - - for (i = 1; i < BDEPTH; i++) { - move(BOARDY + i * 2 - 1, BOARDX); - waddch(boardwin, ACS_VLINE); - for (j = 0; j < BWIDTH; j++) { - waddch(boardwin, ' '); - waddch(boardwin, ' '); - waddch(boardwin, ' '); - waddch(boardwin, ACS_VLINE); - } - move(BOARDY + i * 2, BOARDX); - waddch(boardwin, ACS_LTEE); - for (j = 0; j < BWIDTH - 1; j++) { - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_PLUS); - } - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_RTEE); - } - - move(BOARDY + i * 2 - 1, BOARDX); - waddch(boardwin, ACS_VLINE); - for (j = 0; j < BWIDTH; j++) { - waddch(boardwin, ' '); - waddch(boardwin, ' '); - waddch(boardwin, ' '); - waddch(boardwin, ACS_VLINE); - } - - move(BOARDY + i * 2, BOARDX); - waddch(boardwin, ACS_LLCORNER); - for (j = 0; j < BWIDTH - 1; j++) { - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_BTEE); - } - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_HLINE); - waddch(boardwin, ACS_LRCORNER); -} - -static void -mark_possibles(int prow, int pcol, chtype mark) -{ - unsigned n; - - for (n = 0; n < SIZEOF(offsets); n++) { - if (chksqr(prow + offsets[n].y, pcol + offsets[n].x)) { - cellmove(prow + offsets[n].y, pcol + offsets[n].x); - waddch(boardwin, mark); - } - } -} - -static void -find_next_move(int *y, int *x) -{ - unsigned j, k; - int found = -1; - int first = -1; - int next = 0; - int oldy, oldx; - int newy, newx; - - if (movecount > 1) { - oldy = history[movecount - 1].y; - oldx = history[movecount - 1].x; - for (j = 0; j < SIZEOF(offsets) * 2; j++) { - k = j % SIZEOF(offsets); - newy = oldy + offsets[k].y; - newx = oldx + offsets[k].x; - if (chksqr(newy, newx)) { - if (first < 0) - first = k; - if (newy == *y - && newx == *x) { - found = k; - } else if (found >= 0) { - next = k; - break; - } - } - } - if (found < 0) - next = first; - if (next >= 0) { - *y = oldy + offsets[next].y; - *x = oldx + offsets[next].x; - } - } else { - beep(); - } -} - -static void -unmarkcell(int row, int column) -{ - cellmove(row, column); - waddch(boardwin, '\b'); - waddch(boardwin, ' '); - waddch(boardwin, minus); - waddch(boardwin, ' '); -} - -static void -markcell(chtype tchar, int row, int column) -{ - cellmove(row, column); - waddch(boardwin, '\b'); - waddch(boardwin, tchar); - waddch(boardwin, tchar); - waddch(boardwin, tchar); -} - -static void -drawmove(chtype tchar, int oldy, int oldx, int row, int column) -/* place the stars, update board & currents */ -{ - if (movecount <= 1) { - int i, j; - - for (i = 0; i < BDEPTH; i++) { - for (j = 0; j < BWIDTH; j++) { - if (movecount == 0) { - unmarkcell(i, j); - } else { - cellmove(i, j); - if (winch(boardwin) == minus) - waddch(boardwin, movecount ? ' ' : minus); - } - } - } - } else { - markcell(tchar, oldy, oldx); - mark_possibles(oldy, oldx, ' '); - } - - if (row != -1 && column != -1) { - markcell(trail, row, column); - mark_possibles(row, column, minus); - board[row][column] = TRUE; - } - - wprintw(msgwin, "\nMove %d", movecount); - if (trialcount != movecount) - wprintw(msgwin, " (%d tries)", trialcount); - wclrtoeol(msgwin); -} - -static int -iabs(int num) -{ - if (num < 0) - return (-num); - else - return (num); -} - -static bool -evalmove(int row, int column) -/* evaluate move */ -{ - if (movecount == 1) - return (TRUE); - else if (board[row][column] == TRUE) { - waddstr(msgwin, "\nYou've already been there."); - return (FALSE); - } else { - int rdif = iabs(row - history[movecount - 1].y); - int cdif = iabs(column - history[movecount - 1].x); - - if (!((rdif == 1) && (cdif == 2)) && !((rdif == 2) && (cdif == 1))) { - waddstr(msgwin, "\nThat's not a legal knight's move."); - return (FALSE); - } - } - - return (TRUE); -} - -static int -completed(void) -{ - int i, j, count = 0; - - for (i = 0; i < BDEPTH; i++) - for (j = 0; j < BWIDTH; j++) - if (board[i][j] != 0) - count += 1; - return (count == (BWIDTH * BDEPTH) ? -1 : count); -} - -static void -no_previous_move(void) -{ - waddstr(msgwin, "\nNo previous move."); - beep(); -} - -static void -play(void) -/* play the game */ -{ - bool keyhelp; /* TRUE if keystroke help is up */ - int i, j, count; - int lastcol = 0; /* last location visited */ - int lastrow = 0; - int ny = 0, nx = 0; - int review = 0; /* review history */ - int rw = 0, col = 0; /* current row and column */ - - do { - /* clear screen and draw board */ - werase(boardwin); - werase(helpwin); - werase(msgwin); - dosquares(); - help1(); - wnoutrefresh(stdscr); - wnoutrefresh(helpwin); - wnoutrefresh(msgwin); - wnoutrefresh(boardwin); - doupdate(); - - movecount = 0; - for (i = 0; i < BDEPTH; i++) { - for (j = 0; j < BWIDTH; j++) { - board[i][j] = FALSE; - unmarkcell(i, j); - } - } - memset(history, 0, sizeof(history)); - history[0].y = history[0].x = -1; - history[1].y = history[1].x = -1; - lastrow = lastcol = -2; - movecount = 1; - trialcount = 1; - keyhelp = FALSE; - show_help(&keyhelp); - - for (;;) { - if (rw != lastrow || col != lastcol) { - if (lastrow >= 0 && lastcol >= 0) { - cellmove(lastrow, lastcol); - if (board[lastrow][lastcol]) - waddch(boardwin, trail); - else - waddch(boardwin, oldch); - } - - cellmove(rw, col); - oldch = winch(boardwin); - - lastrow = rw; - lastcol = col; - } - cellmove(rw, col); - waddch(boardwin, plus); - cellmove(rw, col); - - wrefresh(msgwin); - - switch (wgetch(boardwin)) { - case 'k': - case '8': - case KEY_UP: - ny = rw + BDEPTH - 1; - nx = col; - break; - case 'j': - case '2': - case KEY_DOWN: - ny = rw + 1; - nx = col; - break; - case 'h': - case '4': - case KEY_LEFT: - ny = rw; - nx = col + BWIDTH - 1; - break; - case 'l': - case '6': - case KEY_RIGHT: - ny = rw; - nx = col + 1; - break; - case 'y': - case '7': - case KEY_A1: - ny = rw + BDEPTH - 1; - nx = col + BWIDTH - 1; - break; - case 'b': - case '1': - case KEY_C1: - ny = rw + 1; - nx = col + BWIDTH - 1; - break; - case 'u': - case '9': - case KEY_A3: - ny = rw + BDEPTH - 1; - nx = col + 1; - break; - case 'n': - case '3': - case KEY_C3: - ny = rw + 1; - nx = col + 1; - break; - -#ifdef NCURSES_MOUSE_VERSION - case KEY_MOUSE: - { - MEVENT myevent; - - getmouse(&myevent); - if (myevent.y >= CY(0) && myevent.y <= CY(BDEPTH) - && myevent.x >= CX(0) && myevent.x <= CX(BWIDTH)) { - nx = CXINV(myevent.x); - ny = CYINV(myevent.y); - ungetch('\n'); - break; - } else { - beep(); - continue; - } - } -#endif /* NCURSES_MOUSE_VERSION */ - - case KEY_B2: - case '\n': - case ' ': - review = 0; - if (evalmove(rw, col)) { - drawmove(trail, - history[movecount - 1].y, - history[movecount - 1].x, - rw, col); - history[movecount].y = rw; - history[movecount].x = col; - movecount++; - trialcount++; - - if (!chkmoves(rw, col)) { - if (completed() < 0) { - waddstr(msgwin, "\nYou won."); - } else { - waddstr(msgwin, - "\nNo further moves are possible."); - } - } - } else { - beep(); - } - break; - - case KEY_UNDO: - case KEY_BACKSPACE: - case '\b': - review = 0; - if (movecount <= 0) { - no_previous_move(); - } else if (movecount <= 1) { - ny = history[movecount].y; - nx = history[movecount].x; - if (nx < 0 || ny < 0) { - ny = lastrow; - nx = lastcol; - } - movecount = 0; - board[ny][nx] = FALSE; - oldch = minus; - drawmove(' ', ny, nx, -1, -1); - movecount = 1; - trialcount = 1; - no_previous_move(); - } else { - int oldy = history[movecount - 1].y; - int oldx = history[movecount - 1].x; - - if (!board[rw][col]) { - cellmove(rw, col); - waddch(boardwin, ' '); - } - - board[oldy][oldx] = FALSE; - --movecount; - ny = history[movecount - 1].y; - nx = history[movecount - 1].x; - if (nx < 0 || ny < 0) { - ny = oldy; - nx = oldx; - } - drawmove(' ', oldy, oldx, ny, nx); - - /* avoid problems if we just changed the current cell */ - cellmove(lastrow, lastcol); - oldch = winch(boardwin); - } - break; - - case 'a': - nx = col; - ny = rw; - find_next_move(&ny, &nx); - break; - - case 'F': - if (review > 0) { - review--; - ny = history[movecount - review - 1].y; - nx = history[movecount - review - 1].x; - } else { - beep(); - } - break; - - case 'B': - if (review < movecount - 2) { - review++; - ny = history[movecount - review - 1].y; - nx = history[movecount - review - 1].x; - } else { - beep(); - } - break; - - case KEY_REDO: - case '\f': - case 'r': - clearok(curscr, TRUE); - wnoutrefresh(stdscr); - wnoutrefresh(boardwin); - wnoutrefresh(msgwin); - wnoutrefresh(helpwin); - doupdate(); - break; - - case 'q': - case 'x': - goto dropout; - - case '?': - show_help(&keyhelp); - break; - - default: - beep(); - break; - } - - col = nx % BWIDTH; - rw = ny % BDEPTH; - } - - dropout: - if ((count = completed()) < 0) - wprintw(msgwin, "\nYou won. Care to try again? "); - else - wprintw(msgwin, "\n%d squares filled. Try again? ", count); - wclrtoeol(msgwin); - } while - (tolower(wgetch(msgwin)) == 'y'); -} - -int -main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) -{ - init_program(); - - play(); - - endwin(); - ExitProgram(EXIT_SUCCESS); -} - -/* knight.c ends here */ diff --git a/contrib/ncurses/test/lrtest.c b/contrib/ncurses/test/lrtest.c deleted file mode 100644 index a3b856a8fd3d..000000000000 --- a/contrib/ncurses/test/lrtest.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Test lower-right-hand corner access - * - * originally by Eric S. Raymond , written for animation - * and resizing -TD - * - * This can't be part of the ncurses test-program, because ncurses rips off the - * bottom line to do labels. - * - * $Id: lrtest.c,v 0.17 2002/04/06 20:45:22 tom Exp $ - */ - -#include - -typedef struct { - int y, x, mode, dir, inc; - chtype value; -} MARK; - -/* - * Make a couple of markers go 'round the border to demonstrate that we can - * really write to all positions properly. - */ -static void -show(MARK * m) -{ - mvaddch(m->y, m->x, m->value); - if (m->mode == 0) { /* along the x-direction */ - m->x += m->inc; - if (m->x >= COLS) { - m->x = COLS - 1; - m->inc = -m->dir * m->inc; - m->y += m->inc; - m->mode = 1; - } else if (m->x < 0) { - m->x = 0; - m->inc = -m->dir * m->inc; - m->y += m->inc; - m->mode = 1; - } - } else { /* along the y-direction */ - m->y += m->inc; - if (m->y >= LINES) { - m->y = LINES - 1; - m->inc = m->dir * m->inc; - m->x += m->inc; - m->mode = 0; - } else if (m->y < 0) { - m->y = 0; - m->inc = m->dir * m->inc; - m->x += m->inc; - m->mode = 0; - } - } -} - -int -main( - int argc GCC_UNUSED, - char *argv[]GCC_UNUSED) -{ - static MARK marks[] = - { - {0, 0, 0, -1, 1, '+' | A_BOLD}, - {0, 0, 1, 1, 2, 'X'}, - {0, 0, 1, -1, 3, 'Y'}, - {0, 8, 0, -1, 1, '+' | A_BOLD}, - {0, 9, 0, -1, 1, '+' | A_BOLD}, - {1, 0, 1, 1, 1, '*' | A_REVERSE}, - {2, 0, 1, 1, 1, '*' | A_REVERSE} - }; - - initscr(); - noecho(); - cbreak(); - nodelay(stdscr, TRUE); - curs_set(0); - -#ifdef KEY_RESIZE - keypad(stdscr, TRUE); - restart: -#endif - move(LINES / 2 - 1, 4); - if (!(has_ic() - /* see PutCharLR() */ - || auto_right_margin - || (enter_am_mode && exit_am_mode))) { - addstr("Your terminal lacks the capabilities needed to address the\n"); - move(LINES / 2, 4); - addstr("lower-right-hand corner of the screen.\n"); - } else { - addstr("This is a test of access to the lower right corner.\n"); - move(LINES / 2, 4); - addstr("If the top of the box is missing, the test failed.\n"); - move(LINES / 2 + 1, 4); - addstr("Please report this (with a copy of your terminfo entry).\n"); - move(LINES / 2 + 2, 4); - addstr("to the ncurses maintainers, at bug-ncurses@gnu.org.\n"); - } - - for (;;) { - int ch; - unsigned n; - - box(stdscr, 0, 0); - for (n = 0; n < SIZEOF(marks); n++) { - show(&marks[n]); - } - - if ((ch = getch()) > 0) { - if (ch == 'q') - break; - else if (ch == 's') - nodelay(stdscr, FALSE); - else if (ch == ' ') - nodelay(stdscr, TRUE); -#ifdef KEY_RESIZE - else if (ch == KEY_RESIZE) { - for (n = 0; n < SIZEOF(marks); n++) { - if (marks[n].mode == 0) { /* moving along x-direction */ - if (marks[n].y) - marks[n].y = LINES - 1; - } else { - if (marks[n].x) - marks[n].x = COLS - 1; - } - } - flash(); - erase(); - wrefresh(curscr); - goto restart; - } -#endif - } - napms(50); - refresh(); - } - - curs_set(1); - endwin(); - ExitProgram(EXIT_SUCCESS); -} - -/* lrtest.c ends here */ diff --git a/contrib/ncurses/test/modules b/contrib/ncurses/test/modules deleted file mode 100644 index 583f8c76cc8b..000000000000 --- a/contrib/ncurses/test/modules +++ /dev/null @@ -1,59 +0,0 @@ -# Test-Program modules -# $Id: modules,v 1.13 2000/02/13 01:05:13 tom Exp $ -############################################################################## -# Copyright (c) 1998,1999,2000 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 1997 -# - -@ base -blue progs $(srcdir) ../include/term.h -bs progs $(srcdir) -cardfile progs $(srcdir) ../include/panel.h ../include/menu.h ../include/form.h -ditto progs $(srcdir) -dots progs $(srcdir) ../include/term.h -filter progs $(srcdir) -firework progs $(srcdir) ../include/term.h -firstlast progs $(srcdir) -gdc progs $(srcdir) -hanoi progs $(srcdir) -hashtest progs $(srcdir) -keynames progs $(srcdir) -knight progs $(srcdir) -lrtest progs $(srcdir) -ncurses progs $(srcdir) ../include/panel.h ../include/menu.h ../include/form.h -newdemo progs $(srcdir) -rain progs $(srcdir) ../include/term.h -railroad progs $(srcdir) ../include/termcap.h -tclock progs $(srcdir) -testaddch progs $(srcdir) -testcurs progs $(srcdir) -testscanw progs $(srcdir) -view progs $(srcdir) -worm progs $(srcdir) -xmas progs $(srcdir) diff --git a/contrib/ncurses/test/ncurses.c b/contrib/ncurses/test/ncurses.c deleted file mode 100644 index 3d2101dbc904..000000000000 --- a/contrib/ncurses/test/ncurses.c +++ /dev/null @@ -1,4332 +0,0 @@ -/**************************************************************************** - * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "Software"), to deal in the Software without restriction, including * - * without limitation the rights to use, copy, modify, merge, publish, * - * distribute, distribute with modifications, sublicense, and/or sell * - * copies of the Software, and to permit persons to whom the Software is * - * furnished to do so, subject to the following conditions: * - * * - * The above copyright notice and this permission notice shall be included * - * in all copies or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * - * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * * - * Except as contained in this notice, the name(s) of the above copyright * - * holders shall not be used in advertising or otherwise to promote the * - * sale, use or other dealings in this Software without prior written * - * authorization. * - ****************************************************************************/ -/**************************************************************************** - -NAME - ncurses.c --- ncurses library exerciser - -SYNOPSIS - ncurses - -DESCRIPTION - An interactive test module for the ncurses library. - -AUTHOR - Author: Eric S. Raymond 1993 - Thomas E. Dickey (beginning revision 1.27 in 1996). - -$Id: ncurses.c,v 1.173 2002/06/16 00:29:27 tom Exp $ - -***************************************************************************/ - -#include -#include -#include - -#include - -#if HAVE_LOCALE_H -#include -#endif - -#if HAVE_GETTIMEOFDAY -#if HAVE_SYS_TIME_H && HAVE_SYS_TIME_SELECT -#include -#endif -#if HAVE_SYS_SELECT_H -#include -#endif -#endif - -#if HAVE_PANEL_H && HAVE_LIBPANEL -#define USE_LIBPANEL 1 -#include -#else -#define USE_LIBPANEL 0 -#endif - -#if HAVE_MENU_H && HAVE_LIBMENU -#define USE_LIBMENU 1 -#include -#else -#define USE_LIBMENU 0 -#endif - -#if HAVE_FORM_H && HAVE_LIBFORM -#define USE_LIBFORM 1 -#include -#else -#define USE_LIBFORM 0 -#endif - -#ifdef NCURSES_VERSION - -#ifdef TRACE -static int save_trace = TRACE_ORDINARY | TRACE_CALLS; -extern int _nc_tracing; -#endif - -#else - -#define mmask_t chtype /* not specified in XSI */ - -#ifdef CURSES_ACS_ARRAY -#define ACS_S3 (CURSES_ACS_ARRAY['p']) /* scan line 3 */ -#define ACS_S7 (CURSES_ACS_ARRAY['r']) /* scan line 7 */ -#define ACS_LEQUAL (CURSES_ACS_ARRAY['y']) /* less/equal */ -#define ACS_GEQUAL (CURSES_ACS_ARRAY['z']) /* greater/equal */ -#define ACS_PI (CURSES_ACS_ARRAY['{']) /* Pi */ -#define ACS_NEQUAL (CURSES_ACS_ARRAY['|']) /* not equal */ -#define ACS_STERLING (CURSES_ACS_ARRAY['}']) /* UK pound sign */ -#else -#define ACS_S3 (A_ALTCHARSET + 'p') /* scan line 3 */ -#define ACS_S7 (A_ALTCHARSET + 'r') /* scan line 7 */ -#define ACS_LEQUAL (A_ALTCHARSET + 'y') /* less/equal */ -#define ACS_GEQUAL (A_ALTCHARSET + 'z') /* greater/equal */ -#define ACS_PI (A_ALTCHARSET + '{') /* Pi */ -#define ACS_NEQUAL (A_ALTCHARSET + '|') /* not equal */ -#define ACS_STERLING (A_ALTCHARSET + '}') /* UK pound sign */ -#endif - -#ifdef CURSES_WACS_ARRAY -#define WACS_S3 (&(CURSES_WACS_ARRAY['p'])) /* scan line 3 */ -#define WACS_S7 (&(CURSES_WACS_ARRAY['r'])) /* scan line 7 */ -#define WACS_LEQUAL (&(CURSES_WACS_ARRAY['y'])) /* less/equal */ -#define WACS_GEQUAL (&(CURSES_WACS_ARRAY['z'])) /* greater/equal */ -#define WACS_PI (&(CURSES_WACS_ARRAY['{'])) /* Pi */ -#define WACS_NEQUAL (&(CURSES_WACS_ARRAY['|'])) /* not equal */ -#define WACS_STERLING (&(CURSES_WACS_ARRAY['}'])) /* UK pound sign */ -#endif - -#endif - -#define P(string) printw("%s\n", string) -#ifdef CTRL -#undef CTRL -#endif -#define CTRL(x) ((x) & 0x1f) - -#define QUIT CTRL('Q') -#define ESCAPE CTRL('[') -#define BLANK ' ' /* this is the background character */ - -#undef max_colors -static int max_colors; /* the actual number of colors we'll use */ - -#undef max_pairs -static int max_pairs; /* ...and the number of color pairs */ - -/* The behavior of mvhline, mvvline for negative/zero length is unspecified, - * though we can rely on negative x/y values to stop the macro. - */ -static void -do_h_line(int y, int x, chtype c, int to) -{ - if ((to) > (x)) - mvhline(y, x, c, (to) - (x)); -} - -static void -do_v_line(int y, int x, chtype c, int to) -{ - if ((to) > (y)) - mvvline(y, x, c, (to) - (y)); -} - -/* Common function to allow ^T to toggle trace-mode in the middle of a test - * so that trace-files can be made smaller. - */ -static int -wGetchar(WINDOW *win) -{ - int c; -#ifdef TRACE - while ((c = wgetch(win)) == CTRL('T')) { - if (_nc_tracing) { - save_trace = _nc_tracing; - _tracef("TOGGLE-TRACING OFF"); - _nc_tracing = 0; - } else { - _nc_tracing = save_trace; - } - trace(_nc_tracing); - if (_nc_tracing) - _tracef("TOGGLE-TRACING ON"); - } -#else - c = wgetch(win); -#endif - return c; -} -#define Getchar() wGetchar(stdscr) - -#if USE_WIDEC_SUPPORT -static int -wGet_wchar(WINDOW *win, wint_t * result) -{ - int c; -#ifdef TRACE - while ((c = wget_wch(win, result)) == CTRL('T')) { - if (_nc_tracing) { - save_trace = _nc_tracing; - _tracef("TOGGLE-TRACING OFF"); - _nc_tracing = 0; - } else { - _nc_tracing = save_trace; - } - trace(_nc_tracing); - if (_nc_tracing) - _tracef("TOGGLE-TRACING ON"); - } -#else - c = wget_wch(win, result); -#endif - return c; -} -#define Get_wchar(result) wGet_wchar(stdscr, result) - -#endif - -static void -Pause(void) -{ - move(LINES - 1, 0); - addstr("Press any key to continue... "); - (void) Getchar(); -} - -static void -Cannot(const char *what) -{ - printw("\nThis %s terminal %s\n\n", getenv("TERM"), what); - Pause(); -} - -static void -ShellOut(bool message) -{ - if (message) - addstr("Shelling out..."); - def_prog_mode(); - endwin(); - system("sh"); - if (message) - addstr("returned from shellout.\n"); - refresh(); -} - -#ifdef NCURSES_MOUSE_VERSION -static const char * -mouse_decode(MEVENT const *ep) -{ - static char buf[80]; - - (void) sprintf(buf, "id %2d at (%2d, %2d, %2d) state %4lx = {", - ep->id, ep->x, ep->y, ep->z, ep->bstate); - -#define SHOW(m, s) if ((ep->bstate & m)==m) {strcat(buf,s); strcat(buf, ", ");} - SHOW(BUTTON1_RELEASED, "release-1"); - SHOW(BUTTON1_PRESSED, "press-1"); - SHOW(BUTTON1_CLICKED, "click-1"); - SHOW(BUTTON1_DOUBLE_CLICKED, "doubleclick-1"); - SHOW(BUTTON1_TRIPLE_CLICKED, "tripleclick-1"); - SHOW(BUTTON1_RESERVED_EVENT, "reserved-1"); - SHOW(BUTTON2_RELEASED, "release-2"); - SHOW(BUTTON2_PRESSED, "press-2"); - SHOW(BUTTON2_CLICKED, "click-2"); - SHOW(BUTTON2_DOUBLE_CLICKED, "doubleclick-2"); - SHOW(BUTTON2_TRIPLE_CLICKED, "tripleclick-2"); - SHOW(BUTTON2_RESERVED_EVENT, "reserved-2"); - SHOW(BUTTON3_RELEASED, "release-3"); - SHOW(BUTTON3_PRESSED, "press-3"); - SHOW(BUTTON3_CLICKED, "click-3"); - SHOW(BUTTON3_DOUBLE_CLICKED, "doubleclick-3"); - SHOW(BUTTON3_TRIPLE_CLICKED, "tripleclick-3"); - SHOW(BUTTON3_RESERVED_EVENT, "reserved-3"); - SHOW(BUTTON4_RELEASED, "release-4"); - SHOW(BUTTON4_PRESSED, "press-4"); - SHOW(BUTTON4_CLICKED, "click-4"); - SHOW(BUTTON4_DOUBLE_CLICKED, "doubleclick-4"); - SHOW(BUTTON4_TRIPLE_CLICKED, "tripleclick-4"); - SHOW(BUTTON4_RESERVED_EVENT, "reserved-4"); - SHOW(BUTTON_CTRL, "ctrl"); - SHOW(BUTTON_SHIFT, "shift"); - SHOW(BUTTON_ALT, "alt"); - SHOW(ALL_MOUSE_EVENTS, "all-events"); - SHOW(REPORT_MOUSE_POSITION, "position"); -#undef SHOW - - if (buf[strlen(buf) - 1] == ' ') - buf[strlen(buf) - 2] = '\0'; - (void) strcat(buf, "}"); - return (buf); -} -#endif /* NCURSES_MOUSE_VERSION */ - -/**************************************************************************** - * - * Character input test - * - ****************************************************************************/ - -static void -setup_getch(WINDOW *win, bool flags[]) -{ - keypad(win, flags['k']); /* should be redundant, but for testing */ - meta(win, flags['m']); /* force this to a known state */ - if (flags['e']) - echo(); - else - noecho(); -} - -static void -wgetch_help(WINDOW *win, bool flags[]) -{ - static const char *help[] = - { - "e -- toggle echo mode" - ,"g -- triggers a getstr test" - ,"k -- toggle keypad/literal mode" - ,"m -- toggle meta (7-bit/8-bit) mode" - ,"q -- quit (x also exits)" - ,"s -- shell out\n" - ,"w -- create a new window" -#ifdef SIGTSTP - ,"z -- suspend this process" -#endif - }; - int y, x; - unsigned chk = ((SIZEOF(help) + 1) / 2); - unsigned n; - - getyx(win, y, x); - move(0, 0); - printw("Type any key to see its %s value. Also:\n", - flags['k'] ? "keypad" : "literal"); - for (n = 0; n < SIZEOF(help); ++n) { - int row = 1 + (n % chk); - int col = (n >= chk) ? COLS / 2 : 0; - int flg = ((strstr(help[n], "toggle") != 0) - && (flags[UChar(*help[n])] != FALSE)); - if (flg) - standout(); - mvprintw(row, col, "%s", help[n]); - if (col == 0) - clrtoeol(); - if (flg) - standend(); - } - wrefresh(stdscr); - wmove(win, y, x); -} - -static void -wgetch_wrap(WINDOW *win, int first_y) -{ - int last_y = getmaxy(win) - 1; - int y = getcury(win) + 1; - - if (y >= last_y) - y = first_y; - wmove(win, y, 0); - wclrtoeol(win); -} - -#if defined(NCURSES_VERSION) && defined(KEY_RESIZE) -typedef struct { - WINDOW *text; - WINDOW *frame; -} WINSTACK; - -static WINSTACK *winstack = 0; -static unsigned len_winstack = 0; - -static void -remember_boxes(unsigned level, WINDOW *txt_win, WINDOW *box_win) -{ - unsigned need = (level + 1) * 2; - - if (winstack == 0) { - len_winstack = 20; - winstack = malloc(len_winstack * sizeof(WINSTACK)); - } else if (need >= len_winstack) { - len_winstack = need; - winstack = realloc(winstack, len_winstack * sizeof(WINSTACK)); - } - winstack[level].text = txt_win; - winstack[level].frame = box_win; -} - -/* - * For wgetch_test(), we create pairs of windows - one for a box, one for text. - * Resize both and paint the box in the parent. - */ -static void -resize_boxes(int level, WINDOW *win) -{ - unsigned n; - int base = 5; - int high = LINES - base; - int wide = COLS; - - touchwin(stdscr); - wnoutrefresh(stdscr); - - /* FIXME: this chunk should be done in resizeterm() */ - slk_touch(); - slk_clear(); - slk_noutrefresh(); - - for (n = 0; (int) n < level; ++n) { - wresize(winstack[n].frame, high, wide); - wresize(winstack[n].text, high - 2, wide - 2); - high -= 2; - wide -= 2; - werase(winstack[n].text); - box(winstack[n].frame, 0, 0); - wnoutrefresh(winstack[n].frame); - wprintw(winstack[n].text, - "size %dx%d\n", - getmaxy(winstack[n].text), - getmaxx(winstack[n].text)); - wnoutrefresh(winstack[n].text); - if (winstack[n].text == win) - break; - } - doupdate(); -} -#else -#define remember_boxes(level,text,frame) /* nothing */ -#endif - -static void -wgetch_test(int level, WINDOW *win, int delay) -{ - char buf[BUFSIZ]; - int first_y, first_x; - int c; - int incount = 0; - bool flags[256]; - bool blocking = (delay < 0); - int y, x; - - memset(flags, FALSE, sizeof(flags)); - flags['k'] = (win == stdscr); - - setup_getch(win, flags); - wtimeout(win, delay); - getyx(win, first_y, first_x); - - wgetch_help(win, flags); - wsetscrreg(win, first_y, getmaxy(win) - 1); - scrollok(win, TRUE); - - for (;;) { - while ((c = wGetchar(win)) == ERR) { - incount++; - if (blocking) { - (void) wprintw(win, "%05d: input error", incount); - break; - } else { - (void) wprintw(win, "%05d: input timed out", incount); - } - wgetch_wrap(win, first_y); - } - if (c == ERR && blocking) { - wprintw(win, "ERR"); - wgetch_wrap(win, first_y); - } else if (c == 'x' || c == 'q') { - break; - } else if (c == 'e') { - flags['e'] = !flags['e']; - setup_getch(win, flags); - wgetch_help(win, flags); - } else if (c == 'g') { - waddstr(win, "getstr test: "); - echo(); - wgetnstr(win, buf, sizeof(buf) - 1); - noecho(); - wprintw(win, "I saw %d characters:\n\t`%s'.", (int) strlen(buf), buf); - wclrtoeol(win); - wgetch_wrap(win, first_y); - } else if (c == 'k') { - flags['k'] = !flags['k']; - setup_getch(win, flags); - wgetch_help(win, flags); - } else if (c == 'm') { - flags['m'] = !flags['m']; - setup_getch(win, flags); - wgetch_help(win, flags); - } else if (c == 's') { - ShellOut(TRUE); - } else if (c == 'w') { - int high = getmaxy(win) - 1 - first_y + 1; - int wide = getmaxx(win) - first_x; - int old_y, old_x; - int new_y = first_y + getbegy(win); - int new_x = first_x + getbegx(win); - - getyx(win, old_y, old_x); - if (high > 2 && wide > 2) { - WINDOW *wb = newwin(high, wide, new_y, new_x); - WINDOW *wi = newwin(high - 2, wide - 2, new_y + 1, new_x + 1); - - box(wb, 0, 0); - wrefresh(wb); - wmove(wi, 0, 0); - remember_boxes(level, wi, wb); - wgetch_test(level + 1, wi, delay); - delwin(wi); - delwin(wb); - - wgetch_help(win, flags); - wmove(win, old_y, old_x); - touchwin(win); - wrefresh(win); - doupdate(); - } -#ifdef SIGTSTP - } else if (c == 'z') { - kill(getpid(), SIGTSTP); -#endif - } else { - wprintw(win, "Key pressed: %04o ", c); -#ifdef NCURSES_MOUSE_VERSION - if (c == KEY_MOUSE) { - MEVENT event; - - getmouse(&event); - wprintw(win, "KEY_MOUSE, %s", mouse_decode(&event)); - getyx(win, y, x); - move(event.y, event.x); - addch('*'); - wmove(win, y, x); - } else -#endif /* NCURSES_MOUSE_VERSION */ - if (c >= KEY_MIN) { -#if defined(NCURSES_VERSION) && defined(KEY_RESIZE) - if (c == KEY_RESIZE) { - resize_boxes(level, win); - } -#endif - (void) waddstr(win, keyname(c)); - } else if (c > 0x80) { - int c2 = (c & 0x7f); - if (isprint(c2)) - (void) wprintw(win, "M-%c", c2); - else - (void) wprintw(win, "M-%s", unctrl(c2)); - waddstr(win, " (high-half character)"); - } else { - if (isprint(c)) - (void) wprintw(win, "%c (ASCII printable character)", c); - else - (void) wprintw(win, "%s (ASCII control character)", - unctrl(c)); - } - wgetch_wrap(win, first_y); - } - } - - wtimeout(win, -1); -} - -static int -begin_getch_test(void) -{ - char buf[BUFSIZ]; - int delay; - - refresh(); - -#ifdef NCURSES_MOUSE_VERSION - mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0); -#endif - - (void) printw("Delay in 10ths of a second ( for blocking input)? "); - echo(); - getnstr(buf, sizeof(buf) - 1); - noecho(); - nonl(); - - if (isdigit(UChar(buf[0]))) { - delay = atoi(buf) * 100; - } else { - delay = -1; - } - raw(); - move(5, 0); - return delay; -} - -static void -finish_getch_test(void) -{ -#ifdef NCURSES_MOUSE_VERSION - mousemask(0, (mmask_t *) 0); -#endif - erase(); - noraw(); - nl(); - endwin(); -} - -static void -getch_test(void) -{ - int delay = begin_getch_test(); - wgetch_test(0, stdscr, delay); - finish_getch_test(); -} - -#if USE_WIDEC_SUPPORT -/* - * For wgetch_test(), we create pairs of windows - one for a box, one for text. - * Resize both and paint the box in the parent. - */ -static void -resize_wide_boxes(int level, WINDOW *win) -{ - unsigned n; - int base = 5; - int high = LINES - base; - int wide = COLS; - - touchwin(stdscr); - wnoutrefresh(stdscr); - - /* FIXME: this chunk should be done in resizeterm() */ - slk_touch(); - slk_clear(); - slk_noutrefresh(); - - for (n = 0; (int) n < level; ++n) { - wresize(winstack[n].frame, high, wide); - wresize(winstack[n].text, high - 2, wide - 2); - high -= 2; - wide -= 2; - werase(winstack[n].text); - box_set(winstack[n].frame, 0, 0); - wnoutrefresh(winstack[n].frame); - wprintw(winstack[n].text, - "size %dx%d\n", - getmaxy(winstack[n].text), - getmaxx(winstack[n].text)); - wnoutrefresh(winstack[n].text); - if (winstack[n].text == win) - break; - } - doupdate(); -} - -static void -wget_wch_test(int level, WINDOW *win, int delay) -{ - char buf[BUFSIZ]; - int first_y, first_x; - wint_t c; - int incount = 0; - bool flags[256]; - bool blocking = (delay < 0); - int y, x, code; - - memset(flags, FALSE, sizeof(flags)); - flags['k'] = (win == stdscr); - - setup_getch(win, flags); - wtimeout(win, delay); - getyx(win, first_y, first_x); - - wgetch_help(win, flags); - wsetscrreg(win, first_y, getmaxy(win) - 1); - scrollok(win, TRUE); - - for (;;) { - while ((code = wGet_wchar(win, &c)) == ERR) { - incount++; - if (blocking) { - (void) wprintw(win, "%05d: input error", incount); - break; - } else { - (void) wprintw(win, "%05d: input timed out", incount); - } - wgetch_wrap(win, first_y); - } - if (code == ERR && blocking) { - wprintw(win, "ERR"); - wgetch_wrap(win, first_y); - } else if (c == 'x' || c == 'q') { - break; - } else if (c == 'e') { - flags['e'] = !flags['e']; - setup_getch(win, flags); - wgetch_help(win, flags); - } else if (c == 'g') { - waddstr(win, "getstr test: "); - echo(); - wgetnstr(win, buf, sizeof(buf) - 1); - noecho(); - wprintw(win, "I saw %d characters:\n\t`%s'.", strlen(buf), buf); - wclrtoeol(win); - wgetch_wrap(win, first_y); - } else if (c == 'k') { - flags['k'] = !flags['k']; - setup_getch(win, flags); - wgetch_help(win, flags); - } else if (c == 'm') { - flags['m'] = !flags['m']; - setup_getch(win, flags); - wgetch_help(win, flags); - } else if (c == 's') { - ShellOut(TRUE); - } else if (c == 'w') { - int high = getmaxy(win) - 1 - first_y + 1; - int wide = getmaxx(win) - first_x; - int old_y, old_x; - int new_y = first_y + getbegy(win); - int new_x = first_x + getbegx(win); - - getyx(win, old_y, old_x); - if (high > 2 && wide > 2) { - WINDOW *wb = newwin(high, wide, new_y, new_x); - WINDOW *wi = newwin(high - 2, wide - 2, new_y + 1, new_x + 1); - - box_set(wb, 0, 0); - wrefresh(wb); - wmove(wi, 0, 0); - remember_boxes(level, wi, wb); - wget_wch_test(level + 1, wi, delay); - delwin(wi); - delwin(wb); - - wgetch_help(win, flags); - wmove(win, old_y, old_x); - touchwin(win); - wrefresh(win); - } -#ifdef SIGTSTP - } else if (c == 'z') { - kill(getpid(), SIGTSTP); -#endif - } else { - wprintw(win, "Key pressed: %04o ", c); -#ifdef NCURSES_MOUSE_VERSION - if (c == KEY_MOUSE) { - MEVENT event; - - getmouse(&event); - wprintw(win, "KEY_MOUSE, %s", mouse_decode(&event)); - getyx(win, y, x); - move(event.y, event.x); - addch('*'); - wmove(win, y, x); - } else -#endif /* NCURSES_MOUSE_VERSION */ - if (code == KEY_CODE_YES) { -#ifdef KEY_RESIZE - if (c == KEY_RESIZE) { - resize_wide_boxes(level, win); - } -#endif - (void) waddstr(win, key_name(c)); - } else { - if (c < 256 && iscntrl(c)) { - (void) wprintw(win, "%s (control character)", unctrl(c)); - } else { - wchar_t c2 = c; - waddnwstr(win, &c2, 1); - (void) wprintw(win, " = %#x (printable character)", c); - } - } - wgetch_wrap(win, first_y); - } - } - - wtimeout(win, -1); -} - -static void -get_wch_test(void) -{ - int delay = begin_getch_test(); - wget_wch_test(0, stdscr, delay); - finish_getch_test(); -} -#endif - -/**************************************************************************** - * - * Character attributes test - * - ****************************************************************************/ - -static int -show_attr(int row, int skip, chtype attr, const char *name) -{ - static const char *string = "abcde fghij klmno pqrst uvwxy z"; - int ncv = tigetnum("ncv"); - - mvprintw(row, 8, "%s mode:", name); - mvprintw(row, 24, "|"); - if (skip) - printw("%*s", skip, " "); - attrset(attr); - /* - * If we're to write a string in the alternate character set, it is not - * sufficient to just set A_ALTCHARSET. We have to perform the mapping - * that corresponds. This is not needed for vt100-compatible devices - * because the acs_map[] is 1:1, but for PC-style devices such as Linux - * console, the acs_map[] is scattered about the range. - * - * The addch/addstr functions do not themselves do this mapping, since it - * is possible to turn off the A_ALTCHARSET flag for the characters which - * are added, and it would be an unexpected result to have the mapped - * characters visible on the screen. - * - * This example works because the indices into acs_map[] are mostly from - * the lowercase characters. - */ - if (attr & A_ALTCHARSET) { - const char *s = string; - while (*s) { - int ch = *s++; -#ifdef CURSES_ACS_ARRAY - if ((ch = CURSES_ACS_ARRAY[ch]) == 0) - ch = ' '; -#endif - addch(ch); - } - } else { - addstr(string); - } - attroff(attr); - if (skip) - printw("%*s", skip, " "); - printw("|"); - if (attr != A_NORMAL) { - if (!(termattrs() & attr)) { - printw(" (N/A)"); - } else if (ncv > 0 && (getbkgd(stdscr) & A_COLOR)) { - static const chtype table[] = - { - A_STANDOUT, - A_UNDERLINE, - A_REVERSE, - A_BLINK, - A_DIM, - A_BOLD, - A_INVIS, - A_PROTECT, - A_ALTCHARSET - }; - unsigned n; - bool found = FALSE; - for (n = 0; n < SIZEOF(table); n++) { - if ((table[n] & attr) != 0 - && ((1 << n) & ncv) != 0) { - found = TRUE; - break; - } - } - if (found) - printw(" (NCV)"); - } - } - return row + 2; -} - -static bool -attr_getc(int *skip, int *fg, int *bg, int *ac) -{ - int ch = Getchar(); - - if (isdigit(ch)) { - *skip = (ch - '0'); - } else if (ch == CTRL('L')) { - touchwin(stdscr); - touchwin(curscr); - } else if (has_colors()) { - switch (ch) { - case 'a': - *ac = 0; - break; - case 'A': - *ac = A_ALTCHARSET; - break; - case 'f': - *fg = (*fg + 1); - break; - case 'F': - *fg = (*fg - 1); - break; - case 'b': - *bg = (*bg + 1); - break; - case 'B': - *bg = (*bg - 1); - break; - default: - return FALSE; - } - if (*fg >= max_colors) - *fg = 0; - if (*fg < 0) - *fg = max_colors - 1; - if (*bg >= max_colors) - *bg = 0; - if (*bg < 0) - *bg = max_colors - 1; - } else { - switch (ch) { - case 'a': - *ac = 0; - break; - case 'A': - *ac = A_ALTCHARSET; - break; - default: - return FALSE; - } - } - return TRUE; -} - -static void -attr_test(void) -/* test text attributes */ -{ - int n; - int skip = tigetnum("xmc"); - int fg = COLOR_BLACK; /* color pair 0 is special */ - int bg = COLOR_BLACK; - int ac = 0; - bool *pairs = (bool *) calloc(max_pairs, sizeof(bool)); - pairs[0] = TRUE; - - if (skip < 0) - skip = 0; - - n = skip; /* make it easy */ - - do { - int row = 2; - int normal = A_NORMAL | BLANK; - - if (has_colors()) { - int pair = (fg * max_colors) + bg; - if (!pairs[pair]) { - init_pair(pair, fg, bg); - pairs[pair] = TRUE; - } - normal |= COLOR_PAIR(pair); - } - bkgdset(normal); - erase(); - - mvaddstr(0, 20, "Character attribute test display"); - - row = show_attr(row, n, ac | A_STANDOUT, "STANDOUT"); - row = show_attr(row, n, ac | A_REVERSE, "REVERSE"); - row = show_attr(row, n, ac | A_BOLD, "BOLD"); - row = show_attr(row, n, ac | A_UNDERLINE, "UNDERLINE"); - row = show_attr(row, n, ac | A_DIM, "DIM"); - row = show_attr(row, n, ac | A_BLINK, "BLINK"); - row = show_attr(row, n, ac | A_PROTECT, "PROTECT"); - row = show_attr(row, n, ac | A_INVIS, "INVISIBLE"); - row = show_attr(row, n, ac | A_NORMAL, "NORMAL"); - - mvprintw(row, 8, - "This terminal does %shave the magic-cookie glitch", - tigetnum("xmc") > -1 ? "" : "not "); - mvprintw(row + 1, 8, - "Enter a digit to set gaps on each side of displayed attributes"); - mvprintw(row + 2, 8, - "^L = repaint"); - if (has_colors()) - printw(". f/F/b/F toggle colors (now %d/%d), a/A altcharset (%d)", - fg, bg, ac != 0); - else - printw(". a/A altcharset (%d)", ac != 0); - - refresh(); - } while (attr_getc(&n, &fg, &bg, &ac)); - - free((char *) pairs); - bkgdset(A_NORMAL | BLANK); - erase(); - endwin(); -} - -/**************************************************************************** - * - * Color support tests - * - ****************************************************************************/ - -static NCURSES_CONST char *the_color_names[] = -{ - "black", - "red", - "green", - "yellow", - "blue", - "magenta", - "cyan", - "white", - "BLACK", - "RED", - "GREEN", - "YELLOW", - "BLUE", - "MAGENTA", - "CYAN", - "WHITE" -}; - -static void -show_color_name(int y, int x, int color) -{ - if (max_colors > 8) - mvprintw(y, x, "%02d ", color); - else - mvaddstr(y, x, the_color_names[color]); -} - -static void -color_test(void) -/* generate a color test pattern */ -{ - int i; - int base, top, width; - NCURSES_CONST char *hello; - - refresh(); - (void) printw("There are %d color pairs\n", COLOR_PAIRS); - - width = (max_colors > 8) ? 4 : 8; - hello = (max_colors > 8) ? "Test" : "Hello"; - - for (base = 0; base < 2; base++) { - top = (max_colors > 8) ? 0 : base * (max_colors + 3); - clrtobot(); - (void) mvprintw(top + 1, 0, - "%dx%d matrix of foreground/background colors, bright *%s*\n", - max_colors, max_colors, - base ? "on" : "off"); - for (i = 0; i < max_colors; i++) - show_color_name(top + 2, (i + 1) * width, i); - for (i = 0; i < max_colors; i++) - show_color_name(top + 3 + i, 0, i); - for (i = 1; i < max_pairs; i++) { - init_pair(i, i % max_colors, i / max_colors); - attron((attr_t) COLOR_PAIR(i)); - if (base) - attron((attr_t) A_BOLD); - mvaddstr(top + 3 + (i / max_colors), (i % max_colors + 1) * - width, hello); - attrset(A_NORMAL); - } - if ((max_colors > 8) || base) - Pause(); - } - - erase(); - endwin(); -} - -static void -change_color(int current, int field, int value, int usebase) -{ - short red, green, blue; - - if (usebase) - color_content(current, &red, &green, &blue); - else - red = green = blue = 0; - - switch (field) { - case 0: - red += value; - break; - case 1: - green += value; - break; - case 2: - blue += value; - break; - } - - if (init_color(current, red, green, blue) == ERR) - beep(); -} - -static void -color_edit(void) -/* display the color test pattern, without trying to edit colors */ -{ - int i, this_c = 0, value = 0, current = 0, field = 0; - int last_c; - - refresh(); - - for (i = 0; i < max_colors; i++) - init_pair(i, COLOR_WHITE, i); - - mvprintw(LINES - 2, 0, "Number: %d", value); - - do { - short red, green, blue; - - attron(A_BOLD); - mvaddstr(0, 20, "Color RGB Value Editing"); - attroff(A_BOLD); - - for (i = 0; i < max_colors; i++) { - mvprintw(2 + i, 0, "%c %-8s:", - (i == current ? '>' : ' '), - (i < (int) SIZEOF(the_color_names) - ? the_color_names[i] : "")); - attrset(COLOR_PAIR(i)); - addstr(" "); - attrset(A_NORMAL); - - /* - * Note: this refresh should *not* be necessary! It works around - * a bug in attribute handling that apparently causes the A_NORMAL - * attribute sets to interfere with the actual emission of the - * color setting somehow. This needs to be fixed. - */ - refresh(); - - color_content(i, &red, &green, &blue); - addstr(" R = "); - if (current == i && field == 0) - attron(A_STANDOUT); - printw("%04d", red); - if (current == i && field == 0) - attrset(A_NORMAL); - addstr(", G = "); - if (current == i && field == 1) - attron(A_STANDOUT); - printw("%04d", green); - if (current == i && field == 1) - attrset(A_NORMAL); - addstr(", B = "); - if (current == i && field == 2) - attron(A_STANDOUT); - printw("%04d", blue); - if (current == i && field == 2) - attrset(A_NORMAL); - attrset(A_NORMAL); - addstr(")"); - } - - mvaddstr(max_colors + 3, 0, - "Use up/down to select a color, left/right to change fields."); - mvaddstr(max_colors + 4, 0, - "Modify field by typing nnn=, nnn-, or nnn+. ? for help."); - - move(2 + current, 0); - - last_c = this_c; - this_c = Getchar(); - if (isdigit(this_c) && !isdigit(last_c)) - value = 0; - - switch (this_c) { - case KEY_UP: - current = (current == 0 ? (max_colors - 1) : current - 1); - break; - - case KEY_DOWN: - current = (current == (max_colors - 1) ? 0 : current + 1); - break; - - case KEY_RIGHT: - field = (field == 2 ? 0 : field + 1); - break; - - case KEY_LEFT: - field = (field == 0 ? 2 : field - 1); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - value = value * 10 + (this_c - '0'); - break; - - case '+': - change_color(current, field, value, 1); - break; - - case '-': - change_color(current, field, -value, 1); - break; - - case '=': - change_color(current, field, value, 0); - break; - - case '?': - erase(); - P(" RGB Value Editing Help"); - P(""); - P("You are in the RGB value editor. Use the arrow keys to select one of"); - P("the fields in one of the RGB triples of the current colors; the one"); - P("currently selected will be reverse-video highlighted."); - P(""); - P("To change a field, enter the digits of the new value; they are echoed"); - P("as entered. Finish by typing `='. The change will take effect instantly."); - P("To increment or decrement a value, use the same procedure, but finish"); - P("with a `+' or `-'."); - P(""); - P("To quit, do `x' or 'q'"); - - Pause(); - erase(); - break; - - case 'x': - case 'q': - break; - - default: - beep(); - break; - } - mvprintw(LINES - 2, 0, "Number: %d", value); - clrtoeol(); - } while - (this_c != 'x' && this_c != 'q'); - - erase(); - endwin(); -} - -/**************************************************************************** - * - * Soft-key label test - * - ****************************************************************************/ - -static void -slk_test(void) -/* exercise the soft keys */ -{ - int c, fmt = 1; - char buf[9]; - - c = CTRL('l'); - do { - move(0, 0); - switch (c) { - case CTRL('l'): - erase(); - attron(A_BOLD); - mvaddstr(0, 20, "Soft Key Exerciser"); - attroff(A_BOLD); - - move(2, 0); - P("Available commands are:"); - P(""); - P("^L -- refresh screen"); - P("a -- activate or restore soft keys"); - P("d -- disable soft keys"); - P("c -- set centered format for labels"); - P("l -- set left-justified format for labels"); - P("r -- set right-justified format for labels"); - P("[12345678] -- set label; labels are numbered 1 through 8"); - P("e -- erase stdscr (should not erase labels)"); - P("s -- test scrolling of shortened screen"); - P("x, q -- return to main menu"); - P(""); - P("Note: if activating the soft keys causes your terminal to"); - P("scroll up one line, your terminal auto-scrolls when anything"); - P("is written to the last screen position. The ncurses code"); - P("does not yet handle this gracefully."); - refresh(); - /* fall through */ - - case 'a': - slk_restore(); - break; - - case 'e': - wclear(stdscr); - break; - - case 's': - mvprintw(20, 0, "Press Q to stop the scrolling-test: "); - while ((c = Getchar()) != 'Q' && (c != ERR)) - addch((chtype) c); - break; - - case 'd': - slk_clear(); - break; - - case 'l': - fmt = 0; - break; - - case 'c': - fmt = 1; - break; - - case 'r': - fmt = 2; - break; - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - (void) mvaddstr(20, 0, "Please enter the label value: "); - echo(); - wgetnstr(stdscr, buf, 8); - noecho(); - slk_set((c - '0'), buf, fmt); - slk_refresh(); - move(20, 0); - clrtoeol(); - break; - - case 'x': - case 'q': - goto done; - - default: - beep(); - } - } while - ((c = Getchar()) != EOF); - - done: - erase(); - endwin(); -} - -/**************************************************************************** - * - * Alternate character-set stuff - * - ****************************************************************************/ - -/* ISO 6429: codes 0x80 to 0x9f may be control characters that cause the - * terminal to perform functions. The remaining codes can be graphic. - */ -static void -show_upper_chars(int first) -{ - bool C1 = (first == 128); - int code; - int last = first + 31; - int reply; - - erase(); - attron(A_BOLD); - mvprintw(0, 20, "Display of %s Character Codes %d to %d", - C1 ? "C1" : "GR", first, last); - attroff(A_BOLD); - refresh(); - - for (code = first; code <= last; code++) { - int row = 4 + ((code - first) % 16); - int col = ((code - first) / 16) * COLS / 2; - char tmp[80]; - sprintf(tmp, "%3d (0x%x)", code, code); - mvprintw(row, col, "%*s: ", COLS / 4, tmp); - if (C1) - nodelay(stdscr, TRUE); - echochar(code); - if (C1) { - /* (yes, this _is_ crude) */ - while ((reply = Getchar()) != ERR) { - addch(reply); - napms(10); - } - nodelay(stdscr, FALSE); - } - } -} - -static void -show_box_chars(void) -{ - erase(); - attron(A_BOLD); - mvaddstr(0, 20, "Display of the ACS Line-Drawing Set"); - attroff(A_BOLD); - refresh(); - box(stdscr, 0, 0); - /* *INDENT-OFF* */ - mvhline(LINES / 2, 0, ACS_HLINE, COLS); - mvvline(0, COLS / 2, ACS_VLINE, LINES); - mvaddch(0, COLS / 2, ACS_TTEE); - mvaddch(LINES / 2, COLS / 2, ACS_PLUS); - mvaddch(LINES - 1, COLS / 2, ACS_BTEE); - mvaddch(LINES / 2, 0, ACS_LTEE); - mvaddch(LINES / 2, COLS - 1, ACS_RTEE); - /* *INDENT-ON* */ - -} - -static int -show_1_acs(int n, const char *name, chtype code) -{ - const int height = 16; - int row = 4 + (n % height); - int col = (n / height) * COLS / 2; - mvprintw(row, col, "%*s : ", COLS / 4, name); - addch(code); - return n + 1; -} - -static void -show_acs_chars(void) -/* display the ACS character set */ -{ - int n; - -#define BOTH(name) #name, name - - erase(); - attron(A_BOLD); - mvaddstr(0, 20, "Display of the ACS Character Set"); - attroff(A_BOLD); - refresh(); - - n = show_1_acs(0, BOTH(ACS_ULCORNER)); - n = show_1_acs(n, BOTH(ACS_URCORNER)); - n = show_1_acs(n, BOTH(ACS_LLCORNER)); - n = show_1_acs(n, BOTH(ACS_LRCORNER)); - - n = show_1_acs(n, BOTH(ACS_LTEE)); - n = show_1_acs(n, BOTH(ACS_RTEE)); - n = show_1_acs(n, BOTH(ACS_TTEE)); - n = show_1_acs(n, BOTH(ACS_BTEE)); - - n = show_1_acs(n, BOTH(ACS_HLINE)); - n = show_1_acs(n, BOTH(ACS_VLINE)); - - n = show_1_acs(n, BOTH(ACS_LARROW)); - n = show_1_acs(n, BOTH(ACS_RARROW)); - n = show_1_acs(n, BOTH(ACS_UARROW)); - n = show_1_acs(n, BOTH(ACS_DARROW)); - - n = show_1_acs(n, BOTH(ACS_BLOCK)); - n = show_1_acs(n, BOTH(ACS_BOARD)); - n = show_1_acs(n, BOTH(ACS_LANTERN)); - n = show_1_acs(n, BOTH(ACS_BULLET)); - n = show_1_acs(n, BOTH(ACS_CKBOARD)); - n = show_1_acs(n, BOTH(ACS_DEGREE)); - n = show_1_acs(n, BOTH(ACS_DIAMOND)); - n = show_1_acs(n, BOTH(ACS_PLMINUS)); - n = show_1_acs(n, BOTH(ACS_PLUS)); - - n = show_1_acs(n, BOTH(ACS_GEQUAL)); - n = show_1_acs(n, BOTH(ACS_NEQUAL)); - n = show_1_acs(n, BOTH(ACS_LEQUAL)); - - n = show_1_acs(n, BOTH(ACS_STERLING)); - n = show_1_acs(n, BOTH(ACS_PI)); - n = show_1_acs(n, BOTH(ACS_S1)); - n = show_1_acs(n, BOTH(ACS_S3)); - n = show_1_acs(n, BOTH(ACS_S7)); - n = show_1_acs(n, BOTH(ACS_S9)); -} - -static void -acs_display(void) -{ - int c = 'a'; - - do { - switch (c) { - case 'a': - show_acs_chars(); - break; - case 'b': - show_box_chars(); - break; - case '0': - case '1': - case '2': - case '3': - show_upper_chars((c - '0') * 32 + 128); - break; - } - mvprintw(LINES - 3, 0, - "Note: ANSI terminals may not display C1 characters."); - mvprintw(LINES - 2, 0, - "Select: a=ACS, b=box, 0=C1, 1,2,3=GR characters, q=quit"); - refresh(); - } while ((c = Getchar()) != 'x' && c != 'q'); - - Pause(); - erase(); - endwin(); -} - -#if USE_WIDEC_SUPPORT -static void -show_upper_widechars(int first) -{ - cchar_t temp; - wchar_t code; - int last = first + 31; - - erase(); - attron(A_BOLD); - mvprintw(0, 20, "Display of Character Codes %d to %d", first, last); - attroff(A_BOLD); - refresh(); - - for (code = first; code <= last; code++) { - int row = 4 + ((code - first) % 16); - int col = ((code - first) / 16) * COLS / 2; - attr_t attrs = A_NORMAL; - char tmp[80]; - sprintf(tmp, "%3d (0x%x)", code, code); - mvprintw(row, col, "%*s: ", COLS / 4, tmp); - setcchar(&temp, &code, attrs, 0, 0); - echo_wchar(&temp); - } -} - -static int -show_1_wacs(int n, const char *name, const cchar_t * code) -{ - const int height = 16; - int row = 4 + (n % height); - int col = (n / height) * COLS / 2; - mvprintw(row, col, "%*s : ", COLS / 4, name); - add_wchnstr(code, 1); - return n + 1; -} - -static void -show_wacs_chars(void) -/* display the wide-ACS character set */ -{ - int n; - -/*#define BOTH2(name) #name, &(name) */ -#define BOTH2(name) #name, name - - erase(); - attron(A_BOLD); - mvaddstr(0, 20, "Display of the Wide-ACS Character Set"); - attroff(A_BOLD); - refresh(); - - n = show_1_wacs(0, BOTH2(WACS_ULCORNER)); - n = show_1_wacs(n, BOTH2(WACS_URCORNER)); - n = show_1_wacs(n, BOTH2(WACS_LLCORNER)); - n = show_1_wacs(n, BOTH2(WACS_LRCORNER)); - - n = show_1_wacs(n, BOTH2(WACS_LTEE)); - n = show_1_wacs(n, BOTH2(WACS_RTEE)); - n = show_1_wacs(n, BOTH2(WACS_TTEE)); - n = show_1_wacs(n, BOTH2(WACS_BTEE)); - - n = show_1_wacs(n, BOTH2(WACS_HLINE)); - n = show_1_wacs(n, BOTH2(WACS_VLINE)); - - n = show_1_wacs(n, BOTH2(WACS_LARROW)); - n = show_1_wacs(n, BOTH2(WACS_RARROW)); - n = show_1_wacs(n, BOTH2(WACS_UARROW)); - n = show_1_wacs(n, BOTH2(WACS_DARROW)); - - n = show_1_wacs(n, BOTH2(WACS_BLOCK)); - n = show_1_wacs(n, BOTH2(WACS_BOARD)); - n = show_1_wacs(n, BOTH2(WACS_LANTERN)); - n = show_1_wacs(n, BOTH2(WACS_BULLET)); - n = show_1_wacs(n, BOTH2(WACS_CKBOARD)); - n = show_1_wacs(n, BOTH2(WACS_DEGREE)); - n = show_1_wacs(n, BOTH2(WACS_DIAMOND)); - n = show_1_wacs(n, BOTH2(WACS_PLMINUS)); - n = show_1_wacs(n, BOTH2(WACS_PLUS)); - -#ifdef CURSES_WACS_ARRAY - n = show_1_wacs(n, BOTH2(WACS_GEQUAL)); - n = show_1_wacs(n, BOTH2(WACS_NEQUAL)); - n = show_1_wacs(n, BOTH2(WACS_LEQUAL)); - - n = show_1_wacs(n, BOTH2(WACS_STERLING)); - n = show_1_wacs(n, BOTH2(WACS_PI)); - n = show_1_wacs(n, BOTH2(WACS_S1)); - n = show_1_wacs(n, BOTH2(WACS_S3)); - n = show_1_wacs(n, BOTH2(WACS_S7)); - n = show_1_wacs(n, BOTH2(WACS_S9)); -#endif -} - -static void -show_wbox_chars(void) -{ - erase(); - attron(A_BOLD); - mvaddstr(0, 20, "Display of the Wide-ACS Line-Drawing Set"); - attroff(A_BOLD); - refresh(); - box_set(stdscr, 0, 0); - /* *INDENT-OFF* */ - mvhline_set(LINES / 2, 0, WACS_HLINE, COLS); - mvvline_set(0, COLS / 2, WACS_VLINE, LINES); - mvadd_wch(0, COLS / 2, WACS_TTEE); - mvadd_wch(LINES / 2, COLS / 2, WACS_PLUS); - mvadd_wch(LINES - 1, COLS / 2, WACS_BTEE); - mvadd_wch(LINES / 2, 0, WACS_LTEE); - mvadd_wch(LINES / 2, COLS - 1, WACS_RTEE); - /* *INDENT-ON* */ - -} - -static int -show_2_wacs(int n, const char *name, char *code) -{ - const int height = 16; - int row = 4 + (n % height); - int col = (n / height) * COLS / 2; - mvprintw(row, col, "%*s : ", COLS / 4, name); - addstr(code); - return n + 1; -} - -static void -show_utf8_chars(void) -/* display the wide-ACS character set */ -{ - int n; - - erase(); - attron(A_BOLD); - mvaddstr(0, 20, "Display of the Wide-ACS Character Set"); - attroff(A_BOLD); - refresh(); - /* *INDENT-OFF* */ - n = show_2_wacs(0, "WACS_ULCORNER", "\342\224\214"); - n = show_2_wacs(n, "WACS_URCORNER", "\342\224\220"); - n = show_2_wacs(n, "WACS_LLCORNER", "\342\224\224"); - n = show_2_wacs(n, "WACS_LRCORNER", "\342\224\230"); - - n = show_2_wacs(n, "WACS_LTEE", "\342\224\234"); - n = show_2_wacs(n, "WACS_RTEE", "\342\224\244"); - n = show_2_wacs(n, "WACS_TTEE", "\342\224\254"); - n = show_2_wacs(n, "WACS_BTEE", "\342\224\264"); - - n = show_2_wacs(n, "WACS_HLINE", "\342\224\200"); - n = show_2_wacs(n, "WACS_VLINE", "\342\224\202"); - - n = show_2_wacs(n, "WACS_LARROW", "\342\206\220"); - n = show_2_wacs(n, "WACS_RARROW", "\342\206\222"); - n = show_2_wacs(n, "WACS_UARROW", "\342\206\221"); - n = show_2_wacs(n, "WACS_DARROW", "\342\206\223"); - - n = show_2_wacs(n, "WACS_STERLING", "\302\243"); - - n = show_2_wacs(n, "WACS_BLOCK", "\342\226\256"); - n = show_2_wacs(n, "WACS_BOARD", "\342\226\222"); - n = show_2_wacs(n, "WACS_LANTERN", "\342\230\203"); - n = show_2_wacs(n, "WACS_BULLET", "\302\267"); - n = show_2_wacs(n, "WACS_CKBOARD", "\342\226\222"); - n = show_2_wacs(n, "WACS_DEGREE", "\302\260"); - n = show_2_wacs(n, "WACS_DIAMOND", "\342\227\206"); - n = show_2_wacs(n, "WACS_GEQUAL", "\342\211\245"); - n = show_2_wacs(n, "WACS_NEQUAL", "\342\211\240"); - n = show_2_wacs(n, "WACS_LEQUAL", "\342\211\244"); - n = show_2_wacs(n, "WACS_PLMINUS", "\302\261"); - n = show_2_wacs(n, "WACS_PLUS", "\342\224\274"); - n = show_2_wacs(n, "WACS_PI", "\317\200"); - n = show_2_wacs(n, "WACS_S1", "\342\216\272"); - n = show_2_wacs(n, "WACS_S3", "\342\216\273"); - n = show_2_wacs(n, "WACS_S7", "\342\216\274"); - n = show_2_wacs(n, "WACS_S9", "\342\216\275"); - /* *INDENT-OFF* */ -} - -static void -wide_acs_display(void) -{ - int c = 'a'; - - do { - switch (c) { - case 'a': - show_wacs_chars(); - break; - case 'b': - show_wbox_chars(); - break; - case 'u': - show_utf8_chars(); - break; - default: - if (isdigit(c)) - show_upper_widechars((c - '0') * 32 + 128); - break; - } - mvprintw(LINES - 2, 0, - "Select: a WACS, b box, u UTF-8, 0-9 non-ASCII characters, q=quit"); - refresh(); - } while ((c = Getchar()) != 'x' && c != 'q'); - - Pause(); - erase(); - endwin(); -} - -#endif - -/* - * Graphic-rendition test (adapted from vttest) - */ -static void -test_sgr_attributes(void) -{ - int pass; - - for (pass = 0; pass < 2; pass++) { - int normal = ((pass == 0 ? A_NORMAL : A_REVERSE)) | BLANK; - - /* Use non-default colors if possible to exercise bce a little */ - if (has_colors()) { - init_pair(1, COLOR_WHITE, COLOR_BLUE); - normal |= COLOR_PAIR(1); - } - bkgdset(normal); - erase(); - mvprintw(1, 20, "Graphic rendition test pattern:"); - - mvprintw(4, 1, "vanilla"); - -#define set_sgr(mask) bkgdset((normal^(mask))); - set_sgr(A_BOLD); - mvprintw(4, 40, "bold"); - - set_sgr(A_UNDERLINE); - mvprintw(6, 6, "underline"); - - set_sgr(A_BOLD | A_UNDERLINE); - mvprintw(6, 45, "bold underline"); - - set_sgr(A_BLINK); - mvprintw(8, 1, "blink"); - - set_sgr(A_BLINK | A_BOLD); - mvprintw(8, 40, "bold blink"); - - set_sgr(A_UNDERLINE | A_BLINK); - mvprintw(10, 6, "underline blink"); - - set_sgr(A_BOLD | A_UNDERLINE | A_BLINK); - mvprintw(10, 45, "bold underline blink"); - - set_sgr(A_REVERSE); - mvprintw(12, 1, "negative"); - - set_sgr(A_BOLD | A_REVERSE); - mvprintw(12, 40, "bold negative"); - - set_sgr(A_UNDERLINE | A_REVERSE); - mvprintw(14, 6, "underline negative"); - - set_sgr(A_BOLD | A_UNDERLINE | A_REVERSE); - mvprintw(14, 45, "bold underline negative"); - - set_sgr(A_BLINK | A_REVERSE); - mvprintw(16, 1, "blink negative"); - - set_sgr(A_BOLD | A_BLINK | A_REVERSE); - mvprintw(16, 40, "bold blink negative"); - - set_sgr(A_UNDERLINE | A_BLINK | A_REVERSE); - mvprintw(18, 6, "underline blink negative"); - - set_sgr(A_BOLD | A_UNDERLINE | A_BLINK | A_REVERSE); - mvprintw(18, 45, "bold underline blink negative"); - - bkgdset(normal); - mvprintw(LINES - 2, 1, "%s background. ", pass == 0 ? "Dark" : - "Light"); - clrtoeol(); - Pause(); - } - - bkgdset(A_NORMAL | BLANK); - erase(); - endwin(); -} - -/**************************************************************************** - * - * Windows and scrolling tester. - * - ****************************************************************************/ - -#define BOTLINES 4 /* number of line stolen from screen bottom */ - -typedef struct { - int y, x; -} pair; - -#define FRAME struct frame -FRAME -{ - FRAME *next, *last; - bool do_scroll; - bool do_keypad; - WINDOW *wind; -}; - -#ifdef NCURSES_VERSION -#define keypad_active(win) (win)->_use_keypad -#define scroll_active(win) (win)->_scroll -#else -#define keypad_active(win) FALSE -#define scroll_active(win) FALSE -#endif - -/* We need to know if these flags are actually set, so don't look in FRAME. - * These names are known to work with SVr4 curses as well as ncurses. The - * _use_keypad name does not work with Solaris 8. - */ -static bool -HaveKeypad(FRAME * curp) -{ - WINDOW *win = (curp ? curp->wind : stdscr); - return keypad_active(win); -} - -static bool -HaveScroll(FRAME * curp) -{ - WINDOW *win = (curp ? curp->wind : stdscr); - return scroll_active(win); -} - -static void -newwin_legend(FRAME * curp) -{ - static const struct { - const char *msg; - int code; - } legend[] = { - { - "^C = create window", 0 - }, - { - "^N = next window", 0 - }, - { - "^P = previous window", 0 - }, - { - "^F = scroll forward", 0 - }, - { - "^B = scroll backward", 0 - }, - { - "^K = keypad(%s)", 1 - }, - { - "^S = scrollok(%s)", 2 - }, - { - "^W = save window to file", 0 - }, - { - "^R = restore window", 0 - }, -#if HAVE_WRESIZE - { - "^X = resize", 0 - }, -#endif - { - "^Q%s = exit", 3 - } - }; - size_t n; - int x; - bool do_keypad = HaveKeypad(curp); - bool do_scroll = HaveScroll(curp); - char buf[BUFSIZ]; - - move(LINES - 4, 0); - for (n = 0; n < SIZEOF(legend); n++) { - switch (legend[n].code) { - default: - strcpy(buf, legend[n].msg); - break; - case 1: - sprintf(buf, legend[n].msg, do_keypad ? "yes" : "no"); - break; - case 2: - sprintf(buf, legend[n].msg, do_scroll ? "yes" : "no"); - break; - case 3: - sprintf(buf, legend[n].msg, do_keypad ? "/ESC" : ""); - break; - } - x = getcurx(stdscr); - addstr((COLS < (x + 3 + (int) strlen(buf))) ? "\n" : (n ? ", " : "")); - addstr(buf); - } - clrtoeol(); -} - -static void -transient(FRAME * curp, NCURSES_CONST char *msg) -{ - newwin_legend(curp); - if (msg) { - mvaddstr(LINES - 1, 0, msg); - refresh(); - napms(1000); - } - - move(LINES - 1, 0); - printw("%s characters are echoed, window should %sscroll.", - HaveKeypad(curp) ? "Non-arrow" : "All other", - HaveScroll(curp) ? "" : "not "); - clrtoeol(); -} - -static void -newwin_report(FRAME * curp) -/* report on the cursor's current position, then restore it */ -{ - WINDOW *win = (curp != 0) ? curp->wind : stdscr; - int y, x; - - if (win != stdscr) - transient(curp, (char *) 0); - getyx(win, y, x); - move(LINES - 1, COLS - 17); - printw("Y = %2d X = %2d", y, x); - if (win != stdscr) - refresh(); - else - wmove(win, y, x); -} - -static pair * -selectcell(int uli, int ulj, int lri, int lrj) -/* arrows keys move cursor, return location at current on non-arrow key */ -{ - static pair res; /* result cell */ - int si = lri - uli + 1; /* depth of the select area */ - int sj = lrj - ulj + 1; /* width of the select area */ - int i = 0, j = 0; /* offsets into the select area */ - - res.y = uli; - res.x = ulj; - for (;;) { - move(uli + i, ulj + j); - newwin_report((FRAME *) 0); - - switch (Getchar()) { - case KEY_UP: - i += si - 1; - break; - case KEY_DOWN: - i++; - break; - case KEY_LEFT: - j += sj - 1; - break; - case KEY_RIGHT: - j++; - break; - case QUIT: - case ESCAPE: - return ((pair *) 0); -#ifdef NCURSES_MOUSE_VERSION - case KEY_MOUSE: - { - MEVENT event; - - getmouse(&event); - if (event.y > uli && event.x > ulj) { - i = event.y - uli; - j = event.x - ulj; - } else { - beep(); - break; - } - } - /* FALLTHRU */ -#endif - default: - res.y = uli + i; - res.x = ulj + j; - return (&res); - } - i %= si; - j %= sj; - } -} - -static void -outerbox(pair ul, pair lr, bool onoff) -/* draw or erase a box *outside* the given pair of corners */ -{ - mvaddch(ul.y - 1, lr.x - 1, onoff ? ACS_ULCORNER : ' '); - mvaddch(ul.y - 1, lr.x + 1, onoff ? ACS_URCORNER : ' '); - mvaddch(lr.y + 1, lr.x + 1, onoff ? ACS_LRCORNER : ' '); - mvaddch(lr.y + 1, ul.x - 1, onoff ? ACS_LLCORNER : ' '); - move(ul.y - 1, ul.x); - hline(onoff ? ACS_HLINE : ' ', lr.x - ul.x + 1); - move(ul.y, ul.x - 1); - vline(onoff ? ACS_VLINE : ' ', lr.y - ul.y + 1); - move(lr.y + 1, ul.x); - hline(onoff ? ACS_HLINE : ' ', lr.x - ul.x + 1); - move(ul.y, lr.x + 1); - vline(onoff ? ACS_VLINE : ' ', lr.y - ul.y + 1); -} - -static WINDOW * -getwindow(void) -/* Ask user for a window definition */ -{ - WINDOW *rwindow; - pair ul, lr, *tmp; - - move(0, 0); - clrtoeol(); - addstr("Use arrows to move cursor, anything else to mark corner 1"); - refresh(); - if ((tmp = selectcell(2, 1, LINES - BOTLINES - 2, COLS - 2)) == (pair *) 0) - return ((WINDOW *) 0); - memcpy(&ul, tmp, sizeof(pair)); - mvaddch(ul.y - 1, ul.x - 1, ACS_ULCORNER); - move(0, 0); - clrtoeol(); - addstr("Use arrows to move cursor, anything else to mark corner 2"); - refresh(); - if ((tmp = selectcell(ul.y, ul.x, LINES - BOTLINES - 2, COLS - 2)) == - (pair *) 0) - return ((WINDOW *) 0); - memcpy(&lr, tmp, sizeof(pair)); - - rwindow = subwin(stdscr, lr.y - ul.y + 1, lr.x - ul.x + 1, ul.y, ul.x); - - outerbox(ul, lr, TRUE); - refresh(); - - wrefresh(rwindow); - - move(0, 0); - clrtoeol(); - return (rwindow); -} - -static void -newwin_move(FRAME * curp, int dy, int dx) -{ - WINDOW *win = (curp != 0) ? curp->wind : stdscr; - int cur_y, cur_x; - int max_y, max_x; - - getyx(win, cur_y, cur_x); - getmaxyx(win, max_y, max_x); - if ((cur_x += dx) < 0) - cur_x = 0; - else if (cur_x >= max_x) - cur_x = max_x - 1; - if ((cur_y += dy) < 0) - cur_y = 0; - else if (cur_y >= max_y) - cur_y = max_y - 1; - wmove(win, cur_y, cur_x); -} - -static FRAME * -delete_framed(FRAME * fp, bool showit) -{ - FRAME *np; - - fp->last->next = fp->next; - fp->next->last = fp->last; - - if (showit) { - werase(fp->wind); - wrefresh(fp->wind); - } - delwin(fp->wind); - - np = (fp == fp->next) ? 0 : fp->next; - free(fp); - return np; -} - -static void -acs_and_scroll(void) -/* Demonstrate windows */ -{ - int c, i; - FILE *fp; - FRAME *current = (FRAME *) 0, *neww; - WINDOW *usescr = stdscr; - -#define DUMPFILE "screendump" - -#ifdef NCURSES_MOUSE_VERSION - mousemask(BUTTON1_CLICKED, (mmask_t *) 0); -#endif - c = CTRL('C'); - raw(); - do { - transient((FRAME *) 0, (char *) 0); - switch (c) { - case CTRL('C'): - neww = (FRAME *) calloc(1, sizeof(FRAME)); - if ((neww->wind = getwindow()) == (WINDOW *) 0) - goto breakout; - - if (current == 0) { /* First element, */ - neww->next = neww; /* so point it at itself */ - neww->last = neww; - } else { - neww->next = current->next; - neww->last = current; - neww->last->next = neww; - neww->next->last = neww; - } - current = neww; - /* SVr4 curses sets the keypad on all newly-created windows to - * false. Someone reported that PDCurses makes new windows inherit - * this flag. Remove the following 'keypad()' call to test this - */ - keypad(current->wind, TRUE); - current->do_keypad = HaveKeypad(current); - current->do_scroll = HaveScroll(current); - break; - - case CTRL('N'): /* go to next window */ - if (current) - current = current->next; - break; - - case CTRL('P'): /* go to previous window */ - if (current) - current = current->last; - break; - - case CTRL('F'): /* scroll current window forward */ - if (current) - wscrl(current->wind, 1); - break; - - case CTRL('B'): /* scroll current window backwards */ - if (current) - wscrl(current->wind, -1); - break; - - case CTRL('K'): /* toggle keypad mode for current */ - if (current) { - current->do_keypad = !current->do_keypad; - keypad(current->wind, current->do_keypad); - } - break; - - case CTRL('S'): - if (current) { - current->do_scroll = !current->do_scroll; - scrollok(current->wind, current->do_scroll); - } - break; - - case CTRL('W'): /* save and delete window */ - if (current == current->next) - break; - if ((fp = fopen(DUMPFILE, "w")) == (FILE *) 0) - transient(current, "Can't open screen dump file"); - else { - (void) putwin(current->wind, fp); - (void) fclose(fp); - - current = delete_framed(current, TRUE); - } - break; - - case CTRL('R'): /* restore window */ - if ((fp = fopen(DUMPFILE, "r")) == (FILE *) 0) - transient(current, "Can't open screen dump file"); - else { - neww = (FRAME *) calloc(1, sizeof(FRAME)); - - neww->next = current->next; - neww->last = current; - neww->last->next = neww; - neww->next->last = neww; - - neww->wind = getwin(fp); - (void) fclose(fp); - - wrefresh(neww->wind); - } - break; - -#if HAVE_WRESIZE - case CTRL('X'): /* resize window */ - if (current) { - pair *tmp, ul, lr; - int mx, my; - - move(0, 0); - clrtoeol(); - addstr("Use arrows to move cursor, anything else to mark new corner"); - refresh(); - - getbegyx(current->wind, ul.y, ul.x); - - tmp = selectcell(ul.y, ul.x, LINES - BOTLINES - 2, COLS - 2); - if (tmp == (pair *) 0) { - beep(); - break; - } - - getmaxyx(current->wind, lr.y, lr.x); - lr.y += (ul.y - 1); - lr.x += (ul.x - 1); - outerbox(ul, lr, FALSE); - wnoutrefresh(stdscr); - - /* strictly cosmetic hack for the test */ - getmaxyx(current->wind, my, mx); - if (my > tmp->y - ul.y) { - getyx(current->wind, lr.y, lr.x); - wmove(current->wind, tmp->y - ul.y + 1, 0); - wclrtobot(current->wind); - wmove(current->wind, lr.y, lr.x); - } - if (mx > tmp->x - ul.x) - for (i = 0; i < my; i++) { - wmove(current->wind, i, tmp->x - ul.x + 1); - wclrtoeol(current->wind); - } - wnoutrefresh(current->wind); - - memcpy(&lr, tmp, sizeof(pair)); - (void) wresize(current->wind, lr.y - ul.y + 0, lr.x - ul.x + 0); - - getbegyx(current->wind, ul.y, ul.x); - getmaxyx(current->wind, lr.y, lr.x); - lr.y += (ul.y - 1); - lr.x += (ul.x - 1); - outerbox(ul, lr, TRUE); - wnoutrefresh(stdscr); - - wnoutrefresh(current->wind); - move(0, 0); - clrtoeol(); - doupdate(); - } - break; -#endif /* HAVE_WRESIZE */ - - case KEY_F(10): /* undocumented --- use this to test area clears */ - selectcell(0, 0, LINES - 1, COLS - 1); - clrtobot(); - refresh(); - break; - - case KEY_UP: - newwin_move(current, -1, 0); - break; - case KEY_DOWN: - newwin_move(current, 1, 0); - break; - case KEY_LEFT: - newwin_move(current, 0, -1); - break; - case KEY_RIGHT: - newwin_move(current, 0, 1); - break; - - case KEY_BACKSPACE: - /* FALLTHROUGH */ - case KEY_DC: - { - int y, x; - getyx(current->wind, y, x); - if (--x < 0) { - if (--y < 0) - break; - x = getmaxx(current->wind) - 1; - } - mvwdelch(current->wind, y, x); - } - break; - - case '\r': - c = '\n'; - /* FALLTHROUGH */ - - default: - if (current) - waddch(current->wind, (chtype) c); - else - beep(); - break; - } - newwin_report(current); - usescr = (current ? current->wind : stdscr); - wrefresh(usescr); - } while - ((c = wGetchar(usescr)) != QUIT - && !((c == ESCAPE) && (keypad_active(usescr))) - && (c != ERR)); - - breakout: - while (current != 0) - current = delete_framed(current, FALSE); - - scrollok(stdscr, TRUE); /* reset to driver's default */ -#ifdef NCURSES_MOUSE_VERSION - mousemask(0, (mmask_t *) 0); -#endif - noraw(); - erase(); - endwin(); -} - -/**************************************************************************** - * - * Panels tester - * - ****************************************************************************/ - -#if USE_LIBPANEL -static unsigned long nap_msec = 1; - -static NCURSES_CONST char *mod[] = -{ - "test ", - "TEST ", - "(**) ", - "*()* ", - "<--> ", - "LAST " -}; - -/*+------------------------------------------------------------------------- - wait_a_while(msec) ---------------------------------------------------------------------------*/ -static void -wait_a_while(unsigned long msec GCC_UNUSED) -{ -#if HAVE_NAPMS - if (nap_msec == 1) - wGetchar(stdscr); - else - napms(nap_msec); -#else - if (nap_msec == 1) - wGetchar(stdscr); - else if (msec > 1000L) - sleep((int) msec / 1000L); - else - sleep(1); -#endif -} /* end of wait_a_while */ - -/*+------------------------------------------------------------------------- - saywhat(text) ---------------------------------------------------------------------------*/ -static void -saywhat(NCURSES_CONST char *text) -{ - wmove(stdscr, LINES - 1, 0); - wclrtoeol(stdscr); - waddstr(stdscr, text); -} /* end of saywhat */ - -/*+------------------------------------------------------------------------- - mkpanel(rows,cols,tly,tlx) - alloc a win and panel and associate them ---------------------------------------------------------------------------*/ -static PANEL * -mkpanel(int color, int rows, int cols, int tly, int tlx) -{ - WINDOW *win; - PANEL *pan = 0; - - if ((win = newwin(rows, cols, tly, tlx)) != 0) { - if ((pan = new_panel(win)) == 0) { - delwin(win); - } else if (has_colors()) { - int fg = (color == COLOR_BLUE) ? COLOR_WHITE : COLOR_BLACK; - int bg = color; - init_pair(color, fg, bg); - wbkgdset(win, COLOR_PAIR(color) | ' '); - } else { - wbkgdset(win, A_BOLD | ' '); - } - } - return pan; -} /* end of mkpanel */ - -/*+------------------------------------------------------------------------- - rmpanel(pan) ---------------------------------------------------------------------------*/ -static void -rmpanel(PANEL * pan) -{ - WINDOW *win = panel_window(pan); - del_panel(pan); - delwin(win); -} /* end of rmpanel */ - -/*+------------------------------------------------------------------------- - pflush() ---------------------------------------------------------------------------*/ -static void -pflush(void) -{ - update_panels(); - doupdate(); -} /* end of pflush */ - -/*+------------------------------------------------------------------------- - fill_panel(win) ---------------------------------------------------------------------------*/ -static void -fill_panel(PANEL * pan) -{ - WINDOW *win = panel_window(pan); - int num = ((const char *) panel_userptr(pan))[1]; - int y, x; - - wmove(win, 1, 1); - wprintw(win, "-pan%c-", num); - wclrtoeol(win); - box(win, 0, 0); - for (y = 2; y < getmaxy(win) - 1; y++) { - for (x = 1; x < getmaxx(win) - 1; x++) { - wmove(win, y, x); - waddch(win, num); - } - } -} /* end of fill_panel */ - -static void -demo_panels(void) -{ - int itmp; - register int y, x; - - refresh(); - - for (y = 0; y < LINES - 1; y++) { - for (x = 0; x < COLS; x++) - wprintw(stdscr, "%d", (y + x) % 10); - } - for (y = 0; y < 5; y++) { - PANEL *p1; - PANEL *p2; - PANEL *p3; - PANEL *p4; - PANEL *p5; - - p1 = mkpanel(COLOR_RED, - LINES / 2 - 2, - COLS / 8 + 1, - 0, - 0); - set_panel_userptr(p1, "p1"); - - p2 = mkpanel(COLOR_GREEN, - LINES / 2 + 1, - COLS / 7, - LINES / 4, - COLS / 10); - set_panel_userptr(p2, "p2"); - - p3 = mkpanel(COLOR_YELLOW, - LINES / 4, - COLS / 10, - LINES / 2, - COLS / 9); - set_panel_userptr(p3, "p3"); - - p4 = mkpanel(COLOR_BLUE, - LINES / 2 - 2, - COLS / 8, - LINES / 2 - 2, - COLS / 3); - set_panel_userptr(p4, "p4"); - - p5 = mkpanel(COLOR_MAGENTA, - LINES / 2 - 2, - COLS / 8, - LINES / 2, - COLS / 2 - 2); - set_panel_userptr(p5, "p5"); - - fill_panel(p1); - fill_panel(p2); - fill_panel(p3); - fill_panel(p4); - fill_panel(p5); - hide_panel(p4); - hide_panel(p5); - pflush(); - saywhat("press any key to continue"); - wait_a_while(nap_msec); - - saywhat("h3 s1 s2 s4 s5; press any key to continue"); - move_panel(p1, 0, 0); - hide_panel(p3); - show_panel(p1); - show_panel(p2); - show_panel(p4); - show_panel(p5); - pflush(); - wait_a_while(nap_msec); - - saywhat("s1; press any key to continue"); - show_panel(p1); - pflush(); - wait_a_while(nap_msec); - - saywhat("s2; press any key to continue"); - show_panel(p2); - pflush(); - wait_a_while(nap_msec); - - saywhat("m2; press any key to continue"); - move_panel(p2, LINES / 3 + 1, COLS / 8); - pflush(); - wait_a_while(nap_msec); - - saywhat("s3;"); - show_panel(p3); - pflush(); - wait_a_while(nap_msec); - - saywhat("m3; press any key to continue"); - move_panel(p3, LINES / 4 + 1, COLS / 15); - pflush(); - wait_a_while(nap_msec); - - saywhat("b3; press any key to continue"); - bottom_panel(p3); - pflush(); - wait_a_while(nap_msec); - - saywhat("s4; press any key to continue"); - show_panel(p4); - pflush(); - wait_a_while(nap_msec); - - saywhat("s5; press any key to continue"); - show_panel(p5); - pflush(); - wait_a_while(nap_msec); - - saywhat("t3; press any key to continue"); - top_panel(p3); - pflush(); - wait_a_while(nap_msec); - - saywhat("t1; press any key to continue"); - top_panel(p1); - pflush(); - wait_a_while(nap_msec); - - saywhat("t2; press any key to continue"); - top_panel(p2); - pflush(); - wait_a_while(nap_msec); - - saywhat("t3; press any key to continue"); - top_panel(p3); - pflush(); - wait_a_while(nap_msec); - - saywhat("t4; press any key to continue"); - top_panel(p4); - pflush(); - wait_a_while(nap_msec); - - for (itmp = 0; itmp < 6; itmp++) { - WINDOW *w4 = panel_window(p4); - WINDOW *w5 = panel_window(p5); - - saywhat("m4; press any key to continue"); - wmove(w4, LINES / 8, 1); - waddstr(w4, mod[itmp]); - move_panel(p4, LINES / 6, itmp * (COLS / 8)); - wmove(w5, LINES / 6, 1); - waddstr(w5, mod[itmp]); - pflush(); - wait_a_while(nap_msec); - - saywhat("m5; press any key to continue"); - wmove(w4, LINES / 6, 1); - waddstr(w4, mod[itmp]); - move_panel(p5, LINES / 3 - 1, (itmp * 10) + 6); - wmove(w5, LINES / 8, 1); - waddstr(w5, mod[itmp]); - pflush(); - wait_a_while(nap_msec); - } - - saywhat("m4; press any key to continue"); - move_panel(p4, LINES / 6, itmp * (COLS / 8)); - pflush(); - wait_a_while(nap_msec); - - saywhat("t5; press any key to continue"); - top_panel(p5); - pflush(); - wait_a_while(nap_msec); - - saywhat("t2; press any key to continue"); - top_panel(p2); - pflush(); - wait_a_while(nap_msec); - - saywhat("t1; press any key to continue"); - top_panel(p1); - pflush(); - wait_a_while(nap_msec); - - saywhat("d2; press any key to continue"); - rmpanel(p2); - pflush(); - wait_a_while(nap_msec); - - saywhat("h3; press any key to continue"); - hide_panel(p3); - pflush(); - wait_a_while(nap_msec); - - saywhat("d1; press any key to continue"); - rmpanel(p1); - pflush(); - wait_a_while(nap_msec); - - saywhat("d4; press any key to continue"); - rmpanel(p4); - pflush(); - wait_a_while(nap_msec); - - saywhat("d5; press any key to continue"); - rmpanel(p5); - pflush(); - wait_a_while(nap_msec); - if (nap_msec == 1) - break; - nap_msec = 100L; - } - - erase(); - endwin(); -} - -/**************************************************************************** - * - * Pad tester - * - ****************************************************************************/ - -#define GRIDSIZE 3 - -static bool pending_pan = FALSE; -static bool show_panner_legend = TRUE; - -static int -panner_legend(int line) -{ - static const char *const legend[] = - { - "Use arrow keys (or U,D,L,R) to pan, q to quit, ! to shell-out.", - "Use +,- (or j,k) to grow/shrink the panner vertically.", - "Use <,> (or h,l) to grow/shrink the panner horizontally.", - "Number repeats. Toggle legend:?, timer:t, scroll mark:s." - }; - int n = (SIZEOF(legend) - (LINES - line)); - if (line < LINES && (n >= 0)) { - move(line, 0); - if (show_panner_legend) - printw("%s", legend[n]); - clrtoeol(); - return show_panner_legend; - } - return FALSE; -} - -static void -panner_h_cleanup(int from_y, int from_x, int to_x) -{ - if (!panner_legend(from_y)) - do_h_line(from_y, from_x, ' ', to_x); -} - -static void -panner_v_cleanup(int from_y, int from_x, int to_y) -{ - if (!panner_legend(from_y)) - do_v_line(from_y, from_x, ' ', to_y); -} - -static void -panner(WINDOW *pad, - int top_x, int top_y, int porty, int portx, - int (*pgetc) (WINDOW *)) -{ -#if HAVE_GETTIMEOFDAY - struct timeval before, after; - bool timing = TRUE; -#endif - bool scrollers = TRUE; - int basex = 0; - int basey = 0; - int pxmax, pymax, lowend, highend, c; - - getmaxyx(pad, pymax, pxmax); - scrollok(stdscr, FALSE); /* we don't want stdscr to scroll! */ - - c = KEY_REFRESH; - do { -#ifdef NCURSES_VERSION - /* - * During shell-out, the user may have resized the window. Adjust - * the port size of the pad to accommodate this. Ncurses automatically - * resizes all of the normal windows to fit on the new screen. - */ - if (top_x > COLS) - top_x = COLS; - if (portx > COLS) - portx = COLS; - if (top_y > LINES) - top_y = LINES; - if (porty > LINES) - porty = LINES; -#endif - switch (c) { - case KEY_REFRESH: - erase(); - - /* FALLTHRU */ - case '?': - if (c == '?') - show_panner_legend = !show_panner_legend; - panner_legend(LINES - 4); - panner_legend(LINES - 3); - panner_legend(LINES - 2); - panner_legend(LINES - 1); - break; -#if HAVE_GETTIMEOFDAY - case 't': - timing = !timing; - if (!timing) - panner_legend(LINES - 1); - break; -#endif - case 's': - scrollers = !scrollers; - break; - - /* Move the top-left corner of the pad, keeping the bottom-right - * corner fixed. - */ - case 'h': /* increase-columns: move left edge to left */ - if (top_x <= 0) - beep(); - else { - panner_v_cleanup(top_y, top_x, porty); - top_x--; - } - break; - - case 'j': /* decrease-lines: move top-edge down */ - if (top_y >= porty) - beep(); - else { - panner_h_cleanup(top_y - 1, top_x - (top_x > 0), portx); - top_y++; - } - break; - - case 'k': /* increase-lines: move top-edge up */ - if (top_y <= 0) - beep(); - else { - top_y--; - panner_h_cleanup(top_y, top_x, portx); - } - break; - - case 'l': /* decrease-columns: move left-edge to right */ - if (top_x >= portx) - beep(); - else { - panner_v_cleanup(top_y - (top_y > 0), top_x - 1, porty); - top_x++; - } - break; - - /* Move the bottom-right corner of the pad, keeping the top-left - * corner fixed. - */ - case KEY_IC: /* increase-columns: move right-edge to right */ - if (portx >= pxmax || portx >= COLS) - beep(); - else { - panner_v_cleanup(top_y - (top_y > 0), portx - 1, porty); - ++portx; - } - break; - - case KEY_IL: /* increase-lines: move bottom-edge down */ - if (porty >= pymax || porty >= LINES) - beep(); - else { - panner_h_cleanup(porty - 1, top_x - (top_x > 0), portx); - ++porty; - } - break; - - case KEY_DC: /* decrease-columns: move bottom edge up */ - if (portx <= top_x) - beep(); - else { - portx--; - panner_v_cleanup(top_y - (top_y > 0), portx, porty); - } - break; - - case KEY_DL: /* decrease-lines */ - if (porty <= top_y) - beep(); - else { - porty--; - panner_h_cleanup(porty, top_x - (top_x > 0), portx); - } - break; - - case KEY_LEFT: /* pan leftwards */ - if (basex > 0) - basex--; - else - beep(); - break; - - case KEY_RIGHT: /* pan rightwards */ - if (basex + portx - (pymax > porty) < pxmax) - basex++; - else - beep(); - break; - - case KEY_UP: /* pan upwards */ - if (basey > 0) - basey--; - else - beep(); - break; - - case KEY_DOWN: /* pan downwards */ - if (basey + porty - (pxmax > portx) < pymax) - basey++; - else - beep(); - break; - - case 'H': - case KEY_HOME: - case KEY_FIND: - basey = 0; - break; - - case 'E': - case KEY_END: - case KEY_SELECT: - basey = pymax - porty; - if (basey < 0) - basey = 0; - break; - - default: - beep(); - break; - } - - mvaddch(top_y - 1, top_x - 1, ACS_ULCORNER); - do_v_line(top_y, top_x - 1, ACS_VLINE, porty); - do_h_line(top_y - 1, top_x, ACS_HLINE, portx); - - if (scrollers && (pxmax > portx - 1)) { - int length = (portx - top_x - 1); - float ratio = ((float) length) / ((float) pxmax); - - lowend = (int) (top_x + (basex * ratio)); - highend = (int) (top_x + ((basex + length) * ratio)); - - do_h_line(porty - 1, top_x, ACS_HLINE, lowend); - if (highend < portx) { - attron(A_REVERSE); - do_h_line(porty - 1, lowend, ' ', highend + 1); - attroff(A_REVERSE); - do_h_line(porty - 1, highend + 1, ACS_HLINE, portx); - } - } else - do_h_line(porty - 1, top_x, ACS_HLINE, portx); - - if (scrollers && (pymax > porty - 1)) { - int length = (porty - top_y - 1); - float ratio = ((float) length) / ((float) pymax); - - lowend = (int) (top_y + (basey * ratio)); - highend = (int) (top_y + ((basey + length) * ratio)); - - do_v_line(top_y, portx - 1, ACS_VLINE, lowend); - if (highend < porty) { - attron(A_REVERSE); - do_v_line(lowend, portx - 1, ' ', highend + 1); - attroff(A_REVERSE); - do_v_line(highend + 1, portx - 1, ACS_VLINE, porty); - } - } else - do_v_line(top_y, portx - 1, ACS_VLINE, porty); - - mvaddch(top_y - 1, portx - 1, ACS_URCORNER); - mvaddch(porty - 1, top_x - 1, ACS_LLCORNER); - mvaddch(porty - 1, portx - 1, ACS_LRCORNER); - - if (!pending_pan) { -#if HAVE_GETTIMEOFDAY - gettimeofday(&before, 0); -#endif - wnoutrefresh(stdscr); - - pnoutrefresh(pad, - basey, basex, - top_y, top_x, - porty - (pxmax > portx) - 1, - portx - (pymax > porty) - 1); - - doupdate(); -#if HAVE_GETTIMEOFDAY - if (timing) { - double elapsed; - gettimeofday(&after, 0); - elapsed = (after.tv_sec + after.tv_usec / 1.0e6) - - (before.tv_sec + before.tv_usec / 1.0e6); - move(LINES - 1, COLS - 20); - printw("Secs: %2.03f", elapsed); - refresh(); - } -#endif - } - - } while - ((c = pgetc(pad)) != KEY_EXIT); - - scrollok(stdscr, TRUE); /* reset to driver's default */ -} - -static int -padgetch(WINDOW *win) -{ - static int count; - static int last; - int c; - - if ((pending_pan = (count > 0)) != FALSE) { - count--; - pending_pan = (count != 0); - } else { - for (;;) { - switch (c = wGetchar(win)) { - case '!': - ShellOut(FALSE); - /* FALLTHRU */ - case CTRL('r'): - endwin(); - refresh(); - c = KEY_REFRESH; - break; - case CTRL('l'): - c = KEY_REFRESH; - break; - case 'U': - c = KEY_UP; - break; - case 'D': - c = KEY_DOWN; - break; - case 'R': - c = KEY_RIGHT; - break; - case 'L': - c = KEY_LEFT; - break; - case '+': - c = KEY_IL; - break; - case '-': - c = KEY_DL; - break; - case '>': - c = KEY_IC; - break; - case '<': - c = KEY_DC; - break; - case ERR: /* FALLTHRU */ - case 'q': - count = 0; - c = KEY_EXIT; - break; - default: - if (c >= '0' && c <= '9') { - count = count * 10 + (c - '0'); - continue; - } - break; - } - last = c; - break; - } - if (count > 0) - count--; - } - return (last); -} - -#define PAD_HIGH 200 -#define PAD_WIDE 200 - -static void -demo_pad(void) -/* Demonstrate pads. */ -{ - int i, j; - unsigned gridcount = 0; - WINDOW *panpad = newpad(PAD_HIGH, PAD_WIDE); - - if (panpad == 0) { - Cannot("cannot create requested pad"); - return; - } - - for (i = 0; i < PAD_HIGH; i++) { - for (j = 0; j < PAD_WIDE; j++) - if (i % GRIDSIZE == 0 && j % GRIDSIZE == 0) { - if (i == 0 || j == 0) - waddch(panpad, '+'); - else - waddch(panpad, (chtype) ('A' + (gridcount++ % 26))); - } else if (i % GRIDSIZE == 0) - waddch(panpad, '-'); - else if (j % GRIDSIZE == 0) - waddch(panpad, '|'); - else - waddch(panpad, ' '); - } - panner_legend(LINES - 4); - panner_legend(LINES - 3); - panner_legend(LINES - 2); - panner_legend(LINES - 1); - - keypad(panpad, TRUE); - - /* Make the pad (initially) narrow enough that a trace file won't wrap. - * We'll still be able to widen it during a test, since that's required - * for testing boundaries. - */ - panner(panpad, 2, 2, LINES - 5, COLS - 15, padgetch); - - delwin(panpad); - endwin(); - erase(); -} -#endif /* USE_LIBPANEL */ - -/**************************************************************************** - * - * Tests from John Burnell's PDCurses tester - * - ****************************************************************************/ - -static void -Continue(WINDOW *win) -{ - noecho(); - wmove(win, 10, 1); - mvwaddstr(win, 10, 1, " Press any key to continue"); - wrefresh(win); - wGetchar(win); -} - -static void -flushinp_test(WINDOW *win) -/* Input test, adapted from John Burnell's PDCurses tester */ -{ - int w, h, bx, by, sw, sh, i; - - WINDOW *subWin; - wclear(win); - - getmaxyx(win, h, w); - getbegyx(win, by, bx); - sw = w / 3; - sh = h / 3; - if ((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2)) == 0) - return; - -#ifdef A_COLOR - if (has_colors()) { - init_pair(2, COLOR_CYAN, COLOR_BLUE); - wbkgd(subWin, COLOR_PAIR(2) | ' '); - } -#endif - wattrset(subWin, A_BOLD); - box(subWin, ACS_VLINE, ACS_HLINE); - mvwaddstr(subWin, 2, 1, "This is a subwindow"); - wrefresh(win); - - /* - * This used to set 'nocbreak()'. However, Alexander Lukyanov says that - * it only happened to "work" on SVr4 because that implementation does not - * emulate nocbreak+noecho mode, whereas ncurses does. To get the desired - * test behavior, we're using 'cbreak()', which will allow a single - * character to return without needing a newline. - T.Dickey 1997/10/11. - */ - cbreak(); - mvwaddstr(win, 0, 1, "This is a test of the flushinp() call."); - - mvwaddstr(win, 2, 1, "Type random keys for 5 seconds."); - mvwaddstr(win, 3, 1, - "These should be discarded (not echoed) after the subwindow goes away."); - wrefresh(win); - - for (i = 0; i < 5; i++) { - mvwprintw(subWin, 1, 1, "Time = %d", i); - wrefresh(subWin); - napms(1000); - flushinp(); - } - - delwin(subWin); - werase(win); - flash(); - wrefresh(win); - napms(1000); - - mvwaddstr(win, 2, 1, - "If you were still typing when the window timer expired,"); - mvwaddstr(win, 3, 1, - "or else you typed nothing at all while it was running,"); - mvwaddstr(win, 4, 1, - "test was invalid. You'll see garbage or nothing at all. "); - mvwaddstr(win, 6, 1, "Press a key"); - wmove(win, 9, 10); - wrefresh(win); - echo(); - wGetchar(win); - flushinp(); - mvwaddstr(win, 12, 0, - "If you see any key other than what you typed, flushinp() is broken."); - Continue(win); - - wmove(win, 9, 10); - wdelch(win); - wrefresh(win); - wmove(win, 12, 0); - clrtoeol(); - waddstr(win, - "What you typed should now have been deleted; if not, wdelch() failed."); - Continue(win); - - cbreak(); -} - -/**************************************************************************** - * - * Menu test - * - ****************************************************************************/ - -#if USE_LIBMENU - -#define MENU_Y 8 -#define MENU_X 8 - -static int -menu_virtualize(int c) -{ - if (c == '\n' || c == KEY_EXIT) - return (MAX_COMMAND + 1); - else if (c == 'u') - return (REQ_SCR_ULINE); - else if (c == 'd') - return (REQ_SCR_DLINE); - else if (c == 'b' || c == KEY_NPAGE) - return (REQ_SCR_UPAGE); - else if (c == 'f' || c == KEY_PPAGE) - return (REQ_SCR_DPAGE); - else if (c == 'n' || c == KEY_DOWN) - return (REQ_NEXT_ITEM); - else if (c == 'p' || c == KEY_UP) - return (REQ_PREV_ITEM); - else if (c == ' ') - return (REQ_TOGGLE_ITEM); - else { - if (c != KEY_MOUSE) - beep(); - return (c); - } -} - -static const char *animals[] = -{ - "Lions", "Tigers", "Bears", "(Oh my!)", "Newts", "Platypi", "Lemurs", - (char *) 0 -}; - -static void -menu_test(void) -{ - MENU *m; - ITEM *items[SIZEOF(animals)]; - ITEM **ip = items; - const char **ap; - int mrows, mcols, c; - WINDOW *menuwin; - -#ifdef NCURSES_MOUSE_VERSION - mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0); -#endif - mvaddstr(0, 0, "This is the menu test:"); - mvaddstr(2, 0, " Use up and down arrow to move the select bar."); - mvaddstr(3, 0, " 'n' and 'p' act like arrows."); - mvaddstr(4, 0, - " 'b' and 'f' scroll up/down (page), 'u' and 'd' (line)."); - mvaddstr(5, 0, " Press return to exit."); - refresh(); - - for (ap = animals; *ap; ap++) - *ip++ = new_item(*ap, ""); - *ip = (ITEM *) 0; - - m = new_menu(items); - - set_menu_format(m, (SIZEOF(animals) + 1) / 2, 1); - scale_menu(m, &mrows, &mcols); - - menuwin = newwin(mrows + 2, mcols + 2, MENU_Y, MENU_X); - set_menu_win(m, menuwin); - keypad(menuwin, TRUE); - box(menuwin, 0, 0); - - set_menu_sub(m, derwin(menuwin, mrows, mcols, 1, 1)); - - post_menu(m); - - while ((c = menu_driver(m, menu_virtualize(wGetchar(menuwin)))) != E_UNKNOWN_COMMAND) { - if (c == E_REQUEST_DENIED) - beep(); - continue; - } - - (void) mvprintw(LINES - 2, 0, - "You chose: %s\n", item_name(current_item(m))); - (void) addstr("Press any key to continue..."); - wGetchar(stdscr); - - unpost_menu(m); - delwin(menuwin); - - free_menu(m); - for (ip = items; *ip; ip++) - free_item(*ip); -#ifdef NCURSES_MOUSE_VERSION - mousemask(0, (mmask_t *) 0); -#endif -} - -#ifdef TRACE -#define T_TBL(name) { #name, name } -static struct { - const char *name; - int mask; -} t_tbl[] = { - - T_TBL(TRACE_DISABLE), - T_TBL(TRACE_TIMES), - T_TBL(TRACE_TPUTS), - T_TBL(TRACE_UPDATE), - T_TBL(TRACE_MOVE), - T_TBL(TRACE_CHARPUT), - T_TBL(TRACE_ORDINARY), - T_TBL(TRACE_CALLS), - T_TBL(TRACE_VIRTPUT), - T_TBL(TRACE_IEVENT), - T_TBL(TRACE_BITS), - T_TBL(TRACE_ICALLS), - T_TBL(TRACE_CCALLS), - T_TBL(TRACE_DATABASE), - T_TBL(TRACE_ATTRS), - T_TBL(TRACE_MAXIMUM), - { - (char *) 0, 0 - } -}; - -static char * -tracetrace(int tlevel) -{ - static char *buf; - int n; - - if (buf == 0) { - size_t need = 12; - for (n = 0; t_tbl[n].name != 0; n++) - need += strlen(t_tbl[n].name) + 2; - buf = (char *) malloc(need); - } - sprintf(buf, "0x%02x = {", tlevel); - if (tlevel == 0) { - sprintf(buf + strlen(buf), "%s, ", t_tbl[0].name); - } else { - for (n = 1; t_tbl[n].name != 0; n++) - if ((tlevel & t_tbl[n].mask) == t_tbl[n].mask) { - strcat(buf, t_tbl[n].name); - strcat(buf, ", "); - } - } - if (buf[strlen(buf) - 2] == ',') - buf[strlen(buf) - 2] = '\0'; - return (strcat(buf, "}")); -} - -/* fake a dynamically reconfigurable menu using the 0th entry to deselect - * the others - */ -static int -run_trace_menu(MENU * m) -{ - ITEM **items; - ITEM *i, **p; - - for (;;) { - bool changed = FALSE; - switch (menu_driver(m, menu_virtualize(wGetchar(menu_win(m))))) { - case E_UNKNOWN_COMMAND: - return FALSE; - default: - items = menu_items(m); - i = current_item(m); - if (i == items[0]) { - if (item_value(i)) { - for (p = items + 1; *p != 0; p++) - if (item_value(*p)) { - set_item_value(*p, FALSE); - changed = TRUE; - } - } - } else { - for (p = items + 1; *p != 0; p++) - if (item_value(*p)) { - set_item_value(items[0], FALSE); - changed = TRUE; - break; - } - } - if (!changed) - return TRUE; - } - } -} - -static void -trace_set(void) -/* interactively set the trace level */ -{ - MENU *m; - ITEM *items[SIZEOF(t_tbl)]; - ITEM **ip = items; - int mrows, mcols, newtrace; - int n; - WINDOW *menuwin; - - mvaddstr(0, 0, "Interactively set trace level:"); - mvaddstr(2, 0, " Press space bar to toggle a selection."); - mvaddstr(3, 0, " Use up and down arrow to move the select bar."); - mvaddstr(4, 0, " Press return to set the trace level."); - mvprintw(6, 0, "(Current trace level is %s)", tracetrace(_nc_tracing)); - - refresh(); - - for (n = 0; t_tbl[n].name != 0; n++) - *ip++ = new_item(t_tbl[n].name, ""); - *ip = (ITEM *) 0; - - m = new_menu(items); - - set_menu_format(m, 0, 2); - scale_menu(m, &mrows, &mcols); - - menu_opts_off(m, O_ONEVALUE); - menuwin = newwin(mrows + 2, mcols + 2, MENU_Y, MENU_X); - set_menu_win(m, menuwin); - keypad(menuwin, TRUE); - box(menuwin, 0, 0); - - set_menu_sub(m, derwin(menuwin, mrows, mcols, 1, 1)); - - post_menu(m); - - for (ip = menu_items(m); *ip; ip++) { - int mask = t_tbl[item_index(*ip)].mask; - if (mask == 0) - set_item_value(*ip, _nc_tracing == 0); - else if ((mask & _nc_tracing) == mask) - set_item_value(*ip, TRUE); - } - - while (run_trace_menu(m)) - continue; - - newtrace = 0; - for (ip = menu_items(m); *ip; ip++) - if (item_value(*ip)) - newtrace |= t_tbl[item_index(*ip)].mask; - trace(newtrace); - _tracef("trace level interactively set to %s", tracetrace(_nc_tracing)); - - (void) mvprintw(LINES - 2, 0, - "Trace level is %s\n", tracetrace(_nc_tracing)); - (void) addstr("Press any key to continue..."); - wGetchar(stdscr); - - unpost_menu(m); - delwin(menuwin); - - free_menu(m); - for (ip = items; *ip; ip++) - free_item(*ip); -} -#endif /* TRACE */ -#endif /* USE_LIBMENU */ - -/**************************************************************************** - * - * Forms test - * - ****************************************************************************/ -#if USE_LIBFORM -static FIELD * -make_label(int frow, int fcol, NCURSES_CONST char *label) -{ - FIELD *f = new_field(1, strlen(label), frow, fcol, 0, 0); - - if (f) { - set_field_buffer(f, 0, label); - set_field_opts(f, field_opts(f) & ~O_ACTIVE); - } - return (f); -} - -static FIELD * -make_field(int frow, int fcol, int rows, int cols, bool secure) -{ - FIELD *f = new_field(rows, cols, frow, fcol, 0, secure ? 1 : 0); - - if (f) { - set_field_back(f, A_UNDERLINE); - set_field_userptr(f, (void *) 0); - } - return (f); -} - -static void -display_form(FORM * f) -{ - WINDOW *w; - int rows, cols; - - scale_form(f, &rows, &cols); - - if ((w = newwin(rows + 2, cols + 4, 0, 0)) != (WINDOW *) 0) { - set_form_win(f, w); - set_form_sub(f, derwin(w, rows, cols, 1, 2)); - box(w, 0, 0); - keypad(w, TRUE); - } - - if (post_form(f) != E_OK) - wrefresh(w); -} - -static void -erase_form(FORM * f) -{ - WINDOW *w = form_win(f); - WINDOW *s = form_sub(f); - - unpost_form(f); - werase(w); - wrefresh(w); - delwin(s); - delwin(w); -} - -static int -edit_secure(FIELD * me, int c) -{ - int rows, cols, frow, fcol, nrow, nbuf; - - if (field_info(me, &rows, &cols, &frow, &fcol, &nrow, &nbuf) == E_OK - && nbuf > 0) { - char temp[80]; - long len; - - strcpy(temp, field_buffer(me, 1)); - len = (long) (char *) field_userptr(me); - if (c <= KEY_MAX) { - if (isgraph(c)) { - temp[len++] = c; - temp[len] = 0; - set_field_buffer(me, 1, temp); - c = '*'; - } else { - c = 0; - } - } else { - switch (c) { - case REQ_BEG_FIELD: - case REQ_CLR_EOF: - case REQ_CLR_EOL: - case REQ_DEL_LINE: - case REQ_DEL_WORD: - case REQ_DOWN_CHAR: - case REQ_END_FIELD: - case REQ_INS_CHAR: - case REQ_INS_LINE: - case REQ_LEFT_CHAR: - case REQ_NEW_LINE: - case REQ_NEXT_WORD: - case REQ_PREV_WORD: - case REQ_RIGHT_CHAR: - case REQ_UP_CHAR: - c = 0; /* we don't want to do inline editing */ - break; - case REQ_CLR_FIELD: - if (len) { - temp[0] = 0; - set_field_buffer(me, 1, temp); - } - break; - case REQ_DEL_CHAR: - case REQ_DEL_PREV: - if (len) { - temp[--len] = 0; - set_field_buffer(me, 1, temp); - } - break; - } - } - set_field_userptr(me, (void *) len); - } - return c; -} - -static int -form_virtualize(FORM * f, WINDOW *w) -{ - static const struct { - int code; - int result; - } lookup[] = { - { - CTRL('A'), REQ_NEXT_CHOICE - }, - { - CTRL('B'), REQ_PREV_WORD - }, - { - CTRL('C'), REQ_CLR_EOL - }, - { - CTRL('D'), REQ_DOWN_FIELD - }, - { - CTRL('E'), REQ_END_FIELD - }, - { - CTRL('F'), REQ_NEXT_PAGE - }, - { - CTRL('G'), REQ_DEL_WORD - }, - { - CTRL('H'), REQ_DEL_PREV - }, - { - CTRL('I'), REQ_INS_CHAR - }, - { - CTRL('K'), REQ_CLR_EOF - }, - { - CTRL('L'), REQ_LEFT_FIELD - }, - { - CTRL('M'), REQ_NEW_LINE - }, - { - CTRL('N'), REQ_NEXT_FIELD - }, - { - CTRL('O'), REQ_INS_LINE - }, - { - CTRL('P'), REQ_PREV_FIELD - }, - { - CTRL('R'), REQ_RIGHT_FIELD - }, - { - CTRL('S'), REQ_BEG_FIELD - }, - { - CTRL('U'), REQ_UP_FIELD - }, - { - CTRL('V'), REQ_DEL_CHAR - }, - { - CTRL('W'), REQ_NEXT_WORD - }, - { - CTRL('X'), REQ_CLR_FIELD - }, - { - CTRL('Y'), REQ_DEL_LINE - }, - { - CTRL('Z'), REQ_PREV_CHOICE - }, - { - ESCAPE, MAX_FORM_COMMAND + 1 - }, - { - KEY_BACKSPACE, REQ_DEL_PREV - }, - { - KEY_DOWN, REQ_DOWN_CHAR - }, - { - KEY_END, REQ_LAST_FIELD - }, - { - KEY_HOME, REQ_FIRST_FIELD - }, - { - KEY_LEFT, REQ_LEFT_CHAR - }, - { - KEY_LL, REQ_LAST_FIELD - }, - { - KEY_NEXT, REQ_NEXT_FIELD - }, - { - KEY_NPAGE, REQ_NEXT_PAGE - }, - { - KEY_PPAGE, REQ_PREV_PAGE - }, - { - KEY_PREVIOUS, REQ_PREV_FIELD - }, - { - KEY_RIGHT, REQ_RIGHT_CHAR - }, - { - KEY_UP, REQ_UP_CHAR - }, - { - QUIT, MAX_FORM_COMMAND + 1 - } - }; - - static int mode = REQ_INS_MODE; - int c = wGetchar(w); - unsigned n; - FIELD *me = current_field(f); - - if (c == CTRL(']')) { - if (mode == REQ_INS_MODE) - mode = REQ_OVL_MODE; - else - mode = REQ_INS_MODE; - c = mode; - } else { - for (n = 0; n < SIZEOF(lookup); n++) { - if (lookup[n].code == c) { - c = lookup[n].result; - break; - } - } - } - - /* - * Force the field that the user is typing into to be in reverse video, - * while the other fields are shown underlined. - */ - if (c <= KEY_MAX) { - c = edit_secure(me, c); - set_field_back(me, A_REVERSE); - } else if (c <= MAX_FORM_COMMAND) { - c = edit_secure(me, c); - set_field_back(me, A_UNDERLINE); - } - return c; -} - -static int -my_form_driver(FORM * form, int c) -{ - if (c == (MAX_FORM_COMMAND + 1) - && form_driver(form, REQ_VALIDATION) == E_OK) - return (TRUE); - else { - beep(); - return (FALSE); - } -} - -static void -demo_forms(void) -{ - WINDOW *w; - FORM *form; - FIELD *f[12], *secure; - int finished = 0, c; - unsigned n = 0; - - move(18, 0); - addstr("Defined form-traversal keys: ^Q/ESC- exit form\n"); - addstr("^N -- go to next field ^P -- go to previous field\n"); - addstr("Home -- go to first field End -- go to last field\n"); - addstr("^L -- go to field to left ^R -- go to field to right\n"); - addstr("^U -- move upward to field ^D -- move downward to field\n"); - addstr("^W -- go to next word ^B -- go to previous word\n"); - addstr("^S -- go to start of field ^E -- go to end of field\n"); - addstr("^H -- delete previous char ^Y -- delete line\n"); - addstr("^G -- delete current word ^C -- clear to end of line\n"); - addstr("^K -- clear to end of field ^X -- clear field\n"); - addstr("Arrow keys move within a field as you would expect."); - - mvaddstr(4, 57, "Forms Entry Test"); - - refresh(); - - /* describe the form */ - f[n++] = make_label(0, 15, "Sample Form"); - f[n++] = make_label(2, 0, "Last Name"); - f[n++] = make_field(3, 0, 1, 18, FALSE); - f[n++] = make_label(2, 20, "First Name"); - f[n++] = make_field(3, 20, 1, 12, FALSE); - f[n++] = make_label(2, 34, "Middle Name"); - f[n++] = make_field(3, 34, 1, 12, FALSE); - f[n++] = make_label(5, 0, "Comments"); - f[n++] = make_field(6, 0, 4, 46, FALSE); - f[n++] = make_label(5, 20, "Password:"); - secure = - f[n++] = make_field(5, 30, 1, 9, TRUE); - f[n++] = (FIELD *) 0; - - form = new_form(f); - - display_form(form); - - w = form_win(form); - raw(); - nonl(); /* lets us read ^M's */ - while (!finished) { - switch (form_driver(form, c = form_virtualize(form, w))) { - case E_OK: - mvaddstr(5, 57, field_buffer(secure, 1)); - clrtoeol(); - refresh(); - break; - case E_UNKNOWN_COMMAND: - finished = my_form_driver(form, c); - break; - default: - beep(); - break; - } - } - - erase_form(form); - - free_form(form); - for (c = 0; f[c] != 0; c++) - free_field(f[c]); - noraw(); - nl(); -} -#endif /* USE_LIBFORM */ - -/**************************************************************************** - * - * Overlap test - * - ****************************************************************************/ - -static void -fillwin(WINDOW *win, char ch) -{ - int y, x; - int y1, x1; - - getmaxyx(win, y1, x1); - for (y = 0; y < y1; y++) { - wmove(win, y, 0); - for (x = 0; x < x1; x++) - waddch(win, ch); - } -} - -static void -crosswin(WINDOW *win, char ch) -{ - int y, x; - int y1, x1; - - getmaxyx(win, y1, x1); - for (y = 0; y < y1; y++) { - for (x = 0; x < x1; x++) - if (((x > (x1 - 1) / 3) && (x <= (2 * (x1 - 1)) / 3)) - || (((y > (y1 - 1) / 3) && (y <= (2 * (y1 - 1)) / 3)))) { - wmove(win, y, x); - waddch(win, ch); - } - } -} - -static void -overlap_test(void) -/* test effects of overlapping windows */ -{ - int ch; - - WINDOW *win1 = newwin(9, 20, 3, 3); - WINDOW *win2 = newwin(9, 20, 9, 16); - - raw(); - refresh(); - move(0, 0); - printw("This test shows the behavior of wnoutrefresh() with respect to\n"); - printw("the shared region of two overlapping windows A and B. The cross\n"); - printw("pattern in each window does not overlap the other.\n"); - - move(18, 0); - printw("a = refresh A, then B, then doupdate. b = refresh B, then A, then doupdaute\n"); - printw("c = fill window A with letter A. d = fill window B with letter B.\n"); - printw("e = cross pattern in window A. f = cross pattern in window B.\n"); - printw("g = clear window A. h = clear window B.\n"); - printw("i = overwrite A onto B. j = overwrite B onto A.\n"); - printw("^Q/ESC = terminate test."); - - while ((ch = Getchar()) != QUIT && ch != ESCAPE) - switch (ch) { - case 'a': /* refresh window A first, then B */ - wnoutrefresh(win1); - wnoutrefresh(win2); - doupdate(); - break; - - case 'b': /* refresh window B first, then A */ - wnoutrefresh(win2); - wnoutrefresh(win1); - doupdate(); - break; - - case 'c': /* fill window A so it's visible */ - fillwin(win1, 'A'); - break; - - case 'd': /* fill window B so it's visible */ - fillwin(win2, 'B'); - break; - - case 'e': /* cross test pattern in window A */ - crosswin(win1, 'A'); - break; - - case 'f': /* cross test pattern in window A */ - crosswin(win2, 'B'); - break; - - case 'g': /* clear window A */ - wclear(win1); - wmove(win1, 0, 0); - break; - - case 'h': /* clear window B */ - wclear(win2); - wmove(win2, 0, 0); - break; - - case 'i': /* overwrite A onto B */ - overwrite(win1, win2); - break; - - case 'j': /* overwrite B onto A */ - overwrite(win2, win1); - break; - } - - delwin(win2); - delwin(win1); - erase(); - endwin(); -} - -/**************************************************************************** - * - * Main sequence - * - ****************************************************************************/ - -static bool -do_single_test(const char c) -/* perform a single specified test */ -{ - switch (c) { - case 'a': - getch_test(); - break; - -#if USE_WIDEC_SUPPORT - case 'A': - get_wch_test(); - break; -#endif - - case 'b': - attr_test(); - break; - - case 'c': - if (!has_colors()) - Cannot("does not support color."); - else - color_test(); - break; - - case 'd': - if (!has_colors()) - Cannot("does not support color."); - else if (!can_change_color()) - Cannot("has hardwired color values."); - else - color_edit(); - break; - - case 'e': - slk_test(); - break; - - case 'f': - acs_display(); - break; - -#if USE_WIDEC_SUPPORT - case 'F': - wide_acs_display(); - break; -#endif - -#if USE_LIBPANEL - case 'o': - demo_panels(); - break; -#endif - - case 'g': - acs_and_scroll(); - break; - - case 'i': - flushinp_test(stdscr); - break; - - case 'k': - test_sgr_attributes(); - break; - -#if USE_LIBMENU - case 'm': - menu_test(); - break; -#endif - -#if USE_LIBPANEL - case 'p': - demo_pad(); - break; -#endif - -#if USE_LIBFORM - case 'r': - demo_forms(); - break; -#endif - - case 's': - overlap_test(); - break; - -#if USE_LIBMENU && defined(TRACE) - case 't': - trace_set(); - break; -#endif - - case '?': - break; - - default: - return FALSE; - } - - return TRUE; -} - -static void -usage(void) -{ - static const char *const tbl[] = - { - "Usage: ncurses [options]" - ,"" - ,"Options:" -#ifdef NCURSES_VERSION - ," -a f,b set default-colors (assumed white-on-black)" - ," -d use default-colors if terminal supports them" -#endif - ," -e fmt specify format for soft-keys test (e)" - ," -f rip-off footer line (can repeat)" - ," -h rip-off header line (can repeat)" - ," -s msec specify nominal time for panel-demo (default: 1, to hold)" -#ifdef TRACE - ," -t mask specify default trace-level (may toggle with ^T)" -#endif - }; - size_t n; - for (n = 0; n < SIZEOF(tbl); n++) - fprintf(stderr, "%s\n", tbl[n]); - ExitProgram(EXIT_FAILURE); -} - -static void -set_terminal_modes(void) -{ - noraw(); - cbreak(); - noecho(); - scrollok(stdscr, TRUE); - idlok(stdscr, TRUE); - keypad(stdscr, TRUE); -} - -#ifdef SIGUSR1 -static RETSIGTYPE -announce_sig(int sig) -{ - (void) fprintf(stderr, "Handled signal %d\r\n", sig); -} -#endif - -static int -rip_footer(WINDOW *win, int cols) -{ - wbkgd(win, A_REVERSE); - werase(win); - wmove(win, 0, 0); - wprintw(win, "footer: %d columns", cols); - wnoutrefresh(win); - return OK; -} - -static int -rip_header(WINDOW *win, int cols) -{ - wbkgd(win, A_REVERSE); - werase(win); - wmove(win, 0, 0); - wprintw(win, "header: %d columns", cols); - wnoutrefresh(win); - return OK; -} - -/*+------------------------------------------------------------------------- - main(argc,argv) ---------------------------------------------------------------------------*/ - -int -main(int argc, char *argv[]) -{ - int command, c; - int my_e_param = 1; -#ifdef NCURSES_VERSION - int default_fg = COLOR_WHITE; - int default_bg = COLOR_BLACK; - bool assumed_colors = FALSE; - bool default_colors = FALSE; -#endif - -#if HAVE_LOCALE_H - setlocale(LC_CTYPE, ""); -#endif - - while ((c = getopt(argc, argv, "a:de:fhs:t:")) != EOF) { - switch (c) { -#ifdef NCURSES_VERSION - case 'a': - assumed_colors = TRUE; - sscanf(optarg, "%d,%d", &default_fg, &default_bg); - break; - case 'd': - default_colors = TRUE; - break; -#endif - case 'e': - my_e_param = atoi(optarg); -#ifdef NCURSES_VERSION - if (my_e_param > 3) /* allow extended layouts */ - usage(); -#else - if (my_e_param > 1) - usage(); -#endif - break; - case 'f': - ripoffline(-1, rip_footer); - break; - case 'h': - ripoffline(1, rip_header); - break; -#if USE_LIBPANEL - case 's': - nap_msec = atol(optarg); - break; -#endif -#ifdef TRACE - case 't': - save_trace = atoi(optarg); - break; -#endif - default: - usage(); - } - } - - /* - * If there's no menus (unlikely for ncurses!), then we'll have to set - * tracing on initially, just in case the user wants to test something that - * doesn't involve wGetchar. - */ -#ifdef TRACE - /* enable debugging */ -#if !USE_LIBMENU - trace(save_trace); -#else - if (!isatty(fileno(stdin))) - trace(save_trace); -#endif /* USE_LIBMENU */ -#endif /* TRACE */ - - /* tell it we're going to play with soft keys */ - slk_init(my_e_param); - -#ifdef SIGUSR1 - /* set up null signal catcher so we can see what interrupts to getch do */ - signal(SIGUSR1, announce_sig); -#endif - - /* we must initialize the curses data structure only once */ - initscr(); - bkgdset(BLANK); - - /* tests, in general, will want these modes */ - if (has_colors()) { - start_color(); -#ifdef NCURSES_VERSION_PATCH - max_colors = COLORS > 16 ? 16 : COLORS; -#if HAVE_USE_DEFAULT_COLORS - if (default_colors) - use_default_colors(); -#if NCURSES_VERSION_PATCH >= 20000708 - else if (assumed_colors) - assume_default_colors(default_fg, default_bg); -#endif -#endif -#else /* normal SVr4 curses */ - max_colors = COLORS > 8 ? 8 : COLORS; -#endif - max_pairs = (max_colors * max_colors); - if (max_pairs < COLOR_PAIRS) - max_pairs = COLOR_PAIRS; - } - set_terminal_modes(); - def_prog_mode(); - - /* - * Return to terminal mode, so we're guaranteed of being able to - * select terminal commands even if the capabilities are wrong. - */ - endwin(); - -#if HAVE_CURSES_VERSION - (void) printf("Welcome to %s. Press ? for help.\n", curses_version()); -#elif defined(NCURSES_VERSION_MAJOR) && defined(NCURSES_VERSION_MINOR) && defined(NCURSES_VERSION_PATCH) - (void) printf("Welcome to ncurses %d.%d.%d. Press ? for help.\n", - NCURSES_VERSION_MAJOR, - NCURSES_VERSION_MINOR, - NCURSES_VERSION_PATCH); -#else - (void) puts("Welcome to ncurses. Press ? for help."); -#endif - - do { - (void) puts("This is the ncurses main menu"); - (void) puts("a = keyboard and mouse input test"); -#if USE_WIDEC_SUPPORT - (void) puts("A = wide-character keyboard and mouse input test"); -#endif - (void) puts("b = character attribute test"); - (void) puts("c = color test pattern"); - (void) puts("d = edit RGB color values"); - (void) puts("e = exercise soft keys"); - (void) puts("f = display ACS characters"); -#if USE_WIDEC_SUPPORT - (void) puts("F = display Wide-ACS characters"); -#endif - (void) puts("g = display windows and scrolling"); - (void) puts("i = test of flushinp()"); - (void) puts("k = display character attributes"); -#if USE_LIBMENU - (void) puts("m = menu code test"); -#endif -#if USE_LIBPANEL - (void) puts("o = exercise panels library"); - (void) puts("p = exercise pad features"); - (void) puts("q = quit"); -#endif -#if USE_LIBFORM - (void) puts("r = exercise forms code"); -#endif - (void) puts("s = overlapping-refresh test"); -#if USE_LIBMENU && defined(TRACE) - (void) puts("t = set trace level"); -#endif - (void) puts("? = repeat this command summary"); - - (void) fputs("> ", stdout); - (void) fflush(stdout); /* necessary under SVr4 curses */ - - /* - * This used to be an 'fgets()' call. However (on Linux, at least) - * mixing stream I/O and 'read()' (used in the library) causes the - * input stream to be flushed when switching between the two. - */ - command = 0; - for (;;) { - char ch; - if (read(fileno(stdin), &ch, 1) <= 0) { - if (command == 0) - command = 'q'; - break; - } else if (command == 0 && !isspace(UChar(ch))) { - command = ch; - } else if (ch == '\n' || ch == '\r') { - if (command != 0) - break; - (void) fputs("> ", stdout); - (void) fflush(stdout); - } - } - - if (do_single_test(command)) { - /* - * This may be overkill; it's intended to reset everything back - * to the initial terminal modes so that tests don't get in - * each other's way. - */ - flushinp(); - set_terminal_modes(); - reset_prog_mode(); - clear(); - refresh(); - endwin(); - if (command == '?') { - (void) puts("This is the ncurses capability tester."); - (void) - puts("You may select a test from the main menu by typing the"); - (void) - puts("key letter of the choice (the letter to left of the =)"); - (void) - puts("at the > prompt. The commands `x' or `q' will exit."); - } - continue; - } - } while - (command != 'q'); - - ExitProgram(EXIT_SUCCESS); -} - -/* ncurses.c ends here */ diff --git a/contrib/ncurses/test/ncurses_tst.hin b/contrib/ncurses/test/ncurses_tst.hin deleted file mode 100644 index 1d77cbd3fee2..000000000000 --- a/contrib/ncurses/test/ncurses_tst.hin +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** - * Copyright (c) 1998 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 1998 * - ****************************************************************************/ -/* - * $Id: ncurses_tst.hin,v 1.2 1998/02/11 12:14:05 tom Exp $ - * - * This is a template-file used to generate the "ncurses_cfg.h" file. - * - * Rather than list every definition, the configuration script substitutes - * the definitions that it finds using 'sed'. You need a patch (971222) - * to autoconf 2.12 to do this. - */ -#ifndef NC_CONFIG_H -#define NC_CONFIG_H -@DEFS@ - - /* The C compiler may not treat these properly but C++ has to */ -#ifdef __cplusplus -#undef const -#undef inline -#else -#if defined(lint) || defined(TRACE) -#undef inline -#define inline /* nothing */ -#endif -#endif - -#endif /* NC_CONFIG_H */ diff --git a/contrib/ncurses/test/newdemo.c b/contrib/ncurses/test/newdemo.c deleted file mode 100644 index f10a2d6cef27..000000000000 --- a/contrib/ncurses/test/newdemo.c +++ /dev/null @@ -1,356 +0,0 @@ -/* - * newdemo.c - A demo program using PDCurses. The program illustrate - * the use of colours for text output. - * - * $Id: newdemo.c,v 1.23 2002/03/23 22:17:24 tom Exp $ - */ - -#include - -#include - -#define delay_output(x) napms(x) - -/* - * The Australian map - */ -const char *AusMap[16] = -{ - " A A ", - " N.T. AAAAA AAAA ", - " AAAAAAAAAAA AAAAAAAA ", - " AAAAAAAAAAAAAAAAAAAAAAAAA Qld.", - "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ", - "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ", - " AAAAAAAAAAAAAAAAAAAAAAAAAAAA ", - " AAAAAAAAAAAAAAAAAAAAAAAAA N.S.W.", - "W.A. AAAAAAAAA AAAAAA Vic.", - " AAA S.A. AA", - " A Tas.", - "" -}; - -/* - * Funny messages - */ -#define NMESSAGES 6 - -NCURSES_CONST char *messages[] = -{ - "Hello from the Land Down Under", - "The Land of crocs. and a big Red Rock", - "Where the sunflower runs along the highways", - "the dusty red roads lead one to loneliness", - "Blue sky in the morning and", - "freezing nights and twinkling stars", - "" -}; - -/* - * Trap interrupt - */ -static RETSIGTYPE -trap(int sig GCC_UNUSED) -{ - endwin(); - ExitProgram(EXIT_FAILURE); -} - -/* - * Wait for user - */ -static int -WaitForUser(WINDOW *win) -{ - time_t t; - chtype key; - - nodelay(win, TRUE); - t = time((time_t *) 0); - while (1) { - if ((int) (key = wgetch(win)) != ERR) { - if (key == 'q' || key == 'Q') - return 1; - else - return 0; - } - if (time((time_t *) 0) - t > 5) - return 0; - } -} - -static void -set_colors(WINDOW *win, int pair, int foreground, int background) -{ - if (has_colors()) { - if (pair > COLOR_PAIRS) - pair = COLOR_PAIRS; - init_pair(pair, foreground, background); - wattrset(win, COLOR_PAIR(pair)); - } -} - -static int -use_colors(WINDOW *win, int pair, int attrs) -{ - if (has_colors()) { - if (pair > COLOR_PAIRS) - pair = COLOR_PAIRS; - attrs |= COLOR_PAIR(pair); - } - wattrset(win, attrs); - return attrs; -} - -/* - * Test sub windows - */ -static int -SubWinTest(WINDOW *win) -{ - int w, h, sw, sh, bx, by; - WINDOW *swin1, *swin2, *swin3; - - getmaxyx(win, h, w); - getbegyx(win, by, bx); - sw = w / 3; - sh = h / 3; - if ((swin1 = subwin(win, sh, sw, by + 3, bx + 5)) == NULL) - return 1; - if ((swin2 = subwin(win, sh, sw, by + 4, bx + 8)) == NULL) - return 1; - if ((swin3 = subwin(win, sh, sw, by + 5, bx + 11)) == NULL) - return 1; - - set_colors(swin1, 8, COLOR_RED, COLOR_BLUE); - werase(swin1); - mvwaddstr(swin1, 0, 3, "Sub-window 1"); - wrefresh(swin1); - - set_colors(swin2, 9, COLOR_CYAN, COLOR_MAGENTA); - werase(swin2); - mvwaddstr(swin2, 0, 3, "Sub-window 2"); - wrefresh(swin2); - - set_colors(swin3, 10, COLOR_YELLOW, COLOR_GREEN); - werase(swin3); - mvwaddstr(swin3, 0, 3, "Sub-window 3"); - wrefresh(swin3); - - delwin(swin1); - delwin(swin2); - delwin(swin3); - WaitForUser(win); - return 0; -} - -static int -bounce(int n, int *dir, int len) -{ - if (*dir > 0) - ++n; - else - --n; - if (n <= 1 || n >= len - 2) - *dir = *dir ? 0 : 1; - return n; -} - -/* - * Bouncing balls - */ -static int -BouncingBalls(WINDOW *win) -{ - int w, h; - int x1, y1, xd1, yd1; - int x2, y2, xd2, yd2; - int x3, y3, xd3, yd3; - - getmaxyx(win, h, w); - - x1 = 2 + rand() % (w - 4); - y1 = 2 + rand() % (h - 4); - x2 = 2 + rand() % (w - 4); - y2 = 2 + rand() % (h - 4); - x3 = 2 + rand() % (w - 4); - y3 = 2 + rand() % (h - 4); - - xd1 = 1; - yd1 = 1; - xd2 = 1; - yd2 = 0; - xd3 = 0; - yd3 = 1; - - nodelay(win, TRUE); - - while (wgetch(win) == ERR) { - x1 = bounce(x1, &xd1, w); - y1 = bounce(y1, &yd1, h); - x2 = bounce(x2, &xd2, w); - y2 = bounce(y2, &yd2, h); - x3 = bounce(x3, &xd3, w); - y3 = bounce(y3, &yd3, h); - - set_colors(win, 11, COLOR_RED, COLOR_BLUE); - mvwaddch(win, y1, x1, 'O'); - - set_colors(win, 12, COLOR_BLUE, COLOR_RED); - mvwaddch(win, y2, x2, '*'); - - set_colors(win, 13, COLOR_YELLOW, COLOR_WHITE); - mvwaddch(win, y3, x3, '@'); - - wmove(win, 0, 0); - wrefresh(win); - delay_output(100); - } - return 0; -} - -/* - * Main driver - */ -int -main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) -{ - WINDOW *win; - int w, x, y, i, j, k; - char buffer[200]; - const char *message; - int width, height; - chtype save[80]; - chtype c; - - initscr(); - if (has_colors()) - start_color(); - cbreak(); - curs_set(0); - signal(SIGINT, trap); - width = 48; - height = 14; /* Create a drawing window */ - win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2); - if (win == NULL) { - endwin(); - ExitProgram(EXIT_FAILURE); - } - - while (1) { - set_colors(win, 1, COLOR_WHITE, COLOR_BLUE); - werase(win); - - set_colors(win, 2, COLOR_RED, COLOR_RED); - box(win, ACS_VLINE, ACS_HLINE); - wrefresh(win); - /* Do ramdom output of a character */ - use_colors(win, 1, A_NORMAL); - c = 'a'; - for (i = 0; i < 5000; ++i) { - x = rand() % (width - 2) + 1; - y = rand() % (height - 2) + 1; - mvwaddch(win, y, x, c); - wrefresh(win); - nodelay(win, TRUE); - if (wgetch(win) != ERR) - break; - if (i == 2000) { - c = 'b'; - set_colors(win, 3, COLOR_CYAN, COLOR_YELLOW); - } - } - - SubWinTest(win); - /* Erase and draw green window */ - set_colors(win, 4, COLOR_YELLOW, COLOR_GREEN); - wbkgd(win, use_colors(win, 4, A_BOLD)); - werase(win); - wrefresh(win); - /* Draw RED bounding box */ - use_colors(win, 2, A_NORMAL); - box(win, ' ', ' '); - wrefresh(win); - /* Display Australia map */ - use_colors(win, 4, A_BOLD); - i = 0; - while (*AusMap[i]) { - mvwaddstr(win, i + 1, 8, AusMap[i]); - wrefresh(win); - delay_output(50); - ++i; - } - - set_colors(win, 5, COLOR_BLUE, COLOR_WHITE); - use_colors(win, 5, A_BLINK); - mvwaddstr(win, height - 2, 6, " PDCurses 2.1 for DOS, OS/2 and Unix"); - wrefresh(win); - - /* Draw running messages */ - set_colors(win, 6, COLOR_YELLOW, COLOR_WHITE); - message = messages[j = 0]; - i = 1; - w = width - 2; - strcpy(buffer, message); - while (j < NMESSAGES) { - while ((int) strlen(buffer) < w) { - strcat(buffer, " ... "); - strcat(buffer, messages[++j % NMESSAGES]); - } - - if (i < w) - mvwaddnstr(win, height / 2, w - i, buffer, i); - else - mvwaddnstr(win, height / 2, 1, buffer, w); - - wrefresh(win); - nodelay(win, TRUE); - if (wgetch(win) != ERR) { - flushinp(); - break; - } - if (i++ >= w) { - for (k = 0; (buffer[k] = buffer[k + 1]) != '\0'; k++) ; - } - delay_output(100); - } - - j = 0; - /* Draw running As across in RED */ - set_colors(win, 7, COLOR_RED, COLOR_GREEN); - for (i = 2; i < width - 4; ++i) { - k = mvwinch(win, 4, i); - if (k == ERR) - break; - save[j++] = c = k; - c &= A_CHARTEXT; - mvwaddch(win, 4, i, c); - } - wrefresh(win); - - /* Put a message up wait for a key */ - i = height - 2; - use_colors(win, 5, A_NORMAL); - mvwaddstr(win, i, 5, " Type a key to continue or 'Q' to quit "); - wrefresh(win); - - if (WaitForUser(win) == 1) - break; - - j = 0; /* Restore the old line */ - for (i = 2; i < width - 4; ++i) - mvwaddch(win, 4, i, save[j++]); - wrefresh(win); - - BouncingBalls(win); - /* Put a message up wait for a key */ - i = height - 2; - use_colors(win, 5, A_NORMAL); - mvwaddstr(win, i, 5, " Type a key to continue or 'Q' to quit "); - wrefresh(win); - if (WaitForUser(win) == 1) - break; - } - endwin(); - ExitProgram(EXIT_SUCCESS); -} diff --git a/contrib/ncurses/test/railroad.c b/contrib/ncurses/test/railroad.c deleted file mode 100644 index fd773c8c52e7..000000000000 --- a/contrib/ncurses/test/railroad.c +++ /dev/null @@ -1,242 +0,0 @@ -/**************************************************************************** - * Copyright (c) 2000-2001,2002 Free Software Foundation, Inc. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a * - * copy of this software and associated documentation files (the * - * "Software"), to deal in the Software without restriction, including * - * without limitation the rights to use, copy, modify, merge, publish, * - * distribute, distribute with modifications, sublicense, and/or sell * - * copies of the Software, and to permit persons to whom the Software is * - * furnished to do so, subject to the following conditions: * - * * - * The above copyright notice and this permission notice shall be included * - * in all copies or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * - * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * * - * Except as contained in this notice, the name(s) of the above copyright * - * holders shall not be used in advertising or otherwise to promote the * - * sale, use or other dealings in this Software without prior written * - * authorization. * - ****************************************************************************/ - -/* - * Author: Thomas E. Dickey 2000 - * - * $Id: railroad.c,v 1.10 2002/04/06 20:45:22 tom Exp $ - * - * A simple demo of the termcap interface. - */ -#include - -#include - -static char *wipeit; -static char *moveit; -static int length; -static int height; - -static char *finisC; -static char *finisS; -static char *finisU; - -static char *startC; -static char *startS; -static char *startU; - -static char *backup; - -static bool interrupted = FALSE; - -static int -outc(int c) -{ - if (interrupted) { - char tmp = c; - write(STDOUT_FILENO, &tmp, 1); - } else { - putc(c, stdout); - } - return 0; -} - -static void -PutChar(int ch) -{ - putchar(ch); - fflush(stdout); - napms(moveit ? 10 : 50); /* not really termcap... */ -} - -static void -Backup(void) -{ - tputs(backup != 0 ? backup : "\b", 1, outc); -} - -static void -ShowCursor(int flag) -{ - if (startC != 0 && finisC != 0) { - tputs(flag ? startC : finisC, 1, outc); - } -} - -static void -StandOut(int flag) -{ - if (startS != 0 && finisS != 0) { - tputs(flag ? startS : finisS, 1, outc); - } -} - -static void -Underline(int flag) -{ - if (startU != 0 && finisU != 0) { - tputs(flag ? startU : finisU, 1, outc); - } -} - -static void -ShowSign(char *string) -{ - char *base = string; - int ch, first, last; - - if (moveit != 0) { - tputs(tgoto(moveit, 0, height - 1), 1, outc); - tputs(wipeit, 1, outc); - } - - while (*string != 0) { - ch = *string; - if (ch != ' ') { - if (moveit != 0) { - for (first = length - 2; first >= (string - base); first--) { - if (first < length - 1) { - tputs(tgoto(moveit, first + 1, height - 1), 1, outc); - PutChar(' '); - } - tputs(tgoto(moveit, first, height - 1), 1, outc); - PutChar(ch); - } - } else { - last = ch; - if (isalpha(ch)) { - first = isupper(ch) ? 'A' : 'a'; - } else if (isdigit(ch)) { - first = '0'; - } else { - first = ch; - } - if (first < last) { - Underline(1); - while (first < last) { - PutChar(first); - Backup(); - first++; - } - Underline(0); - } - } - if (moveit != 0) - Backup(); - } - StandOut(1); - PutChar(ch); - StandOut(0); - fflush(stdout); - string++; - } - if (moveit != 0) - tputs(wipeit, 1, outc); - putchar('\n'); -} - -static void -cleanup(void) -{ - Underline(0); - StandOut(0); - ShowCursor(1); -} - -static void -onsig(int n GCC_UNUSED) -{ - interrupted = TRUE; - cleanup(); - ExitProgram(EXIT_FAILURE); -} - -static void -railroad(char **args) -{ - NCURSES_CONST char *name = getenv("TERM"); - char buffer[1024]; - char area[1024], *ap = area; - int j; - - if (name == 0) - name = "dumb"; - if (tgetent(buffer, name)) { - - wipeit = tgetstr("ce", &ap); - height = tgetnum("li"); - length = tgetnum("co"); - moveit = tgetstr("cm", &ap); - - if (wipeit == 0 - || moveit == 0 - || height <= 0 - || length <= 0) { - wipeit = 0; - moveit = 0; - height = 0; - length = 0; - } - - startS = tgetstr("so", &ap); - finisS = tgetstr("se", &ap); - - startU = tgetstr("us", &ap); - finisU = tgetstr("ue", &ap); - - backup = tgetstr("le", &ap); - - startC = tgetstr("ve", &ap); - finisC = tgetstr("vi", &ap); - - ShowCursor(0); - - for (j = SIGHUP; j <= SIGTERM; j++) - if (signal(j, SIG_IGN) != SIG_IGN) - signal(j, onsig); - - while (*args) { - ShowSign(*args++); - } - ShowCursor(1); - } -} - -int -main(int argc, char *argv[]) -{ - if (argc > 1) { - railroad(argv + 1); - } else { - static char world[] = "Hello World"; - static char *hello[] = - {world, 0}; - railroad(hello); - } - ExitProgram(EXIT_SUCCESS); -} diff --git a/contrib/ncurses/test/rain.c b/contrib/ncurses/test/rain.c deleted file mode 100644 index 46fa80a59ece..000000000000 --- a/contrib/ncurses/test/rain.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * $Id: rain.c,v 1.19 2002/04/06 20:45:22 tom Exp $ - */ -#include - -/* rain 11/3/1980 EPS/CITHEP */ - -static float ranf(void); -static void onsig(int sig); - -static int -next_j(int j) -{ - if (j == 0) - j = 4; - else - --j; - if (has_colors()) { - int z = (int) (3 * ranf()); - chtype color = COLOR_PAIR(z); - if (z) - color |= A_BOLD; - attrset(color); - } - return j; -} - -int -main( - int argc GCC_UNUSED, - char *argv[]GCC_UNUSED) -{ - int x, y, j; - static int xpos[5], ypos[5]; - float r; - float c; - - for (j = SIGHUP; j <= SIGTERM; j++) - if (signal(j, SIG_IGN) != SIG_IGN) - signal(j, onsig); - - initscr(); - if (has_colors()) { - int bg = COLOR_BLACK; - start_color(); -#if HAVE_USE_DEFAULT_COLORS - if (use_default_colors() == OK) - bg = -1; -#endif - init_pair(1, COLOR_BLUE, bg); - init_pair(2, COLOR_CYAN, bg); - } - nl(); - noecho(); - curs_set(0); - timeout(0); - - r = (float) (LINES - 4); - c = (float) (COLS - 4); - for (j = 5; --j >= 0;) { - xpos[j] = (int) (c * ranf()) + 2; - ypos[j] = (int) (r * ranf()) + 2; - } - - for (j = 0;;) { - x = (int) (c * ranf()) + 2; - y = (int) (r * ranf()) + 2; - - mvaddch(y, x, '.'); - - mvaddch(ypos[j], xpos[j], 'o'); - - j = next_j(j); - mvaddch(ypos[j], xpos[j], 'O'); - - j = next_j(j); - mvaddch(ypos[j] - 1, xpos[j], '-'); - mvaddstr(ypos[j], xpos[j] - 1, "|.|"); - mvaddch(ypos[j] + 1, xpos[j], '-'); - - j = next_j(j); - mvaddch(ypos[j] - 2, xpos[j], '-'); - mvaddstr(ypos[j] - 1, xpos[j] - 1, "/ \\"); - mvaddstr(ypos[j], xpos[j] - 2, "| O |"); - mvaddstr(ypos[j] + 1, xpos[j] - 1, "\\ /"); - mvaddch(ypos[j] + 2, xpos[j], '-'); - - j = next_j(j); - mvaddch(ypos[j] - 2, xpos[j], ' '); - mvaddstr(ypos[j] - 1, xpos[j] - 1, " "); - mvaddstr(ypos[j], xpos[j] - 2, " "); - mvaddstr(ypos[j] + 1, xpos[j] - 1, " "); - mvaddch(ypos[j] + 2, xpos[j], ' '); - - xpos[j] = x; - ypos[j] = y; - - switch (getch()) { - case ('q'): - case ('Q'): - curs_set(1); - endwin(); - ExitProgram(EXIT_SUCCESS); - case 's': - nodelay(stdscr, FALSE); - break; - case ' ': - nodelay(stdscr, TRUE); - break; -#ifdef KEY_RESIZE - case (KEY_RESIZE): - r = (float) (LINES - 4); - c = (float) (COLS - 4); - break; -#endif - } - napms(50); - } -} - -static void -onsig(int n GCC_UNUSED) -{ - curs_set(1); - endwin(); - ExitProgram(EXIT_FAILURE); -} - -static float -ranf(void) -{ - long r = (rand() & 077777); - return ((float) r / 32768.); -} diff --git a/contrib/ncurses/test/tclock.c b/contrib/ncurses/test/tclock.c deleted file mode 100644 index 6661b834b862..000000000000 --- a/contrib/ncurses/test/tclock.c +++ /dev/null @@ -1,246 +0,0 @@ -#include "test.priv.h" - -#include - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -/* - tclock - analog/digital clock for curses. - If it gives you joy, then - (a) I'm glad - (b) you need to get out more :-) - - This program is copyright Howard Jones, September 1994 - (ha.jones@ic.ac.uk). It may be freely distributed as - long as this copyright message remains intact, and any - modifications are clearly marked as such. [In fact, if - you modify it, I wouldn't mind the modifications back, - especially if they add any nice features. A good one - would be a precalc table for the 60 hand positions, so - that the floating point stuff can be ditched. As I said, - it was a 20 hackup minute job.] - - COMING SOON: tfishtank. Be the envy of your mac-owning - colleagues. -*/ - -/* To compile: cc -o tclock tclock.c -lcurses -lm */ - -#ifndef PI -#define PI 3.141592654 -#endif - -#define sign(_x) (_x<0?-1:1) - -#define ASPECT 2.2 -#define ROUND(value) ((int)((value) + 0.5)) - -#define A2X(angle,radius) ROUND(ASPECT * radius * sin(angle)) -#define A2Y(angle,radius) ROUND(radius * cos(angle)) - -/* Plot a point */ -static void -plot(int x, int y, char col) -{ - mvaddch(y, x, (chtype) col); -} - -/* Draw a diagonal(arbitrary) line using Bresenham's alogrithm. */ -static void -dline(int pair, int from_x, int from_y, int x2, int y2, char ch) -{ - int dx, dy; - int ax, ay; - int sx, sy; - int x, y; - int d; - - if (has_colors()) - attrset(COLOR_PAIR(pair)); - - dx = x2 - from_x; - dy = y2 - from_y; - - ax = abs(dx * 2); - ay = abs(dy * 2); - - sx = sign(dx); - sy = sign(dy); - - x = from_x; - y = from_y; - - if (ax > ay) { - d = ay - (ax / 2); - - while (1) { - plot(x, y, ch); - if (x == x2) - return; - - if (d >= 0) { - y += sy; - d -= ax; - } - x += sx; - d += ay; - } - } else { - d = ax - (ay / 2); - - while (1) { - plot(x, y, ch); - if (y == y2) - return; - - if (d >= 0) { - x += sx; - d -= ay; - } - y += sy; - d += ax; - } - } -} - -int -main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) -{ - int i, cx, cy; - double cr, mradius, hradius, mangle, hangle; - double sangle, sradius, hours; - int hdx, hdy; - int mdx, mdy; - int sdx, sdy; - int ch; - int lastbeep = -1; - time_t tim; - struct tm *t; - char szChar[10]; - int my_bg = COLOR_BLACK; -#if HAVE_GETTIMEOFDAY - struct timeval current; - double fraction = 0.0; -#endif - - initscr(); - noecho(); - cbreak(); - nodelay(stdscr, TRUE); - curs_set(0); - - if (has_colors()) { - start_color(); -#if HAVE_USE_DEFAULT_COLORS - if (use_default_colors() == OK) - my_bg = -1; -#endif - init_pair(1, COLOR_RED, my_bg); - init_pair(2, COLOR_MAGENTA, my_bg); - init_pair(3, COLOR_GREEN, my_bg); - } -#ifdef KEY_RESIZE - keypad(stdscr, TRUE); - restart: -#endif - cx = (COLS - 1) / 2; /* 39 */ - cy = LINES / 2; /* 12 */ - if (cx / ASPECT < cy) - cr = cx / ASPECT; - else - cr = cy; - sradius = (5 * cr) / 6; /* 10 */ - mradius = (3 * cr) / 4; /* 9 */ - hradius = cr / 2; /* 6 */ - - for (i = 0; i < 12; i++) { - sangle = (i + 1) * (2.0 * PI) / 12.0; - sdx = A2X(sangle, sradius); - sdy = A2Y(sangle, sradius); - sprintf(szChar, "%d", i + 1); - - mvaddstr(cy - sdy, cx + sdx, szChar); - } - - mvaddstr(0, 0, "ASCII Clock by Howard Jones (ha.jones@ic.ac.uk),1994"); - - sradius = (4 * sradius) / 5; - for (;;) { - napms(100); - - tim = time(0); - t = localtime(&tim); - - hours = (t->tm_hour + (t->tm_min / 60.0)); - if (hours > 12.0) - hours -= 12.0; - - mangle = ((t->tm_min + (t->tm_sec / 60.0)) * (2 * PI) / 60.0); - mdx = A2X(mangle, mradius); - mdy = A2Y(mangle, mradius); - - hangle = ((hours) * (2.0 * PI) / 12.0); - hdx = A2X(hangle, hradius); - hdy = A2Y(hangle, hradius); - -#if HAVE_GETTIMEOFDAY - gettimeofday(¤t, 0); - fraction = (current.tv_usec / 1.0e6); -#endif - sangle = ((t->tm_sec + fraction) * (2.0 * PI) / 60.0); - sdx = A2X(sangle, sradius); - sdy = A2Y(sangle, sradius); - - dline(3, cx, cy, cx + mdx, cy - mdy, '#'); - - attrset(A_REVERSE); - dline(2, cx, cy, cx + hdx, cy - hdy, '.'); - attroff(A_REVERSE); - - if (has_colors()) - attrset(COLOR_PAIR(1)); - - dline(1, cx, cy, cx + sdx, cy - sdy, 'O'); - - if (has_colors()) - attrset(COLOR_PAIR(0)); - - mvaddstr(LINES - 2, 0, ctime(&tim)); - refresh(); - if ((t->tm_sec % 5) == 0 - && t->tm_sec != lastbeep) { - lastbeep = t->tm_sec; - beep(); - } - - if ((ch = getch()) != ERR) { -#ifdef KEY_RESIZE - if (ch == KEY_RESIZE) { - flash(); - erase(); - wrefresh(curscr); - goto restart; - } -#endif - break; - } - - dline(0, cx, cy, cx + hdx, cy - hdy, ' '); - dline(0, cx, cy, cx + mdx, cy - mdy, ' '); - dline(0, cx, cy, cx + sdx, cy - sdy, ' '); - - } - - curs_set(1); - endwin(); - ExitProgram(EXIT_SUCCESS); -} diff --git a/contrib/ncurses/test/test.priv.h b/contrib/ncurses/test/test.priv.h deleted file mode 100644 index 05973d930029..000000000000 --- a/contrib/ncurses/test/test.priv.h +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** - * Copyright (c) 1998,2000 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 1996 * - ****************************************************************************/ -/* $Id: test.priv.h,v 1.34 2002/04/06 23:32:15 tom Exp $ */ - -#if HAVE_CONFIG_H -#include -#else -#define HAVE_CURSES_VERSION 0 -#define HAVE_RESIZETERM 0 -#define HAVE_USE_DEFAULT_COLORS 0 -#define HAVE_WRESIZE 0 -#endif - -#ifndef HAVE_CURSES_VERSION -#define HAVE_CURSES_VERSION 0 -#endif - -#ifndef HAVE_FORM_H -#define HAVE_FORM_H 0 -#endif - -#ifndef HAVE_LIBFORM -#define HAVE_LIBFORM 0 -#endif - -#ifndef HAVE_LIBMENU -#define HAVE_LIBMENU 0 -#endif - -#ifndef HAVE_LIBPANEL -#define HAVE_LIBPANEL 0 -#endif - -#ifndef HAVE_LOCALE_H -#define HAVE_LOCALE_H 0 -#endif - -#ifndef HAVE_MENU_H -#define HAVE_MENU_H 0 -#endif - -#ifndef HAVE_NAPMS -#define HAVE_NAPMS 1 -#endif - -#ifndef HAVE_NC_ALLOC_H -#define HAVE_NC_ALLOC_H 0 -#endif - -#ifndef HAVE_PANEL_H -#define HAVE_PANEL_H 0 -#endif - -#ifndef HAVE_WRESIZE -#define HAVE_WRESIZE 0 -#endif - -#ifndef NCURSES_NOMACROS -#define NCURSES_NOMACROS 0 -#endif - -#ifndef NEED_PTEM_H -#define NEED_PTEM_H 0 -#endif - -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#endif - -#include /* include before curses.h to work around glibc bug */ - -#include -#include - -#if NCURSES_NOMACROS -#include -#endif - -#if HAVE_GETOPT_H -#include -#else -/* 'getopt()' may be prototyped in , but declaring its variables - * doesn't hurt. - */ -extern char *optarg; -extern int optind; -#endif /* HAVE_GETOPT_H */ - -#ifndef GCC_NORETURN -#define GCC_NORETURN /* nothing */ -#endif -#ifndef GCC_UNUSED -#define GCC_UNUSED /* nothing */ -#endif - -#ifndef HAVE_GETNSTR -#define getnstr(s,n) getstr(s) -#endif - -#ifndef USE_WIDEC_SUPPORT -#if defined(_XOPEN_SOURCE_EXTENDED) && defined(WACS_ULCORNER) -#define USE_WIDEC_SUPPORT 1 -#else -#define USE_WIDEC_SUPPORT 0 -#endif -#endif - -#ifndef HAVE_TYPE_ATTR_T -#if !USE_WIDEC_SUPPORT -#define attr_t long -#endif -#endif - -#ifndef NCURSES_CH_T -#if !USE_WIDEC_SUPPORT -#define NCURSES_CH_T chtype -#else -#define NCURSES_CH_T cchar_t -#endif -#endif - -#ifndef CCHARW_MAX -#define CCHARW_MAX 5 -#endif - -#ifndef KEY_MIN -#define KEY_MIN 256 /* not defined in Solaris 8 */ -#endif - -#ifndef getcurx -#define getcurx(win) ((win)?(win)->_curx:ERR) -#define getcury(win) ((win)?(win)->_cury:ERR) -#endif - -#ifndef getbegx -#define getbegx(win) ((win)?(win)->_begx:ERR) -#define getbegy(win) ((win)?(win)->_begy:ERR) -#endif - -#ifndef getmaxx -#define getmaxx(win) ((win)?((win)->_maxx + 1):ERR) -#define getmaxy(win) ((win)?((win)->_maxy + 1):ERR) -#endif - -/* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list - * (which is incompatible with legacy usage, doesn't solve any problems). - */ -#define tparm3(a,b,c) tparm(a,b,c,0,0,0,0,0,0,0) -#define tparm2(a,b) tparm(a,b,0,0,0,0,0,0,0,0) - -#define UChar(c) ((unsigned char)(c)) - -#define SIZEOF(table) (sizeof(table)/sizeof(table[0])) - -#if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H -#include -#else -#define typeMalloc(type,n) (type *) malloc((n) * sizeof(type)) -#define typeRealloc(type,n,p) (type *) realloc(p, (n) * sizeof(type)) -#endif - -#ifndef ExitProgram -#define ExitProgram(code) exit(code) -#endif - -#ifndef EXIT_SUCCESS -#define EXIT_SUCCESS 0 -#endif -#ifndef EXIT_FAILURE -#define EXIT_FAILURE 1 -#endif - -/* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4 - * curses which doesn't have const parameters declared (so far) in the places - * that XSI shows. - */ -#ifndef NCURSES_CONST -#define NCURSES_CONST /* nothing */ -#endif diff --git a/contrib/ncurses/test/testaddch.c b/contrib/ncurses/test/testaddch.c deleted file mode 100644 index 311eb81c5de8..000000000000 --- a/contrib/ncurses/test/testaddch.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This is an example written by Alexander V. Lukyanov , - * to demonstrate an inconsistency between ncurses and SVr4 curses. - * - * $Id: testaddch.c,v 1.4 2001/09/15 21:46:34 tom Exp $ - */ -#include - -static void -attr_addstr(const char *s, chtype a) -{ - while (*s) - addch(((unsigned char) (*s++)) | a); -} - -int -main( - int argc GCC_UNUSED, - char *argv[]GCC_UNUSED) -{ - unsigned i; - chtype back, set, attr; - - initscr(); - start_color(); - init_pair(1, COLOR_WHITE, COLOR_BLUE); - init_pair(2, COLOR_WHITE, COLOR_RED); - init_pair(3, COLOR_BLACK, COLOR_MAGENTA); - init_pair(4, COLOR_BLACK, COLOR_GREEN); - init_pair(5, COLOR_BLACK, COLOR_CYAN); - init_pair(6, COLOR_BLACK, COLOR_YELLOW); - init_pair(7, COLOR_BLACK, COLOR_WHITE); - - for (i = 0; i < 8; i++) { - back = (i & 1) ? A_BOLD | 'B' : ' '; - set = (i & 2) ? A_REVERSE : 0; - attr = (i & 4) ? COLOR_PAIR(4) : 0; - - bkgdset(back); - attrset(set); - - attr_addstr("Test string with spaces -> <-\n", attr); - } - addch('\n'); - for (i = 0; i < 8; i++) { - back = (i & 1) ? A_BOLD | 'B' | COLOR_PAIR(1) : ' '; - set = (i & 2) ? A_REVERSE | COLOR_PAIR(2) : 0; - attr = (i & 4) ? COLOR_PAIR(4) : 0; - - bkgdset(back); - attrset(set); - - attr_addstr("Test string with spaces -> <-\n", attr); - } - - getch(); - endwin(); - ExitProgram(EXIT_SUCCESS); -} diff --git a/contrib/ncurses/test/testcurs.c b/contrib/ncurses/test/testcurs.c deleted file mode 100644 index 7e92f795c019..000000000000 --- a/contrib/ncurses/test/testcurs.c +++ /dev/null @@ -1,694 +0,0 @@ -/* - * - * This is a test program for the PDCurses screen package for IBM PC type - * machines. - * - * This program was written by John Burnell (johnb@kea.am.dsir.govt.nz) - * wrs(5/28/93) -- modified to be consistent (perform identically) with either - * PDCurses or under Unix System V, R4 - * - * $Id: testcurs.c,v 1.29 2002/06/01 16:17:52 tom Exp $ - */ - -#include -#include - -#if defined(XCURSES) -char *XCursesProgramName = "testcurs"; -#endif - -static int initTest(WINDOW **); -static void display_menu(int, int); -static void inputTest(WINDOW *); -static void introTest(WINDOW *); -static void outputTest(WINDOW *); -static void padTest(WINDOW *); -static void scrollTest(WINDOW *); -#if defined(PDCURSES) && !defined(XCURSES) -static void resizeTest(WINDOW *); -#endif - -struct commands { - NCURSES_CONST char *text; - void (*function) (WINDOW *); -}; -typedef struct commands COMMAND; - -const COMMAND command[] = -{ - {"General Test", introTest}, - {"Pad Test", padTest}, -#if defined(PDCURSES) && !defined(XCURSES) - {"Resize Test", resizeTest}, -#endif - {"Scroll Test", scrollTest}, - {"Input Test", inputTest}, - {"Output Test", outputTest} -}; -#define MAX_OPTIONS SIZEOF(command) - -int width, height; - -int -main( - int argc GCC_UNUSED, - char *argv[]GCC_UNUSED) -{ - WINDOW *win; - int key; - int old_option = (-1); - int new_option = 0; - bool quit = FALSE; - unsigned n; - -#ifdef PDCDEBUG - PDC_debug("testcurs started\n"); -#endif - if (!initTest(&win)) - ExitProgram(EXIT_FAILURE); - - erase(); - display_menu(old_option, new_option); - for (;;) { -#ifdef A_COLOR - if (has_colors()) { - init_pair(1, COLOR_WHITE, COLOR_BLUE); - wbkgd(win, COLOR_PAIR(1)); - } else - wbkgd(win, A_REVERSE); -#else - wbkgd(win, A_REVERSE); -#endif - werase(win); - - noecho(); - keypad(stdscr, TRUE); - raw(); - key = getch(); - if (key < KEY_MIN && key > 0 && isalpha(key)) { - if (islower(key)) - key = toupper(key); - for (n = 0; n < MAX_OPTIONS; ++n) { - if (key == command[n].text[0]) { - display_menu(old_option, new_option = n); - key = ' '; - break; - } - } - } - switch (key) { - case 10: - case 13: - case KEY_ENTER: - erase(); - refresh(); - (*command[new_option].function) (win); - erase(); - display_menu(old_option, new_option); - break; - case KEY_UP: - new_option = (new_option == 0) ? new_option : new_option - 1; - display_menu(old_option, new_option); - break; - case KEY_DOWN: - new_option = (new_option == MAX_OPTIONS - 1) ? new_option : - new_option + 1; - display_menu(old_option, new_option); - break; - case 'Q': - case 'q': - quit = TRUE; - break; - default: - beep(); - break; - case ' ': - break; - } - if (quit == TRUE) - break; - } - - delwin(win); - - endwin(); -#ifdef XCURSES - XCursesExit(); -#endif - ExitProgram(EXIT_SUCCESS); -} - -static void -Continue(WINDOW *win) -{ - int y1 = getmaxy(win); - int x1 = getmaxx(win); - int y0 = y1 < 10 ? y1 : 10; - int x0 = 1; - long save; - - save = mvwinch(win, y0, x1 - 1); - - mvwaddstr(win, y0, x0, " Press any key to continue"); - wclrtoeol(win); - getyx(win, y0, x0); - - mvwaddch(win, y0, x1 - 1, save); - - wmove(win, y0, x0); - raw(); - wgetch(win); -} - -static int -initTest(WINDOW **win) -{ -#ifdef PDCDEBUG - PDC_debug("initTest called\n"); -#endif -#ifdef TRACE - trace(TRACE_MAXIMUM); -#endif - initscr(); -#ifdef PDCDEBUG - PDC_debug("after initscr()\n"); -#endif -#ifdef A_COLOR - if (has_colors()) - start_color(); -#endif - width = 60; - height = 13; /* Create a drawing window */ - *win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2); - if (*win == NULL) { - endwin(); - return 0; - } - return 1; -} - -static void -introTest(WINDOW *win) -{ - wmove(win, height / 2 - 5, width / 2); - wvline(win, ACS_VLINE, 10); - wmove(win, height / 2, width / 2 - 10); - whline(win, ACS_HLINE, 20); - Continue(win); - - beep(); - werase(win); - - box(win, ACS_VLINE, ACS_HLINE); - wrefresh(win); - cbreak(); - mvwaddstr(win, 1, 1, - "You should have rectangle in the middle of the screen"); - mvwaddstr(win, 2, 1, "You should have heard a beep"); - Continue(win); - return; -} - -static void -scrollTest(WINDOW *win) -{ - int i; - int half; - int OldY; - NCURSES_CONST char *Message = "The window will now scroll slowly"; - - wclear(win); - OldY = getmaxy(win); - half = OldY / 2; - mvwprintw(win, OldY - 2, 1, Message); - wrefresh(win); - scrollok(win, TRUE); - for (i = 1; i <= OldY; i++) { - napms(600); - scroll(win); - wrefresh(win); - } - - werase(win); - for (i = 1; i < OldY; i++) { - mvwprintw(win, i, 1, "Line %d", i); - } - mvwprintw(win, OldY - 2, 1, "The top of the window will scroll"); - wmove(win, 1, 1); - wsetscrreg(win, 0, half - 1); - box(win, ACS_VLINE, ACS_HLINE); - wrefresh(win); - for (i = 1; i <= half; i++) { - napms(600); - scroll(win); - box(win, ACS_VLINE, ACS_HLINE); - wrefresh(win); - } - - werase(win); - for (i = 1; i < OldY; i++) { - mvwprintw(win, i, 1, "Line %d", i); - } - mvwprintw(win, 1, 1, "The bottom of the window will scroll"); - wmove(win, OldY - 2, 1); - wsetscrreg(win, half, --OldY); - box(win, ACS_VLINE, ACS_HLINE); - wrefresh(win); - for (i = half; i <= OldY; i++) { - napms(600); - wscrl(win, -1); - box(win, ACS_VLINE, ACS_HLINE); - wrefresh(win); - } - wsetscrreg(win, 0, OldY); -} - -static void -inputTest(WINDOW *win) -{ - int answered; - int repeat; - int w, h, bx, by, sw, sh, i, c, num; - char buffer[80]; - WINDOW *subWin; - wclear(win); - - getmaxyx(win, h, w); - getbegyx(win, by, bx); - sw = w / 3; - sh = h / 3; - if ((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2)) == NULL) - return; - -#ifdef A_COLOR - if (has_colors()) { - init_pair(2, COLOR_WHITE, COLOR_RED); - wbkgd(subWin, COLOR_PAIR(2) | A_BOLD); - } else - wbkgd(subWin, A_BOLD); -#else - wbkgd(subWin, A_BOLD); -#endif - box(subWin, ACS_VLINE, ACS_HLINE); - wrefresh(win); - - nocbreak(); - mvwaddstr(win, 2, 1, "Press some keys for 5 seconds"); - mvwaddstr(win, 1, 1, "Pressing ^C should do nothing"); - wrefresh(win); - - werase(subWin); - box(subWin, ACS_VLINE, ACS_HLINE); - for (i = 0; i < 5; i++) { - mvwprintw(subWin, 1, 1, "Time = %d", i); - wrefresh(subWin); - napms(1000); - flushinp(); - } - - delwin(subWin); - werase(win); - flash(); - wrefresh(win); - napms(500); - - mvwaddstr(win, 2, 1, "Press a key, followed by ENTER"); - wmove(win, 9, 10); - wrefresh(win); - echo(); - noraw(); - wgetch(win); - flushinp(); - - wmove(win, 9, 10); - wdelch(win); - mvwaddstr(win, 4, 1, "The character should now have been deleted"); - Continue(win); - - wclear(win); - mvwaddstr(win, 1, 1, "Press keys (or mouse buttons) to show their names"); - mvwaddstr(win, 2, 1, "Press spacebar to finish"); - wrefresh(win); - keypad(win, TRUE); - raw(); - noecho(); - typeahead(-1); -#if defined(PDCURSES) - mouse_set(ALL_MOUSE_EVENTS); -#endif - for (;;) { - wmove(win, 3, 5); - c = wgetch(win); - wclrtobot(win); - if (c >= KEY_MIN) - wprintw(win, "Key Pressed: %s", keyname(c)); - else if (isprint(c)) - wprintw(win, "Key Pressed: %c", c); - else - wprintw(win, "Key Pressed: %s", unctrl(c)); -#if defined(PDCURSES) - if (c == KEY_MOUSE) { - int button = 0; - request_mouse_pos(); - if (BUTTON_CHANGED(1)) - button = 1; - else if (BUTTON_CHANGED(2)) - button = 2; - else if (BUTTON_CHANGED(3)) - button = 3; - else - button = 0; - wmove(win, 4, 18); - wprintw(win, "Button %d: ", button); - if (MOUSE_MOVED) - wprintw(win, "moved: "); - else if ((BUTTON_STATUS(button) & BUTTON_ACTION_MASK) == BUTTON_PRESSED) - wprintw(win, "pressed: "); - else if ((BUTTON_STATUS(button) & BUTTON_ACTION_MASK) == BUTTON_DOUBLE_CLICKED) - wprintw(win, "double: "); - else - wprintw(win, "released: "); - wprintw(win, " Position: Y: %d X: %d", MOUSE_Y_POS, MOUSE_X_POS); - } -#endif - wrefresh(win); - if (c == ' ') - break; - } -#if 0 - nodelay(win, TRUE); - wgetch(win); - nodelay(win, FALSE); -#endif -#if defined(PDCURSES) - mouse_set(0L); -#endif - refresh(); - - repeat = 0; - do { - static const char *fmt[] = { - "%d %10s", - "%d %[a-zA-Z]s", - "%d %[][a-zA-Z]s", - "%d %[^0-9]" - }; - const char *format = fmt[repeat % SIZEOF(fmt)]; - - wclear(win); - mvwaddstr(win, 3, 2, "The window should have moved"); - mvwaddstr(win, 4, 2, - "This text should have appeared without you pressing a key"); - mvwprintw(win, 6, 2, - "Scanning with format \"%s\"", format); - mvwin(win, 2 + 2 * (repeat % 4), 1 + 2 * (repeat % 4)); - erase(); - refresh(); - wrefresh(win); - echo(); - noraw(); - num = 0; - *buffer = 0; - answered = mvwscanw(win, 7, 6, format, &num, buffer); - mvwprintw(win, 8, 6, - "String: %s Number: %d (%d values read)", - buffer, num, answered); - Continue(win); - ++repeat; - } while (answered > 0); -} - -static void -outputTest(WINDOW *win) -{ - WINDOW *win1; - char Buffer[80]; - chtype ch; - int by, bx; - - nl(); - wclear(win); - mvwaddstr(win, 1, 1, - "You should now have a screen in the upper left corner, and this text should have wrapped"); - mvwin(win, 2, 1); - waddstr(win, "\nThis text should be down\n"); - waddstr(win, "and broken into two here ^"); - Continue(win); - - wclear(win); - wattron(win, A_BOLD); - mvwaddstr(win, 1, 1, "A new window will appear with this text in it"); - mvwaddstr(win, 8, 1, "Press any key to continue"); - wrefresh(win); - wgetch(win); - - getbegyx(win, by, bx); - - if (LINES < 24 || COLS < 75) { - mvwaddstr(win, 5, 1, - "Some tests have been skipped as they require a"); - mvwaddstr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS"); - Continue(win); - } else { - win1 = newwin(10, 50, 14, 25); - if (win1 == NULL) { - endwin(); - return; - } -#ifdef A_COLOR - if (has_colors()) { - init_pair(3, COLOR_BLUE, COLOR_WHITE); - wbkgd(win1, COLOR_PAIR(3)); - } else - wbkgd(win1, A_NORMAL); -#else - wbkgd(win1, A_NORMAL); -#endif - wclear(win1); - mvwaddstr(win1, 5, 1, - "This text should appear; using overlay option"); - copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE); - -#if defined(PDCURSES) && !defined(XCURSES) - box(win1, 0xb3, 0xc4); -#else - box(win1, ACS_VLINE, ACS_HLINE); -#endif - wmove(win1, 8, 26); - wrefresh(win1); - wgetch(win1); - - wclear(win1); - wattron(win1, A_BLINK); - mvwaddstr(win1, 4, 1, - "This blinking text should appear in only the second window"); - wattroff(win1, A_BLINK); - mvwin(win1, by, bx); - overlay(win, win1); - mvwin(win1, 14, 25); - wmove(win1, 8, 26); - wrefresh(win1); - wgetch(win1); - delwin(win1); - } - - clear(); - wclear(win); - wrefresh(win); - mvwaddstr(win, 6, 2, "This line shouldn't appear"); - mvwaddstr(win, 4, 2, "Only half of the next line is visible"); - mvwaddstr(win, 5, 2, "Only half of the next line is visible"); - wmove(win, 6, 1); - wclrtobot(win); - wmove(win, 5, 20); - wclrtoeol(win); - mvwaddstr(win, 8, 2, "This line also shouldn't appear"); - wmove(win, 8, 1); - wdeleteln(win); - Continue(win); - - wmove(win, 5, 9); - ch = winch(win); - - wclear(win); - wmove(win, 6, 2); - waddstr(win, "The next char should be l: "); - winsch(win, ch); - Continue(win); - - mvwinsstr(win, 6, 2, "A1B2C3D4E5"); - Continue(win); - - wmove(win, 5, 1); - winsertln(win); - mvwaddstr(win, 5, 2, "The lines below should have moved down"); - Continue(win); - - wclear(win); - wmove(win, 2, 2); - wprintw(win, "This is a formatted string in a window: %d %s\n", 42, - "is it"); - mvwaddstr(win, 10, 1, "Enter a string: "); - wrefresh(win); - noraw(); - echo(); - *Buffer = 0; - wscanw(win, "%s", Buffer); - - printw("This is a formatted string in stdscr: %d %s\n", 42, "is it"); - mvaddstr(10, 1, "Enter a string: "); - *Buffer = 0; - scanw("%s", Buffer); - - if (tigetstr("cvvis") != 0) { - wclear(win); - curs_set(2); - mvwaddstr(win, 1, 1, "The cursor should appear as a block (visible)"); - Continue(win); - } - - if (tigetstr("civis") != 0) { - wclear(win); - curs_set(0); - mvwaddstr(win, 1, 1, - "The cursor should have disappeared (invisible)"); - Continue(win); - } - - if (tigetstr("cnorm") != 0) { - wclear(win); - curs_set(1); - mvwaddstr(win, 1, 1, "The cursor should be an underline (normal)"); - Continue(win); - } -#ifdef A_COLOR - if (has_colors()) { - wclear(win); - mvwaddstr(win, 1, 1, "Colors should change after you press a key"); - Continue(win); - init_pair(1, COLOR_RED, COLOR_WHITE); - wrefresh(win); - } -#endif - - werase(win); - mvwaddstr(win, 1, 1, "Information About Your Terminal"); - mvwaddstr(win, 3, 1, termname()); - mvwaddstr(win, 4, 1, longname()); - if (termattrs() & A_BLINK) - mvwaddstr(win, 5, 1, "This terminal supports blinking."); - else - mvwaddstr(win, 5, 1, "This terminal does NOT support blinking."); - - mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16); - wrefresh(win); - - mvwinnstr(win, 7, 5, Buffer, 18); - mvaddstr(LINES - 2, 10, Buffer); - refresh(); - Continue(win); -} - -#if defined(PDCURSES) && !defined(XCURSES) -static void -resizeTest(WINDOW *dummy GCC_UNUSED) -{ - WINDOW *win1; - - savetty(); - - clear(); - refresh(); -# if defined(OS2) - resize_term(50, 120); -# else - resize_term(50, 80); -# endif - - win1 = newwin(10, 50, 14, 25); - if (win1 == NULL) { - endwin(); - return; - } -#ifdef A_COLOR - if (has_colors()) { - init_pair(3, COLOR_BLUE, COLOR_WHITE); - wattrset(win1, COLOR_PAIR(3)); - } -#endif - wclear(win1); - - mvwaddstr(win1, 1, 1, "The screen may now have 50 lines"); - Continue(win1); - - wclear(win1); - resetty(); - - mvwaddstr(win1, 1, 1, "The screen should now be reset"); - Continue(win1); - - delwin(win1); - - clear(); - refresh(); - -} -#endif - -static void -padTest(WINDOW *dummy GCC_UNUSED) -{ - WINDOW *pad, *spad; - - pad = newpad(50, 100); - wattron(pad, A_REVERSE); - mvwaddstr(pad, 5, 2, "This is a new pad"); - wattrset(pad, A_NORMAL); - mvwaddstr(pad, 8, 0, - "The end of this line should be truncated here:except now"); - mvwaddstr(pad, 11, 1, "This line should not appear.It will now"); - wmove(pad, 10, 1); - wclrtoeol(pad); - mvwaddstr(pad, 10, 1, " Press any key to continue"); - prefresh(pad, 0, 0, 0, 0, 10, 45); - keypad(pad, TRUE); - raw(); - wgetch(pad); - - spad = subpad(pad, 12, 25, 6, 52); - mvwaddstr(spad, 2, 2, "This is a new subpad"); - box(spad, 0, 0); - prefresh(pad, 0, 0, 0, 0, 15, 75); - keypad(pad, TRUE); - raw(); - wgetch(pad); - - mvwaddstr(pad, 35, 2, "This is displayed at line 35 in the pad"); - mvwaddstr(pad, 40, 1, " Press any key to continue"); - prefresh(pad, 30, 0, 0, 0, 10, 45); - keypad(pad, TRUE); - raw(); - wgetch(pad); - - delwin(pad); -} - -static void -display_menu(int old_option, int new_option) -{ - register size_t i; - - attrset(A_NORMAL); - mvaddstr(3, 20, "PDCurses Test Program"); - - for (i = 0; i < MAX_OPTIONS; i++) - mvaddstr(5 + i, 25, command[i].text); - if (old_option != (-1)) - mvaddstr(5 + old_option, 25, command[old_option].text); - attrset(A_REVERSE); - mvaddstr(5 + new_option, 25, command[new_option].text); - attrset(A_NORMAL); - mvaddstr(13, 3, - "Use Up and Down Arrows to select - Enter to run - Q to quit"); - refresh(); -} diff --git a/contrib/ncurses/test/testscanw.c b/contrib/ncurses/test/testscanw.c deleted file mode 100644 index a1c25b9860bd..000000000000 --- a/contrib/ncurses/test/testscanw.c +++ /dev/null @@ -1,39 +0,0 @@ -/* gleaned from a web-search, shows a bug combining scanw and implicit scroll. - * Date: 1997/03/17 - * From: bayern@morpheus.cis.yale.edu - * - * $Id: testscanw.c,v 1.8 2001/09/15 21:41:45 tom Exp $ - */ -#include -#include - -int -main(int argc, char *argv[]) -{ - long badanswer = 1; - long *response = &badanswer; - - initscr(); - scrollok(stdscr, TRUE); - idlok(stdscr, TRUE); - echo(); - -#if 0 - trace(TRACE_UPDATE | TRACE_CALLS); -#endif - while (argc > 1) { - if (isdigit(UChar(*argv[1]))) - move(atoi(argv[1]), 0); - else if (!strcmp(argv[1], "-k")) - keypad(stdscr, TRUE); - argc--, argv++; - } - - while (badanswer) { - printw("Enter a number (0 to quit):\n"); - printw("--> "); - scanw("%20ld", response); /* yes, it's a pointer */ - } - endwin(); - ExitProgram(EXIT_SUCCESS); -} diff --git a/contrib/ncurses/test/tracemunch b/contrib/ncurses/test/tracemunch deleted file mode 100755 index d6761cd04219..000000000000 --- a/contrib/ncurses/test/tracemunch +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/perl -# -# tracemunch -- compactify ncurses trace logs -# -# The error logs produced by ncurses with tracing enabled can be very tedious -# to wade through. This script helps by compacting runs of log lines that -# can be conveniently expressed as higher-level operations. -# -# ($Id: tracemunch,v 1.2 1995/10/06 15:02:37 esr Exp $) - -$putattr="PutAttrChar\\('(.)' = 0x.., {A_NORMAL}\\) at \\(([0-9]+), ([0-9]+)\\)"; -$waddnstr="waddnstr\\(0x([0-9a-f]+),\"([^\"]+)\",[0-9]+\\) called {A_NORMAL}"; - -sub transaddr -{ - $arg = $_[0]; - - $arg =~ s/$curscr/curscr/ if ($curscr); - $arg =~ s/$newscr/newscr/ if ($newscr); - $arg =~ s/$stdscr/stdscr/ if ($stdscr); - - return $arg; -} - -while () -{ -CLASSIFY: { - # Transform window pointer addresses so it's easier to compare logs - $awaiting = "curscr" if ($_ =~ /creating curscr/); - $awaiting = "newscr" if ($_ =~ /creating newscr/); - $awaiting = "stdscr" if ($_ =~ /creating stdscr/); - if ($awaiting && $_ =~ /newwin: returned window is 0x([0-9a-f]+)/) - { - $curscr = "0x$1" if ($awaiting eq "curscr"); - $newscr = "0x$1" if ($awaiting eq "newscr"); - $stdscr = "0x$1" if ($awaiting eq "stdscr"); - $awaiting = ""; - } - - # Compactify runs of PutAttrChar calls (TR_CHARPUT) - if ($_ =~ /$putattr/) - { - $putattr_chars = $1; - $starty = $2; - $startx = $3; - while () - { - if ($_ =~ /$putattr/) { - $putattr_chars .= $1; - } else { - last; - } - } - print "RUN of PutAttrChar()s: \"$putattr_chars\" from ${starty}, ${startx}\n"; - redo CLASSIFY; - } - - # Compactify runs of waddnstr calls (TR_CALLS) - if ($_ =~ /$waddnstr/) - { - $waddnstr_chars = $2; - $winaddr = $1; - while () - { - if ($_ =~ /$waddnstr/ && $1 eq $winaddr) { - $waddnstr_chars .= $2; - } else { - last; - } - } - $winaddstr = &transaddr($winaddr); - print "RUN of waddnstr()s: $winaddr, \"$waddnstr_chars\"\n"; - redo CLASSIFY; - } - - # More transformations can go here - - # Repeated runs of anything - $anyline = &transaddr($_); - $repeatcount = 1; - while () { - if (&transaddr($_) eq $anyline) { - $repeatcount++; - } else { - last; - } - } - if ($repeatcount > 1) { - print "${repeatcount} REPEATS OF $anyline"; - } else { - print $anyline - } - redo CLASSIFY if $_; - - } # :CLASSIFY -} - -# tracemunch ends here diff --git a/contrib/ncurses/test/view.c b/contrib/ncurses/test/view.c deleted file mode 100644 index 83139d445205..000000000000 --- a/contrib/ncurses/test/view.c +++ /dev/null @@ -1,513 +0,0 @@ -/* - * view.c -- a silly little viewer program - * - * written by Eric S. Raymond December 1994 - * to test the scrolling code in ncurses. - * - * modified by Thomas Dickey July 1995 to demonstrate - * the use of 'resizeterm()', and May 2000 to illustrate wide-character - * handling. - * - * Takes a filename argument. It's a simple file-viewer with various - * scroll-up and scroll-down commands. - * - * n -- scroll one line forward - * p -- scroll one line back - * - * Either command accepts a numeric prefix interpreted as a repeat count. - * Thus, typing `5n' should scroll forward 5 lines in the file. - * - * The way you can tell this is working OK is that, in the trace file, - * there should be one scroll operation plus a small number of line - * updates, as opposed to a whole-page update. This means the physical - * scroll operation worked, and the refresh() code only had to do a - * partial repaint. - * - * $Id: view.c,v 1.52 2002/04/27 22:37:39 tom Exp $ - */ - -#include -#include -#include - -#include - -#if HAVE_TERMIOS_H -# include -#else -# include -#endif - -#if !defined(sun) || !HAVE_TERMIOS_H -# if HAVE_SYS_IOCTL_H -# include -# endif -#endif - -#define my_pair 1 - -/* This is needed to compile 'struct winsize' */ -#if NEED_PTEM_H -#include -#include -#endif - -static RETSIGTYPE finish(int sig) GCC_NORETURN; -static void show_all(const char *tag); - -#if defined(SIGWINCH) && defined(TIOCGWINSZ) && HAVE_RESIZETERM -#define CAN_RESIZE 1 -#else -#define CAN_RESIZE 0 -#endif - -#if CAN_RESIZE -static RETSIGTYPE adjust(int sig); -static int interrupted; -#endif - -static bool waiting = FALSE; -static int shift = 0; -static bool try_color = FALSE; - -static char *fname; -static NCURSES_CH_T **my_lines; -static NCURSES_CH_T **lptr; - -static void -usage(void) -{ - static const char *msg[] = - { - "Usage: view [options] file" - ,"" - ,"Options:" - ," -c use color if terminal supports it" - ," -i ignore INT, QUIT, TERM signals" - ," -n NUM specify maximum number of lines (default 1000)" -#if defined(KEY_RESIZE) - ," -r use old-style sigwinch handler rather than KEY_RESIZE" -#endif -#ifdef TRACE - ," -t trace screen updates" - ," -T NUM specify trace mask" -#endif - }; - size_t n; - for (n = 0; n < SIZEOF(msg); n++) - fprintf(stderr, "%s\n", msg[n]); - ExitProgram(EXIT_FAILURE); -} - -static int -ch_len(NCURSES_CH_T * src) -{ - int result = 0; -#if USE_WIDEC_SUPPORT -#endif - -#if USE_WIDEC_SUPPORT - while (getcchar(src++, NULL, NULL, NULL, NULL) > 0) - result++; -#else - while (*src++) - result++; -#endif - return result; -} - -/* - * Allocate a string into an array of chtype's. If UTF-8 mode is - * active, translate the string accordingly. - */ -static NCURSES_CH_T * -ch_dup(char *src) -{ - unsigned len = strlen(src); - NCURSES_CH_T *dst = typeMalloc(NCURSES_CH_T, len + 1); - unsigned j, k; -#if USE_WIDEC_SUPPORT - wchar_t wstr[CCHARW_MAX + 1]; - wchar_t wch; - int l = 0; - mbstate_t state; - size_t rc; - int width; -#endif - -#if USE_WIDEC_SUPPORT - memset(&state, 0, sizeof(state)); -#endif - for (j = k = 0; j < len; j++) { -#if USE_WIDEC_SUPPORT - rc = mbrtowc(&wch, src + j, len - j, &state); - if (rc == (size_t) -1 || rc == (size_t) -2) - break; - j += rc - 1; - if ((width = wcwidth(wch)) < 0) - break; - if ((width > 0 && l > 0) || l == CCHARW_MAX) { - wstr[l] = L'\0'; - l = 0; - if (setcchar(dst + k, wstr, 0, 0, NULL) != OK) - break; - ++k; - } - if (width == 0 && l == 0) - wstr[l++] = L' '; - wstr[l++] = wch; -#else - dst[k++] = src[j]; -#endif - } -#if USE_WIDEC_SUPPORT - if (l > 0) { - wstr[l] = L'\0'; - if (setcchar(dst + k, wstr, 0, 0, NULL) == OK) - ++k; - } - setcchar(dst + k, L"", 0, 0, NULL); -#else - dst[k] = 0; -#endif - return dst; -} - -int -main(int argc, char *argv[]) -{ - int MAXLINES = 1000; - FILE *fp; - char buf[BUFSIZ]; - int i; - int my_delay = 0; - NCURSES_CH_T **olptr; - int length = 0; - int value = 0; - bool done = FALSE; - bool got_number = FALSE; -#if CAN_RESIZE - bool nonposix_resize = FALSE; -#endif - const char *my_label = "Input"; - - setlocale(LC_ALL, ""); - -#ifndef NCURSES_VERSION - /* - * We know ncurses will catch SIGINT if we don't establish our own handler. - * Other versions of curses may/may not catch it. - */ - (void) signal(SIGINT, finish); /* arrange interrupts to terminate */ -#endif - - while ((i = getopt(argc, argv, "cin:rtT:")) != EOF) { - switch (i) { - case 'c': - try_color = TRUE; - break; - case 'i': - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - signal(SIGTERM, SIG_IGN); - break; - case 'n': - if ((MAXLINES = atoi(optarg)) < 1) - usage(); - break; -#if CAN_RESIZE - case 'r': - nonposix_resize = TRUE; - break; -#endif -#ifdef TRACE - case 'T': - trace(atoi(optarg)); - break; - case 't': - trace(TRACE_CALLS); - break; -#endif - default: - usage(); - } - } - if (optind + 1 != argc) - usage(); - - if ((my_lines = typeMalloc(NCURSES_CH_T *, MAXLINES + 2)) == 0) - usage(); - - fname = argv[optind]; - if ((fp = fopen(fname, "r")) == 0) { - perror(fname); - ExitProgram(EXIT_FAILURE); - } -#if CAN_RESIZE - if (nonposix_resize) - (void) signal(SIGWINCH, adjust); /* arrange interrupts to resize */ -#endif - - /* slurp the file */ - for (lptr = &my_lines[0]; (lptr - my_lines) < MAXLINES; lptr++) { - char temp[BUFSIZ], *s, *d; - int col; - - if (fgets(buf, sizeof(buf), fp) == 0) - break; - - /* convert tabs so that shift will work properly */ - for (s = buf, d = temp, col = 0; (*d = *s) != '\0'; s++) { - if (*d == '\n') { - *d = '\0'; - break; - } else if (*d == '\t') { - col = (col | 7) + 1; - while ((d - temp) != col) - *d++ = ' '; - } else -#if USE_WIDEC_SUPPORT - col++, d++; -#else - if (isprint(UChar(*d))) { - col++; - d++; - } else { - sprintf(d, "\\%03o", UChar(*s)); - d += strlen(d); - col = (d - temp); - } -#endif - } - *lptr = ch_dup(temp); - } - (void) fclose(fp); - length = lptr - my_lines; - - (void) initscr(); /* initialize the curses library */ - keypad(stdscr, TRUE); /* enable keyboard mapping */ - (void) nonl(); /* tell curses not to do NL->CR/NL on output */ - (void) cbreak(); /* take input chars one at a time, no wait for \n */ - (void) noecho(); /* don't echo input */ - nodelay(stdscr, TRUE); - idlok(stdscr, TRUE); /* allow use of insert/delete line */ - - if (try_color) { - if (has_colors()) { - start_color(); - init_pair(my_pair, COLOR_WHITE, COLOR_BLUE); - bkgd(COLOR_PAIR(my_pair)); - } else { - try_color = FALSE; - } - } - - lptr = my_lines; - while (!done) { - int n, c; - - if (!got_number) - show_all(my_label); - - n = 0; - for (;;) { -#if CAN_RESIZE - if (interrupted) { - adjust(0); - my_label = "interrupt"; - } -#endif - waiting = TRUE; - c = getch(); - waiting = FALSE; - if ((c < 127) && isdigit(c)) { - if (!got_number) { - mvprintw(0, 0, "Count: "); - clrtoeol(); - } - addch(c); - value = 10 * value + (c - '0'); - got_number = TRUE; - } else - break; - } - if (got_number && value) { - n = value; - } else { - n = 1; - } - - if (c != ERR) - my_label = keyname(c); - switch (c) { - case KEY_DOWN: - case 'n': - olptr = lptr; - for (i = 0; i < n; i++) - if ((lptr - my_lines) < (length - LINES + 1)) - lptr++; - else - break; - wscrl(stdscr, lptr - olptr); - break; - - case KEY_UP: - case 'p': - olptr = lptr; - for (i = 0; i < n; i++) - if (lptr > my_lines) - lptr--; - else - break; - wscrl(stdscr, lptr - olptr); - break; - - case 'h': - case KEY_HOME: - lptr = my_lines; - break; - - case 'e': - case KEY_END: - if (length > LINES) - lptr = my_lines + length - LINES + 1; - else - lptr = my_lines; - break; - - case 'r': - case KEY_RIGHT: - shift += n; - break; - - case 'l': - case KEY_LEFT: - shift -= n; - if (shift < 0) { - shift = 0; - beep(); - } - break; - - case 'q': - done = TRUE; - break; - -#ifdef KEY_RESIZE - case KEY_RESIZE: /* ignore this; ncurses will repaint */ - break; -#endif - case 's': - if (got_number) { - halfdelay(my_delay = n); - } else { - nodelay(stdscr, FALSE); - my_delay = -1; - } - break; - case ' ': - nodelay(stdscr, TRUE); - my_delay = 0; - break; - case ERR: - if (!my_delay) - napms(50); - break; - default: - beep(); - break; - } - if (c >= KEY_MIN || (c > 0 && !isdigit(c))) { - got_number = FALSE; - value = 0; - } - } - - finish(0); /* we're done */ -} - -static RETSIGTYPE -finish(int sig) -{ - endwin(); - ExitProgram(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS); -} - -#if CAN_RESIZE -/* - * This uses functions that are "unsafe", but it seems to work on SunOS and - * Linux. Usually: the "unsafe" refers to the functions that POSIX lists - * which may be called from a signal handler. Those do not include buffered - * I/O, which is used for instance in wrefresh(). To be really portable, you - * should use the KEY_RESIZE return (which relies on ncurses' sigwinch - * handler). - * - * The 'wrefresh(curscr)' is needed to force the refresh to start from the top - * of the screen -- some xterms mangle the bitmap while resizing. - */ -static RETSIGTYPE -adjust(int sig) -{ - if (waiting || sig == 0) { - struct winsize size; - - if (ioctl(fileno(stdout), TIOCGWINSZ, &size) == 0) { - resize_term(size.ws_row, size.ws_col); - wrefresh(curscr); /* Linux needs this */ - show_all(sig ? "SIGWINCH" : "interrupt"); - } - interrupted = FALSE; - } else { - interrupted = TRUE; - } - (void) signal(SIGWINCH, adjust); /* some systems need this */ -} -#endif /* CAN_RESIZE */ - -static void -show_all(const char *tag) -{ - int i; - char temp[BUFSIZ]; - NCURSES_CH_T *s; - time_t this_time; - -#if CAN_RESIZE - sprintf(temp, "%s (%3dx%3d) col %d ", tag, LINES, COLS, shift); - i = strlen(temp); - sprintf(temp + i, "view %.*s", (int) (sizeof(temp) - 7 - i), fname); -#else - sprintf(temp, "view %.*s", (int) sizeof(temp) - 7, fname); -#endif - move(0, 0); - printw("%.*s", COLS, temp); - clrtoeol(); - this_time = time((time_t *) 0); - strcpy(temp, ctime(&this_time)); - if ((i = strlen(temp)) != 0) { - temp[--i] = 0; - if (move(0, COLS - i - 2) != ERR) - printw(" %s", temp); - } - - scrollok(stdscr, FALSE); /* prevent screen from moving */ - for (i = 1; i < LINES; i++) { - move(i, 0); - printw("%3ld:", (long) (lptr + i - my_lines)); - clrtoeol(); - if ((s = lptr[i - 1]) != 0) { - int len = ch_len(s); - if (len > shift) -#if USE_WIDEC_SUPPORT - add_wchstr(s + shift); -#else - addchstr(s + shift); -#endif - if (try_color) - wchgat(stdscr, -1, A_NORMAL, my_pair, NULL); - } - } - setscrreg(1, LINES - 1); - scrollok(stdscr, TRUE); - refresh(); -} diff --git a/contrib/ncurses/test/worm.c b/contrib/ncurses/test/worm.c deleted file mode 100644 index d493d082fe4d..000000000000 --- a/contrib/ncurses/test/worm.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - - @@@ @@@ @@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@ - @@@ @@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@ - @@@ @@@ @@@@ @@@@ @@@@ @@@@ @@@ @@@@ - @@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ - @@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ - @@@@ @@@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ - @@@@@@@@@@@@ @@@@ @@@@ @@@ @@@ @@@ @@@ - @@@@ @@@@ @@@@@@@@@@@@ @@@ @@@ @@@ @@@ - @@ @@ @@@@@@@@@@ @@@ @@@ @@@ @@@ - - Eric P. Scott - Caltech High Energy Physics - October, 1980 - - Hacks to turn this into a test frame for cursor movement: - Eric S. Raymond - January, 1995 - - July 1995 (esr): worms is now in living color! :-) - -Options: - -f fill screen with copies of 'WORM' at start. - -l set worm length - -n set number of worms - -t make worms leave droppings - -T set trace interval - -S set single-stepping during trace interval - -N suppress cursor-movement optimization - - This program makes a good torture-test for the ncurses cursor-optimization - code. You can use -T to set the worm move interval over which movement - traces will be dumped. The program stops and waits for one character of - input at the beginning and end of the interval. - - $Id: worm.c,v 1.36 2002/03/23 21:46:54 tom Exp $ -*/ - -#include - -static chtype flavor[] = -{ - 'O', '*', '#', '$', '%', '0', '@', -}; -static const short xinc[] = -{ - 1, 1, 1, 0, -1, -1, -1, 0 -}, yinc[] = -{ - -1, 0, 1, 1, 1, 0, -1, -1 -}; -static struct worm { - int orientation, head; - short *xpos, *ypos; -} worm[40]; - -static const char *field; -static int length = 16, number = 3; -static chtype trail = ' '; - -#ifdef TRACE -int generation, trace_start, trace_end, singlestep; -#endif /* TRACE */ -/* *INDENT-OFF* */ -static const struct options { - int nopts; - int opts[3]; -} normal[8]={ - { 3, { 7, 0, 1 } }, - { 3, { 0, 1, 2 } }, - { 3, { 1, 2, 3 } }, - { 3, { 2, 3, 4 } }, - { 3, { 3, 4, 5 } }, - { 3, { 4, 5, 6 } }, - { 3, { 5, 6, 7 } }, - { 3, { 6, 7, 0 } } -}, upper[8]={ - { 1, { 1, 0, 0 } }, - { 2, { 1, 2, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 2, { 4, 5, 0 } }, - { 1, { 5, 0, 0 } }, - { 2, { 1, 5, 0 } } -}, left[8]={ - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 2, { 2, 3, 0 } }, - { 1, { 3, 0, 0 } }, - { 2, { 3, 7, 0 } }, - { 1, { 7, 0, 0 } }, - { 2, { 7, 0, 0 } } -}, right[8]={ - { 1, { 7, 0, 0 } }, - { 2, { 3, 7, 0 } }, - { 1, { 3, 0, 0 } }, - { 2, { 3, 4, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 2, { 6, 7, 0 } } -}, lower[8]={ - { 0, { 0, 0, 0 } }, - { 2, { 0, 1, 0 } }, - { 1, { 1, 0, 0 } }, - { 2, { 1, 5, 0 } }, - { 1, { 5, 0, 0 } }, - { 2, { 5, 6, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } } -}, upleft[8]={ - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 1, { 3, 0, 0 } }, - { 2, { 1, 3, 0 } }, - { 1, { 1, 0, 0 } } -}, upright[8]={ - { 2, { 3, 5, 0 } }, - { 1, { 3, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 1, { 5, 0, 0 } } -}, lowleft[8]={ - { 3, { 7, 0, 1 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 1, { 1, 0, 0 } }, - { 2, { 1, 7, 0 } }, - { 1, { 7, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } } -}, lowright[8]={ - { 0, { 0, 0, 0 } }, - { 1, { 7, 0, 0 } }, - { 2, { 5, 7, 0 } }, - { 1, { 5, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } } -}; -/* *INDENT-ON* */ - -static void -cleanup(void) -{ - standend(); - refresh(); - curs_set(1); - endwin(); -} - -static RETSIGTYPE -onsig(int sig GCC_UNUSED) -{ - cleanup(); - ExitProgram(EXIT_FAILURE); -} - -static float -ranf(void) -{ - long r = (rand() & 077777); - return ((float) r / 32768.); -} - -int -main(int argc, char *argv[]) -{ - short **ref; - int x, y; - int n; - struct worm *w; - const struct options *op; - int h; - short *ip; - int last, bottom; - - for (x = 1; x < argc; x++) { - char *p; - p = argv[x]; - if (*p == '-') - p++; - switch (*p) { - case 'f': - field = "WORM"; - break; - case 'l': - if (++x == argc) - goto usage; - if ((length = atoi(argv[x])) < 2 || length > 1024) { - fprintf(stderr, "%s: Invalid length\n", *argv); - ExitProgram(EXIT_FAILURE); - } - break; - case 'n': - if (++x == argc) - goto usage; - if ((number = atoi(argv[x])) < 1 || number > 40) { - fprintf(stderr, "%s: Invalid number of worms\n", *argv); - ExitProgram(EXIT_FAILURE); - } - break; - case 't': - trail = '.'; - break; -#ifdef TRACE - case 'S': - singlestep = TRUE; - break; - case 'T': - trace_start = atoi(argv[++x]); - trace_end = atoi(argv[++x]); - break; - case 'N': - _nc_optimize_enable ^= OPTIMIZE_ALL; /* declared by ncurses */ - break; -#endif /* TRACE */ - default: - usage: - fprintf(stderr, - "usage: %s [-field] [-length #] [-number #] [-trail]\n", *argv); - ExitProgram(EXIT_FAILURE); - } - } - - signal(SIGINT, onsig); - initscr(); - noecho(); - cbreak(); - nonl(); - - curs_set(0); - - bottom = LINES - 1; - last = COLS - 1; - -#ifdef A_COLOR - if (has_colors()) { - int bg = COLOR_BLACK; - start_color(); -#if HAVE_USE_DEFAULT_COLORS - if (use_default_colors() == OK) - bg = -1; -#endif - -#define SET_COLOR(num, fg) \ - init_pair(num+1, fg, bg); \ - flavor[num] |= COLOR_PAIR(num+1) | A_BOLD - - SET_COLOR(0, COLOR_GREEN); - SET_COLOR(1, COLOR_RED); - SET_COLOR(2, COLOR_CYAN); - SET_COLOR(3, COLOR_WHITE); - SET_COLOR(4, COLOR_MAGENTA); - SET_COLOR(5, COLOR_BLUE); - SET_COLOR(6, COLOR_YELLOW); - } -#endif /* A_COLOR */ - - ref = typeMalloc(short *, LINES); - for (y = 0; y < LINES; y++) { - ref[y] = typeMalloc(short, COLS); - for (x = 0; x < COLS; x++) { - ref[y][x] = 0; - } - } - -#ifdef BADCORNER - /* if addressing the lower right corner doesn't work in your curses */ - ref[bottom][last] = 1; -#endif /* BADCORNER */ - - for (n = number, w = &worm[0]; --n >= 0; w++) { - w->orientation = w->head = 0; - if (!(ip = typeMalloc(short, (length + 1)))) { - fprintf(stderr, "%s: out of memory\n", *argv); - ExitProgram(EXIT_FAILURE); - } - w->xpos = ip; - for (x = length; --x >= 0;) - *ip++ = -1; - if (!(ip = typeMalloc(short, (length + 1)))) { - fprintf(stderr, "%s: out of memory\n", *argv); - ExitProgram(EXIT_FAILURE); - } - w->ypos = ip; - for (y = length; --y >= 0;) - *ip++ = -1; - } - if (field) { - const char *p; - p = field; - for (y = bottom; --y >= 0;) { - for (x = COLS; --x >= 0;) { - addch((chtype) (*p++)); - if (!*p) - p = field; - } - } - } - napms(10); - refresh(); -#ifndef TRACE - nodelay(stdscr, TRUE); -#endif - - for (;;) { -#ifdef TRACE - if (trace_start || trace_end) { - if (generation == trace_start) { - trace(TRACE_CALLS); - getch(); - } else if (generation == trace_end) { - trace(0); - getch(); - } - - if (singlestep && generation > trace_start && generation < trace_end) - getch(); - - generation++; - } -#else - int ch; - - if ((ch = getch()) > 0) { -#ifdef KEY_RESIZE - if (ch == KEY_RESIZE) { - if (last != COLS - 1) { - for (y = 0; y <= bottom; y++) { - ref[y] = typeRealloc(short, COLS, ref[y]); - for (x = last + 1; x < COLS; x++) - ref[y][x] = 0; - } - last = COLS - 1; - } - if (bottom != LINES - 1) { - for (y = LINES; y <= bottom; y++) - free(ref[y]); - ref = typeRealloc(short *, LINES, ref); - for (y = bottom + 1; y < LINES; y++) { - ref[y] = typeMalloc(short, COLS); - for (x = 0; x < COLS; x++) - ref[y][x] = 0; - } - bottom = LINES - 1; - } - } -#endif - /* - * Make it simple to put this into single-step mode, or resume - * normal operation -TD - */ - if (ch == 'q') { - cleanup(); - ExitProgram(EXIT_SUCCESS); - } else if (ch == 's') { - nodelay(stdscr, FALSE); - } else if (ch == ' ') { - nodelay(stdscr, TRUE); - } - } -#endif /* TRACE */ - - for (n = 0, w = &worm[0]; n < number; n++, w++) { - if ((x = w->xpos[h = w->head]) < 0) { - move(y = w->ypos[h] = bottom, x = w->xpos[h] = 0); - addch(flavor[n % SIZEOF(flavor)]); - ref[y][x]++; - } else { - y = w->ypos[h]; - } - if (x > last) - x = last; - if (y > bottom) - y = bottom; - if (++h == length) - h = 0; - if (w->xpos[w->head = h] >= 0) { - int x1, y1; - x1 = w->xpos[h]; - y1 = w->ypos[h]; - if (y1 < LINES - && x1 < COLS - && --ref[y1][x1] == 0) { - move(y1, x1); - addch(trail); - } - } - op = &(x == 0 ? (y == 0 ? upleft : (y == bottom ? lowleft : - left)) : - (x == last ? (y == 0 ? upright : (y == bottom ? lowright : - right)) : - (y == 0 ? upper : (y == bottom ? lower : normal))))[w->orientation]; - switch (op->nopts) { - case 0: - cleanup(); - ExitProgram(EXIT_SUCCESS); - case 1: - w->orientation = op->opts[0]; - break; - default: - w->orientation = op->opts[(int) (ranf() * (float) op->nopts)]; - } - move(y += yinc[w->orientation], x += xinc[w->orientation]); - - if (y < 0) - y = 0; - addch(flavor[n % SIZEOF(flavor)]); - ref[w->ypos[h] = y][w->xpos[h] = x]++; - } - napms(10); - refresh(); - } -} diff --git a/contrib/ncurses/test/xmas.c b/contrib/ncurses/test/xmas.c deleted file mode 100644 index f7edde78d607..000000000000 --- a/contrib/ncurses/test/xmas.c +++ /dev/null @@ -1,1157 +0,0 @@ -/******************************************************************************/ -/* asciixmas */ -/* December 1989 Larry Bartz Indianapolis, IN */ -/* */ -/* */ -/* I'm dreaming of an ascii character-based monochrome Christmas, */ -/* Just like the one's I used to know! */ -/* Via a full duplex communications channel, */ -/* At 9600 bits per second, */ -/* Even though it's kinda slow. */ -/* */ -/* I'm dreaming of an ascii character-based monochrome Christmas, */ -/* With ev'ry C program I write! */ -/* May your screen be merry and bright! */ -/* And may all your Christmases be amber or green, */ -/* (for reduced eyestrain and improved visibility)! */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* IMPLEMENTATION */ -/* */ -/* Feel free to modify the defined string FROMWHO to reflect you, your */ -/* organization, your site, whatever. */ -/* */ -/* This really looks a lot better if you can turn off your cursor before */ -/* execution. I wanted to do that here but very few termcap entries or */ -/* terminfo definitions have the appropriate string defined. If you know */ -/* the string(s) for the terminal(s) you use or which your site supports, */ -/* you could call asciixmas from within a shell in which you issue the */ -/* string to the terminal. The cursor is distracting but it doesn't really */ -/* ruin the show. */ -/* */ -/* At our site, we invoke this for our users just after login and the */ -/* determination of terminal type. */ -/* */ -/* */ -/* PORTABILITY */ -/* */ -/* I wrote this using only the very simplest curses functions so that it */ -/* might be the most portable. I was personally able to test on five */ -/* different cpu/UNIX combinations. */ -/* */ -/* */ -/* COMPILE */ -/* */ -/* usually this: */ -/* */ -/* cc -O asciixmas.c -lcurses -o asciixmas -s */ -/* */ -/* */ -/* Zilog S8000 models 11, 21, 31, etc with ZEUS variant of SYSTEM III */ -/* maybe other SYSTEM III also: */ -/* */ -/* cc asciixmas.c -lcurses -ltermlib -o asciixmas -s */ -/* */ -/* as above with optional "peephole optimizer" installed: */ -/* */ -/* cc -O asciixmas.c -lcurses -ltermlib -o asciixmas -s */ -/* */ -/* */ -/* Zilog S8000 models 32, 130 with WE32100 chip and SYS V, REL2 */ -/* maybe 3B2 also? */ -/* */ -/* cc -f -O -K sd asciixmas.c -lcurses -o asciixmas -s */ -/* */ -/* */ -/* Pyramid, Sequent, any other "dual universe" types compile and execute */ -/* under either universe. The compile line for the ucb universe (as you */ -/* might expect) is the same as for SYS III UNIX: */ -/* */ -/* cc -O asciixmas.c -lcurses -ltermlib -o asciixmas -s */ -/* */ -/* The above compile will also hold true for other BSD systems. (I hope) */ -/* */ -/* */ -/* */ -/* */ -/* For the Scrooges out there among you who don't want this thing to loop */ -/* forever (or until the user hits a key), insert this into your compile */ -/* line just after "cc" : */ -/* */ -/* -DNOLOOP */ -/* */ -/* like so: */ -/* */ -/* cc -DNOLOOP -O asciixmas.c -lcurses -o asciixmas -s */ -/* */ -/* */ -/* */ -/******************************************************************************/ - -/* - * $Id: xmas.c,v 1.18 2002/03/23 21:46:58 tom Exp $ - */ -#include - -#define FROMWHO "Mark Hessling - (M.Hessling@gu.edu.au)" - -static int my_bg = COLOR_BLACK; -static int y_pos, x_pos; - -static WINDOW *treescrn; -static WINDOW *treescrn2; -static WINDOW *treescrn3; -static WINDOW *treescrn4; -static WINDOW *treescrn5; -static WINDOW *treescrn6; -static WINDOW *treescrn7; -static WINDOW *treescrn8; -static WINDOW *dotdeer0; -static WINDOW *stardeer0; -static WINDOW *lildeer0; -static WINDOW *lildeer1; -static WINDOW *lildeer2; -static WINDOW *lildeer3; -static WINDOW *middeer0; -static WINDOW *middeer1; -static WINDOW *middeer2; -static WINDOW *middeer3; -static WINDOW *bigdeer0; -static WINDOW *bigdeer1; -static WINDOW *bigdeer2; -static WINDOW *bigdeer3; -static WINDOW *bigdeer4; -static WINDOW *lookdeer0; -static WINDOW *lookdeer1; -static WINDOW *lookdeer2; -static WINDOW *lookdeer3; -static WINDOW *lookdeer4; -static WINDOW *w_holiday; -static WINDOW *w_del_msg; - -static int boxit(void); -static int seas(void); -static int greet(void); -static int fromwho(void); -static int tree(void); -static int balls(void); -static int star(void); -static int strng1(void); -static int strng2(void); -static int strng3(void); -static int strng4(void); -static int strng5(void); -static int reindeer(void); -static int blinkit(void); - -static RETSIGTYPE done(int sig) GCC_NORETURN; - -static void -set_color(WINDOW *win, chtype color) -{ - if (has_colors()) { - static bool *pairs; - int n = (color + 1); - if (pairs == 0) - pairs = (bool *) calloc(COLORS + 1, sizeof(bool)); - if (!pairs[n]) { - init_pair(n, color, my_bg); - pairs[n] = TRUE; - } - wattroff(win, A_COLOR); - wattron(win, COLOR_PAIR(n)); - } -} - -static void -unset_color(WINDOW *win) -{ - if (has_colors()) - wattrset(win, COLOR_PAIR(0)); -} - -static void -look_out(int msecs) -{ - napms(msecs); - if (getch() != ERR) { - beep(); - done(0); - } -} - -int -main(int argc GCC_UNUSED, char **argv GCC_UNUSED) -{ - int loopy; - - initscr(); - noecho(); - nonl(); - refresh(); - signal(SIGINT, done); - signal(SIGTERM, done); -#if !defined DOS && !defined OS2 - signal(SIGHUP, done); - signal(SIGQUIT, done); -#endif - if (has_colors()) { - start_color(); -#if HAVE_USE_DEFAULT_COLORS - if (use_default_colors() == OK) - my_bg = -1; -#endif - } - curs_set(0); - - treescrn = newwin(16, 27, 3, 53); - treescrn2 = newwin(16, 27, 3, 53); - treescrn3 = newwin(16, 27, 3, 53); - treescrn4 = newwin(16, 27, 3, 53); - treescrn5 = newwin(16, 27, 3, 53); - treescrn6 = newwin(16, 27, 3, 53); - treescrn7 = newwin(16, 27, 3, 53); - treescrn8 = newwin(16, 27, 3, 53); - - dotdeer0 = newwin(3, 71, 0, 8); - - stardeer0 = newwin(4, 56, 0, 8); - - lildeer0 = newwin(7, 53, 0, 8); - lildeer1 = newwin(2, 4, 0, 0); - lildeer2 = newwin(2, 4, 0, 0); - lildeer3 = newwin(2, 4, 0, 0); - - middeer0 = newwin(15, 42, 0, 8); - middeer1 = newwin(3, 7, 0, 0); - middeer2 = newwin(3, 7, 0, 0); - middeer3 = newwin(3, 7, 0, 0); - - bigdeer0 = newwin(10, 23, 0, 0); - bigdeer1 = newwin(10, 23, 0, 0); - bigdeer2 = newwin(10, 23, 0, 0); - bigdeer3 = newwin(10, 23, 0, 0); - bigdeer4 = newwin(10, 23, 0, 0); - - lookdeer0 = newwin(10, 25, 0, 0); - lookdeer1 = newwin(10, 25, 0, 0); - lookdeer2 = newwin(10, 25, 0, 0); - lookdeer3 = newwin(10, 25, 0, 0); - lookdeer4 = newwin(10, 25, 0, 0); - - w_holiday = newwin(1, 26, 3, 27); - - w_del_msg = newwin(1, 19, 23, 60); - - mvwaddstr(w_del_msg, 0, 0, "Hit any key to quit"); - - mvwaddstr(w_holiday, 0, 0, "H A P P Y H O L I D A Y S"); - - /* set up the windows for our various reindeer */ - - /* lildeer1 */ - mvwaddch(lildeer1, 0, 0, (chtype) 'V'); - mvwaddch(lildeer1, 1, 0, (chtype) '@'); - mvwaddch(lildeer1, 1, 1, (chtype) '<'); - mvwaddch(lildeer1, 1, 2, (chtype) '>'); - mvwaddch(lildeer1, 1, 3, (chtype) '~'); - - /* lildeer2 */ - mvwaddch(lildeer2, 0, 0, (chtype) 'V'); - mvwaddch(lildeer2, 1, 0, (chtype) '@'); - mvwaddch(lildeer2, 1, 1, (chtype) '|'); - mvwaddch(lildeer2, 1, 2, (chtype) '|'); - mvwaddch(lildeer2, 1, 3, (chtype) '~'); - - /* lildeer3 */ - mvwaddch(lildeer3, 0, 0, (chtype) 'V'); - mvwaddch(lildeer3, 1, 0, (chtype) '@'); - mvwaddch(lildeer3, 1, 1, (chtype) '>'); - mvwaddch(lildeer3, 1, 2, (chtype) '<'); - mvwaddch(lildeer2, 1, 3, (chtype) '~'); - - /* middeer1 */ - mvwaddch(middeer1, 0, 2, (chtype) 'y'); - mvwaddch(middeer1, 0, 3, (chtype) 'y'); - mvwaddch(middeer1, 1, 2, (chtype) '0'); - mvwaddch(middeer1, 1, 3, (chtype) '('); - mvwaddch(middeer1, 1, 4, (chtype) '='); - mvwaddch(middeer1, 1, 5, (chtype) ')'); - mvwaddch(middeer1, 1, 6, (chtype) '~'); - mvwaddch(middeer1, 2, 3, (chtype) '\\'); - mvwaddch(middeer1, 2, 4, (chtype) '/'); - - /* middeer2 */ - mvwaddch(middeer2, 0, 2, (chtype) 'y'); - mvwaddch(middeer2, 0, 3, (chtype) 'y'); - mvwaddch(middeer2, 1, 2, (chtype) '0'); - mvwaddch(middeer2, 1, 3, (chtype) '('); - mvwaddch(middeer2, 1, 4, (chtype) '='); - mvwaddch(middeer2, 1, 5, (chtype) ')'); - mvwaddch(middeer2, 1, 6, (chtype) '~'); - mvwaddch(middeer2, 2, 3, (chtype) '|'); - mvwaddch(middeer2, 2, 5, (chtype) '|'); - - /* middeer3 */ - mvwaddch(middeer3, 0, 2, (chtype) 'y'); - mvwaddch(middeer3, 0, 3, (chtype) 'y'); - mvwaddch(middeer3, 1, 2, (chtype) '0'); - mvwaddch(middeer3, 1, 3, (chtype) '('); - mvwaddch(middeer3, 1, 4, (chtype) '='); - mvwaddch(middeer3, 1, 5, (chtype) ')'); - mvwaddch(middeer3, 1, 6, (chtype) '~'); - mvwaddch(middeer3, 2, 2, (chtype) '/'); - mvwaddch(middeer3, 2, 6, (chtype) '\\'); - - /* bigdeer1 */ - mvwaddch(bigdeer1, 0, 17, (chtype) '\\'); - mvwaddch(bigdeer1, 0, 18, (chtype) '/'); - mvwaddch(bigdeer1, 0, 20, (chtype) '\\'); - mvwaddch(bigdeer1, 0, 21, (chtype) '/'); - mvwaddch(bigdeer1, 1, 18, (chtype) '\\'); - mvwaddch(bigdeer1, 1, 20, (chtype) '/'); - mvwaddch(bigdeer1, 2, 19, (chtype) '|'); - mvwaddch(bigdeer1, 2, 20, (chtype) '_'); - mvwaddch(bigdeer1, 3, 18, (chtype) '/'); - mvwaddch(bigdeer1, 3, 19, (chtype) '^'); - mvwaddch(bigdeer1, 3, 20, (chtype) '0'); - mvwaddch(bigdeer1, 3, 21, (chtype) '\\'); - mvwaddch(bigdeer1, 4, 17, (chtype) '/'); - mvwaddch(bigdeer1, 4, 18, (chtype) '/'); - mvwaddch(bigdeer1, 4, 19, (chtype) '\\'); - mvwaddch(bigdeer1, 4, 22, (chtype) '\\'); - mvwaddstr(bigdeer1, 5, 7, "^~~~~~~~~// ~~U"); - mvwaddstr(bigdeer1, 6, 7, "( \\_____( /"); - mvwaddstr(bigdeer1, 7, 8, "( ) /"); - mvwaddstr(bigdeer1, 8, 9, "\\\\ /"); - mvwaddstr(bigdeer1, 9, 11, "\\>/>"); - - /* bigdeer2 */ - mvwaddch(bigdeer2, 0, 17, (chtype) '\\'); - mvwaddch(bigdeer2, 0, 18, (chtype) '/'); - mvwaddch(bigdeer2, 0, 20, (chtype) '\\'); - mvwaddch(bigdeer2, 0, 21, (chtype) '/'); - mvwaddch(bigdeer2, 1, 18, (chtype) '\\'); - mvwaddch(bigdeer2, 1, 20, (chtype) '/'); - mvwaddch(bigdeer2, 2, 19, (chtype) '|'); - mvwaddch(bigdeer2, 2, 20, (chtype) '_'); - mvwaddch(bigdeer2, 3, 18, (chtype) '/'); - mvwaddch(bigdeer2, 3, 19, (chtype) '^'); - mvwaddch(bigdeer2, 3, 20, (chtype) '0'); - mvwaddch(bigdeer2, 3, 21, (chtype) '\\'); - mvwaddch(bigdeer2, 4, 17, (chtype) '/'); - mvwaddch(bigdeer2, 4, 18, (chtype) '/'); - mvwaddch(bigdeer2, 4, 19, (chtype) '\\'); - mvwaddch(bigdeer2, 4, 22, (chtype) '\\'); - mvwaddstr(bigdeer2, 5, 7, "^~~~~~~~~// ~~U"); - mvwaddstr(bigdeer2, 6, 7, "(( )____( /"); - mvwaddstr(bigdeer2, 7, 7, "( / |"); - mvwaddstr(bigdeer2, 8, 8, "\\/ |"); - mvwaddstr(bigdeer2, 9, 9, "|> |>"); - - /* bigdeer3 */ - mvwaddch(bigdeer3, 0, 17, (chtype) '\\'); - mvwaddch(bigdeer3, 0, 18, (chtype) '/'); - mvwaddch(bigdeer3, 0, 20, (chtype) '\\'); - mvwaddch(bigdeer3, 0, 21, (chtype) '/'); - mvwaddch(bigdeer3, 1, 18, (chtype) '\\'); - mvwaddch(bigdeer3, 1, 20, (chtype) '/'); - mvwaddch(bigdeer3, 2, 19, (chtype) '|'); - mvwaddch(bigdeer3, 2, 20, (chtype) '_'); - mvwaddch(bigdeer3, 3, 18, (chtype) '/'); - mvwaddch(bigdeer3, 3, 19, (chtype) '^'); - mvwaddch(bigdeer3, 3, 20, (chtype) '0'); - mvwaddch(bigdeer3, 3, 21, (chtype) '\\'); - mvwaddch(bigdeer3, 4, 17, (chtype) '/'); - mvwaddch(bigdeer3, 4, 18, (chtype) '/'); - mvwaddch(bigdeer3, 4, 19, (chtype) '\\'); - mvwaddch(bigdeer3, 4, 22, (chtype) '\\'); - mvwaddstr(bigdeer3, 5, 7, "^~~~~~~~~// ~~U"); - mvwaddstr(bigdeer3, 6, 6, "( ()_____( /"); - mvwaddstr(bigdeer3, 7, 6, "/ / /"); - mvwaddstr(bigdeer3, 8, 5, "|/ \\"); - mvwaddstr(bigdeer3, 9, 5, "/> \\>"); - - /* bigdeer4 */ - mvwaddch(bigdeer4, 0, 17, (chtype) '\\'); - mvwaddch(bigdeer4, 0, 18, (chtype) '/'); - mvwaddch(bigdeer4, 0, 20, (chtype) '\\'); - mvwaddch(bigdeer4, 0, 21, (chtype) '/'); - mvwaddch(bigdeer4, 1, 18, (chtype) '\\'); - mvwaddch(bigdeer4, 1, 20, (chtype) '/'); - mvwaddch(bigdeer4, 2, 19, (chtype) '|'); - mvwaddch(bigdeer4, 2, 20, (chtype) '_'); - mvwaddch(bigdeer4, 3, 18, (chtype) '/'); - mvwaddch(bigdeer4, 3, 19, (chtype) '^'); - mvwaddch(bigdeer4, 3, 20, (chtype) '0'); - mvwaddch(bigdeer4, 3, 21, (chtype) '\\'); - mvwaddch(bigdeer4, 4, 17, (chtype) '/'); - mvwaddch(bigdeer4, 4, 18, (chtype) '/'); - mvwaddch(bigdeer4, 4, 19, (chtype) '\\'); - mvwaddch(bigdeer4, 4, 22, (chtype) '\\'); - mvwaddstr(bigdeer4, 5, 7, "^~~~~~~~~// ~~U"); - mvwaddstr(bigdeer4, 6, 6, "( )______( /"); - mvwaddstr(bigdeer4, 7, 5, "(/ \\"); - mvwaddstr(bigdeer4, 8, 0, "v___= ----^"); - - /* lookdeer1 */ - mvwaddstr(lookdeer1, 0, 16, "\\/ \\/"); - mvwaddstr(lookdeer1, 1, 17, "\\Y/ \\Y/"); - mvwaddstr(lookdeer1, 2, 19, "\\=/"); - mvwaddstr(lookdeer1, 3, 17, "^\\o o/^"); - mvwaddstr(lookdeer1, 4, 17, "//( )"); - mvwaddstr(lookdeer1, 5, 7, "^~~~~~~~~// \\O/"); - mvwaddstr(lookdeer1, 6, 7, "( \\_____( /"); - mvwaddstr(lookdeer1, 7, 8, "( ) /"); - mvwaddstr(lookdeer1, 8, 9, "\\\\ /"); - mvwaddstr(lookdeer1, 9, 11, "\\>/>"); - - /* lookdeer2 */ - mvwaddstr(lookdeer2, 0, 16, "\\/ \\/"); - mvwaddstr(lookdeer2, 1, 17, "\\Y/ \\Y/"); - mvwaddstr(lookdeer2, 2, 19, "\\=/"); - mvwaddstr(lookdeer2, 3, 17, "^\\o o/^"); - mvwaddstr(lookdeer2, 4, 17, "//( )"); - mvwaddstr(lookdeer2, 5, 7, "^~~~~~~~~// \\O/"); - mvwaddstr(lookdeer2, 6, 7, "(( )____( /"); - mvwaddstr(lookdeer2, 7, 7, "( / |"); - mvwaddstr(lookdeer2, 8, 8, "\\/ |"); - mvwaddstr(lookdeer2, 9, 9, "|> |>"); - - /* lookdeer3 */ - mvwaddstr(lookdeer3, 0, 16, "\\/ \\/"); - mvwaddstr(lookdeer3, 1, 17, "\\Y/ \\Y/"); - mvwaddstr(lookdeer3, 2, 19, "\\=/"); - mvwaddstr(lookdeer3, 3, 17, "^\\o o/^"); - mvwaddstr(lookdeer3, 4, 17, "//( )"); - mvwaddstr(lookdeer3, 5, 7, "^~~~~~~~~// \\O/"); - mvwaddstr(lookdeer3, 6, 6, "( ()_____( /"); - mvwaddstr(lookdeer3, 7, 6, "/ / /"); - mvwaddstr(lookdeer3, 8, 5, "|/ \\"); - mvwaddstr(lookdeer3, 9, 5, "/> \\>"); - - /* lookdeer4 */ - mvwaddstr(lookdeer4, 0, 16, "\\/ \\/"); - mvwaddstr(lookdeer4, 1, 17, "\\Y/ \\Y/"); - mvwaddstr(lookdeer4, 2, 19, "\\=/"); - mvwaddstr(lookdeer4, 3, 17, "^\\o o/^"); - mvwaddstr(lookdeer4, 4, 17, "//( )"); - mvwaddstr(lookdeer4, 5, 7, "^~~~~~~~~// \\O/"); - mvwaddstr(lookdeer4, 6, 6, "( )______( /"); - mvwaddstr(lookdeer4, 7, 5, "(/ \\"); - mvwaddstr(lookdeer4, 8, 0, "v___= ----^"); - - /***********************************************/ - cbreak(); - nodelay(stdscr, TRUE); - for (;;) { - clear(); - werase(treescrn); - touchwin(w_del_msg); - touchwin(treescrn); - werase(treescrn2); - touchwin(treescrn2); - werase(treescrn8); - touchwin(treescrn8); - refresh(); - look_out(150); - boxit(); - refresh(); - look_out(150); - seas(); - refresh(); - look_out(150); - greet(); - refresh(); - look_out(150); - fromwho(); - refresh(); - look_out(150); - tree(); - look_out(150); - balls(); - look_out(150); - star(); - look_out(150); - strng1(); - strng2(); - strng3(); - strng4(); - strng5(); - - /* set up the windows for our blinking trees */ - /* **************************************** */ - /* treescrn3 */ - - overlay(treescrn, treescrn3); - - /*balls */ - mvwaddch(treescrn3, 4, 18, ' '); - mvwaddch(treescrn3, 7, 6, ' '); - mvwaddch(treescrn3, 8, 19, ' '); - mvwaddch(treescrn3, 11, 22, ' '); - - /*star */ - mvwaddch(treescrn3, 0, 12, '*'); - - /*strng1 */ - mvwaddch(treescrn3, 3, 11, ' '); - - /*strng2 */ - mvwaddch(treescrn3, 5, 13, ' '); - mvwaddch(treescrn3, 6, 10, ' '); - - /*strng3 */ - mvwaddch(treescrn3, 7, 16, ' '); - mvwaddch(treescrn3, 7, 14, ' '); - - /*strng4 */ - mvwaddch(treescrn3, 10, 13, ' '); - mvwaddch(treescrn3, 10, 10, ' '); - mvwaddch(treescrn3, 11, 8, ' '); - - /*strng5 */ - mvwaddch(treescrn3, 11, 18, ' '); - mvwaddch(treescrn3, 12, 13, ' '); - - /* treescrn4 */ - - overlay(treescrn, treescrn4); - - /*balls */ - mvwaddch(treescrn4, 3, 9, ' '); - mvwaddch(treescrn4, 4, 16, ' '); - mvwaddch(treescrn4, 7, 6, ' '); - mvwaddch(treescrn4, 8, 19, ' '); - mvwaddch(treescrn4, 11, 2, ' '); - mvwaddch(treescrn4, 12, 23, ' '); - - /*star */ - wstandout(treescrn4); - mvwaddch(treescrn4, 0, 12, '*'); - wstandend(treescrn4); - - /*strng1 */ - mvwaddch(treescrn4, 3, 13, ' '); - - /*strng2 */ - - /*strng3 */ - mvwaddch(treescrn4, 7, 15, ' '); - mvwaddch(treescrn4, 8, 11, ' '); - - /*strng4 */ - mvwaddch(treescrn4, 9, 16, ' '); - mvwaddch(treescrn4, 10, 12, ' '); - mvwaddch(treescrn4, 11, 8, ' '); - - /*strng5 */ - mvwaddch(treescrn4, 11, 18, ' '); - mvwaddch(treescrn4, 12, 14, ' '); - - /* treescrn5 */ - - overlay(treescrn, treescrn5); - - /*balls */ - mvwaddch(treescrn5, 3, 15, ' '); - mvwaddch(treescrn5, 10, 20, ' '); - mvwaddch(treescrn5, 12, 1, ' '); - - /*star */ - mvwaddch(treescrn5, 0, 12, '*'); - - /*strng1 */ - mvwaddch(treescrn5, 3, 11, ' '); - - /*strng2 */ - mvwaddch(treescrn5, 5, 12, ' '); - - /*strng3 */ - mvwaddch(treescrn5, 7, 14, ' '); - mvwaddch(treescrn5, 8, 10, ' '); - - /*strng4 */ - mvwaddch(treescrn5, 9, 15, ' '); - mvwaddch(treescrn5, 10, 11, ' '); - mvwaddch(treescrn5, 11, 7, ' '); - - /*strng5 */ - mvwaddch(treescrn5, 11, 17, ' '); - mvwaddch(treescrn5, 12, 13, ' '); - - /* treescrn6 */ - - overlay(treescrn, treescrn6); - - /*balls */ - mvwaddch(treescrn6, 6, 7, ' '); - mvwaddch(treescrn6, 7, 18, ' '); - mvwaddch(treescrn6, 10, 4, ' '); - mvwaddch(treescrn6, 11, 23, ' '); - - /*star */ - wstandout(treescrn6); - mvwaddch(treescrn6, 0, 12, '*'); - wstandend(treescrn6); - - /*strng1 */ - - /*strng2 */ - mvwaddch(treescrn6, 5, 11, ' '); - - /*strng3 */ - mvwaddch(treescrn6, 7, 13, ' '); - mvwaddch(treescrn6, 8, 9, ' '); - - /*strng4 */ - mvwaddch(treescrn6, 9, 14, ' '); - mvwaddch(treescrn6, 10, 10, ' '); - mvwaddch(treescrn6, 11, 6, ' '); - - /*strng5 */ - mvwaddch(treescrn6, 11, 16, ' '); - mvwaddch(treescrn6, 12, 12, ' '); - - /* treescrn7 */ - - overlay(treescrn, treescrn7); - - /*balls */ - mvwaddch(treescrn7, 3, 15, ' '); - mvwaddch(treescrn7, 6, 7, ' '); - mvwaddch(treescrn7, 7, 18, ' '); - mvwaddch(treescrn7, 10, 4, ' '); - mvwaddch(treescrn7, 11, 22, ' '); - - /*star */ - mvwaddch(treescrn7, 0, 12, '*'); - - /*strng1 */ - mvwaddch(treescrn7, 3, 12, ' '); - - /*strng2 */ - mvwaddch(treescrn7, 5, 13, ' '); - mvwaddch(treescrn7, 6, 9, ' '); - - /*strng3 */ - mvwaddch(treescrn7, 7, 15, ' '); - mvwaddch(treescrn7, 8, 11, ' '); - - /*strng4 */ - mvwaddch(treescrn7, 9, 16, ' '); - mvwaddch(treescrn7, 10, 12, ' '); - mvwaddch(treescrn7, 11, 8, ' '); - - /*strng5 */ - mvwaddch(treescrn7, 11, 18, ' '); - mvwaddch(treescrn7, 12, 14, ' '); - - look_out(150); - reindeer(); - - touchwin(w_holiday); - wrefresh(w_holiday); - wrefresh(w_del_msg); - - look_out(500); - for (loopy = 0; loopy < 100; loopy++) { - blinkit(); - } - -#ifdef NOLOOP - done(0); -#endif - } - /*NOTREACHED */ -} - -static int -boxit(void) -{ - int x = 0; - - while (x < 20) { - mvaddch(x, 7, '|'); - ++x; - } - - x = 8; - - while (x < 80) { - mvaddch(19, x, '_'); - ++x; - } - - x = 0; - - while (x < 80) { - mvaddch(22, x, '_'); - ++x; - } - - return (0); -} - -static int -seas(void) -{ - mvaddch(4, 1, 'S'); - mvaddch(6, 1, 'E'); - mvaddch(8, 1, 'A'); - mvaddch(10, 1, 'S'); - mvaddch(12, 1, 'O'); - mvaddch(14, 1, 'N'); - mvaddch(16, 1, '`'); - mvaddch(18, 1, 'S'); - - return (0); -} - -static int -greet(void) -{ - mvaddch(3, 5, 'G'); - mvaddch(5, 5, 'R'); - mvaddch(7, 5, 'E'); - mvaddch(9, 5, 'E'); - mvaddch(11, 5, 'T'); - mvaddch(13, 5, 'I'); - mvaddch(15, 5, 'N'); - mvaddch(17, 5, 'G'); - mvaddch(19, 5, 'S'); - - return (0); -} - -static int -fromwho(void) -{ - mvaddstr(21, 13, FROMWHO); - return (0); -} - -static int -tree(void) -{ - set_color(treescrn, COLOR_GREEN); - mvwaddch(treescrn, 1, 11, (chtype) '/'); - mvwaddch(treescrn, 2, 11, (chtype) '/'); - mvwaddch(treescrn, 3, 10, (chtype) '/'); - mvwaddch(treescrn, 4, 9, (chtype) '/'); - mvwaddch(treescrn, 5, 9, (chtype) '/'); - mvwaddch(treescrn, 6, 8, (chtype) '/'); - mvwaddch(treescrn, 7, 7, (chtype) '/'); - mvwaddch(treescrn, 8, 6, (chtype) '/'); - mvwaddch(treescrn, 9, 6, (chtype) '/'); - mvwaddch(treescrn, 10, 5, (chtype) '/'); - mvwaddch(treescrn, 11, 3, (chtype) '/'); - mvwaddch(treescrn, 12, 2, (chtype) '/'); - - mvwaddch(treescrn, 1, 13, (chtype) '\\'); - mvwaddch(treescrn, 2, 13, (chtype) '\\'); - mvwaddch(treescrn, 3, 14, (chtype) '\\'); - mvwaddch(treescrn, 4, 15, (chtype) '\\'); - mvwaddch(treescrn, 5, 15, (chtype) '\\'); - mvwaddch(treescrn, 6, 16, (chtype) '\\'); - mvwaddch(treescrn, 7, 17, (chtype) '\\'); - mvwaddch(treescrn, 8, 18, (chtype) '\\'); - mvwaddch(treescrn, 9, 18, (chtype) '\\'); - mvwaddch(treescrn, 10, 19, (chtype) '\\'); - mvwaddch(treescrn, 11, 21, (chtype) '\\'); - mvwaddch(treescrn, 12, 22, (chtype) '\\'); - - mvwaddch(treescrn, 4, 10, (chtype) '_'); - mvwaddch(treescrn, 4, 14, (chtype) '_'); - mvwaddch(treescrn, 8, 7, (chtype) '_'); - mvwaddch(treescrn, 8, 17, (chtype) '_'); - - mvwaddstr(treescrn, 13, 0, "//////////// \\\\\\\\\\\\\\\\\\\\\\\\"); - - mvwaddstr(treescrn, 14, 11, "| |"); - mvwaddstr(treescrn, 15, 11, "|_|"); - - unset_color(treescrn); - wrefresh(treescrn); - wrefresh(w_del_msg); - - return (0); -} - -static int -balls(void) -{ - overlay(treescrn, treescrn2); - - set_color(treescrn2, COLOR_BLUE); - mvwaddch(treescrn2, 3, 9, (chtype) '@'); - mvwaddch(treescrn2, 3, 15, (chtype) '@'); - mvwaddch(treescrn2, 4, 8, (chtype) '@'); - mvwaddch(treescrn2, 4, 16, (chtype) '@'); - mvwaddch(treescrn2, 5, 7, (chtype) '@'); - mvwaddch(treescrn2, 5, 17, (chtype) '@'); - mvwaddch(treescrn2, 7, 6, (chtype) '@'); - mvwaddch(treescrn2, 7, 18, (chtype) '@'); - mvwaddch(treescrn2, 8, 5, (chtype) '@'); - mvwaddch(treescrn2, 8, 19, (chtype) '@'); - mvwaddch(treescrn2, 10, 4, (chtype) '@'); - mvwaddch(treescrn2, 10, 20, (chtype) '@'); - mvwaddch(treescrn2, 11, 2, (chtype) '@'); - mvwaddch(treescrn2, 11, 22, (chtype) '@'); - mvwaddch(treescrn2, 12, 1, (chtype) '@'); - mvwaddch(treescrn2, 12, 23, (chtype) '@'); - - unset_color(treescrn2); - wrefresh(treescrn2); - wrefresh(w_del_msg); - return (0); -} - -static int -star(void) -{ - wattrset(treescrn2, A_BOLD | A_BLINK); - set_color(treescrn2, COLOR_YELLOW); - - mvwaddch(treescrn2, 0, 12, (chtype) '*'); - wstandend(treescrn2); - - unset_color(treescrn2); - wrefresh(treescrn2); - wrefresh(w_del_msg); - return (0); -} - -static int -strng1(void) -{ - wattrset(treescrn2, A_BOLD | A_BLINK); - set_color(treescrn2, COLOR_WHITE); - - mvwaddch(treescrn2, 3, 13, (chtype) '\''); - mvwaddch(treescrn2, 3, 12, (chtype) ':'); - mvwaddch(treescrn2, 3, 11, (chtype) '.'); - - wattroff(treescrn2, A_BOLD | A_BLINK); - unset_color(treescrn2); - - wrefresh(treescrn2); - wrefresh(w_del_msg); - return (0); -} - -static int -strng2(void) -{ - wattrset(treescrn2, A_BOLD | A_BLINK); - set_color(treescrn2, COLOR_WHITE); - - mvwaddch(treescrn2, 5, 14, (chtype) '\''); - mvwaddch(treescrn2, 5, 13, (chtype) ':'); - mvwaddch(treescrn2, 5, 12, (chtype) '.'); - mvwaddch(treescrn2, 5, 11, (chtype) ','); - mvwaddch(treescrn2, 6, 10, (chtype) '\''); - mvwaddch(treescrn2, 6, 9, (chtype) ':'); - - wattroff(treescrn2, A_BOLD | A_BLINK); - unset_color(treescrn2); - - wrefresh(treescrn2); - wrefresh(w_del_msg); - return (0); -} - -static int -strng3(void) -{ - wattrset(treescrn2, A_BOLD | A_BLINK); - set_color(treescrn2, COLOR_WHITE); - - mvwaddch(treescrn2, 7, 16, (chtype) '\''); - mvwaddch(treescrn2, 7, 15, (chtype) ':'); - mvwaddch(treescrn2, 7, 14, (chtype) '.'); - mvwaddch(treescrn2, 7, 13, (chtype) ','); - mvwaddch(treescrn2, 8, 12, (chtype) '\''); - mvwaddch(treescrn2, 8, 11, (chtype) ':'); - mvwaddch(treescrn2, 8, 10, (chtype) '.'); - mvwaddch(treescrn2, 8, 9, (chtype) ','); - - wattroff(treescrn2, A_BOLD | A_BLINK); - unset_color(treescrn2); - - wrefresh(treescrn2); - wrefresh(w_del_msg); - return (0); -} - -static int -strng4(void) -{ - wattrset(treescrn2, A_BOLD | A_BLINK); - set_color(treescrn2, COLOR_WHITE); - - mvwaddch(treescrn2, 9, 17, (chtype) '\''); - mvwaddch(treescrn2, 9, 16, (chtype) ':'); - mvwaddch(treescrn2, 9, 15, (chtype) '.'); - mvwaddch(treescrn2, 9, 14, (chtype) ','); - mvwaddch(treescrn2, 10, 13, (chtype) '\''); - mvwaddch(treescrn2, 10, 12, (chtype) ':'); - mvwaddch(treescrn2, 10, 11, (chtype) '.'); - mvwaddch(treescrn2, 10, 10, (chtype) ','); - mvwaddch(treescrn2, 11, 9, (chtype) '\''); - mvwaddch(treescrn2, 11, 8, (chtype) ':'); - mvwaddch(treescrn2, 11, 7, (chtype) '.'); - mvwaddch(treescrn2, 11, 6, (chtype) ','); - mvwaddch(treescrn2, 12, 5, (chtype) '\''); - - wattroff(treescrn2, A_BOLD | A_BLINK); - unset_color(treescrn2); - - wrefresh(treescrn2); - wrefresh(w_del_msg); - return (0); -} - -static int -strng5(void) -{ - wattrset(treescrn2, A_BOLD | A_BLINK); - set_color(treescrn2, COLOR_WHITE); - - mvwaddch(treescrn2, 11, 19, (chtype) '\''); - mvwaddch(treescrn2, 11, 18, (chtype) ':'); - mvwaddch(treescrn2, 11, 17, (chtype) '.'); - mvwaddch(treescrn2, 11, 16, (chtype) ','); - mvwaddch(treescrn2, 12, 15, (chtype) '\''); - mvwaddch(treescrn2, 12, 14, (chtype) ':'); - mvwaddch(treescrn2, 12, 13, (chtype) '.'); - mvwaddch(treescrn2, 12, 12, (chtype) ','); - - wattroff(treescrn2, A_BOLD | A_BLINK); - unset_color(treescrn2); - - /* save a fully lit tree */ - overlay(treescrn2, treescrn); - - wrefresh(treescrn2); - wrefresh(w_del_msg); - return (0); -} - -static int -blinkit(void) -{ - static int cycle; - - if (cycle > 4) { - cycle = 0; - } - - touchwin(treescrn8); - - switch (cycle) { - case 0: - overlay(treescrn3, treescrn8); - wrefresh(treescrn8); - wrefresh(w_del_msg); - break; - case 1: - overlay(treescrn4, treescrn8); - wrefresh(treescrn8); - wrefresh(w_del_msg); - break; - case 2: - overlay(treescrn5, treescrn8); - wrefresh(treescrn8); - wrefresh(w_del_msg); - break; - case 3: - overlay(treescrn6, treescrn8); - wrefresh(treescrn8); - wrefresh(w_del_msg); - break; - case 4: - overlay(treescrn7, treescrn8); - wrefresh(treescrn8); - wrefresh(w_del_msg); - break; - } - touchwin(treescrn8); - - /*ALL ON************************************************** */ - - overlay(treescrn, treescrn8); - wrefresh(treescrn8); - wrefresh(w_del_msg); - - ++cycle; - return (0); -} - -static void -deer_step(WINDOW *win, int y, int x) -{ - mvwin(win, y, x); - wrefresh(win); - wrefresh(w_del_msg); - look_out(5); -} - -static int -reindeer(void) -{ - int looper; - y_pos = 0; - - for (x_pos = 70; x_pos > 62; x_pos--) { - if (x_pos < 62) { - y_pos = 1; - } - for (looper = 0; looper < 4; looper++) { - mvwaddch(dotdeer0, y_pos, x_pos, (chtype) '.'); - wrefresh(dotdeer0); - wrefresh(w_del_msg); - werase(dotdeer0); - wrefresh(dotdeer0); - wrefresh(w_del_msg); - look_out(50); - } - } - - y_pos = 2; - - for (; x_pos > 50; x_pos--) { - for (looper = 0; looper < 4; looper++) { - - if (x_pos < 56) { - y_pos = 3; - - mvwaddch(stardeer0, y_pos, x_pos, (chtype) '*'); - wrefresh(stardeer0); - wrefresh(w_del_msg); - werase(stardeer0); - wrefresh(stardeer0); - wrefresh(w_del_msg); - } else { - mvwaddch(dotdeer0, y_pos, x_pos, (chtype) '*'); - wrefresh(dotdeer0); - wrefresh(w_del_msg); - werase(dotdeer0); - wrefresh(dotdeer0); - wrefresh(w_del_msg); - } - } - } - - x_pos = 58; - - for (y_pos = 2; y_pos < 5; y_pos++) { - - touchwin(lildeer0); - wrefresh(lildeer0); - wrefresh(w_del_msg); - - for (looper = 0; looper < 4; looper++) { - deer_step(lildeer3, y_pos, x_pos); - deer_step(lildeer2, y_pos, x_pos); - deer_step(lildeer1, y_pos, x_pos); - deer_step(lildeer2, y_pos, x_pos); - deer_step(lildeer3, y_pos, x_pos); - - touchwin(lildeer0); - wrefresh(lildeer0); - wrefresh(w_del_msg); - - x_pos -= 2; - } - } - - x_pos = 35; - - for (y_pos = 5; y_pos < 10; y_pos++) { - - touchwin(middeer0); - wrefresh(middeer0); - wrefresh(w_del_msg); - - for (looper = 0; looper < 2; looper++) { - deer_step(middeer3, y_pos, x_pos); - deer_step(middeer2, y_pos, x_pos); - deer_step(middeer1, y_pos, x_pos); - deer_step(middeer2, y_pos, x_pos); - deer_step(middeer3, y_pos, x_pos); - - touchwin(middeer0); - wrefresh(middeer0); - wrefresh(w_del_msg); - - x_pos -= 3; - } - } - - look_out(300); - - y_pos = 1; - - for (x_pos = 8; x_pos < 16; x_pos++) { - deer_step(bigdeer4, y_pos, x_pos); - deer_step(bigdeer3, y_pos, x_pos); - deer_step(bigdeer2, y_pos, x_pos); - deer_step(bigdeer1, y_pos, x_pos); - deer_step(bigdeer2, y_pos, x_pos); - deer_step(bigdeer3, y_pos, x_pos); - deer_step(bigdeer4, y_pos, x_pos); - deer_step(bigdeer0, y_pos, x_pos); - } - - --x_pos; - - for (looper = 0; looper < 6; looper++) { - deer_step(lookdeer4, y_pos, x_pos); - deer_step(lookdeer3, y_pos, x_pos); - deer_step(lookdeer2, y_pos, x_pos); - deer_step(lookdeer1, y_pos, x_pos); - deer_step(lookdeer2, y_pos, x_pos); - deer_step(lookdeer3, y_pos, x_pos); - deer_step(lookdeer4, y_pos, x_pos); - } - - deer_step(lookdeer0, y_pos, x_pos); - - for (; y_pos < 10; y_pos++) { - for (looper = 0; looper < 2; looper++) { - deer_step(bigdeer4, y_pos, x_pos); - deer_step(bigdeer3, y_pos, x_pos); - deer_step(bigdeer2, y_pos, x_pos); - deer_step(bigdeer1, y_pos, x_pos); - deer_step(bigdeer2, y_pos, x_pos); - deer_step(bigdeer3, y_pos, x_pos); - deer_step(bigdeer4, y_pos, x_pos); - } - deer_step(bigdeer0, y_pos, x_pos); - } - - --y_pos; - - deer_step(lookdeer3, y_pos, x_pos); - return (0); -} - -static RETSIGTYPE -done(int sig GCC_UNUSED) -{ - signal(SIGINT, done); - signal(SIGTERM, done); -#if !defined DOS && !defined OS2 - signal(SIGHUP, done); - signal(SIGQUIT, done); -#endif - move(LINES - 1, 0); - refresh(); - endwin(); - curs_set(1); - ExitProgram(EXIT_SUCCESS); -}