Use src/contrib/ncurses, v5.0.990821 prerelease.
This isn't quite finished yet, there are still some unresolved problems with ospeed and the sgtty.h (non-posix) terminal interface. Mostly this only causes problems with src/games. The other tools and libraries (libform,libpanel,libmenu) will come shortly but are seperate. Beware, there be dragons here! (The build will be broken for a short while)
This commit is contained in:
parent
02e1576966
commit
99af2e21c7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=50624
@ -1,19 +0,0 @@
|
||||
/***************************************************************************
|
||||
* COPYRIGHT NOTICE *
|
||||
****************************************************************************
|
||||
* ncurses is copyright (C) 1992, 1993, 1994 *
|
||||
* by Zeyd M. Ben-Halim *
|
||||
* zmbenhal@netcom.com *
|
||||
* *
|
||||
* Permission is hereby granted to reproduce and distribute ncurses *
|
||||
* by any means and for any fee, whether alone or as part of a *
|
||||
* larger distribution, in source or in binary form, PROVIDED *
|
||||
* this notice is included with any such distribution, not removed *
|
||||
* from header files, and is reproduced in any documentation *
|
||||
* accompanying it or the applications linked with it. *
|
||||
* *
|
||||
* ncurses comes AS IS with no warranty, implied or expressed. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
|
||||
Pavel Curtis has given up his copyright to the public domain. This mean
|
||||
his ORIGINAL sources are in the public domain, not this current release.
|
||||
This current release IS copyrighted, see COPYRIGHT.NEW.
|
||||
|
@ -1,30 +0,0 @@
|
||||
|
||||
BEGIN {
|
||||
print ""
|
||||
print "#include <stdlib.h>"
|
||||
print "#include \"curses.h\""
|
||||
print ""
|
||||
print "struct kn {"
|
||||
print "\tchar *name;"
|
||||
print "\tint code;"
|
||||
print "};"
|
||||
print ""
|
||||
print "struct kn key_names[] = {"
|
||||
}
|
||||
|
||||
{printf "\t{\"%s\", %s,},\n", $1, $2;}
|
||||
|
||||
END {
|
||||
print "};"
|
||||
print ""
|
||||
print "char *keyname(int c)"
|
||||
print "{"
|
||||
print "int i, size = sizeof(key_names)/sizeof(struct kn);"
|
||||
print ""
|
||||
print "\tfor (i = 0; i < size; i++) {"
|
||||
print "\t\tif (key_names[i].code == c) return key_names[i].name;"
|
||||
print "\t}"
|
||||
print "\treturn NULL;"
|
||||
print "}"
|
||||
print ""
|
||||
}
|
@ -1 +0,0 @@
|
||||
{printf "\tadd_to_try(%s, %s);\n", $1, $2;}
|
@ -1,205 +1,516 @@
|
||||
# Makefile for ncurses
|
||||
# $FreeBSD$
|
||||
|
||||
LIB= ncurses
|
||||
SHLIB_MAJOR= 3
|
||||
SHLIB_MINOR= 1
|
||||
SRCS= lib_kernel.c lib_pad.c lib_bkgd.c \
|
||||
lib_unctrl.c lib_raw.c lib_vidattr.c lib_trace.c lib_beep.c \
|
||||
lib_doupdate.c lib_refresh.c lib_initscr.c lib_newwin.c lib_addch.c \
|
||||
lib_addstr.c lib_scroll.c lib_clreol.c lib_touch.c lib_mvcur.c \
|
||||
lib_keyname.c keys.tries.h \
|
||||
lib_delwin.c lib_endwin.c lib_clrbot.c lib_move.c lib_printw.c \
|
||||
lib_scanw.c lib_erase.c lib_getch.c lib_options.c lib_acs.c lib_slk.c\
|
||||
lib_box.c lib_clear.c lib_delch.c lib_insch.c lib_instr.c \
|
||||
lib_getstr.c lib_mvwin.c lib_longname.c lib_tstp.c \
|
||||
lib_newterm.c lib_set_term.c lib_overlay.c lib_scrreg.c lib_color.c \
|
||||
lib_insstr.c lib_insdel.c lib_twait.c lib_window.c copyright.c
|
||||
NCURSES=${.CURDIR}/../../contrib/ncurses
|
||||
|
||||
CFLAGS+= -I. -I${.CURDIR} -Wall -DMYTINFO #-DTRACE
|
||||
DPADD= ${LIBMYTINFO}
|
||||
LDADD= -lmytinfo
|
||||
LIB= ncurses
|
||||
SHLIB_MAJOR=5
|
||||
SHLIB_MINOR=0
|
||||
|
||||
CLEANFILES+= lib_keyname.c keys.tries.h
|
||||
# Should be elsewhere
|
||||
AWK?= awk
|
||||
TERMINFODIR?= ${DESTDIR}/usr/share/misc
|
||||
|
||||
beforeinstall:
|
||||
${INSTALL} -C -m 444 -o $(BINOWN) -g $(BINGRP) ${.CURDIR}/unctrl.h \
|
||||
${DESTDIR}/usr/include
|
||||
${INSTALL} -C -m 444 -o $(BINOWN) -g $(BINGRP) ${.CURDIR}/curses.h \
|
||||
${DESTDIR}/usr/include/ncurses.h
|
||||
NCURSES_MAJOR!=egrep 'NCURSES_MAJOR[ ]*=' ${NCURSES}/dist.mk | sed -e 's/^[^0-9]*//'
|
||||
NCURSES_MINOR!=egrep 'NCURSES_MINOR[ ]*=' ${NCURSES}/dist.mk | sed -e 's/^[^0-9]*//'
|
||||
NCURSES_PATCH!=egrep 'NCURSES_PATCH[ ]*=' ${NCURSES}/dist.mk | sed -e 's/^[^0-9]*//'
|
||||
|
||||
keys.tries.h: ${.CURDIR}/keys.list ${.CURDIR}/MKkeys.awk
|
||||
awk -f ${.CURDIR}/MKkeys.awk ${.CURDIR}/keys.list > keys.tries.h
|
||||
# From autoconf (!)
|
||||
NCURSES_CONST=
|
||||
NCURSES_XNAMES= 0
|
||||
OSPEED_INCLUDES=\#include <termios.h>
|
||||
OSPEED_TYPE= speed_t
|
||||
BUILTIN_BOOL= 1
|
||||
BOOL_TYPE= 0
|
||||
TYPE_OF_BOOL= char
|
||||
TYPEOF_CHTYPE= long
|
||||
WIDEC_SHIFT= 8
|
||||
SHIFT_LIMIT= 32
|
||||
ONEUL= 1UL
|
||||
|
||||
lib_keyname.c: ${.CURDIR}/keys.list ${.CURDIR}/MKkeyname.awk
|
||||
awk -f ${.CURDIR}/MKkeyname.awk ${.CURDIR}/keys.list > lib_keyname.c
|
||||
.PATH: ${NCURSES}/ncurses
|
||||
.PATH: ${NCURSES}/ncurses/base
|
||||
.PATH: ${NCURSES}/ncurses/tinfo
|
||||
.PATH: ${NCURSES}/ncurses/tty
|
||||
.PATH: ${NCURSES}/ncurses/trace
|
||||
.PATH: ${NCURSES}/include
|
||||
.PATH: ${NCURSES}/man
|
||||
|
||||
MAN3 = curs_addch.3 \
|
||||
curs_addchst.3 \
|
||||
curs_addstr.3 \
|
||||
curs_attr.3 \
|
||||
curs_beep.3 \
|
||||
curs_bkgd.3 \
|
||||
curs_border.3 \
|
||||
curs_clear.3 \
|
||||
curs_color.3 \
|
||||
curs_delch.3 \
|
||||
curs_delln.3 \
|
||||
curs_getch.3 \
|
||||
curs_getstr.3 \
|
||||
curs_getyx.3 \
|
||||
curs_inch.3 \
|
||||
curs_inchstr.3 \
|
||||
curs_initscr.3 \
|
||||
curs_inopts.3 \
|
||||
curs_insch.3 \
|
||||
curs_insstr.3 \
|
||||
curs_instr.3 \
|
||||
curs_kernel.3 \
|
||||
curs_move.3 \
|
||||
curs_outopts.3 \
|
||||
curs_overlay.3 \
|
||||
curs_pad.3 \
|
||||
curs_printw.3 \
|
||||
curs_refresh.3 \
|
||||
curs_scanw.3 \
|
||||
curs_scr_dmp.3 \
|
||||
curs_scroll.3 \
|
||||
curs_slk.3 \
|
||||
curs_termatt.3 \
|
||||
curs_termin.3 \
|
||||
curs_touch.3 \
|
||||
curs_util.3 \
|
||||
curs_window.3 \
|
||||
ncurses.3
|
||||
INCS= -I. -I${.CURDIR} -I${NCURSES}/ncurses -I${NCURSES}/include
|
||||
CFLAGS+=${INCS} -Wall -DFREEBSD_NATIVE -DNDEBUG -DHAVE_CONFIG_H
|
||||
|
||||
MAN5 = term.5
|
||||
GENSRC= \
|
||||
codes.c \
|
||||
expanded.c \
|
||||
fallback.c \
|
||||
lib_gen.c \
|
||||
lib_keyname.c \
|
||||
names.c \
|
||||
unctrl.c
|
||||
|
||||
MLINKS+=curs_addch.3 addch.3 curs_addch.3 waddch.3 curs_addch.3 echochar.3 \
|
||||
curs_addch.3 wechochar.3 curs_addch.3 mvaddch.3 \
|
||||
curs_addch.3 mvwaddch.3
|
||||
MLINKS+=curs_addchst.3 addchstr.3 curs_addchst.3 addchnstr.3 \
|
||||
curs_addchst.3 waddchstr.3 curs_addchst.3 waddchnstr.3 \
|
||||
curs_addchst.3 mvaddchstr.3 curs_addchst.3 mvaddchnstr.3 \
|
||||
curs_addchst.3 mvwaddchstr.3 curs_addchst.3 mvwaddchnstr.3
|
||||
MLINKS+=curs_addstr.3 addstr.3 curs_addstr.3 addnstr.3 \
|
||||
curs_addstr.3 waddstr.3 curs_addstr.3 waddnstr.3 \
|
||||
curs_addstr.3 mvaddstr.3 curs_addstr.3 mvaddnstr.3 \
|
||||
curs_addstr.3 mvwaddstr.3 curs_addstr.3 mvwaddnstr.3
|
||||
MLINKS+=curs_attr.3 attroff.3 curs_attr.3 wattroff.3 \
|
||||
curs_attr.3 attron.3 curs_attr.3 wattron.3 \
|
||||
curs_attr.3 attrset.3 curs_attr.3 wattrset.3 \
|
||||
curs_attr.3 standend.3 curs_attr.3 wstandend.3 \
|
||||
curs_attr.3 standout.3 curs_attr.3 wstandout.3
|
||||
GENHDR= \
|
||||
curses.h \
|
||||
hashsize.h \
|
||||
init_keytry.h \
|
||||
nomacros.h \
|
||||
parametrized.h \
|
||||
term.h \
|
||||
termcap.h \
|
||||
unctrl.h
|
||||
|
||||
# Installed
|
||||
HEADERS=curses.h term.h termcap.h unctrl.h
|
||||
|
||||
# Components of names.c and codes.c
|
||||
NAMESRC=boolnames boolfnames numnames numfnames strnames strfnames
|
||||
CODESRC=boolcodes numcodes strcodes
|
||||
|
||||
SRCS= ${GENHDR} ${GENSRC} \
|
||||
access.c \
|
||||
add_tries.c \
|
||||
alloc_entry.c \
|
||||
alloc_ttype.c \
|
||||
captoinfo.c \
|
||||
comp_captab.c \
|
||||
comp_error.c \
|
||||
comp_expand.c \
|
||||
comp_hash.c \
|
||||
comp_parse.c \
|
||||
comp_scan.c \
|
||||
define_key.c \
|
||||
doalloc.c \
|
||||
free_ttype.c \
|
||||
getenv_num.c \
|
||||
hardscroll.c \
|
||||
hashmap.c \
|
||||
home_terminfo.c \
|
||||
init_keytry.c \
|
||||
keybound.c \
|
||||
keyok.c \
|
||||
lib_acs.c \
|
||||
lib_addch.c \
|
||||
lib_addstr.c \
|
||||
lib_baudrate.c \
|
||||
lib_beep.c \
|
||||
lib_bkgd.c \
|
||||
lib_box.c \
|
||||
lib_chgat.c \
|
||||
lib_clear.c \
|
||||
lib_clearok.c \
|
||||
lib_clrbot.c \
|
||||
lib_clreol.c \
|
||||
lib_color.c \
|
||||
lib_colorset.c \
|
||||
lib_cur_term.c \
|
||||
lib_data.c \
|
||||
lib_delch.c \
|
||||
lib_delwin.c \
|
||||
lib_dft_fgbg.c \
|
||||
lib_echo.c \
|
||||
lib_endwin.c \
|
||||
lib_erase.c \
|
||||
lib_flash.c \
|
||||
lib_freeall.c \
|
||||
lib_getch.c \
|
||||
lib_getstr.c \
|
||||
lib_has_cap.c \
|
||||
lib_hline.c \
|
||||
lib_immedok.c \
|
||||
lib_inchstr.c \
|
||||
lib_initscr.c \
|
||||
lib_insch.c \
|
||||
lib_insdel.c \
|
||||
lib_insstr.c \
|
||||
lib_instr.c \
|
||||
lib_isendwin.c \
|
||||
lib_kernel.c \
|
||||
lib_leaveok.c \
|
||||
lib_longname.c \
|
||||
lib_mouse.c \
|
||||
lib_move.c \
|
||||
lib_mvcur.c \
|
||||
lib_mvwin.c \
|
||||
lib_napms.c \
|
||||
lib_newterm.c \
|
||||
lib_newwin.c \
|
||||
lib_nl.c \
|
||||
lib_options.c \
|
||||
lib_overlay.c \
|
||||
lib_pad.c \
|
||||
lib_print.c \
|
||||
lib_printw.c \
|
||||
lib_raw.c \
|
||||
lib_redrawln.c \
|
||||
lib_refresh.c \
|
||||
lib_restart.c \
|
||||
lib_scanw.c \
|
||||
lib_screen.c \
|
||||
lib_scroll.c \
|
||||
lib_scrollok.c \
|
||||
lib_scrreg.c \
|
||||
lib_set_term.c \
|
||||
lib_setup.c \
|
||||
lib_slk.c \
|
||||
lib_slkatr_set.c \
|
||||
lib_slkatrof.c \
|
||||
lib_slkatron.c \
|
||||
lib_slkatrset.c \
|
||||
lib_slkattr.c \
|
||||
lib_slkclear.c \
|
||||
lib_slkcolor.c \
|
||||
lib_slkinit.c \
|
||||
lib_slklab.c \
|
||||
lib_slkrefr.c \
|
||||
lib_slkset.c \
|
||||
lib_slktouch.c \
|
||||
lib_termcap.c \
|
||||
lib_termname.c \
|
||||
lib_ti.c \
|
||||
lib_touch.c \
|
||||
lib_tparm.c \
|
||||
lib_tputs.c \
|
||||
lib_trace.c \
|
||||
lib_traceatr.c \
|
||||
lib_tracebits.c \
|
||||
lib_tracechr.c \
|
||||
lib_tracedmp.c \
|
||||
lib_tracemse.c \
|
||||
lib_tstp.c \
|
||||
lib_ttyflags.c \
|
||||
lib_twait.c \
|
||||
lib_ungetch.c \
|
||||
lib_vidattr.c \
|
||||
lib_vline.c \
|
||||
lib_wattroff.c \
|
||||
lib_wattron.c \
|
||||
lib_winch.c \
|
||||
lib_window.c \
|
||||
memmove.c \
|
||||
name_match.c \
|
||||
nc_panel.c \
|
||||
parse_entry.c \
|
||||
read_entry.c \
|
||||
resizeterm.c \
|
||||
safe_sprintf.c \
|
||||
setbuf.c \
|
||||
sigaction.c \
|
||||
trace_buf.c \
|
||||
trace_tries.c \
|
||||
trace_xnames.c \
|
||||
tries.c \
|
||||
tty_update.c \
|
||||
vsscanf.c \
|
||||
wresize.c \
|
||||
write_entry.c \
|
||||
|
||||
# From our old libtermcap.
|
||||
# Used instead of the hideous read_termcap.c abomination.
|
||||
SRCS+= termcap.c
|
||||
|
||||
CLEANFILES+= ${GENSRC} ${GENHDR} keys.tries make_hash term.h.new \
|
||||
make_keys MKterm.h.awk comp_captab.c \
|
||||
namehdr nameftr codeftr ${NAMESRC} ${CODESRC}
|
||||
|
||||
SYMLINKS+=${LIBDIR}/libncurses.a ${LIBDIR}/libcurses.a
|
||||
SYMLINKS+=${LIBDIR}/libncurses.a ${LIBDIR}/libtermcap.a
|
||||
SYMLINKS+=${LIBDIR}/libncurses.a ${LIBDIR}/libtermlib.a
|
||||
SYMLINKS+=${LIBDIR}/libncurses.a ${LIBDIR}/libmytinfo.a
|
||||
SYMLINKS+=${LIBDIR}/libncurses.a ${LIBDIR}/libtinfo.a
|
||||
.if !defined(NOPIC)
|
||||
.if ${OBJFORMAT} == aout
|
||||
SYMLINKS+=${SHLIBDIR}/libncurses.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
|
||||
${SHLIBDIR}/libcurses.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
|
||||
SYMLINKS+=${SHLIBDIR}/libncurses.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
|
||||
${SHLIBDIR}/libtermcap.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
|
||||
SYMLINKS+=${SHLIBDIR}/libncurses.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
|
||||
${SHLIBDIR}/libtermlib.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
|
||||
SYMLINKS+=${SHLIBDIR}/libncurses.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
|
||||
${SHLIBDIR}/libmytinfo.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
|
||||
SYMLINKS+=${SHLIBDIR}/libncurses.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
|
||||
${SHLIBDIR}/libtinfo.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
|
||||
.else
|
||||
# no need for major at all, it's an ld-time redirection only
|
||||
SYMLINKS+=${SHLIBDIR}/libncurses.so ${SHLIBDIR}/libcurses.so
|
||||
SYMLINKS+=${SHLIBDIR}/libncurses.so ${SHLIBDIR}/libtermcap.so
|
||||
SYMLINKS+=${SHLIBDIR}/libncurses.so ${SHLIBDIR}/libtermlib.so
|
||||
SYMLINKS+=${SHLIBDIR}/libncurses.so ${SHLIBDIR}/libmytinfo.so
|
||||
SYMLINKS+=${SHLIBDIR}/libncurses.so ${SHLIBDIR}/libtinfo.so
|
||||
.endif
|
||||
.endif
|
||||
.if !defined(NOPROFILE)
|
||||
SYMLINKS+=${LIBDIR}/libncurses_p.a ${LIBDIR}/libcurses_p.a
|
||||
SYMLINKS+=${LIBDIR}/libncurses_p.a ${LIBDIR}/libtermcap_p.a
|
||||
SYMLINKS+=${LIBDIR}/libncurses_p.a ${LIBDIR}/libtermlib_p.a
|
||||
SYMLINKS+=${LIBDIR}/libncurses_p.a ${LIBDIR}/libmytinfo_p.a
|
||||
SYMLINKS+=${LIBDIR}/libncurses_p.a ${LIBDIR}/libtinfo_p.a
|
||||
.endif
|
||||
|
||||
beforeinstall: ${HEADERS}
|
||||
${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${HEADERS} \
|
||||
${DESTDIR}/usr/include
|
||||
rm -f ${DESTDIR}/usr/include/ncurses.h
|
||||
ln -s curses.h ${DESTDIR}/usr/include/ncurses.h
|
||||
|
||||
# Generated source
|
||||
namehdr nameftr codeftr ${NAMESRC} ${CODESRC}: MKnames.awk Caps
|
||||
${AWK} -f ${NCURSES}/ncurses/tinfo/MKnames.awk ${NCURSES}/include/Caps
|
||||
|
||||
names.c: namehdr ${NAMESRC} nameftr
|
||||
cat namehdr ${NAMESRC} nameftr > $@
|
||||
|
||||
codes.c: namehdr ${CODESRC} codeftr
|
||||
cat namehdr ${CODESRC} codeftr > $@
|
||||
|
||||
lib_gen.c: MKlib_gen.sh curses.h
|
||||
sh ${NCURSES}/ncurses/base/MKlib_gen.sh "${CC} -E ${INCS}" \
|
||||
"${AWK}" < curses.h >$@
|
||||
|
||||
lib_keyname.c: keys.list MKkeyname.awk
|
||||
${AWK} -f ${NCURSES}/ncurses/base/MKkeyname.awk \
|
||||
${NCURSES}/ncurses/tinfo/keys.list > lib_keyname.c
|
||||
|
||||
unctrl.c: MKunctrl.awk
|
||||
echo | ${AWK} -f ${NCURSES}/ncurses/base/MKunctrl.awk > unctrl.c
|
||||
|
||||
comp_captab.c: MKcaptab.awk Caps make_hash
|
||||
sh ${NCURSES}/ncurses/tinfo/MKcaptab.awk "${AWK}" \
|
||||
${NCURSES}/include/Caps > comp_captab.c
|
||||
|
||||
expanded.c: MKexpanded.sh
|
||||
sh ${NCURSES}/ncurses/tty/MKexpanded.sh "${CC} -E" ${CFLAGS} >expanded.c
|
||||
|
||||
fallback.c: MKfallback.sh
|
||||
sh ${NCURSES}/ncurses/tinfo/MKfallback.sh > fallback.c
|
||||
|
||||
# Generated headers
|
||||
nomacros.h: MKlib_gen.sh curses.h
|
||||
sh ${NCURSES}/ncurses/base/MKlib_gen.sh "${CC} -E ${INCS}" \
|
||||
"${AWK}" < curses.h | fgrep undef > $@
|
||||
|
||||
init_keytry.h: keys.list make_keys
|
||||
./make_keys ${NCURSES}/ncurses/tinfo/keys.list > init_keytry.h
|
||||
|
||||
hashsize.h: MKhashsize.sh Caps
|
||||
sh ${NCURSES}/include/MKhashsize.sh ${NCURSES}/include/Caps > $@
|
||||
|
||||
parametrized.h: MKparametrized.sh Caps
|
||||
AWK=${AWK} sh ${NCURSES}/include/MKparametrized.sh \
|
||||
${NCURSES}/include/Caps > $@
|
||||
|
||||
term.h: MKterm.h.awk edit_cfg.sh Caps
|
||||
${AWK} -f MKterm.h.awk ${NCURSES}/include/Caps > $@.new
|
||||
sh ${NCURSES}/include/edit_cfg.sh ${.CURDIR}/ncurses_cfg.h $@.new
|
||||
mv -f $@.new $@
|
||||
|
||||
# Build tools
|
||||
make_keys: make_keys.c names.c
|
||||
${CC} -o $@ ${CFLAGS} ${NCURSES}/ncurses/tinfo/make_keys.c
|
||||
|
||||
make_hash: comp_hash.c
|
||||
${CC} -o $@ ${CFLAGS} -DMAIN_PROGRAM \
|
||||
${NCURSES}/ncurses/tinfo/comp_hash.c
|
||||
|
||||
# ./configure generated
|
||||
MKterm.h.awk: MKterm.h.awk.in
|
||||
sed <${NCURSES}/include/$@.in >$@ \
|
||||
-e "/@NCURSES_MAJOR@/s//${NCURSES_MAJOR}/" \
|
||||
-e "/@NCURSES_MINOR@/s//${NCURSES_MINOR}/" \
|
||||
-e "/@NCURSES_CONST@/s//${NCURSES_CONST}/" \
|
||||
-e "/@NCURSES_XNAMES@/s//${NCURSES_XNAMES}/"
|
||||
|
||||
termcap.h: termcap.h.in
|
||||
sed <${NCURSES}/include/$@.in >$@ \
|
||||
-e "/@NCURSES_MAJOR@/s//${NCURSES_MAJOR}/" \
|
||||
-e "/@NCURSES_MINOR@/s//${NCURSES_MINOR}/" \
|
||||
-e "/@NCURSES_CONST@/s//${NCURSES_CONST}/" \
|
||||
-e "/@OSPEED_INCLUDES@/s//${OSPEED_INCLUDES}/" \
|
||||
-e "/@OSPEED_TYPE@/s//${OSPEED_TYPE}/"
|
||||
|
||||
curses.h: curses.h.in
|
||||
sed <${NCURSES}/include/$@.in >$@ \
|
||||
-e "/@NCURSES_MAJOR@/s//${NCURSES_MAJOR}/" \
|
||||
-e "/@NCURSES_MINOR@/s//${NCURSES_MINOR}/" \
|
||||
-e "/@NCURSES_PATCH@/s//${NCURSES_PATCH}/" \
|
||||
-e "/@NCURSES_CONST@/s//${NCURSES_CONST}/" \
|
||||
-e "s/@cf_cv_builtin_bool@/${BUILTIN_BOOL}/g" \
|
||||
-e "s/@cf_cv_cc_bool_type@/${BOOL_TYPE}/g" \
|
||||
-e "s/@cf_cv_type_of_bool@/${TYPE_OF_BOOL}/g" \
|
||||
-e "s/@cf_cv_typeof_chtype@/${TYPEOF_CHTYPE}/g" \
|
||||
-e "s/@cf_cv_widec_shift@/${WIDEC_SHIFT}/g" \
|
||||
-e "s/@cf_cv_shift_limit@/${SHIFT_LIMIT}/g" \
|
||||
-e "s/@cf_cv_1UL@/${ONEUL}/g"
|
||||
|
||||
unctrl.h: unctrl.h.in
|
||||
sed <${NCURSES}/include/$@.in >$@ \
|
||||
-e "/@NCURSES_MAJOR@/s//${NCURSES_MAJOR}/" \
|
||||
-e "/@NCURSES_MINOR@/s//${NCURSES_MINOR}/"
|
||||
|
||||
# MAN page gunk
|
||||
terminfo.5: MKterminfo.sh terminfo.head Caps
|
||||
sh ${NCURSES}/man/MKterminfo.sh ${NCURSES}/man/terminfo.head \
|
||||
${NCURSES}/include/Caps ${NCURSES}/man/terminfo.tail >$@
|
||||
|
||||
CLEANFILES+= terminfo.5
|
||||
MANFILTER= sed -e 's\#@DATADIR@\#${TERMINFODIR}/terminfo\#g'
|
||||
|
||||
MAN3x= curs_addch.3x curs_addchstr.3x curs_addstr.3x curs_attr.3x \
|
||||
curs_beep.3x curs_bkgd.3x curs_border.3x curs_clear.3x curs_color.3x \
|
||||
curs_delch.3x curs_deleteln.3x curs_getch.3x curs_getstr.3x \
|
||||
curs_getyx.3x curs_inch.3x curs_inchstr.3x curs_initscr.3x \
|
||||
curs_inopts.3x curs_insch.3x curs_insstr.3x curs_instr.3x \
|
||||
curs_kernel.3x curs_mouse.3x curs_move.3x curs_outopts.3x \
|
||||
curs_overlay.3x curs_pad.3x curs_print.3x curs_printw.3x \
|
||||
curs_refresh.3x curs_scanw.3x curs_scr_dump.3x curs_scroll.3x \
|
||||
curs_slk.3x curs_termattrs.3x curs_termcap.3x curs_terminfo.3x \
|
||||
curs_touch.3x curs_util.3x curs_window.3x define_key.3x \
|
||||
dft_fgbg.3x keybound.3x keyok.3x ncurses.3x resizeterm.3x wresize.3x
|
||||
MAN5= term.5 terminfo.5
|
||||
MAN7= term.7
|
||||
|
||||
# Generate the MAN3 list from MAN3x
|
||||
.for page in ${MAN3x}
|
||||
CLEANFILES+=${page:T:S/3x$/3/g}
|
||||
MAN3+=${page:T:S/3x$/3/g}
|
||||
all-man: ${page:T:S/3x$/3/g}
|
||||
${page:T:S/3x$/3/g}: ${page}
|
||||
ln -s ${.ALLSRC} ${.TARGET}
|
||||
.endfor
|
||||
|
||||
MLINKS+=curs_addch.3 addch.3 curs_addch.3 echochar.3 curs_addch.3 mvaddch.3 \
|
||||
curs_addch.3 mvwaddch.3 curs_addch.3 waddch.3 curs_addch.3 wechochar.3
|
||||
MLINKS+=curs_addchstr.3 addchnstr.3 curs_addchstr.3 addchstr.3 \
|
||||
curs_addchstr.3 mvaddchnstr.3 curs_addchstr.3 mvaddchstr.3 \
|
||||
curs_addchstr.3 mvwaddchnstr.3 curs_addchstr.3 mvwaddchstr.3 \
|
||||
curs_addchstr.3 waddchnstr.3 curs_addchstr.3 waddchstr.3
|
||||
MLINKS+=curs_addstr.3 addnstr.3 curs_addstr.3 addstr.3 \
|
||||
curs_addstr.3 mvaddnstr.3 curs_addstr.3 mvaddstr.3 \
|
||||
curs_addstr.3 mvwaddnstr.3 curs_addstr.3 mvwaddstr.3 \
|
||||
curs_addstr.3 waddnstr.3 curs_addstr.3 waddstr.3
|
||||
MLINKS+=curs_attr.3 attr_get.3 curs_attr.3 attr_off.3 curs_attr.3 attr_on.3 \
|
||||
curs_attr.3 attr_set.3 curs_attr.3 attroff.3 curs_attr.3 attron.3 \
|
||||
curs_attr.3 attrset.3 curs_attr.3 chgat.3 curs_attr.3 color_set.3 \
|
||||
curs_attr.3 mvchgat.3 curs_attr.3 mvwchgat.3 curs_attr.3 standend.3 \
|
||||
curs_attr.3 standout.3 curs_attr.3 wattr_get.3 curs_attr.3 wattr_off.3 \
|
||||
curs_attr.3 wattr_on.3 curs_attr.3 wattr_set.3 curs_attr.3 wattroff.3 \
|
||||
curs_attr.3 wattron.3 curs_attr.3 wattrset.3 curs_attr.3 wchgat.3 \
|
||||
curs_attr.3 wcolor_set.3 curs_attr.3 wstandend.3 \
|
||||
curs_attr.3 wstandout.3
|
||||
MLINKS+=curs_beep.3 beep.3 curs_beep.3 flash.3
|
||||
MLINKS+=curs_bkgd.3 bkgdset.3 curs_bkgd.3 wbkgdset.3 \
|
||||
curs_bkgd.3 bkgd.3 curs_bkgd.3 wbkgd.3
|
||||
MLINKS+=curs_border.3 border.3 curs_border.3 wborder.3 curs_border.3 box.3 \
|
||||
curs_border.3 hline.3 curs_border.3 whline.3 \
|
||||
curs_border.3 vline.3 curs_border.3 wvline.3
|
||||
MLINKS+=curs_clear.3 erase.3 curs_clear.3 werase.3 curs_clear.3 clear.3 \
|
||||
curs_clear.3 wclear.3 curs_clear.3 clrtobot.3 \
|
||||
curs_clear.3 wclrtobot.3 curs_clear.3 clrtoeol.3 \
|
||||
curs_clear.3 wclrtoeol.3
|
||||
MLINKS+=curs_color.3 start_color.3 curs_color.3 init_pair.3 \
|
||||
curs_color.3 init_color.3 curs_color.3 has_colors.3 \
|
||||
curs_color.3 can_change_color.3 curs_color.3 color_content.3 \
|
||||
curs_color.3 pair_content.3
|
||||
MLINKS+=curs_delch.3 delch.3 curs_delch.3 wdelch.3 curs_delch.3 mvdelch.3 \
|
||||
curs_delch.3 mvwdelch.3
|
||||
MLINKS+=curs_delln.3 deleteln.3 curs_delln.3 wdeleteln.3 \
|
||||
curs_delln.3 insdelln.3 curs_delln.3 winsdelln.3 \
|
||||
curs_delln.3 insertln.3 curs_delln.3 winsertln.3
|
||||
MLINKS+=curs_getch.3 getch.3 curs_getch.3 wgetch.3 curs_getch.3 mvgetch.3 \
|
||||
curs_getch.3 mvwgetch.3 curs_getch.3 ungetch.3
|
||||
MLINKS+=curs_getstr.3 getstr.3 curs_getstr.3 wgetstr.3 \
|
||||
curs_getstr.3 mvgetstr.3 curs_getstr.3 mvwgetstr.3 \
|
||||
curs_getstr.3 wgetnstr.3
|
||||
MLINKS+=curs_getyx.3 getyx.3 curs_getyx.3 pgetparyx.3 curs_getyx.3 getbegyx.3 \
|
||||
curs_getyx.3 getmaxyx.3
|
||||
MLINKS+=curs_inch.3 inch.3 curs_inch.3 winch.3 curs_inch.3 mvinch.3 \
|
||||
curs_inch.3 mvwinch.3
|
||||
MLINKS+=curs_inchstr.3 inchstr.3 curs_inchstr.3 inchnstr.3 \
|
||||
curs_inchstr.3 winchstr.3 curs_inchstr.3 winchnstr.3 \
|
||||
curs_inchstr.3 mvinchstr.3 curs_inchstr.3 mvinchnstr.3 \
|
||||
curs_inchstr.3 mvwinchstr.3 curs_inchstr.3 mvwinchnstr.3
|
||||
MLINKS+=curs_initscr.3 initscr.3 curs_initscr.3 newterm.3 \
|
||||
curs_initscr.3 endwin.3 curs_initscr.3 isendwin.3 \
|
||||
curs_initscr.3 set_term.3 curs_initscr.3 delscreen.3
|
||||
MLINKS+=curs_inopts.3 cbreak.3 curs_inopts.3 nocbreak.3 curs_inopts.3 echo.3 \
|
||||
curs_inopts.3 noecho.3 curs_inopts.3 halfdelay.3 \
|
||||
MLINKS+=curs_bkgd.3 bkgd.3 curs_bkgd.3 bkgdset.3 curs_bkgd.3 getbkgd.3 \
|
||||
curs_bkgd.3 wbkgd.3 curs_bkgd.3 wbkgdset.3
|
||||
MLINKS+=curs_border.3 border.3 curs_border.3 box.3 curs_border.3 hline.3 \
|
||||
curs_border.3 mvhline.3 curs_border.3 mvwhline.3 \
|
||||
curs_border.3 mvwvline.3 curs_border.3 vline.3 curs_border.3 wborder.3 \
|
||||
curs_border.3 whline.3 curs_border.3 wvline.3
|
||||
MLINKS+=curs_clear.3 clear.3 curs_clear.3 clrtobot.3 curs_clear.3 clrtoeol.3 \
|
||||
curs_clear.3 erase.3 curs_clear.3 wclear.3 curs_clear.3 wclrtobot.3 \
|
||||
curs_clear.3 wclrtoeol.3 curs_clear.3 werase.3
|
||||
MLINKS+=curs_color.3 can_change_color.3 curs_color.3 color_content.3 \
|
||||
curs_color.3 has_colors.3 curs_color.3 init_color.3 \
|
||||
curs_color.3 init_pair.3 curs_color.3 pair_content.3 \
|
||||
curs_color.3 start_color.3
|
||||
MLINKS+=curs_delch.3 delch.3 curs_delch.3 mvdelch.3 curs_delch.3 mvwdelch.3 \
|
||||
curs_delch.3 wdelch.3
|
||||
MLINKS+=curs_deleteln.3 deleteln.3 curs_deleteln.3 insdelln.3 \
|
||||
curs_deleteln.3 insertln.3 curs_deleteln.3 wdeleteln.3 \
|
||||
curs_deleteln.3 winsdelln.3 curs_deleteln.3 winsertln.3
|
||||
MLINKS+=curs_getch.3 getch.3 curs_getch.3 has_key.3 curs_getch.3 mvgetch.3 \
|
||||
curs_getch.3 mvwgetch.3 curs_getch.3 ungetch.3 curs_getch.3 wgetch.3
|
||||
MLINKS+=curs_getstr.3 getnstr.3 curs_getstr.3 getstr.3 \
|
||||
curs_getstr.3 mvgetnstr.3 curs_getstr.3 mvgetstr.3 \
|
||||
curs_getstr.3 mvwgetnstr.3 curs_getstr.3 mvwgetstr.3 \
|
||||
curs_getstr.3 wgetnstr.3 curs_getstr.3 wgetstr.3
|
||||
MLINKS+=curs_getyx.3 getbegyx.3 curs_getyx.3 getmaxyx.3 \
|
||||
curs_getyx.3 getparyx.3 curs_getyx.3 getyx.3
|
||||
MLINKS+=curs_inch.3 inch.3 curs_inch.3 mvinch.3 curs_inch.3 mvwinch.3 \
|
||||
curs_inch.3 winch.3
|
||||
MLINKS+=curs_inchstr.3 inchnstr.3 curs_inchstr.3 inchstr.3 \
|
||||
curs_inchstr.3 mvinchnstr.3 curs_inchstr.3 mvinchstr.3 \
|
||||
curs_inchstr.3 mvwinchnstr.3 curs_inchstr.3 mvwinchstr.3 \
|
||||
curs_inchstr.3 winchnstr.3 curs_inchstr.3 winchstr.3
|
||||
MLINKS+=curs_initscr.3 delscreen.3 curs_initscr.3 endwin.3 \
|
||||
curs_initscr.3 initscr.3 curs_initscr.3 isendwin.3 \
|
||||
curs_initscr.3 newterm.3 curs_initscr.3 set_term.3
|
||||
MLINKS+=curs_inopts.3 cbreak.3 curs_inopts.3 echo.3 curs_inopts.3 halfdelay.3 \
|
||||
curs_inopts.3 intrflush.3 curs_inopts.3 keypad.3 curs_inopts.3 meta.3 \
|
||||
curs_inopts.3 nodelay.3 curs_inopts.3 notimeout.3 curs_inopts.3 raw.3 \
|
||||
curs_inopts.3 noraw.3 curs_inopts.3 noqiflush.3 \
|
||||
curs_inopts.3 qiflush.3 curs_inopts.3 timeout.3 \
|
||||
curs_inopts.3 wtimeout.3 curs_inopts.3 typeahead.3
|
||||
MLINKS+=curs_insch.3 insch.3 curs_insch.3 winsch.3 curs_insch.3 mvinsch.3 \
|
||||
curs_insch.3 mvwinsch.3
|
||||
MLINKS+=curs_insstr.3 insstr.3 curs_insstr.3 insnstr.3 \
|
||||
curs_insstr.3 winsstr.3 curs_insstr.3 winsnstr.3 \
|
||||
curs_insstr.3 mvinsstr.3 curs_insstr.3 mvinsnstr.3 \
|
||||
curs_insstr.3 mvwinsstr.3 curs_insstr.3 mvwinsnstr.3
|
||||
MLINKS+=curs_instr.3 instr.3 curs_instr.3 innstr.3 curs_instr.3 winstr.3 \
|
||||
curs_instr.3 winnstr.3 curs_instr.3 mvinstr.3 curs_instr.3 mvinnstr.3 \
|
||||
curs_instr.3 mvwinstr.3 curs_instr.3 mvwinnstr.3
|
||||
MLINKS+=curs_kernel.3 def_prog_mode.3 curs_kernel.3 def_shell_mode.3 \
|
||||
curs_kernel.3 reset_prog_mode.3 curs_kernel.3 reset_shell_mode.3 \
|
||||
curs_kernel.3 resetty.3 curs_kernel.3 savetty.3 \
|
||||
curs_kernel.3 getsyx.3 curs_kernel.3 setsyx.3 \
|
||||
curs_kernel.3 ripoffline.3 curs_kernel.3 curs_set.3 \
|
||||
curs_kernel.3 napms.3
|
||||
curs_inopts.3 nocbreak.3 curs_inopts.3 nodelay.3 \
|
||||
curs_inopts.3 noecho.3 curs_inopts.3 noqiflush.3 curs_inopts.3 noraw.3 \
|
||||
curs_inopts.3 notimeout.3 curs_inopts.3 qiflush.3 curs_inopts.3 raw.3 \
|
||||
curs_inopts.3 timeout.3 curs_inopts.3 typeahead.3 \
|
||||
curs_inopts.3 wtimeout.3
|
||||
MLINKS+=curs_insch.3 insch.3 curs_insch.3 mvinsch.3 curs_insch.3 mvwinsch.3 \
|
||||
curs_insch.3 winsch.3
|
||||
MLINKS+=curs_insstr.3 insnstr.3 curs_insstr.3 insstr.3 \
|
||||
curs_insstr.3 mvinsnstr.3 curs_insstr.3 mvinsstr.3 \
|
||||
curs_insstr.3 mvwinsnstr.3 curs_insstr.3 mvwinsstr.3 \
|
||||
curs_insstr.3 winsnstr.3 curs_insstr.3 winsstr.3
|
||||
MLINKS+=curs_instr.3 innstr.3 curs_instr.3 instr.3 curs_instr.3 mvinnstr.3 \
|
||||
curs_instr.3 mvinstr.3 curs_instr.3 mvwinnstr.3 \
|
||||
curs_instr.3 mvwinstr.3 curs_instr.3 winnstr.3 curs_instr.3 winstr.3
|
||||
MLINKS+=curs_kernel.3 curs_set.3 curs_kernel.3 def_prog_mode.3 \
|
||||
curs_kernel.3 def_shell_mode.3 curs_kernel.3 getsyx.3 \
|
||||
curs_kernel.3 napms.3 curs_kernel.3 reset_prog_mode.3 \
|
||||
curs_kernel.3 reset_shell_mode.3 curs_kernel.3 resetty.3 \
|
||||
curs_kernel.3 ripoffline.3 curs_kernel.3 savetty.3 \
|
||||
curs_kernel.3 setsyx.3
|
||||
MLINKS+=curs_mouse.3 getmouse.3 curs_mouse.3 mouseinterval.3 \
|
||||
curs_mouse.3 mousemask.3 curs_mouse.3 ungetmouse.3 \
|
||||
curs_mouse.3 wenclose.3 curs_mouse.3 wmouse_trafo.3
|
||||
MLINKS+=curs_move.3 move.3 curs_move.3 wmove.3
|
||||
MLINKS+=curs_outopts.3 clearok.3 curs_outopts.3 idlok.3 \
|
||||
curs_outopts.3 idcok.3 curs_outopts.3 immedok.3 \
|
||||
curs_outopts.3 leaveok.3 curs_outopts.3 setscrreg.3 \
|
||||
curs_outopts.3 wsetscrreg.3 curs_outopts.3 scrollok.3 \
|
||||
curs_outopts.3 nl.3 curs_outopts.3 nonl.3
|
||||
MLINKS+=curs_overlay.3 overlay.3 curs_overlay.3 overwrite.3 \
|
||||
curs_overlay.3 copywin.3
|
||||
MLINKS+=curs_pad.3 newpad.3 curs_pad.3 subpad.3 curs_pad.3 prefresh.3 \
|
||||
curs_pad.3 pnoutrefresh.3 curs_pad.3 pechochar.3
|
||||
MLINKS+=curs_printw.3 printw.3 curs_printw.3 wprintw.3 \
|
||||
curs_printw.3 mvprintw.3 curs_printw.3 mvwprintw.3 \
|
||||
curs_printw.3 vwprintw.3
|
||||
MLINKS+=curs_refresh.3 refresh.3 curs_refresh.3 wrefresh.3 \
|
||||
curs_refresh.3 wnoutrefresh.3 curs_refresh.3 doupdate.3 \
|
||||
curs_refresh.3 redrawwin.3 curs_refresh.3 wredrawln.3
|
||||
MLINKS+=curs_scanw.3 scanw.3 curs_scanw.3 wscanw.3 curs_scanw.3 mvscanw.3 \
|
||||
curs_scanw.3 mvwscanw.3 curs_scanw.3 vwscanw.3
|
||||
MLINKS+=curs_scr_dmp.3 scr_dump.3 curs_scr_dmp.3 scr_restore.3 \
|
||||
curs_scr_dmp.3 scr_init.3 curs_scr_dmp.3 scr_set.3
|
||||
MLINKS+=curs_scroll.3 scroll.3 curs_scroll.3 scrl.3 curs_scroll.3 wscrl.3
|
||||
MLINKS+=curs_slk.3 slk_init.3 curs_slk.3 slk_set.3 curs_slk.3 slk_refresh.3 \
|
||||
curs_slk.3 slk_noutrefresh.3 curs_slk.3 slk_label.3 \
|
||||
curs_slk.3 slk_clear.3 curs_slk.3 slk_restore.3 \
|
||||
curs_slk.3 slk_touch.3 curs_slk.3 slk_attron.3 \
|
||||
curs_slk.3 slk_attrset.3 curs_slk.3 slk_attroff.3
|
||||
MLINKS+=curs_termatt.3 baudrate.3 curs_termatt.3 erasechar.3 \
|
||||
curs_termatt.3 has_ic.3 curs_termatt.3 has_il.3 \
|
||||
curs_termatt.3 killchar.3 curs_termatt.3 longname.3 \
|
||||
curs_termatt.3 termattrs.3 curs_termatt.3 termname.3
|
||||
|
||||
# XXX name clash with termcap(3)
|
||||
# MLINKS+= curs_termin.3 tparm.3
|
||||
MLINKS+=curs_termin.3 setupterm.3 curs_termin.3 setterm.3 \
|
||||
curs_termin.3 set_curterm.3 curs_termin.3 del_curterm.3 \
|
||||
curs_termin.3 restartterm.3 \
|
||||
curs_termin.3 putp.3 curs_termin.3 vidputs.3 \
|
||||
curs_termin.3 vidattr.3 curs_termin.3 mvcur.3 \
|
||||
curs_termin.3 tigetflag.3 curs_termin.3 tigetnum.3 \
|
||||
curs_termin.3 tigetstr.3
|
||||
MLINKS+=curs_touch.3 touchwin.3 curs_touch.3 touchline.3 \
|
||||
curs_touch.3 untouchwin.3 curs_touch.3 wtouchln.3 \
|
||||
curs_touch.3 is_linetouched.3 curs_touch.3 is_wintouched.3
|
||||
MLINKS+=curs_util.3 unctrl.3 curs_util.3 keyname.3 \
|
||||
curs_util.3 filter.3 curs_util.3 use_env.3 \
|
||||
curs_util.3 putwin.3 curs_util.3 getwin.3 \
|
||||
curs_util.3 delay_output.3 curs_util.3 flushinp.3
|
||||
MLINKS+=curs_window.3 newwin.3 curs_window.3 delwin.3 \
|
||||
curs_window.3 mvwin.3 curs_window.3 subwin.3 \
|
||||
curs_window.3 derwin.3 curs_window.3 mvderwin.3 \
|
||||
curs_window.3 dupwin.3 curs_window.3 wsyncup.3 \
|
||||
curs_window.3 syncok.3 curs_window.3 wcursyncup.3 \
|
||||
curs_window.3 wsyncdown.3
|
||||
MLINKS+=curs_outopts.3 clearok.3 curs_outopts.3 idcok.3 curs_outopts.3 idlok.3 \
|
||||
curs_outopts.3 immedok.3 curs_outopts.3 leaveok.3 curs_outopts.3 nl.3 \
|
||||
curs_outopts.3 nonl.3 curs_outopts.3 scrollok.3 \
|
||||
curs_outopts.3 setscrreg.3 curs_outopts.3 wsetscrreg.3
|
||||
MLINKS+=curs_overlay.3 copywin.3 curs_overlay.3 overlay.3 \
|
||||
curs_overlay.3 overwrite.3
|
||||
MLINKS+=curs_pad.3 newpad.3 curs_pad.3 pechochar.3 curs_pad.3 pnoutrefresh.3 \
|
||||
curs_pad.3 prefresh.3 curs_pad.3 subpad.3
|
||||
MLINKS+=curs_print.3 mcprint.3
|
||||
MLINKS+=curs_printw.3 mvprintw.3 curs_printw.3 mvwprintw.3 \
|
||||
curs_printw.3 printw.3 curs_printw.3 vw_printw.3 \
|
||||
curs_printw.3 vwprintw.3 curs_printw.3 wprintw.3
|
||||
MLINKS+=curs_refresh.3 doupdate.3 curs_refresh.3 redrawwin.3 \
|
||||
curs_refresh.3 refresh.3 curs_refresh.3 wnoutrefresh.3 \
|
||||
curs_refresh.3 wredrawln.3 curs_refresh.3 wrefresh.3
|
||||
MLINKS+=curs_scanw.3 mvscanw.3 curs_scanw.3 mvwscanw.3 curs_scanw.3 scanw.3 \
|
||||
curs_scanw.3 vw_scanw.3 curs_scanw.3 vwscanw.3 curs_scanw.3 wscanw.3
|
||||
MLINKS+=curs_scr_dump.3 scr_dump.3 curs_scr_dump.3 scr_init.3 \
|
||||
curs_scr_dump.3 scr_restore.3 curs_scr_dump.3 scr_set.3
|
||||
MLINKS+=curs_scroll.3 scrl.3 curs_scroll.3 scroll.3 curs_scroll.3 wscrl.3
|
||||
MLINKS+=curs_slk.3 slk_attr.3 curs_slk.3 slk_attr_off.3 \
|
||||
curs_slk.3 slk_attr_on.3 curs_slk.3 slk_attr_set.3 \
|
||||
curs_slk.3 slk_attroff.3 curs_slk.3 slk_attron.3 \
|
||||
curs_slk.3 slk_attrset.3 curs_slk.3 slk_clear.3 \
|
||||
curs_slk.3 slk_color.3 curs_slk.3 slk_init.3 curs_slk.3 slk_label.3 \
|
||||
curs_slk.3 slk_noutrefresh.3 curs_slk.3 slk_refresh.3 \
|
||||
curs_slk.3 slk_restore.3 curs_slk.3 slk_set.3 curs_slk.3 slk_touch.3
|
||||
MLINKS+=curs_termattrs.3 baudrate.3 curs_termattrs.3 erasechar.3 \
|
||||
curs_termattrs.3 has_ic.3 curs_termattrs.3 has_il.3 \
|
||||
curs_termattrs.3 killchar.3 curs_termattrs.3 longname.3 \
|
||||
curs_termattrs.3 termattrs.3 curs_termattrs.3 termname.3
|
||||
MLINKS+=curs_termcap.3 tgetent.3 curs_termcap.3 tgetflag.3 \
|
||||
curs_termcap.3 tgetnum.3 curs_termcap.3 tgetstr.3 \
|
||||
curs_termcap.3 tgoto.3 curs_termcap.3 tputs.3
|
||||
MLINKS+=curs_terminfo.3 del_curterm.3 curs_terminfo.3 mvcur.3 \
|
||||
curs_terminfo.3 putp.3 curs_terminfo.3 restartterm.3 \
|
||||
curs_terminfo.3 set_curterm.3 curs_terminfo.3 setterm.3 \
|
||||
curs_terminfo.3 setupterm.3 curs_terminfo.3 tigetflag.3 \
|
||||
curs_terminfo.3 tigetnum.3 curs_terminfo.3 tigetstr.3 \
|
||||
curs_terminfo.3 tparm.3 curs_terminfo.3 tputs.3 \
|
||||
curs_terminfo.3 vidattr.3 curs_terminfo.3 vidputs.3
|
||||
MLINKS+=curs_touch.3 is_linetouched.3 curs_touch.3 is_wintouched.3 \
|
||||
curs_touch.3 touchline.3 curs_touch.3 touchwin.3 \
|
||||
curs_touch.3 untouchwin.3 curs_touch.3 wtouchln.3
|
||||
MLINKS+=curs_util.3 delay_output.3 curs_util.3 filter.3 \
|
||||
curs_util.3 flushinp.3 curs_util.3 getwin.3 \
|
||||
curs_util.3 keyname.3 curs_util.3 putwin.3 \
|
||||
curs_util.3 unctrl.3 curs_util.3 use_env.3
|
||||
MLINKS+=curs_window.3 delwin.3 curs_window.3 derwin.3 curs_window.3 dupwin.3 \
|
||||
curs_window.3 mvderwin.3 curs_window.3 mvwin.3 curs_window.3 newwin.3 \
|
||||
curs_window.3 subwin.3 curs_window.3 syncok.3 \
|
||||
curs_window.3 wcursyncup.3 curs_window.3 wsyncdown.3 \
|
||||
curs_window.3 wsyncup.3
|
||||
MLINKS+=dft_fgbg.3 use_default_colors.3
|
||||
|
||||
.include <bsd.lib.mk>
|
||||
|
||||
.SUFFIXES: .3x .3
|
||||
|
@ -1,42 +0,0 @@
|
||||
NCURSES 1.8.6 - July 24, 1994
|
||||
-----------------------------
|
||||
This file is intended to help people interested in working
|
||||
on fixing ncurses, enhancing it, or porting it to other
|
||||
platforms.
|
||||
|
||||
PORTABILITY:
|
||||
The file matrix is an attempt at centralizing all portability
|
||||
information. The top line lists the different options, down
|
||||
the leftside are the operating systems supported. If an option
|
||||
is not needed then it should have an entry of NONE. Note the
|
||||
use of ':' to terminate each field. If somebody knows awk better
|
||||
than me, get in touch.
|
||||
|
||||
OS: name of operating system
|
||||
ISPOSIX: -DNONPOSIX if <unistd.h> is missing
|
||||
POSIX: -DSTRICTPOSIX if _POSIX_SOURCE turns off non-POSIX features.
|
||||
-DSVR4_ACTION if like svr4 you need _POSIX_SOURCE to have sigaction
|
||||
TERMINAL: -DNOTERMIOS if you don't have <termios.h> but have <sgtty.h>
|
||||
HEADERS: -DBRAINDEAD if system headers don't declare external variables
|
||||
TABS: -DBSDTABS if you don't have TABS3 but have OXTABS
|
||||
OPT: -DOPT_MVCUR if you want mvcur() to cost its actions or you have a
|
||||
terminal that doesn't have direct cursor addressing.
|
||||
SRCDIR: the directory where the terminfo database lives
|
||||
CC: ANSI C compiler
|
||||
FLAGS: standard compiler flags
|
||||
EXTRA: extra flags needed by individual systems
|
||||
Sun: -DSUNIOCTL <sys/ioctl.h> conflicts with <termios.h>
|
||||
HP-UX: -D_HPUX_SOURCE so that we get POSIX and XOPEN features.
|
||||
SVR4: -DBROKEN_TIOCGETWINSZ guess what?
|
||||
AIX: -DSYS_SELECT if you need <sys/select.h>
|
||||
BASE: The directory under which headers and libraries will
|
||||
be installed.
|
||||
INSTALL: The name of an install program similar to BSD's (ie. understands
|
||||
-m, -g, -o, etc.) GNU install works.
|
||||
|
||||
The awk script in script.src reads matrix and generates all the Config.*
|
||||
files.
|
||||
|
||||
There are several problems with strict POSIX systems so extra flags
|
||||
or #define's maybe needed.
|
||||
|
@ -1,35 +0,0 @@
|
||||
TESTS = test corner ensor getch ncurses hanoi knight rain worm \
|
||||
over scroll2 battle newdemo scroll3 xmas copy firework testcurs \
|
||||
scroll
|
||||
|
||||
CLEANFILES += $(TESTS)
|
||||
|
||||
LIBS += -lncurses -lmytinfo
|
||||
|
||||
all: $(TESTS)
|
||||
|
||||
$(TESTS):
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) ${.CURDIR}/${.TARGET}.c -o ${.TARGET} $(LIBS)
|
||||
|
||||
test: test.c
|
||||
corner: corner.c
|
||||
ensor: ensor.c
|
||||
getch: getch.c
|
||||
ncurses: ncurses.c
|
||||
hanoi: hanoi.c
|
||||
knight: knight.c
|
||||
rain: rain.c
|
||||
worm: worm.c
|
||||
over: over.c
|
||||
scroll2: scroll2.c
|
||||
battle: battle.c
|
||||
newdemo: newdemo.c
|
||||
scroll3: scroll3.c
|
||||
xmas: xmas.c
|
||||
copy: copy.c
|
||||
firework: firework.c
|
||||
testcurs: testcurs.c
|
||||
scroll: scroll.c
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -1,21 +0,0 @@
|
||||
The programs in this directory are designed to test your newest toy :-)
|
||||
Check the sources for any further details.
|
||||
|
||||
asc.c - tests the line drawing functions
|
||||
attr.c - display attributes available on the terminal
|
||||
bs.c - the game of battleship
|
||||
battle.c - older version of battleship with different interface
|
||||
caps.c - output a list of all capabilites to stderr (redirect to a file
|
||||
or it will screw up the terminal)
|
||||
copy.c - test overlay
|
||||
gdc.c - Great Digital Clock, gives an example of usng color
|
||||
getch.c - tests ketpad() and getch()
|
||||
hanoi.c - the game of hanoi, also an example of using color
|
||||
knight.c - the game of Knight's Tour
|
||||
rain.c - rain drops are falling on my head..
|
||||
scroll.c - test scrolling region
|
||||
slk.c - test soft labels
|
||||
worm.c - worms run all over your screen
|
||||
firework.c - multi-colored fireworks
|
||||
newdemo.c - a demo from the PDCurses people
|
||||
testcurs.c - a test from the PDCurses people
|
@ -1,705 +0,0 @@
|
||||
/*
|
||||
* battle.c - original author: Bruce Holloway
|
||||
* mods by: Chuck A DeGaul
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#include <ncurses.h>
|
||||
|
||||
#define OTHER 1-turn
|
||||
|
||||
char numbers[] = " 0 1 2 3 4 5 6 7 8 9";
|
||||
|
||||
char carrier[] = "Aircraft Carrier";
|
||||
char battle[] = "Battleship";
|
||||
char sub[] = "Submarine";
|
||||
char destroy[] = "Destroyer";
|
||||
char ptboat[] = "PT Boat";
|
||||
|
||||
char name[40];
|
||||
char dftname[] = "Stranger";
|
||||
|
||||
struct _ships {
|
||||
char *name;
|
||||
char symbol;
|
||||
char length;
|
||||
char start; /* Coordinates - 0,0=0; 10,10=100. */
|
||||
char dir; /* Direction - 0 = right; 1 = down. */
|
||||
char hits; /* How many times has this ship been hit? (-1==sunk) */
|
||||
};
|
||||
|
||||
struct _ships plyship[] = {
|
||||
{ carrier,'A',5,0,0,0 },
|
||||
{ battle,'B',4,0,0,0 },
|
||||
{ destroy,'D',3,0,0,0 },
|
||||
{ sub,'S',3,0,0,0 },
|
||||
{ ptboat,'P',2,0,0,0 },
|
||||
};
|
||||
|
||||
struct _ships cpuship[] = {
|
||||
{ carrier,'A',5,0,0,0 },
|
||||
{ battle,'B',4,0,0,0 },
|
||||
{ destroy,'D',3,0,0,0 },
|
||||
{ sub,'S',3,0,0,0 },
|
||||
{ ptboat,'P',2,0,0,0 },
|
||||
};
|
||||
|
||||
char hits[2][100], board[2][100]; /* "Hits" board, and main board. */
|
||||
|
||||
int srchstep;
|
||||
int cpuhits;
|
||||
int cstart, cdir;
|
||||
int plywon=0, cpuwon=0; /* How many games has each won? */
|
||||
int turn; /* 0=player, 1=computer */
|
||||
int huntoffs; /* Offset on search strategy */
|
||||
|
||||
int salvo, blitz, ask, seemiss; /* options */
|
||||
|
||||
void intro(void);
|
||||
void initgame(void);
|
||||
int rnd(int);
|
||||
void plyplace(struct _ships *);
|
||||
int getdir(void);
|
||||
void placeship(struct _ships *, int, int);
|
||||
int checkplace(struct _ships *, int, int);
|
||||
void error(char *);
|
||||
void prompt(void);
|
||||
char getcoord(void);
|
||||
void cpuplace(struct _ships *);
|
||||
int awinna(void);
|
||||
int plyturn(void);
|
||||
int hitship(int);
|
||||
int cputurn(void);
|
||||
int playagain(void);
|
||||
void uninitgame();
|
||||
int sgetc(char *);
|
||||
int do_options(int, char *[]);
|
||||
int scount(int);
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
do_options(argc, argv);
|
||||
|
||||
intro();
|
||||
do {
|
||||
initgame();
|
||||
while(awinna() == -1) {
|
||||
if (!blitz) {
|
||||
if (!salvo) {
|
||||
if (turn)
|
||||
cputurn();
|
||||
else plyturn();
|
||||
} else {
|
||||
register int i;
|
||||
|
||||
i = scount(turn);
|
||||
while (i--) {
|
||||
if (turn)
|
||||
if (cputurn())
|
||||
if (awinna() != -1)
|
||||
i = 0;
|
||||
else
|
||||
if(plyturn())
|
||||
if (awinna() != -1)
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while((turn) ? cputurn() : plyturn());
|
||||
}
|
||||
turn = OTHER;
|
||||
}
|
||||
} while(playagain());
|
||||
uninitgame();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#define PR addstr
|
||||
|
||||
void
|
||||
intro()
|
||||
{
|
||||
char *tmpname;
|
||||
|
||||
srand(time(0L)); /* Kick the random number generator */
|
||||
|
||||
signal(SIGINT,uninitgame);
|
||||
if(signal(SIGQUIT,SIG_IGN) != SIG_IGN) signal(SIGQUIT,uninitgame);
|
||||
#if 1
|
||||
/* for some bizzare reason, getlogin or cuserid cause havoc with the terminal */
|
||||
if ((tmpname = getlogin()) != NULL) {
|
||||
strcpy(name, tmpname);
|
||||
} else
|
||||
#endif
|
||||
strcpy(name,dftname);
|
||||
name[0] = toupper(name[0]);
|
||||
|
||||
initscr();
|
||||
savetty();
|
||||
nonl();
|
||||
cbreak();
|
||||
noecho();
|
||||
clear();
|
||||
mvaddstr(4,29,"Welcome to Battleship!");
|
||||
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");
|
||||
mvaddstr(20,27,"Hit any key to continue..."); refresh();
|
||||
getch();
|
||||
}
|
||||
|
||||
void
|
||||
initgame()
|
||||
{
|
||||
int i;
|
||||
|
||||
clear();
|
||||
mvaddstr(0,35,"BATTLESHIP");
|
||||
mvaddstr(4,12,"Main Board");
|
||||
mvaddstr(6,0,numbers);
|
||||
move(7,0);
|
||||
for(i=0; i<10; ++i){
|
||||
printw("%c . . . . . . . . . . %c\n",i+'A',i+'A');
|
||||
}
|
||||
mvaddstr(17,0,numbers);
|
||||
mvaddstr(4,55,"Hit/Miss Board");
|
||||
mvaddstr(6,45,numbers);
|
||||
for(i=0; i<10; ++i){
|
||||
mvprintw(7+i,45,"%c . . . . . . . . . . %c",i+'A',i+'A');
|
||||
}
|
||||
mvaddstr(17,45,numbers);
|
||||
for(turn=0; turn<2; ++turn)
|
||||
for(i=0; i<100; ++i){
|
||||
hits[turn][i] = board[turn][i] = 0;
|
||||
}
|
||||
for(turn=0; turn<2; ++turn){
|
||||
for(i=0; i<5; ++i)
|
||||
if (!turn)
|
||||
plyplace(&plyship[i]);
|
||||
else
|
||||
cpuplace(&cpuship[i]);
|
||||
}
|
||||
turn = rnd(2);
|
||||
cstart = cdir = -1;
|
||||
cpuhits = 0;
|
||||
srchstep = 3;
|
||||
huntoffs = rnd(srchstep);
|
||||
}
|
||||
|
||||
int
|
||||
rnd(int n)
|
||||
{
|
||||
return(((rand() & 0x7FFF) % n));
|
||||
}
|
||||
|
||||
void
|
||||
plyplace(ss)
|
||||
struct _ships *ss;
|
||||
{
|
||||
int c, d;
|
||||
|
||||
do {
|
||||
prompt();
|
||||
printw("Place your %s (ex.%c%d) ? ",ss->name,rnd(10)+'A',rnd(10));
|
||||
c = getcoord();
|
||||
d = getdir();
|
||||
} while(!checkplace(ss,c,d));
|
||||
placeship(ss,c,d);
|
||||
}
|
||||
|
||||
int
|
||||
getdir()
|
||||
{
|
||||
|
||||
prompt();
|
||||
addstr("What direction (0=right, 1=down) ? ");
|
||||
return(sgetc("01")-'0');
|
||||
}
|
||||
|
||||
void
|
||||
placeship(ss,c,d)
|
||||
struct _ships *ss;
|
||||
int c, d;
|
||||
{
|
||||
int x, y, l, i;
|
||||
|
||||
for(l=0; l<ss->length; ++l){
|
||||
i = c + l * ((d) ? 10 : 1);
|
||||
board[turn][i] = ss->symbol;
|
||||
x = (i % 10) * 3 + 3;
|
||||
y = (i / 10) + 7;
|
||||
if(!turn) mvaddch(y,x,ss->symbol);
|
||||
}
|
||||
ss->start = c;
|
||||
ss->dir = d;
|
||||
ss->hits = 0;
|
||||
}
|
||||
|
||||
int
|
||||
checkplace(ss,c,d)
|
||||
struct _ships *ss;
|
||||
int c, d;
|
||||
{
|
||||
int x, y, l;
|
||||
|
||||
x = c%10; y = c/10;
|
||||
if(((x+ss->length) > 10 && !d) || ((y+ss->length) > 10 && d==1)){
|
||||
if(!turn)
|
||||
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(0);
|
||||
}
|
||||
for(l=0; l<ss->length; ++l){
|
||||
x = c + l * ((d) ? 10 : 1);
|
||||
if(board[turn][x]){
|
||||
if(!turn)
|
||||
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(0);
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
void
|
||||
error(s)
|
||||
char *s;
|
||||
{
|
||||
prompt();
|
||||
beep();
|
||||
printw("%s -- hit any key to continue --",s);
|
||||
refresh();
|
||||
getch();
|
||||
}
|
||||
|
||||
void
|
||||
prompt(){
|
||||
move(22,0);
|
||||
clrtoeol();
|
||||
}
|
||||
|
||||
char
|
||||
getcoord()
|
||||
{
|
||||
int ch, x, y;
|
||||
|
||||
redo:
|
||||
y = sgetc("ABCDEFGHIJ");
|
||||
do {
|
||||
ch = getch();
|
||||
if (ch == 0x7F || ch == 8) {
|
||||
addstr("\b \b");
|
||||
refresh();
|
||||
goto redo;
|
||||
}
|
||||
} while(ch < '0' || ch > '9');
|
||||
addch(x = ch);
|
||||
refresh();
|
||||
return((y-'A')*10+x-'0');
|
||||
}
|
||||
|
||||
void
|
||||
cpuplace(ss)
|
||||
struct _ships *ss;
|
||||
{
|
||||
int c, d;
|
||||
|
||||
do{
|
||||
c = rnd(100);
|
||||
d = rnd(2);
|
||||
} while(!checkplace(ss,c,d));
|
||||
placeship(ss,c,d);
|
||||
}
|
||||
|
||||
int
|
||||
awinna()
|
||||
{
|
||||
int i, j;
|
||||
struct _ships *ss;
|
||||
|
||||
for (i = 0; i < 2; ++i) {
|
||||
ss = (i) ? cpuship : plyship;
|
||||
for(j=0; j<5; ++j, ++ss)
|
||||
if(ss->length != ss->hits)
|
||||
break;
|
||||
if(j == 5) return(OTHER);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int
|
||||
plyturn()
|
||||
{
|
||||
int c, res;
|
||||
char *m;
|
||||
|
||||
prompt();
|
||||
addstr("Where do you want to shoot? ");
|
||||
c = getcoord();
|
||||
if(!(res = hits[turn][c])){
|
||||
hits[turn][c] = res = (board[OTHER][c]) ? 'H' : 'M';
|
||||
mvaddch(7+c/10,48+3*(c%10),(res=='H') ? 'H' : 'o');
|
||||
if(c = hitship(c)){
|
||||
prompt();
|
||||
switch(rnd(3)){
|
||||
case 0:
|
||||
m = "You sank my %s!";
|
||||
break;
|
||||
case 1:
|
||||
m = "I have this sinking feeling about my %s....";
|
||||
break;
|
||||
case 2:
|
||||
m = "Have some mercy for my %s!";
|
||||
break;
|
||||
}
|
||||
move(23,0);
|
||||
clrtoeol();
|
||||
beep();
|
||||
printw(m,cpuship[c-1].name); refresh();
|
||||
return(awinna() == -1);
|
||||
}
|
||||
}
|
||||
prompt();
|
||||
move(23,0); clrtoeol();
|
||||
printw("You %s.",(res=='M')?"missed":"scored a hit"); refresh();
|
||||
return(res == 'H');
|
||||
}
|
||||
|
||||
int
|
||||
hitship(c)
|
||||
int c;
|
||||
{
|
||||
struct _ships *ss;
|
||||
int sym, i, j;
|
||||
|
||||
ss = (turn) ? plyship : cpuship;
|
||||
if (!(sym = board[OTHER][c])) return(0);
|
||||
for (i = 0; i < 5; ++i, ++ss)
|
||||
if (ss->symbol == sym) {
|
||||
j = ss->hits;
|
||||
++j;
|
||||
ss->hits = j;
|
||||
if (j == ss->length)
|
||||
return(i+1);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
cputurn()
|
||||
{
|
||||
int c, res, x, y, i, d;
|
||||
|
||||
redo:
|
||||
if (cstart == -1){
|
||||
if (cpuhits){
|
||||
for(i=0, c=rnd(100); i<100; ++i, c = (c+1) % 100)
|
||||
if(hits[turn][c] == 'H')
|
||||
break;
|
||||
if(i != 100){
|
||||
cstart = c;
|
||||
cdir = -1;
|
||||
goto fndir;
|
||||
}
|
||||
}
|
||||
do {
|
||||
i = 0;
|
||||
do{
|
||||
while(hits[turn][c=rnd(100)]);
|
||||
x = c % 10; y = c / 10;
|
||||
if(++i == 1000) break;
|
||||
} while(((x+huntoffs) % srchstep) != (y % srchstep));
|
||||
if(i == 1000) --srchstep;
|
||||
} while(i == 1000);
|
||||
}
|
||||
else if(cdir == -1){
|
||||
fndir: for(i=0, d=rnd(4); i++ < 4; d = (d+1) % 4){
|
||||
x = cstart%10; y = cstart/10;
|
||||
switch(d){
|
||||
case 0: ++x; break;
|
||||
case 1: ++y; break;
|
||||
case 2: --x; break;
|
||||
case 3: --y; break;
|
||||
}
|
||||
if(x<0 || x>9 || y<0 || y>9) continue;
|
||||
if(hits[turn][c=y*10+x]) continue;
|
||||
cdir = -2;
|
||||
break;
|
||||
}
|
||||
if(i == 4){
|
||||
cstart = -1;
|
||||
goto redo;
|
||||
}
|
||||
}
|
||||
else{
|
||||
x = cstart%10; y = cstart/10;
|
||||
switch(cdir){
|
||||
case 0: ++x; break;
|
||||
case 1: ++y; break;
|
||||
case 2: --x; break;
|
||||
case 3: --y; break;
|
||||
}
|
||||
if(x<0 || x>9 || y<0 || y>9 || hits[turn][y*10+x]){
|
||||
cdir = (cdir+2) % 4;
|
||||
for(;;){
|
||||
switch(cdir){
|
||||
case 0: ++x; break;
|
||||
case 1: ++y; break;
|
||||
case 2: --x; break;
|
||||
case 3: --y; break;
|
||||
}
|
||||
if(x<0 || x>9 || y<0 || y>9){ cstart = -1;
|
||||
goto redo;
|
||||
}
|
||||
if(!hits[turn][y*10+x]) break;
|
||||
}
|
||||
}
|
||||
c = y*10 + x;
|
||||
}
|
||||
|
||||
if (!ask) {
|
||||
res = (board[OTHER][c]) ? 'H' : 'M';
|
||||
move(21,0); clrtoeol();
|
||||
printw("I shoot at %c%d. I %s!",c/10+'A',c%10,(res=='H')?"hit":"miss");
|
||||
} else {
|
||||
for(;;){
|
||||
prompt();
|
||||
printw("I shoot at %c%d. Do I (H)it or (M)iss? ",c/10+'A',c%10);
|
||||
res = sgetc("HM");
|
||||
if((res=='H' && !board[OTHER][c]) || (res=='M' && board[OTHER][c])){
|
||||
error("You lie!");
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
addch(res);
|
||||
}
|
||||
hits[turn][c] = res;
|
||||
if(res == 'H') {
|
||||
++cpuhits;
|
||||
if(cstart == -1) cdir = -1;
|
||||
cstart = c;
|
||||
if(cdir == -2) cdir = d;
|
||||
mvaddch(7+(c/10),3+3*(c%10),'*');
|
||||
if (blitz && !ask) {
|
||||
refresh();
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (seemiss) {
|
||||
mvaddch(7+(c/10),3+3*(c%10),' ');
|
||||
} else {
|
||||
if(cdir == -2) cdir = -1;
|
||||
}
|
||||
}
|
||||
if(c=hitship(c)){
|
||||
cstart = -1;
|
||||
cpuhits -= plyship[c-1].length;
|
||||
x = plyship[c-1].start;
|
||||
d = plyship[c-1].dir;
|
||||
y = plyship[c-1].length;
|
||||
for(i=0; i<y; ++i){
|
||||
hits[turn][x] = '*';
|
||||
x += (d) ? 10 : 1;
|
||||
}
|
||||
}
|
||||
if (salvo && !ask) {
|
||||
refresh();
|
||||
sleep(1);
|
||||
}
|
||||
if(awinna() != -1) return(0);
|
||||
return(res == 'H');
|
||||
}
|
||||
|
||||
int
|
||||
playagain()
|
||||
{
|
||||
int i, x, y, dx, dy, j;
|
||||
|
||||
for(i=0; i<5; ++i){
|
||||
x = cpuship[i].start; y = x/10+7; x = (x % 10) * 3 + 48;
|
||||
dx = (cpuship[i].dir) ? 0 : 3;
|
||||
dy = (cpuship[i].dir) ? 1 : 0;
|
||||
for(j=0; j < cpuship[i].length; ++j){
|
||||
mvaddch(y,x,cpuship[i].symbol);
|
||||
x += dx; y += dy;
|
||||
}
|
||||
}
|
||||
|
||||
if(awinna()) ++cpuwon; else ++plywon;
|
||||
i = 18 + strlen(name);
|
||||
if(plywon >= 10) ++i;
|
||||
if(cpuwon >= 10) ++i;
|
||||
mvprintw(2,(80-i)/2,"%s: %d Computer: %d",name,plywon,cpuwon);
|
||||
|
||||
prompt();
|
||||
printw((awinna()) ? "Want to be humiliated again, %s? "
|
||||
: "Going to give me a chance for revenge, %s? ",name);
|
||||
return(sgetc("YN") == 'Y');
|
||||
}
|
||||
|
||||
void
|
||||
uninitgame(int sig)
|
||||
{
|
||||
refresh();
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int
|
||||
sgetc(s)
|
||||
char *s;
|
||||
{
|
||||
char *s1;
|
||||
int ch;
|
||||
|
||||
refresh();
|
||||
for (;;) {
|
||||
ch = toupper(getch());
|
||||
for (s1 = s; *s1 && ch != *s1; ++s1);
|
||||
if (*s1) {
|
||||
addch(ch);
|
||||
refresh();
|
||||
return(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* I should use getopts() from libc.a, but I'm leary that other UNIX
|
||||
* systems might not have it, although I'd love to use it.
|
||||
*/
|
||||
|
||||
int
|
||||
do_options(c,op)
|
||||
int c;
|
||||
char *op[];
|
||||
{
|
||||
register int i;
|
||||
|
||||
if (c > 1) {
|
||||
for (i=1; i<c; i++) {
|
||||
switch(op[i][0]) {
|
||||
default:
|
||||
case '?':
|
||||
fprintf(stderr, "Usage: battle [ -s | -b ] [ -a ] [ -m ]\n");
|
||||
fprintf(stderr, "\tWhere the options are:\n");
|
||||
fprintf(stderr, "\t-s : play a salvo game (mutex with -b)\n");
|
||||
fprintf(stderr, "\t-b : play a blitz game (mutex with -s)\n");
|
||||
fprintf(stderr, "\t-a : computer asks you for hit/miss\n");
|
||||
fprintf(stderr, "\t-m : computer misses are displayed\n");
|
||||
exit(1);
|
||||
break;
|
||||
case '-':
|
||||
switch(op[i][1]) {
|
||||
case 'b':
|
||||
blitz = 1;
|
||||
if (salvo == 1) {
|
||||
fprintf(stderr,
|
||||
"Bad Arg: -b and -s are mutually exclusive\n");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
salvo = 1;
|
||||
if (blitz == 1) {
|
||||
fprintf(stderr,
|
||||
"Bad Arg: -s and -b are mutually exclusive\n");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'a':
|
||||
ask = 1;
|
||||
break;
|
||||
case 'm':
|
||||
seemiss = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"Bad Arg: type \"%s ?\" for usage message\n", op[0]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(stdout, "Playing optional game (");
|
||||
if (salvo)
|
||||
fprintf(stdout, "salvo, noblitz, ");
|
||||
else if (blitz)
|
||||
fprintf(stdout, "blitz, nosalvo, ");
|
||||
else
|
||||
fprintf(stdout, "noblitz, nosalvo, ");
|
||||
|
||||
if (ask)
|
||||
fprintf(stdout, "ask, ");
|
||||
else
|
||||
fprintf(stdout, "noask, ");
|
||||
|
||||
if (seemiss)
|
||||
fprintf(stdout, "seemiss)\n");
|
||||
else
|
||||
fprintf(stdout, "noseemiss)\n");
|
||||
}
|
||||
else
|
||||
fprintf(stdout,
|
||||
"Playing standard game (no blitz, no slavo, no ask, no seemiss)\n");
|
||||
sleep(2);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
scount(who)
|
||||
int who;
|
||||
{
|
||||
int i, shots;
|
||||
struct _ships *sp;
|
||||
|
||||
if (who) {
|
||||
/* count cpu shots */
|
||||
sp = cpuship;
|
||||
} else {
|
||||
/* count player shots */
|
||||
sp = plyship;
|
||||
}
|
||||
for (i=0, shots = 0; i<5; i++, sp++) {
|
||||
/* extra test for machines with unsigned chars! */
|
||||
if (sp->hits == (char) -1 || sp->hits >= sp->length) {
|
||||
continue; /* dead ship */
|
||||
} else {
|
||||
shots++;
|
||||
}
|
||||
}
|
||||
return(shots);
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
main()
|
||||
{
|
||||
WINDOW *win1, *win2;
|
||||
int h, i;
|
||||
|
||||
initscr();
|
||||
cbreak();
|
||||
noecho();
|
||||
win1 = newwin(20, 50, 0, 20);
|
||||
for (h = 0; h < 20; h++)
|
||||
for (i = 0; i < 50; i++)
|
||||
mvwaddch(win1, h, i, 'X');
|
||||
wrefresh(win1);
|
||||
getch();
|
||||
|
||||
win2 = newwin(20, 50, 3, 30);
|
||||
for (h = 0; h < 20; h++)
|
||||
for (i = 0; i < 50; i++)
|
||||
mvwaddch(win2, h, i, 'Y');
|
||||
wnoutrefresh(win1);
|
||||
wnoutrefresh(win2);
|
||||
doupdate();
|
||||
getch();
|
||||
|
||||
/* now, remove window 2 and restore the contents of window 1 */
|
||||
i = copywin(win1, win2, 5, 10, 0, 0, 14, 39, 0);
|
||||
wnoutrefresh(win1);
|
||||
wnoutrefresh(win2);
|
||||
printw("copywin returns %d\n", i);
|
||||
wnoutrefresh(stdscr);
|
||||
doupdate();
|
||||
|
||||
getch();
|
||||
|
||||
endwin();
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int i, j;
|
||||
|
||||
initscr();
|
||||
|
||||
for (i = 0; i < LINES; i++) {
|
||||
j = mvaddch(i, COLS - 1, 'A' + i);
|
||||
}
|
||||
refresh();
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
||||
|
@ -1,52 +0,0 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
main()
|
||||
{
|
||||
int i;
|
||||
WINDOW *win;
|
||||
|
||||
initscr();
|
||||
noecho();
|
||||
nonl();
|
||||
cbreak();
|
||||
|
||||
scrollok(stdscr, TRUE);
|
||||
|
||||
for (i=0; i<25; i++)
|
||||
printw("This is in the background, this should be left alone!\n");
|
||||
|
||||
refresh();
|
||||
win=newwin(10,50,6,20);
|
||||
scrollok(win,TRUE);
|
||||
wmove(win,0,0);
|
||||
whline(win,0,49);
|
||||
wmove(win,9,0);
|
||||
whline(win,0,49);
|
||||
wrefresh(win);
|
||||
wattrset(win,A_STANDOUT);
|
||||
mvwprintw(win, 0, 14, " Scrolling Demo! ");
|
||||
mvwprintw(win, 9, 14, " Scrolling Demo! ");
|
||||
wattroff(win,A_STANDOUT);
|
||||
wsetscrreg(win, 1,8);
|
||||
|
||||
mvwprintw(win, 0, 5, " DOWN ");
|
||||
wmove(win,1,0);
|
||||
wrefresh(win);
|
||||
|
||||
getch();
|
||||
for (i=0; i<25; i++){ wprintw(win, "This is window line test (%d).\n", i);
|
||||
if (i%2) wattrset(win,A_BOLD); else wattroff(win,A_BOLD);
|
||||
wrefresh(win); }
|
||||
|
||||
mvwprintw(win, 0, 5, " UP ");
|
||||
wrefresh(win);
|
||||
getch();
|
||||
for (i=0; i<25; i++) { wmove(win,1,0); winsertln(win);
|
||||
if (i%2) wattrset(win,A_BOLD); else wattroff(win,A_BOLD);
|
||||
wprintw(win, "Scrolling backwards! (%d)\n", i); wrefresh(win); }
|
||||
|
||||
mvwprintw(win, 0, 5, " DONE "); wrefresh(win);
|
||||
|
||||
endwin();
|
||||
}
|
||||
|
@ -1,113 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <ncurses.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
void explode();
|
||||
|
||||
int main()
|
||||
{
|
||||
int start,end,row,diff,flag,direction,seed;
|
||||
|
||||
initscr();
|
||||
if (has_colors())
|
||||
start_color();
|
||||
seed = time((time_t *)0);
|
||||
srand(seed);
|
||||
cbreak();
|
||||
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++) {
|
||||
refresh();
|
||||
erase();
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
if (flag++) {
|
||||
refresh();
|
||||
flag = 0;
|
||||
}
|
||||
seed = time((time_t *)0);
|
||||
srand(seed);
|
||||
explode(LINES-row,start+(diff*direction));
|
||||
erase();
|
||||
refresh();
|
||||
}
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void explode(int row, int col)
|
||||
{
|
||||
erase();
|
||||
mvprintw(row,col,"-");
|
||||
refresh();
|
||||
|
||||
init_pair(1,get_colour(),COLOR_BLACK);
|
||||
attrset(COLOR_PAIR(1));
|
||||
mvprintw(row-1,col-1," - ");
|
||||
mvprintw(row,col-1,"-+-");
|
||||
mvprintw(row+1,col-1," - ");
|
||||
refresh();
|
||||
|
||||
init_pair(1,get_colour(),COLOR_BLACK);
|
||||
attrset(COLOR_PAIR(1));
|
||||
mvprintw(row-2,col-2," --- ");
|
||||
mvprintw(row-1,col-2,"-+++-");
|
||||
mvprintw(row, col-2,"-+#+-");
|
||||
mvprintw(row+1,col-2,"-+++-");
|
||||
mvprintw(row+2,col-2," --- ");
|
||||
refresh();
|
||||
|
||||
init_pair(1,get_colour(),COLOR_BLACK);
|
||||
attrset(COLOR_PAIR(1));
|
||||
mvprintw(row-2,col-2," +++ ");
|
||||
mvprintw(row-1,col-2,"++#++");
|
||||
mvprintw(row, col-2,"+# #+");
|
||||
mvprintw(row+1,col-2,"++#++");
|
||||
mvprintw(row+2,col-2," +++ ");
|
||||
refresh();
|
||||
|
||||
init_pair(1,get_colour(),COLOR_BLACK);
|
||||
attrset(COLOR_PAIR(1));
|
||||
mvprintw(row-2,col-2," # ");
|
||||
mvprintw(row-1,col-2,"## ##");
|
||||
mvprintw(row, col-2,"# #");
|
||||
mvprintw(row+1,col-2,"## ##");
|
||||
mvprintw(row+2,col-2," # ");
|
||||
refresh();
|
||||
|
||||
init_pair(1,get_colour(),COLOR_BLACK);
|
||||
attrset(COLOR_PAIR(1));
|
||||
mvprintw(row-2,col-2," # # ");
|
||||
mvprintw(row-1,col-2,"# #");
|
||||
mvprintw(row, col-2," ");
|
||||
mvprintw(row+1,col-2,"# #");
|
||||
mvprintw(row+2,col-2," # # ");
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
int get_colour()
|
||||
{
|
||||
int attr;
|
||||
attr = (rand() % 16)+1;
|
||||
if (attr == 1 || attr == 9)
|
||||
attr = COLOR_RED;
|
||||
if (attr > 8)
|
||||
attr |= A_BOLD;
|
||||
return(attr);
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
main()
|
||||
{
|
||||
int c,i;
|
||||
initscr();
|
||||
cbreak();
|
||||
noecho();
|
||||
#if 1
|
||||
wtimeout(stdscr,1000);
|
||||
#endif
|
||||
scrollok(stdscr,TRUE);
|
||||
for (c='A';c<='Z';c++)
|
||||
for (i=0;i<25;i++)
|
||||
{
|
||||
move(i,i);
|
||||
addch(c);
|
||||
refresh();
|
||||
}
|
||||
move (0,0);
|
||||
while ((c=wgetch(stdscr))!='A')
|
||||
{
|
||||
if (c == EOF) printw(">>wait for keypress<<");
|
||||
else printw(">>%c<<\n",c);
|
||||
refresh();
|
||||
}
|
||||
endwin();
|
||||
}
|
||||
|
@ -1,275 +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).
|
||||
*
|
||||
* Date: 05.Nov.90
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ncurses.h>
|
||||
|
||||
#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 {
|
||||
int Length[MAXTILES];
|
||||
int Count;
|
||||
};
|
||||
|
||||
struct Peg Pegs[NPEGS];
|
||||
int PegPos[] = { LEFTPEG, MIDPEG, RIGHTPEG };
|
||||
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 */
|
||||
};
|
||||
int NMoves = 0;
|
||||
|
||||
static unsigned char AutoFlag;
|
||||
|
||||
void InitTiles(), DisplayTiles(), MakeMove(), AutoMove(), Usage();
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int NTiles, FromCol, ToCol;
|
||||
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (strcmp(argv[2], "a")) {
|
||||
Usage();
|
||||
exit(1);
|
||||
}
|
||||
NTiles = atoi(argv[1]);
|
||||
if (NTiles > MAXTILES || NTiles < MINTILES) {
|
||||
fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
|
||||
exit(1);
|
||||
}
|
||||
AutoFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
Usage();
|
||||
exit(1);
|
||||
}
|
||||
initscr();
|
||||
if (!has_colors()) {
|
||||
puts("terminal doesn't support color.");
|
||||
exit(1);
|
||||
}
|
||||
start_color();
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 9; i++)
|
||||
init_pair(i+1, COLOR_BLACK, TileColour[i]);
|
||||
}
|
||||
cbreak();
|
||||
if (LINES < 24) {
|
||||
fprintf(stderr, "Min screen length 24 lines\n");
|
||||
endwin();
|
||||
exit(1);
|
||||
}
|
||||
if(AutoFlag)
|
||||
leaveok(stdscr, TRUE); /* Attempt to remove cursor */
|
||||
InitTiles(NTiles);
|
||||
DisplayTiles();
|
||||
if(AutoFlag) {
|
||||
do {
|
||||
noecho();
|
||||
AutoMove(0, 2, NTiles);
|
||||
} while(!Solved(NTiles));
|
||||
sleep(2);
|
||||
} else {
|
||||
for(;;) {
|
||||
if(GetMove(&FromCol, &ToCol))
|
||||
break;
|
||||
if (AutoFlag) {
|
||||
AutoMove(0, 2, NTiles);
|
||||
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();
|
||||
}
|
||||
|
||||
int
|
||||
InvalidMove(int From, int To)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#define gc() {noecho();getch();echo();}
|
||||
|
||||
void
|
||||
DisplayTiles()
|
||||
{
|
||||
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);
|
||||
standout();
|
||||
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');
|
||||
standend();
|
||||
|
||||
/* 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';
|
||||
attrset(COLOR_PAIR(LENTOIND(Pegs[Peg].Length[SlotNo])));
|
||||
mvaddstr(BASELINE-(SlotNo+1),
|
||||
PegPos[Peg]-Pegs[Peg].Length[SlotNo]/2, TileBuf);
|
||||
}
|
||||
}
|
||||
attrset(A_NORMAL);
|
||||
refresh();
|
||||
}
|
||||
|
||||
int
|
||||
GetMove(int *From, int *To)
|
||||
{
|
||||
mvaddstr(STATUSLINE, 0, "Next move ('q' to quit) from ");
|
||||
clrtoeol();
|
||||
refresh();
|
||||
if((*From = getch()) == 'q')
|
||||
return TRUE;
|
||||
else if (*From == 'a') {
|
||||
AutoFlag = TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
*From -= ('0'+1);
|
||||
addstr(" to ");
|
||||
clrtoeol();
|
||||
refresh();
|
||||
if((*To = getch()) == 'q')
|
||||
return TRUE;
|
||||
*To -= ('0'+1);
|
||||
move(STATUSLINE, 0);
|
||||
clrtoeol();
|
||||
refresh();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
void
|
||||
AutoMove(int From, int To, int Num)
|
||||
{
|
||||
|
||||
if(Num == 1) {
|
||||
MakeMove(From, To);
|
||||
return;
|
||||
}
|
||||
AutoMove(From, OTHER(From, To), Num-1);
|
||||
MakeMove(From, To);
|
||||
AutoMove(OTHER(From, To), To, Num-1);
|
||||
}
|
||||
|
||||
int
|
||||
Solved(int NumTiles)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 1; i < NPEGS; i++)
|
||||
if (Pegs[i].Count == NumTiles)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
Usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: hanoi [<No Of Tiles>] [a]\n");
|
||||
fprintf(stderr, "The 'a' option causes the tower to be solved automatically\n");
|
||||
}
|
||||
|
@ -1,320 +0,0 @@
|
||||
/* Knights Tour - a brain game */
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <signal.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#define srand48 srandom
|
||||
#define lrand48 random
|
||||
#endif
|
||||
|
||||
short board [64]; /* the squares */
|
||||
char row, column; /* input characters */
|
||||
int rw,col; /* numeric equivalent of row and column */
|
||||
int curow,curcol; /* current row and column integers */
|
||||
int rdif, cdif; /* difference between input and current */
|
||||
int j; /* index into board */
|
||||
|
||||
char script[]={"'_)//,/(-)/__/__(_<_(__),|/|/_///_/_<//_/_)__o__o'______///_(--_(_)___,(_/,_/__(_\0"};
|
||||
|
||||
int ypos[] ={1,0,1,2,3,0,1,2,2,3,3,2,2,3,2,2,3,3,3,3,3,2,3,3,2,4,5,5,
|
||||
4,3,3,2,1,2,3,3,3,2,1,3,3,2,3,3,3,2,1,1,0,1,4,4,4,4,4,4,5,6,7,7,
|
||||
7,6,6,6,7,7,7,6,6,6,6,7,7,7,6,7,7,6,6,7,7};
|
||||
|
||||
int xpos[]={0,1,2,1,0,5,4,3,2,4,6,7,8,8,9,10,10,11,12,13,14,15,15,16,
|
||||
16,16,15,14,15,17,18,19,20,20,20,21,22,23,24,23,25,26,27,26,28,
|
||||
13,23,25,27,27,2,3,4,5,6,7,4,3,2,1,0,1,2,5,4,5,6,6,7,8,9,8,9,10,
|
||||
11,11,12,13,14,14,15};
|
||||
|
||||
static char *instructions[] =
|
||||
{
|
||||
" Knight's Tour is a board game for one player. It is played on",
|
||||
"an eight by eight board and is based on the allowable moves that a knight",
|
||||
"can make in the game of chess. For those who are unfamiliar with the",
|
||||
"game, a knight may move either on a row or a column but not diagonally.",
|
||||
"He may move one square in any direction and two squares in a perpendicular",
|
||||
"direction >or< two squares in any direction and one square in a",
|
||||
"perpendicular direction. He may not, of course, move off the board.",
|
||||
"",
|
||||
" At the beginning of a game you will be asked to either choose a",
|
||||
"starting square or allow the computer to select a random location.",
|
||||
"Squares are designated by a letter-number combination where the row is",
|
||||
"specified by a letter A-H and the numbers 1-8 define a column. Invalid",
|
||||
"entries are ignored and illegal moves produce a beep at the terminal.",
|
||||
"",
|
||||
" The objective is to visit every square on the board. When you claim",
|
||||
"a square a marker is placed on it to show where you've been. You may",
|
||||
"not revisit a square that you've landed on before.",
|
||||
"",
|
||||
" After each move the program checks to see if you have any legal",
|
||||
"moves left. If not, the game ends and your squares are counted. If",
|
||||
"you've made all the squares you win the game. Otherwise, you are told",
|
||||
"the number of squares you did make.",
|
||||
"END"
|
||||
};
|
||||
|
||||
void init(void);
|
||||
int play(void);
|
||||
void drawboard(void);
|
||||
void dosquares(void);
|
||||
void getfirst(void);
|
||||
void getrc(void);
|
||||
void putstars(void);
|
||||
int evalmove(void);
|
||||
int chkmoves(void);
|
||||
int endgame(void);
|
||||
int chksqr(int, int);
|
||||
void instruct(void);
|
||||
void title(int, int);
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
init ();
|
||||
for (;;)
|
||||
if (!play ()) {
|
||||
endwin ();
|
||||
exit (0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
init ()
|
||||
{
|
||||
|
||||
srand48 (getpid());
|
||||
initscr ();
|
||||
cbreak (); /* immediate char return */
|
||||
noecho (); /* no immediate echo */
|
||||
title (1,23);
|
||||
mvaddstr (23, 25, "Would you like instructions? ");
|
||||
refresh();
|
||||
if ((toupper(getch())) == 'Y')
|
||||
instruct();
|
||||
clear ();
|
||||
}
|
||||
|
||||
int
|
||||
play ()
|
||||
{
|
||||
drawboard (); /* clear screen and drawboard */
|
||||
for (j = 0; j < 64; j++) board[j]=0;
|
||||
getfirst (); /* get the starting square */
|
||||
for (;;) {
|
||||
getrc();
|
||||
if (evalmove()) {
|
||||
putstars ();
|
||||
if (!chkmoves())
|
||||
return (endgame ());
|
||||
}
|
||||
else beep();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
drawboard ()
|
||||
{
|
||||
erase ();
|
||||
dosquares ();
|
||||
refresh ();
|
||||
mvaddstr (0, 7, "1 2 3 4 5 6 7 8");
|
||||
for (j = 0; j < 8; j++) mvaddch (2*j+2, 3, j + 'A');
|
||||
refresh ();
|
||||
mvaddstr (20, 5, "ROW:");
|
||||
mvaddstr (20, 27, "COLUMN:");
|
||||
mvaddstr (14, 49, "CURRENT ROW");
|
||||
mvaddstr (16, 49, "CURRENT COL");
|
||||
mvaddstr (22, 5, "A - H or Q to quit");
|
||||
mvaddstr (22, 27, "1 - 8 or ESC to cancel row");
|
||||
refresh ();
|
||||
title (1,40);
|
||||
}
|
||||
|
||||
void
|
||||
dosquares ()
|
||||
{
|
||||
mvaddstr (1, 6, "-------------------------------");
|
||||
for (j = 1; j < 9; j++){
|
||||
mvaddstr (2*j, 5, "| | | | | | | | |");
|
||||
mvaddstr (2*j+1, 6, "-------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
getfirst () /* get first square */
|
||||
{
|
||||
mvaddstr (23, 25, "(S)elect or (R)andom "); refresh ();
|
||||
do {
|
||||
row = toupper(getch());
|
||||
} while ((row != 'S') && (row != 'R'));
|
||||
if (row == 'R') {
|
||||
rw = lrand48() % 8;
|
||||
col = lrand48() % 8;
|
||||
j = 8* rw + col;
|
||||
row = rw + 'A';
|
||||
column = col + '1';
|
||||
}
|
||||
else {
|
||||
mvaddstr (23, 25, "Enter starting row and column");
|
||||
refresh ();
|
||||
getrc(); /* get row and column */
|
||||
}
|
||||
putstars ();
|
||||
move (23, 0);
|
||||
clrtobot();
|
||||
}
|
||||
|
||||
void
|
||||
getrc () /* get row and column */
|
||||
{
|
||||
noecho ();
|
||||
do {
|
||||
mvaddstr (20, 35, " ");
|
||||
refresh ();
|
||||
do {
|
||||
mvaddch (20, 11, ' ');
|
||||
move (20, 11);
|
||||
refresh ();
|
||||
row=toupper(getch());
|
||||
if (row == 'Q') {
|
||||
endwin ();
|
||||
exit (1);
|
||||
}
|
||||
} while ((row < 'A') || (row > 'H'));
|
||||
addch (row);
|
||||
move (20, 35);
|
||||
refresh ();
|
||||
do {
|
||||
column=getch();
|
||||
if (column == '\033') break;
|
||||
} while ((column < '1') || (column > '8'));
|
||||
if (column != '\033') addch (column);
|
||||
} while (column == '\033');
|
||||
refresh();
|
||||
rw = row - 'A';
|
||||
col= column - '1';
|
||||
j = 8 * rw + col;
|
||||
}
|
||||
|
||||
void
|
||||
putstars () /* place the stars, update board & currents */
|
||||
{
|
||||
mvaddch (2*curow+2, 38, ' ');
|
||||
mvaddch (2*rw+2, 38, '<');
|
||||
mvaddch (18, curcol*4+7, ' ');
|
||||
mvaddch (18, col*4+7, '^');
|
||||
curow = rw;
|
||||
curcol= col;
|
||||
mvaddstr (2 * rw + 2, 4*col+6, "***");
|
||||
mvaddch (14, 61, row);
|
||||
mvaddch (16, 61, column);
|
||||
refresh ();
|
||||
board[j] = 1;
|
||||
}
|
||||
|
||||
int
|
||||
evalmove() /* convert row and column to integers */
|
||||
/* and evaluate move */
|
||||
{
|
||||
rdif = rw - curow;
|
||||
cdif = col - curcol;
|
||||
rdif = abs(rw - curow);
|
||||
cdif = abs(col - curcol);
|
||||
refresh ();
|
||||
if ((rdif == 1) && (cdif == 2)) if (board [j] == 0) return (1);
|
||||
if ((rdif == 2) && (cdif == 1)) if (board [j] == 0) return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
chkmoves () /* check to see if valid moves are available */
|
||||
{
|
||||
if (chksqr(2,1)) return (1);
|
||||
if (chksqr(2,-1)) return (1);
|
||||
if (chksqr(-2,1)) return (1);
|
||||
if (chksqr(-2,-1)) return (1);
|
||||
if (chksqr(1,2)) return (1);
|
||||
if (chksqr(1,-2)) return (1);
|
||||
if (chksqr(-1,2)) return (1);
|
||||
if (chksqr(-1,-2)) return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
endgame () /* check for filled board or not */
|
||||
{
|
||||
rw = 0;
|
||||
for (j = 0; j < 64; j++) if (board[j] != 0) rw+=1;
|
||||
if (rw == 64) mvaddstr (20, 20, "Congratulations !! You got 'em all");
|
||||
else mvprintw (20, 20, "You have ended up with %2d squares",rw);
|
||||
mvaddstr (21, 25, "Play again ? (y/n) ");
|
||||
refresh ();
|
||||
if ((row=tolower(getch())) == 'y') return (1);
|
||||
else return (0);
|
||||
}
|
||||
|
||||
#ifndef abs
|
||||
abs(num)
|
||||
int num;
|
||||
{
|
||||
if (num < 0) return (-num);
|
||||
else return (num);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
chksqr (int n1, int n2)
|
||||
{
|
||||
int r1, c1;
|
||||
|
||||
r1 = rw + n1;
|
||||
c1 = col + n2;
|
||||
if ((r1<0) || (r1>7)) return (0);
|
||||
if ((c1<0) || (c1>7)) return (0);
|
||||
if (board[r1*8+c1] == 0) return (1);
|
||||
else return (0);
|
||||
}
|
||||
|
||||
void
|
||||
instruct()
|
||||
{
|
||||
int i;
|
||||
|
||||
clear ();
|
||||
for (i=0;;i++) {
|
||||
if ((strcmp(instructions[i],"END"))) mvaddstr (i, 0, instructions[i]);
|
||||
else {
|
||||
mvaddstr (23, 25, "Ready to play ? (y/n) ");
|
||||
refresh();
|
||||
if (toupper(getch()) == 'Y') {
|
||||
clear ();
|
||||
return;
|
||||
} else {
|
||||
clear ();
|
||||
refresh ();
|
||||
endwin ();
|
||||
exit (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
title (y,x)
|
||||
int y,x;
|
||||
{
|
||||
char c;
|
||||
|
||||
j = 0;
|
||||
do {
|
||||
c = script[j];
|
||||
if (c == 0) break ;
|
||||
mvaddch (ypos[j]+y, xpos[j]+x, c);
|
||||
j++;
|
||||
} while (c != 0);
|
||||
refresh ();
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,350 +0,0 @@
|
||||
/* $FreeBSD$
|
||||
*
|
||||
* newdemo.c - A demo program using PDCurses. The program illustrate
|
||||
* the use of colours for text output.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <ncurses.h>
|
||||
|
||||
#define delay_output(x)
|
||||
|
||||
/*
|
||||
* The Australian map
|
||||
*/
|
||||
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
|
||||
|
||||
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",
|
||||
""
|
||||
};
|
||||
|
||||
/*
|
||||
* Main driver
|
||||
*/
|
||||
main()
|
||||
{
|
||||
WINDOW *win;
|
||||
int w, x, y, i, j, c, len;
|
||||
time_t t;
|
||||
char buffer[80], *message;
|
||||
int width, height;
|
||||
chtype save[80];
|
||||
void trap();
|
||||
|
||||
initscr();
|
||||
start_color();
|
||||
cbreak();
|
||||
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();
|
||||
return 1;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{ init_pair(1,COLOR_WHITE,COLOR_BLUE);
|
||||
wattrset(win, COLOR_PAIR(1));
|
||||
werase(win);
|
||||
|
||||
init_pair(2,COLOR_RED,COLOR_RED);
|
||||
wattrset(win, COLOR_PAIR(2));
|
||||
box(win, ACS_VLINE, ACS_HLINE);
|
||||
wrefresh(win);
|
||||
/* Do ramdom output of a character */
|
||||
wattrset(win, COLOR_PAIR(1));
|
||||
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';
|
||||
init_pair(3,COLOR_CYAN,COLOR_YELLOW);
|
||||
wattron(win, COLOR_PAIR(3));
|
||||
}
|
||||
}
|
||||
|
||||
SubWinTest(win);
|
||||
/* Erase and draw green window */
|
||||
init_pair(4,COLOR_YELLOW,COLOR_GREEN);
|
||||
wattrset(win, COLOR_PAIR(4) | A_BOLD);
|
||||
werase(win);
|
||||
wrefresh(win);
|
||||
/* Draw RED bounding box */
|
||||
wattrset(win, COLOR_PAIR(2));
|
||||
box(win, ' ', ' ');
|
||||
wrefresh(win);
|
||||
/* Display Australia map */
|
||||
wattrset(win, COLOR_PAIR(4) | A_BOLD);
|
||||
i = 0;
|
||||
while(*AusMap[i])
|
||||
{ mvwaddstr(win, i+1, 8, AusMap[i]);
|
||||
wrefresh(win);
|
||||
delay_output(100);
|
||||
++i;
|
||||
}
|
||||
|
||||
init_pair(5,COLOR_BLUE,COLOR_WHITE);
|
||||
wattrset(win, COLOR_PAIR(5) | A_BLINK);
|
||||
mvwaddstr(win, height-2, 6, " PDCurses 2.1 for DOS, OS/2 and Unix");
|
||||
wrefresh(win);
|
||||
|
||||
/* Draw running messages */
|
||||
init_pair(6,COLOR_YELLOW,COLOR_WHITE);
|
||||
wattrset(win, COLOR_PAIR(6));
|
||||
message = messages[0];
|
||||
len = strlen(message);
|
||||
j = 0;
|
||||
i = 2;
|
||||
w = width-2;
|
||||
while(j < NMESSAGES)
|
||||
{ strncpy(buffer, message, w - i);
|
||||
buffer[w-i] = 0;
|
||||
mvwaddstr(win, height/2, i, buffer);
|
||||
if(w - i < len)
|
||||
{ memset(buffer, ' ', i);
|
||||
strcpy(buffer, message + (w - i));
|
||||
buffer[strlen(buffer)] = ' ';
|
||||
buffer[i-2] = '\0';
|
||||
mvwaddstr(win, height/2, 2, buffer);
|
||||
}
|
||||
wrefresh(win);
|
||||
nodelay(win,TRUE);
|
||||
if (wgetch(win) != ERR)
|
||||
{ flushinp();
|
||||
break;
|
||||
}
|
||||
mvwaddch(win, height/2, i, ' ');
|
||||
i = ++i % w;
|
||||
if(i < 2)
|
||||
{ message = messages[++j%NMESSAGES];
|
||||
memset(buffer, ' ', w-2);
|
||||
buffer[w-2] = 0;
|
||||
mvwaddstr(win, height/2, 2, buffer);
|
||||
i = 2;
|
||||
}
|
||||
delay_output(300);
|
||||
}
|
||||
|
||||
j = 0;
|
||||
/* Draw running As across in RED */
|
||||
init_pair(7,COLOR_RED,COLOR_GREEN);
|
||||
wattron(win, COLOR_PAIR(7));
|
||||
for(i=2; i < width - 4; ++i)
|
||||
{ c = mvwinch(win, 4, i);
|
||||
save[j++] = c;
|
||||
c = c & 0x7f;
|
||||
mvwaddch(win, 4, i, c);
|
||||
}
|
||||
wrefresh(win);
|
||||
|
||||
/* Put a message up wait for a key */
|
||||
i = height-2;
|
||||
wattrset(win, COLOR_PAIR(5));
|
||||
mvwaddstr(win, i, 5, " Type a key to continue or 'Q' to quit ");
|
||||
wrefresh(win);
|
||||
|
||||
if(WaitForUser() == 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;
|
||||
wattrset(win, COLOR_PAIR(5));
|
||||
mvwaddstr(win, i, 5, " Type a key to continue or 'Q' to quit ");
|
||||
wrefresh(win);
|
||||
if(WaitForUser() == 1)
|
||||
break;
|
||||
}
|
||||
exit:
|
||||
endwin();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test sub windows
|
||||
*/
|
||||
SubWinTest(WINDOW *win)
|
||||
{
|
||||
int w, h, sw, sh, bx, by;
|
||||
WINDOW *swin1, *swin2, *swin3;
|
||||
|
||||
w = win->_maxx;
|
||||
h = win->_maxy;
|
||||
bx = win->_begx;
|
||||
by = win->_begy;
|
||||
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;
|
||||
|
||||
init_pair(8,COLOR_RED,COLOR_BLUE);
|
||||
wattrset(swin1, COLOR_PAIR(8));
|
||||
werase(swin1);
|
||||
mvwaddstr(swin1, 0, 3, "Sub-window 1");
|
||||
wrefresh(swin1);
|
||||
|
||||
init_pair(8,COLOR_CYAN,COLOR_MAGENTA);
|
||||
wattrset(swin2, COLOR_PAIR(8));
|
||||
werase(swin2);
|
||||
mvwaddstr(swin2, 0, 3, "Sub-window 2");
|
||||
wrefresh(swin2);
|
||||
|
||||
init_pair(8,COLOR_YELLOW,COLOR_GREEN);
|
||||
wattrset(swin3, COLOR_PAIR(8));
|
||||
werase(swin3);
|
||||
mvwaddstr(swin3, 0, 3, "Sub-window 3");
|
||||
wrefresh(swin3);
|
||||
|
||||
delwin(swin1);
|
||||
delwin(swin2);
|
||||
delwin(swin3);
|
||||
WaitForUser();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Bouncing balls
|
||||
*/
|
||||
BouncingBalls(WINDOW *win)
|
||||
{
|
||||
chtype c1, c2, c3;
|
||||
int w, h;
|
||||
int x1, y1, xd1, yd1;
|
||||
int x2, y2, xd2, yd2;
|
||||
int x3, y3, xd3, yd3;
|
||||
|
||||
w = win->_maxx;
|
||||
h = win->_maxy;
|
||||
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 = xd1 > 0 ? ++x1 : --x1;
|
||||
if(x1 <= 1 || x1 >= w - 2)
|
||||
xd1 = xd1 ? 0 : 1;
|
||||
y1 = yd1 > 0 ? ++y1 : --y1;
|
||||
if(y1 <= 1 || y1 >= h - 2)
|
||||
yd1 = yd1 ? 0 : 1;
|
||||
|
||||
x2 = xd2 > 0 ? ++x2 : --x2;
|
||||
if(x2 <= 1 || x2 >= w - 2)
|
||||
xd2 = xd2 ? 0 : 1;
|
||||
y2 = yd2 > 0 ? ++y2 : --y2;
|
||||
if(y2 <= 1 || y2 >= h - 2)
|
||||
yd2 = yd2 ? 0 : 1;
|
||||
|
||||
x3 = xd3 > 0 ? ++x3 : --x3;
|
||||
if(x3 <= 1 || x3 >= w - 2)
|
||||
xd3 = xd3 ? 0 : 1;
|
||||
y3 = yd3 > 0 ? ++y3 : --y3;
|
||||
if(y3 <= 1 || y3 >= h - 2)
|
||||
yd3 = yd3 ? 0 : 1;
|
||||
|
||||
c1 = mvwinch(win, y1, x1);
|
||||
c2 = mvwinch(win, y2, x2);
|
||||
c3 = mvwinch(win, y3, x3);
|
||||
|
||||
init_pair(8,COLOR_RED,COLOR_BLUE);
|
||||
wattrset(win, COLOR_PAIR(8));
|
||||
mvwaddch(win, y1, x1, 'O');
|
||||
init_pair(8,COLOR_BLUE,COLOR_RED);
|
||||
wattrset(win, COLOR_PAIR(8));
|
||||
mvwaddch(win, y2, x2, '*');
|
||||
init_pair(8,COLOR_YELLOW,COLOR_WHITE);
|
||||
wattrset(win, COLOR_PAIR(8));
|
||||
mvwaddch(win, y3, x3, '@');
|
||||
wmove(win, 0, 0);
|
||||
wrefresh(win);
|
||||
mvwaddch(win, y1, x1, c1);
|
||||
mvwaddch(win, y2, x2, c2);
|
||||
mvwaddch(win, y3, x3, c3);
|
||||
delay_output(150);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for user
|
||||
*/
|
||||
int WaitForUser()
|
||||
{
|
||||
time_t t;
|
||||
chtype key;
|
||||
|
||||
nodelay(stdscr,TRUE);
|
||||
t = time((time_t *)0);
|
||||
while(1)
|
||||
{
|
||||
if ((key = getch()) != ERR)
|
||||
{
|
||||
if (key == 'q' || key == 'Q')
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
if (time((time_t *)0) - t > 5)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Trap interrupt
|
||||
*/
|
||||
void trap()
|
||||
{
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* End of DEMO.C */
|
@ -1,120 +0,0 @@
|
||||
/*********************************************************************
|
||||
* [program] overwrite() - Play with overwrite() function to *
|
||||
* attempt pop-up windows. *
|
||||
* ----------------------------------------------------------------- *
|
||||
* [written] 1-Feb-1993 by Neal Ensor (ensor@cs.utk.edu) *
|
||||
* ----------------------------------------------------------------- *
|
||||
* [notes] Originally written on SVR4 UNIX, then recompiled on *
|
||||
* Linux (Slackware 1.1.1, ncurses 1.8.1) *
|
||||
* ----------------------------------------------------------------- *
|
||||
* [problem] On ncurses, the overwrite() function doesn't seem to *
|
||||
* overwrite. Maybe I'm missing something, but this *
|
||||
* program in SVR4 displays three windows, waits for a *
|
||||
* keypress, then removes the top window. With ncurses, *
|
||||
* nothing changes on the display. *
|
||||
*********************************************************************/
|
||||
|
||||
# include <ncurses.h> /* ncurses include lives here */
|
||||
|
||||
main()
|
||||
{
|
||||
/****************************************************************
|
||||
* Declare three little window pointers... *
|
||||
****************************************************************/
|
||||
WINDOW *win, *win1, *win2;
|
||||
|
||||
/****************************************************************
|
||||
* Set up the screen... *
|
||||
****************************************************************/
|
||||
initscr();
|
||||
/* traceon(); */
|
||||
noecho();
|
||||
nonl();
|
||||
cbreak();
|
||||
refresh();
|
||||
|
||||
/****************************************************************
|
||||
* Draw three overlapping windows. *
|
||||
****************************************************************/
|
||||
win=newwin(6,45, 6,6);
|
||||
win1=newwin(10,20,5,5);
|
||||
win2=newwin(10,30,7,7);
|
||||
|
||||
/****************************************************************
|
||||
* Box them, and print a hidden message... *
|
||||
****************************************************************/
|
||||
box(win, 0, 0);
|
||||
box(win1, 0, 0);
|
||||
box(win2, 0, 0);
|
||||
mvwprintw(win1, 6,6, "Hey!");
|
||||
mvwaddch(win, 1, 1, '0');
|
||||
mvwaddch(win1, 1, 1, '1');
|
||||
mvwaddch(win2, 1, 1, '2');
|
||||
wnoutrefresh(win);
|
||||
wnoutrefresh(win1);
|
||||
wnoutrefresh(win2);
|
||||
doupdate();
|
||||
|
||||
/****************************************************************
|
||||
* Await a keypress to show what we've done so far. *
|
||||
****************************************************************/
|
||||
getch();
|
||||
|
||||
/****************************************************************
|
||||
* Now, overwrite win2 with contents of all lower windows IN *
|
||||
* ORDER from the stdscr up... *
|
||||
****************************************************************/
|
||||
if (overwrite(stdscr, win2) == ERR)
|
||||
fprintf(stderr, "overwrite(stdscr, win2) failed!\n");
|
||||
|
||||
touchwin(stdscr); wnoutrefresh(stdscr);
|
||||
touchwin(win); wnoutrefresh(win);
|
||||
touchwin(win1); wnoutrefresh(win1);
|
||||
touchwin(win2); wnoutrefresh(win2);
|
||||
doupdate();
|
||||
|
||||
getch();
|
||||
if (overwrite(win, win2) == ERR)
|
||||
fprintf(stderr, "overwrite(win, win2) failed!\n");
|
||||
|
||||
touchwin(stdscr); wnoutrefresh(stdscr);
|
||||
touchwin(win); wnoutrefresh(win);
|
||||
touchwin(win1); wnoutrefresh(win1);
|
||||
touchwin(win2); wnoutrefresh(win2);
|
||||
doupdate();
|
||||
|
||||
getch();
|
||||
if (overwrite(win1, win2) == ERR)
|
||||
fprintf(stderr, "overwrite(win1, win2) failed!\n");
|
||||
|
||||
/****************************************************************
|
||||
* Perform touches, and hidden refreshes on each window. *
|
||||
* ------------------------------------------------------------ *
|
||||
* NOTE: If you replace the wnoutrefresh() call with wrefresh()*
|
||||
* you can see all windows being redrawn untouched. *
|
||||
****************************************************************/
|
||||
touchwin(stdscr); wnoutrefresh(stdscr);
|
||||
touchwin(win); wnoutrefresh(win);
|
||||
touchwin(win1); wnoutrefresh(win1);
|
||||
touchwin(win2); wnoutrefresh(win2);
|
||||
doupdate();
|
||||
|
||||
/****************************************************************
|
||||
* At this point, win2 should be "destroyed"; having all other *
|
||||
* window contents overwritten onto it. The doupdate() should *
|
||||
* effectively remove it from the screen, leaving the others *
|
||||
* untouched. On SVR4, this happens, but not with ncurses. *
|
||||
* I'd suspect something in overwrite() causes this, as nothing *
|
||||
* appears to be overwritten after the calls, with no errors *
|
||||
* being reported. This was compiled on my Linux from Slackware*
|
||||
* 1.1.1, with ncurses1.8.1 recompiled on it, using the console *
|
||||
* entry from the "new" terminfo from ncurses1.8.1. *
|
||||
****************************************************************/
|
||||
getch();
|
||||
|
||||
/****************************************************************
|
||||
* Clean up our act and exit. *
|
||||
****************************************************************/
|
||||
endwin();
|
||||
}
|
||||
|
@ -1,96 +0,0 @@
|
||||
#include <ncurses.h>
|
||||
#include <signal.h>
|
||||
/* rain 11/3/1980 EPS/CITHEP */
|
||||
|
||||
#define cursor(col,row) move(row,col)
|
||||
|
||||
float ranf();
|
||||
void onsig();
|
||||
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
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();
|
||||
nl();
|
||||
noecho();
|
||||
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;
|
||||
|
||||
cursor(x,y); addch('.');
|
||||
|
||||
cursor(xpos[j],ypos[j]); addch('o');
|
||||
|
||||
if (j==0) j=4; else --j;
|
||||
cursor(xpos[j],ypos[j]); addch('O');
|
||||
|
||||
if (j==0) j=4; else --j;
|
||||
cursor(xpos[j],ypos[j]-1);
|
||||
addch('-');
|
||||
cursor(xpos[j]-1,ypos[j]);
|
||||
addstr("|.|");
|
||||
cursor(xpos[j],ypos[j]+1);
|
||||
addch('-');
|
||||
|
||||
if (j==0) j=4; else --j;
|
||||
cursor(xpos[j],ypos[j]-2);
|
||||
addch('-');
|
||||
cursor(xpos[j]-1,ypos[j]-1);
|
||||
addstr("/ \\");
|
||||
cursor(xpos[j]-2,ypos[j]);
|
||||
addstr("| O |");
|
||||
cursor(xpos[j]-1,ypos[j]+1);
|
||||
addstr("\\ /");
|
||||
cursor(xpos[j],ypos[j]+2);
|
||||
addch('-');
|
||||
|
||||
if (j==0) j=4; else --j;
|
||||
cursor(xpos[j],ypos[j]-2);
|
||||
addch(' ');
|
||||
cursor(xpos[j]-1,ypos[j]-1);
|
||||
addstr(" ");
|
||||
cursor(xpos[j]-2,ypos[j]);
|
||||
addstr(" ");
|
||||
cursor(xpos[j]-1,ypos[j]+1);
|
||||
addstr(" ");
|
||||
cursor(xpos[j],ypos[j]+2);
|
||||
addch(' ');
|
||||
xpos[j]=x; ypos[j]=y;
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
onsig(n)
|
||||
int n;
|
||||
{
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
float
|
||||
ranf()
|
||||
{
|
||||
float rv;
|
||||
long r = rand();
|
||||
|
||||
r &= 077777;
|
||||
rv =((float)r/32767.);
|
||||
return rv;
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
main()
|
||||
{
|
||||
int i;
|
||||
|
||||
initscr();
|
||||
noecho();
|
||||
scrollok(stdscr, TRUE);
|
||||
setscrreg(0, 9);
|
||||
mvaddstr(0,0,"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
||||
mvaddstr(1,0,"bbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
|
||||
mvaddstr(2,0,"ccccccccccccccccccccccccccccc");
|
||||
mvaddstr(3,0,"ddddddddddddddddddddddddddddd");
|
||||
mvaddstr(4,0,"eeeeeeeeeeeeeeeeeeeeeeeeeeeee");
|
||||
mvaddstr(5,0,"fffffffffffffffffffffffffffff");
|
||||
mvaddstr(6,0,"ggggggggggggggggggggggggggggg");
|
||||
mvaddstr(7,0,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
|
||||
mvaddstr(8,0,"iiiiiiiiiiiiiiiiiiiiiiiiiiiii");
|
||||
mvaddstr(9,0,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
|
||||
refresh();
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scrl(-1);
|
||||
refresh();
|
||||
}
|
||||
getch();
|
||||
endwin();
|
||||
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
#include <ncurses.h>
|
||||
#define ROWS 20
|
||||
#define scroll_window wscrl
|
||||
|
||||
main()
|
||||
{
|
||||
int i;
|
||||
WINDOW * w;
|
||||
|
||||
|
||||
initscr();
|
||||
cbreak();
|
||||
noecho();
|
||||
w = newwin (ROWS, 35, 2, 25);
|
||||
scrollok(w, TRUE);
|
||||
wsetscrreg(w, 0, ROWS-1);
|
||||
|
||||
#ifdef LELE
|
||||
mvaddstr (0, 0, "With my function");
|
||||
#else
|
||||
mvaddstr (0, 0, "With the original wscrl");
|
||||
#endif
|
||||
refresh();
|
||||
|
||||
|
||||
for (i=0; i<ROWS-1; i++)
|
||||
{
|
||||
mvwprintw (w, i, 0, "Line number %d", i);
|
||||
}
|
||||
mvwaddstr (w, ROWS-1, 0, "Moving one line at a time");
|
||||
wrefresh(w);
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scroll_window (w, 1);
|
||||
wrefresh(w);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scroll_window (w, -1);
|
||||
wrefresh(w);
|
||||
}
|
||||
getch();
|
||||
wclear (w);
|
||||
|
||||
|
||||
for (i=0; i<ROWS-1; i++)
|
||||
{
|
||||
mvwprintw (w, i, 0, "Line number %d", i);
|
||||
}
|
||||
mvwaddstr (w, ROWS-1, 0, "Moving two line at a time");
|
||||
#ifndef LELE
|
||||
mvaddstr (0, 30, "** THIS FAILS ON MY MACHINE WITH A BUS ERROR
|
||||
**");
|
||||
#endif
|
||||
|
||||
|
||||
wrefresh(w);
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scroll_window (w, 2);
|
||||
wrefresh(w);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scroll_window (w, -2);
|
||||
wrefresh(w);
|
||||
}
|
||||
getch();
|
||||
wclear (w);
|
||||
for (i=0; i<ROWS-1; i++)
|
||||
{
|
||||
mvwprintw (w, i, 0, "Line number %d", i);
|
||||
}
|
||||
mvwaddstr (w, ROWS-1, 0, "Moving three line at a time");
|
||||
wrefresh(w);
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scroll_window (w, 3);
|
||||
wrefresh(w);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
getch();
|
||||
scroll_window (w, -3);
|
||||
wrefresh(w);
|
||||
}
|
||||
getch();
|
||||
|
||||
|
||||
endwin();
|
||||
}
|
||||
|
@ -1,51 +0,0 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
WINDOW *w, *x;
|
||||
|
||||
initscr();
|
||||
w = newwin(0, 0, 0, 0);
|
||||
if (argc > 2)
|
||||
x = newwin(0, 0, 0, 0);
|
||||
scrollok(w, TRUE);
|
||||
if (argc > 2)
|
||||
scrollok(x, TRUE);
|
||||
idlok(w, TRUE);
|
||||
if (argc > 2)
|
||||
idlok(x, TRUE);
|
||||
wmove(w, LINES - 1, 0);
|
||||
waddstr(w, "test 1 in w");
|
||||
wrefresh(w);
|
||||
sleep(1);
|
||||
if (argc == 2 || argc == 4)
|
||||
{
|
||||
waddch(w, '\n');
|
||||
sleep(1);
|
||||
waddch(w, '\n');
|
||||
sleep(1);
|
||||
waddch(w, '\n');
|
||||
sleep(1);
|
||||
beep();
|
||||
wrefresh(w);
|
||||
}
|
||||
sleep(1);
|
||||
if (argc > 2)
|
||||
{
|
||||
wmove(x, LINES - 1, 0);
|
||||
waddstr(x, "test 2 in x");
|
||||
sleep(1);
|
||||
waddch(x, '\n');
|
||||
sleep(1);
|
||||
waddch(x, '\n');
|
||||
sleep(1);
|
||||
waddch(x, '\n');
|
||||
sleep(1);
|
||||
beep();
|
||||
wrefresh(w);
|
||||
sleep(1);
|
||||
}
|
||||
endwin();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
|
||||
#include <ncurses.h>
|
||||
|
||||
main()
|
||||
{
|
||||
int x, y;
|
||||
|
||||
initscr();
|
||||
cbreak();
|
||||
nodelay(stdscr, TRUE);
|
||||
|
||||
for (y = 0; y < 43; y++)
|
||||
for (x =0; x < 132; x++) {
|
||||
move(y,x);
|
||||
printw("X");
|
||||
refresh();
|
||||
if (!getch()) {
|
||||
beep();
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
nocbreak();
|
||||
endwin();
|
||||
}
|
||||
|
||||
|
@ -1,532 +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)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ncurses.h>
|
||||
|
||||
#ifdef __STDC__
|
||||
void inputTest (WINDOW *);
|
||||
void scrollTest (WINDOW *);
|
||||
void introTest (WINDOW *);
|
||||
int initTest (WINDOW **);
|
||||
void outputTest (WINDOW *);
|
||||
void padTest (WINDOW *);
|
||||
void resizeTest (WINDOW *);
|
||||
void display_menu(int,int);
|
||||
#else
|
||||
void inputTest ();
|
||||
void scrollTest ();
|
||||
void introTest ();
|
||||
int initTest ();
|
||||
void outputTest ();
|
||||
void padTest ();
|
||||
void resizeTest ();
|
||||
void display_menu();
|
||||
#endif
|
||||
|
||||
struct commands
|
||||
{
|
||||
char *text;
|
||||
#ifdef __STDC__
|
||||
void (*function)(WINDOW *);
|
||||
#else
|
||||
void (*function)();
|
||||
#endif
|
||||
};
|
||||
typedef struct commands COMMAND;
|
||||
#define MAX_OPTIONS 6
|
||||
COMMAND command[MAX_OPTIONS] =
|
||||
{
|
||||
{"Intro Test",introTest},
|
||||
{"Pad Test",padTest},
|
||||
{"Resize Test",resizeTest},
|
||||
{"Scroll Test",scrollTest},
|
||||
{"Input Test",inputTest},
|
||||
{"Output Test",outputTest}
|
||||
};
|
||||
|
||||
int width, height;
|
||||
|
||||
main()
|
||||
{
|
||||
WINDOW *win;
|
||||
int key,old_option=(-1),new_option=0;
|
||||
bool quit=FALSE;
|
||||
|
||||
#ifdef PDCDEBUG
|
||||
PDC_debug("testcurs started\n");
|
||||
#endif
|
||||
if (!initTest (&win)) {return 1;}
|
||||
|
||||
#ifdef A_COLOR
|
||||
if (has_colors())
|
||||
{
|
||||
init_pair(1,COLOR_WHITE,COLOR_BLUE);
|
||||
wattrset(win, COLOR_PAIR(1));
|
||||
}
|
||||
else
|
||||
wattrset(win, A_REVERSE);
|
||||
#else
|
||||
wattrset(win, A_REVERSE);
|
||||
#endif
|
||||
|
||||
erase();
|
||||
display_menu(old_option,new_option);
|
||||
while(1)
|
||||
{
|
||||
noecho();
|
||||
keypad(stdscr,TRUE);
|
||||
raw();
|
||||
key = getch();
|
||||
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: break;
|
||||
}
|
||||
if (quit == TRUE)
|
||||
break;
|
||||
}
|
||||
|
||||
delwin (win);
|
||||
|
||||
endwin();
|
||||
return 0;
|
||||
}
|
||||
#ifdef __STDC__
|
||||
void Continue (WINDOW *win)
|
||||
#else
|
||||
void Continue (win)
|
||||
WINDOW *win;
|
||||
#endif
|
||||
{
|
||||
wmove(win, 10, 1);
|
||||
/* wclrtoeol(win);
|
||||
*/ mvwaddstr(win, 10, 1, " Press any key to continue");
|
||||
wrefresh(win);
|
||||
raw();
|
||||
wgetch(win);
|
||||
}
|
||||
#ifdef __STDC_
|
||||
int initTest (WINDOW **win)
|
||||
#else
|
||||
int initTest (win)
|
||||
WINDOW **win;
|
||||
#endif
|
||||
{
|
||||
#ifdef PDCDEBUG
|
||||
PDC_debug("initTest called\n");
|
||||
#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 1;
|
||||
}
|
||||
}
|
||||
#ifdef __STDC__
|
||||
void introTest (WINDOW *win)
|
||||
#else
|
||||
void introTest (win)
|
||||
WINDOW *win;
|
||||
#endif
|
||||
{
|
||||
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;
|
||||
}
|
||||
#ifdef __STDC__
|
||||
void scrollTest (WINDOW *win)
|
||||
#else
|
||||
void scrollTest (win)
|
||||
WINDOW *win;
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
int OldX, OldY;
|
||||
char *Message = "The window will now scroll slowly";
|
||||
|
||||
mvwprintw (win, height - 2, 1, Message);
|
||||
wrefresh (win);
|
||||
scrollok(win, TRUE);
|
||||
for (i = 1; i <= height; i++) {
|
||||
usleep (250);
|
||||
scroll(win);
|
||||
wrefresh (win);
|
||||
};
|
||||
|
||||
getmaxyx (win, OldY, OldX);
|
||||
mvwprintw (win, 6, 1, "The top of the window will scroll");
|
||||
wmove (win, 1, 1);
|
||||
wsetscrreg (win, 0, 4);
|
||||
box(win, ACS_VLINE, ACS_HLINE);
|
||||
wrefresh (win);
|
||||
for (i = 1; i <= 5; i++) {
|
||||
usleep (500);
|
||||
scroll(win);
|
||||
wrefresh (win);
|
||||
};
|
||||
wsetscrreg (win, 0, --OldY);
|
||||
|
||||
}
|
||||
#ifdef __STDC__
|
||||
void inputTest (WINDOW *win)
|
||||
#else
|
||||
void inputTest (win)
|
||||
WINDOW *win;
|
||||
#endif
|
||||
{
|
||||
int w, h, bx, by, sw, sh, i, c,num;
|
||||
char buffer [80];
|
||||
WINDOW *subWin;
|
||||
wclear (win);
|
||||
|
||||
w = win->_maxx;
|
||||
h = win->_maxy;
|
||||
bx = win->_begx;
|
||||
by = win->_begy;
|
||||
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_CYAN,COLOR_BLUE);
|
||||
wattrset(subWin, COLOR_PAIR(2) | A_BOLD);
|
||||
}
|
||||
else
|
||||
wattrset(subWin, A_BOLD);
|
||||
#else
|
||||
wattrset(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);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
werase (subWin);
|
||||
box(subWin, ACS_VLINE, ACS_HLINE);
|
||||
mvwprintw (subWin, 1, 1, "Time = %d", i);
|
||||
wrefresh(subWin);
|
||||
usleep(1000);
|
||||
flushinp();
|
||||
}
|
||||
|
||||
delwin (subWin);
|
||||
werase(win);
|
||||
flash();
|
||||
wrefresh(win);
|
||||
usleep(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, 2, 1, "Press a function key or an arrow key");
|
||||
wrefresh(win);
|
||||
keypad(win, TRUE);
|
||||
raw();
|
||||
c = wgetch(win);
|
||||
|
||||
nodelay(win, TRUE);
|
||||
wgetch(win);
|
||||
nodelay(win, FALSE);
|
||||
|
||||
refresh();
|
||||
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, 2, 2, "Keycode = %d", c);
|
||||
mvwaddstr(win, 6, 2, "Enter a number then a string seperated by space");
|
||||
echo();
|
||||
noraw();
|
||||
mvwscanw(win, 7, 6, "%d %s", &num,buffer);
|
||||
mvwprintw(win, 8, 6, "String: %s Number: %d", buffer,num);
|
||||
Continue(win);
|
||||
}
|
||||
#ifdef __STDC__
|
||||
void outputTest (WINDOW *win)
|
||||
#else
|
||||
void outputTest (win)
|
||||
WINDOW *win;
|
||||
#endif
|
||||
{
|
||||
WINDOW *win1;
|
||||
char Buffer [80];
|
||||
chtype ch;
|
||||
|
||||
/* traceon(); */
|
||||
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);
|
||||
Continue(win);
|
||||
|
||||
wclear(win);
|
||||
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);
|
||||
|
||||
win1 = newwin(10, 50, 15, 25);
|
||||
if(win1 == NULL)
|
||||
{ endwin();
|
||||
return;
|
||||
}
|
||||
#ifdef A_COLOR
|
||||
if (has_colors())
|
||||
{
|
||||
init_pair(3,COLOR_BLUE,COLOR_WHITE);
|
||||
wattrset(win1, COLOR_PAIR(3));
|
||||
}
|
||||
else
|
||||
wattrset(win1, A_NORMAL);
|
||||
#else
|
||||
wattrset(win1, A_NORMAL);
|
||||
#endif
|
||||
wclear (win1);
|
||||
mvwaddstr(win1, 5, 1, "This text should appear; using overlay option");
|
||||
copywin(win, win1,0,0,0,0,10,50,TRUE);
|
||||
|
||||
#ifdef UNIX
|
||||
box(win1,ACS_VLINE,ACS_HLINE);
|
||||
#else
|
||||
box(win1,0xb3,0xc4);
|
||||
#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);
|
||||
wrefresh(win1);
|
||||
wgetch(win1);
|
||||
delwin(win1);
|
||||
|
||||
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);
|
||||
/* traceoff(); */
|
||||
|
||||
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);
|
||||
|
||||
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();
|
||||
wscanw (win, "%s", Buffer);
|
||||
|
||||
wclear(win);
|
||||
mvwaddstr(win, 10, 1, "Enter a string");
|
||||
wrefresh(win);
|
||||
clear();
|
||||
move(0,0);
|
||||
printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
|
||||
mvaddstr(10, 1, "Enter a string: ");
|
||||
refresh();
|
||||
noraw();
|
||||
echo();
|
||||
scanw ("%s", Buffer);
|
||||
|
||||
wclear(win);
|
||||
curs_set(2);
|
||||
mvwaddstr(win, 1, 1, "The cursor should appear as a block");
|
||||
Continue(win);
|
||||
|
||||
wclear(win);
|
||||
curs_set(0);
|
||||
mvwaddstr(win, 1, 1, "The cursor should have disappeared");
|
||||
Continue(win);
|
||||
|
||||
wclear(win);
|
||||
curs_set(1);
|
||||
mvwaddstr(win, 1, 1, "The cursor should be an underline");
|
||||
Continue(win);
|
||||
}
|
||||
|
||||
#ifdef __STDC__
|
||||
void resizeTest(WINDOW *dummy)
|
||||
#else
|
||||
void resizeTest(dummy)
|
||||
WINDOW *dummy;
|
||||
#endif
|
||||
{
|
||||
WINDOW *win1;
|
||||
char Buffer [80];
|
||||
chtype ch;
|
||||
|
||||
savetty ();
|
||||
|
||||
clear();
|
||||
refresh();
|
||||
#ifdef __PDCURSES__
|
||||
resize(50);
|
||||
#endif
|
||||
|
||||
|
||||
win1 = newwin(11, 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);
|
||||
|
||||
resetty ();
|
||||
|
||||
wclear (win1);
|
||||
mvwaddstr(win1, 1, 1, "The screen should now be reset");
|
||||
Continue(win1);
|
||||
|
||||
delwin(win1);
|
||||
|
||||
clear();
|
||||
refresh();
|
||||
|
||||
}
|
||||
#ifdef __STDC__
|
||||
void padTest(WINDOW *dummy)
|
||||
#else
|
||||
void padTest(dummy)
|
||||
WINDOW *dummy;
|
||||
#endif
|
||||
{
|
||||
WINDOW *pad;
|
||||
|
||||
pad = newpad(50,100);
|
||||
mvwaddstr(pad, 5, 2, "This is a new pad");
|
||||
mvwaddstr(pad, 8, 0, "The end of this line should be truncated here:abcd");
|
||||
mvwaddstr(pad,11, 1, "This line should not appear.");
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#ifdef __STDC__
|
||||
void display_menu(int old_option,int new_option)
|
||||
#else
|
||||
void display_menu(old_option,new_option)
|
||||
int old_option,new_option;
|
||||
#endif
|
||||
{
|
||||
register int 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();
|
||||
}
|
||||
|
@ -1,268 +0,0 @@
|
||||
/*
|
||||
|
||||
@@@ @@@ @@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@ @@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@
|
||||
@@@ @@@ @@@@ @@@@ @@@@ @@@@ @@@ @@@@
|
||||
@@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
|
||||
@@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
|
||||
@@@@ @@@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@
|
||||
@@@@@@@@@@@@ @@@@ @@@@ @@@ @@@ @@@ @@@
|
||||
@@@@ @@@@ @@@@@@@@@@@@ @@@ @@@ @@@ @@@
|
||||
@@ @@ @@@@@@@@@@ @@@ @@@ @@@ @@@
|
||||
|
||||
Eric P. Scott
|
||||
Caltech High Energy Physics
|
||||
October, 1980
|
||||
|
||||
*/
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define cursor(col,row) move(row,col)
|
||||
|
||||
int Wrap;
|
||||
short *ref[128];
|
||||
static char flavor[]={
|
||||
'O', '*', '#', '$', '%', '0'
|
||||
};
|
||||
static 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 char *field;
|
||||
static int length=16, number=3, trail=' ';
|
||||
static 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 } }
|
||||
};
|
||||
|
||||
void onsig();
|
||||
float ranf();
|
||||
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int x, y;
|
||||
int n;
|
||||
struct worm *w;
|
||||
struct options *op;
|
||||
int h;
|
||||
short *ip;
|
||||
int last, bottom;
|
||||
|
||||
for (x=1;x<argc;x++) {
|
||||
register 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);
|
||||
exit(1);
|
||||
}
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
trail='.';
|
||||
break;
|
||||
default:
|
||||
usage:
|
||||
fprintf(stderr, "usage: %s [-field] [-length #] [-number #] [-trail]\n",*argv);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
signal(SIGINT, onsig);
|
||||
initscr();
|
||||
bottom = LINES-1;
|
||||
last = COLS-1;
|
||||
|
||||
ip=(short *)malloc(LINES*COLS*sizeof (short));
|
||||
|
||||
for (n=0;n<LINES;) {
|
||||
ref[n++]=ip; ip+=COLS;
|
||||
}
|
||||
for (ip=ref[0],n=LINES*COLS;--n>=0;) *ip++=0;
|
||||
ref[bottom][last]=1;
|
||||
for (n=number, w= &worm[0];--n>=0;w++) {
|
||||
w->orientation=w->head=0;
|
||||
if (!(ip=(short *)malloc(length*sizeof (short)))) {
|
||||
fprintf(stderr,"%s: out of memory\n",*argv);
|
||||
exit(1);
|
||||
}
|
||||
w->xpos=ip;
|
||||
for (x=length;--x>=0;) *ip++ = -1;
|
||||
if (!(ip=(short *)malloc(length*sizeof (short)))) {
|
||||
fprintf(stderr,"%s: out of memory\n",*argv);
|
||||
exit(1);
|
||||
}
|
||||
w->ypos=ip;
|
||||
for (y=length;--y>=0;) *ip++ = -1;
|
||||
}
|
||||
if (field) {
|
||||
register char *p;
|
||||
p=field;
|
||||
for (y=bottom;--y>=0;) {
|
||||
for (x=COLS;--x>=0;) {
|
||||
addch(*p++);
|
||||
if (!*p) p=field;
|
||||
}
|
||||
addch('\n');
|
||||
}
|
||||
}
|
||||
refresh();
|
||||
|
||||
for (;;) {
|
||||
for (n=0,w= &worm[0];n<number;n++,w++) {
|
||||
if ((x=w->xpos[h=w->head])<0) {
|
||||
cursor(x=w->xpos[h]=0,y=w->ypos[h]=bottom);
|
||||
addch(flavor[n%6]);
|
||||
ref[y][x]++;
|
||||
}
|
||||
else y=w->ypos[h];
|
||||
if (++h==length) h=0;
|
||||
if (w->xpos[w->head=h]>=0) {
|
||||
register int x1, y1;
|
||||
x1=w->xpos[h]; y1=w->ypos[h];
|
||||
if (--ref[y1][x1]==0) {
|
||||
cursor(x1,y1); 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:
|
||||
refresh();
|
||||
endwin();
|
||||
exit(0);
|
||||
case 1:
|
||||
w->orientation=op->opts[0];
|
||||
break;
|
||||
default:
|
||||
w->orientation=op->opts[(int)(ranf()*(float)op->nopts)];
|
||||
}
|
||||
cursor(x+=xinc[w->orientation], y+=yinc[w->orientation]);
|
||||
if (!Wrap||x!=last||y!=bottom) addch(flavor[n%6]);
|
||||
ref[w->ypos[h]=y][w->xpos[h]=x]++;
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
onsig()
|
||||
{
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
float
|
||||
ranf()
|
||||
{
|
||||
float rv;
|
||||
long r = rand();
|
||||
|
||||
r &= 077777;
|
||||
rv =((float)r/32767.);
|
||||
return rv;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,19 +0,0 @@
|
||||
char _ncurses_copyright[] = "\n\
|
||||
/***************************************************************************
|
||||
* COPYRIGHT NOTICE *
|
||||
****************************************************************************
|
||||
* ncurses is copyright (C) 1992, 1993, 1994 *
|
||||
* by Zeyd M. Ben-Halim *
|
||||
* zmbenhal@netcom.com *
|
||||
* *
|
||||
* Permission is hereby granted to reproduce and distribute ncurses *
|
||||
* by any means and for any fee, whether alone or as part of a *
|
||||
* larger distribution, in source or in binary form, PROVIDED *
|
||||
* this notice is included with any such distribution, not removed *
|
||||
* from header files, and is reproduced in any documentation *
|
||||
* accompanying it or the applications linked with it. *
|
||||
* *
|
||||
* ncurses comes AS IS with no warranty, implied or expressed. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
\n";
|
@ -1,115 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_addch 3 ""
|
||||
.SH NAME
|
||||
\fBaddch\fR, \fBwaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR,
|
||||
\fBechochar\fR,
|
||||
\fBwechochar\fR - add a character (with attributes) to a \fBncurses\fR window, then advance the cursor
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBaddch(chtype ch);\fR
|
||||
.br
|
||||
\fBwaddch(WINDOW *win, chtype ch);\fR
|
||||
.br
|
||||
\fBmvaddch(int y, int x, chtype ch);\fR
|
||||
.br
|
||||
\fBmvwaddch(WINDOW *win, int y, int x, chtype ch);\fR
|
||||
.br
|
||||
\fBechochar(chtype ch);\fR
|
||||
.br
|
||||
\fBwechochar(WINDOW *win, chtype ch);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBaddch\fR, \fBwaddch\fR, \fBmvaddch\fR and \fBmvwaddch\fR routines put
|
||||
the character \fIch\fR into the given window at its current window position,
|
||||
which is then advanced. They are analogous to \fBputchar\fR in \fBstdio\fR(3).
|
||||
If the advance is at the right margin, the cursor automatically wraps to the
|
||||
beginning of the next line. At the bottom of the scrolling region, if
|
||||
\fBscrollok\fR is enabled, the scrolling region is scrolled up one line.
|
||||
|
||||
If \fIch\fR is a tab, newline, or backspace, the cursor is moved appropriately
|
||||
within the window. A newline also does a \fBclrtoeol\fR before moving. Tabs
|
||||
are considered to be at every eighth column.
|
||||
|
||||
If \fIch\fR is any control character other than tab, newline, or backspace, it
|
||||
is drawn in \fB^\fR\fIX\fR notation. Calling \fBwinch\fR after adding a
|
||||
control character does not return the control character, but instead returns
|
||||
the representation of the control character. (To emit control characters
|
||||
literally, use \fBechochar\fR.)
|
||||
|
||||
Video attributes can be combined with a character by OR-ing them into the
|
||||
parameter. This results in these attributes also being set. (The intent here
|
||||
is that text, including attributes, can be copied from one place to another
|
||||
using \fBinch\fR and \fBaddch\fR.) [see \fBstandout\fR, predefined video
|
||||
attribute constants, on the curs_attr(3) page].
|
||||
|
||||
The \fBechochar\fR and \fBwechochar\fR routines are functionally equivalent to
|
||||
a call to \fBaddch\fR followed by a call to \fBrefresh\fR, or a call to
|
||||
\fBwaddch\fR followed by a call to \fBwrefresh\fR. The knowledge that only a
|
||||
single character is being output is taken into consideration and, for
|
||||
non-control characters, a considerable performance gain might be seen by using
|
||||
these routines instead of their equivalents.
|
||||
.SS Line Graphics
|
||||
The following variables may be used to add line drawing characters to the
|
||||
screen with routines of the \fBaddch\fR family. The default character listed
|
||||
below is used if the \fBacsc\fR capability doesn't define a terminal-specific
|
||||
replacement for it. The names are taken from the VT100 nomenclature.
|
||||
|
||||
.TS
|
||||
l l l
|
||||
_ _ _
|
||||
l l l.
|
||||
\fIName\fR \fIDefault\fR \fIDescription\fR
|
||||
ACS_ULCORNER + upper left-hand corner
|
||||
ACS_LLCORNER + lower left-hand corner
|
||||
ACS_URCORNER + upper right-hand corner
|
||||
ACS_LRCORNER + lower right-hand corner
|
||||
ACS_RTEE + right tee
|
||||
ACS_LTEE + left tee
|
||||
ACS_BTEE + bottom tee
|
||||
ACS_TTEE + top tee
|
||||
ACS_HLINE - horizontal line
|
||||
ACS_VLINE | vertical line
|
||||
ACS_PLUS + plus
|
||||
ACS_S1 - scan line 1
|
||||
ACS_S9 \&_ scan line 9
|
||||
ACS_DIAMOND + diamond
|
||||
ACS_CKBOARD : checker board (stipple)
|
||||
ACS_DEGREE ' degree symbol
|
||||
ACS_PLMINUS # plus/minus
|
||||
ACS_BULLET o bullet
|
||||
ACS_LARROW < arrow pointing left
|
||||
ACS_RARROW > arrow pointing right
|
||||
ACS_DARROW v arrow pointing down
|
||||
ACS_UARROW ^ arrow pointing up
|
||||
ACS_BOARD # board of squares
|
||||
ACS_LANTERN # lantern symbol
|
||||
ACS_BLOCK # solid square block
|
||||
.TE
|
||||
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion, unless otherwise noted in the
|
||||
preceding routine descriptions.
|
||||
.SH BUGS
|
||||
.SH NOTES
|
||||
Note that \fBaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR, and
|
||||
\fBechochar\fR may be macros.
|
||||
|
||||
On 386 and 486 consoles, giving \fBwechochar\fR an argument with its high
|
||||
bit set will produce the corresponding high-half ASCIIZ graphic (SVr4 curses
|
||||
also has this feature but does not document it). A control-character argument,
|
||||
however, will not typically produce the corresponding graphic;
|
||||
characters such as CR, NL, FF and TAB are typically interpreted by the console
|
||||
driver itself, and ESC will be interpreted as the leader of a control sequence.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_attr\fR(3), \fBcurs_clear\fR(3),
|
||||
\fBcurs_inch\fR(3), \fBcurs_outopts\fR(3), \fBcurs_refresh\fR(3),
|
||||
\fBputc\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,51 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_addchstr 3 ""
|
||||
.SH NAME
|
||||
\fBaddchstr\fR, \fBaddchnstr\fR, \fBwaddchstr\fR,
|
||||
\fBwaddchnstr\fR, \fBmvaddchstr\fR, \fBmvaddchnstr\fR, \fBmvwaddchstr\fR,
|
||||
\fBmvwaddchnstr\fR - add string of characters (and attributes) to a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint addchstr(chtype *chstr);\fR
|
||||
.br
|
||||
\fBint addchnstr(chtype *chstr, int n);\fR
|
||||
.br
|
||||
\fBint waddchstr(WINDOW *win, chtype *chstr);\fR
|
||||
.br
|
||||
\fBint waddchnstr(WINDOW *win, chtype *chstr, int n);\fR
|
||||
.br
|
||||
\fBint mvaddchstr(int y, int x, chtype *chstr);\fR
|
||||
.br
|
||||
\fBint mvaddchnstr(int y, int x, chtype *chstr, int n);\fR
|
||||
.br
|
||||
\fBint mvwaddchstr(WINDOW *win, int y, int x, chtype *chstr);\fR
|
||||
.br
|
||||
\fBint mvwaddchnstr(WINDOW *win, int y, int x, chtype *chstr, int n);\fR
|
||||
.SH DESCRIPTION
|
||||
These routines copy \fIchstr\fR into the window image structure at and after
|
||||
the current cursor position. The four routines with \fIn\fR as the last
|
||||
argument copy at most \fIn\fR elements, but no more than will fit on the line.
|
||||
If \fBn\fR=\fB-1\fR then the whole string is copied, to the maximum number of
|
||||
characters that will fit on the line.
|
||||
|
||||
The window cursor is \fINOT\fR advanced, and these routines work faster than
|
||||
\fBwaddnstr\fR. On the other hand, care must be taken when using them because
|
||||
they don't perform any kind of checking (such as for the newline character),
|
||||
they don't advance the current cursor position, and they truncate the string if
|
||||
it crosses the right margin, rather then wrapping it around to the new line.
|
||||
.SH RETURN VALUES
|
||||
All these routines return the integer \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion, unless
|
||||
otherwise noted in the preceding routine descriptions.
|
||||
.SH NOTES
|
||||
Note that all routines except \fBwaddchnstr\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,46 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_addstr 3 ""
|
||||
.SH NAME
|
||||
\fBaddstr\fR, \fBaddnstr\fR, \fBwaddstr\fR, \fBwaddnstr\fR,
|
||||
\fBmvaddstr\fR, \fBmvaddnstr\fR, \fBmvwaddstr\fR,
|
||||
\fBmvwaddnstr\fR - add a string of characters to a \fBncurses\fR window and advance cursor
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint addstr(char *str);\fR
|
||||
.br
|
||||
\fBint addnstr(char *str, int n);\fR
|
||||
.br
|
||||
\fBint waddstr(WINDOW *win, char *str);\fR
|
||||
.br
|
||||
\fBint waddnstr(WINDOW *win, char *str, int n);\fR
|
||||
.br
|
||||
\fBint mvaddstr(int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvaddnstr(int y, int x, char *str, int n);\fR
|
||||
.br
|
||||
\fBint mvwaddstr(WINDOW *win, int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvwaddnstr(WINDOW *win, int y, int x, char *str,
|
||||
int n);\fR
|
||||
.SH DESCRIPTION
|
||||
These routines write the characters of the null terminated character string
|
||||
\fIstr\fR on the given window. It is similar to calling \fBwaddch\fR once for
|
||||
each character in the string. The four routines with \fIn\fR as the last
|
||||
argument write at most \fIn\fR characters. If \fIn\fR is negative, then the
|
||||
entire string will be added.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that all of these routines except \fBwaddstr\fR and \fBwaddnstr\fR may be
|
||||
macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_addch\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,86 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_attr 3 ""
|
||||
.SH NAME
|
||||
\fBattroff\fR, \fBwattroff\fR, \fBattron\fR, \fBwattron\fR,
|
||||
\fBattrset\fR, \fBwattrset\fR, \fBstandend\fR, \fBwstandend\fR, \fBstandout\fR,
|
||||
\fBwstandout\fR - \fBncurses\fR character and window attribute control routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
.br
|
||||
\fBint attroff(int attrs);\fR
|
||||
.br
|
||||
\fBint wattroff(WINDOW *win, int attrs);\fR
|
||||
.br
|
||||
\fBint attron(int attrs);\fR
|
||||
.br
|
||||
\fBint wattron(WINDOW *win, int attrs);\fR
|
||||
.br
|
||||
\fBint attrset(int attrs);\fR
|
||||
.br
|
||||
\fBint wattrset(WINDOW *win, int attrs);\fR
|
||||
.br
|
||||
\fBint standend(void);\fR
|
||||
.br
|
||||
\fBint wstandend(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint standout(void);\fR
|
||||
.br
|
||||
\fBint wstandout(WINDOW *win);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines manipulate the current attributes of the named window. The
|
||||
current attributes of a window apply to all characters that are written into
|
||||
the window with \fBwaddch\fR, \fBwaddstr\fR and \fBwprintw\fR. Attributes are
|
||||
a property of the character, and move with the character through any scrolling
|
||||
and insert/delete line/character operations. To the extent possible, they are
|
||||
displayed as appropriate modifications to the graphic rendition of characters
|
||||
put on the screen.
|
||||
|
||||
The routine \fBattrset\fR sets the current attributes of the given window to
|
||||
\fIattrs\fR. The routine \fBattroff\fR turns off the named attributes without
|
||||
turning any other attributes on or off. The routine \fBattron\fR turns on the
|
||||
named attributes without affecting any others. The routine \fBstandout\fR is
|
||||
the same as \fBattron(A_STANDOUT)\fR. The routine \fBstandend\fR is the same
|
||||
as \fBattrset(A_NORMAL)\fR or \fBattrset(0)\fR, that is, it turns off all
|
||||
attributes.
|
||||
.SS Attributes
|
||||
The following video attributes, defined in \fB<ncurses.h>\fR, can be passed to
|
||||
the routines \fBattron\fR, \fBattroff\fR, and \fBattrset\fR, or OR-ed with the
|
||||
characters passed to \fBaddch\fR.
|
||||
|
||||
.nf
|
||||
\fBA_NORMAL\fR Normal display (no highlight)
|
||||
\fBA_STANDOUT\fR Best highlighting mode of the terminal.
|
||||
\fBA_UNDERLINE\fR Underlining
|
||||
\fBA_REVERSE\fR Reverse video
|
||||
\fBA_BLINK\fR Blinking
|
||||
\fBA_DIM\fR Half bright
|
||||
\fBA_BOLD\fR Extra bright or bold
|
||||
\fBA_ALTCHARSET\fR Alternate character set
|
||||
\fBA_CHARTEXT\fR Bit-mask to extract a character
|
||||
\fBCOLOR_PAIR(\fR\fIn\fR\fB)\fR Color-pair number \fIn\fR
|
||||
.fi
|
||||
|
||||
The following macro is the reverse of \fBCOLOR_PAIR(\fR\fIn\fR\fB)\fR:
|
||||
|
||||
.DS C
|
||||
\fBPAIR_NUMBER(\fIattrs\fR) Returns the pair number associated
|
||||
with the \fBCOLOR_PAIR(\fR\fIn\fR\fB)\fR attribute.
|
||||
.DE
|
||||
|
||||
The return values of these routines are not meaningful (many are implemented
|
||||
as macro-expanded assignments and simply return their argument). The SVr4
|
||||
manual page claims (falsely) that these routines always return \fB1\fR.
|
||||
.SH NOTES
|
||||
Note that \fBattroff\fR, \fBwattroff\fR, \fBattron\fR, \fBwattron\fR,
|
||||
\fBattrset\fR, \fBwattrset\fR, \fBstandend\fR and \fBstandout\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_addch\fR(3), \fBcurs_addstr\fR(3),
|
||||
\fBcurs_printw\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,31 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_beep 3 ""
|
||||
.SH NAME
|
||||
\fBbeep\fR, \fBflash\fR - \fBncurses\fR bell and screen flash routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint beep(void);\fR
|
||||
.br
|
||||
\fBint flash(void);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBbeep\fR and \fBflash\fR routines are used to alert the terminal user.
|
||||
The routine \fBbeep\fR sounds an audible alarm on the terminal, if possible;
|
||||
otherwise it flashes the screen (visible bell). The routine \fBflash\fR
|
||||
flashes the screen, and if that is not possible, sounds the alert. If neither
|
||||
alert is possible, nothing happens. Nearly all terminals have an audible alert
|
||||
(bell or beep), but only some can flash the screen.
|
||||
.SH RETURN VALUE
|
||||
These routines always return \fBOK\fR.
|
||||
.SH CAPABILITIES
|
||||
\fBbell\fR, \fBflash_screen\fR.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,52 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_bkgd 3 ""
|
||||
.SH NAME
|
||||
\fBbkgdset\fR, \fBwbkgdset\fR, \fBbkgd\fR,
|
||||
\fBwbkgd\fR - \fBncurses\fR window background manipulation routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBvoid bkgdset(chtype ch);\fR
|
||||
.br
|
||||
\fBvoid wbkgdset(WINDOW *win, chtype ch);\fR
|
||||
.br
|
||||
\fBint bkgd(chtype ch);\fR
|
||||
.br
|
||||
\fBint wbkgd(WINDOW *win, chtype ch);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBbkgdset\fR and \fBwbkgdset\fR routines manipulate the
|
||||
background of the named window. Background is a \fBchtype\fR
|
||||
consisting of any combination of attributes and a character. The
|
||||
attribute part of the background is combined (ORed) with all non-blank
|
||||
characters that are written into the window with \fBwaddch\fR. Both
|
||||
the character and attribute parts of the background are combined with
|
||||
the blank characters. The background becomes a property of the
|
||||
character and moves with the character through any scrolling and
|
||||
insert/delete line/character operations. To the extent possible on a
|
||||
particular terminal, the attribute part of the background is displayed
|
||||
as the graphic rendition of the character put on the screen.
|
||||
|
||||
The \fBbkgd\fR and \fBwbkgd\fR routines combine the new background
|
||||
with every position in the window. Background is any combination of
|
||||
attributes and a character. Only the attribute part is used to set
|
||||
the background of non-blank characters, while both character and
|
||||
attributes are used for blank positions. To the extent possible on a
|
||||
particular terminal, the attribute part of the background is displayed
|
||||
as the graphic rendition of the character put on the screen.
|
||||
.SH RETURN VALUE
|
||||
\fBbkgd\fR and \fBwbkgd\fR return the integer \fBOK\fR, or a
|
||||
non-negative integer, if \fBimmedok\fR is set.
|
||||
.SH NOTES
|
||||
Note that \fBbkgdset\fR and \fBbkgd\fR may be macros.
|
||||
.SH BUGS
|
||||
\fBimmedok\fR is not yet implemented in ncurses 1.8.6.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_addch\fR(3), \fBcurs_outopts\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,69 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_border 3 ""
|
||||
.SH NAME
|
||||
\fBborder\fR, \fBwborder\fR, \fBbox\fR,
|
||||
\fBhline\fR, \fBwhline\fR, \fBvline\fR,
|
||||
\fBwvline\fR - create \fBncurses\fR borders, horizontal and vertical lines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
.br
|
||||
\fBint border(chtype ls, chtype rs, chtype ts, chtype bs,
|
||||
chtype tl, chtype tr, chtype bl, chtype br);\fR
|
||||
.br
|
||||
\fBint wborder(WINDOW *win, chtype ls, chtype rs,
|
||||
chtype ts, chtype bs, chtype tl, chtype tr,
|
||||
chtype bl, chtype br);\fR
|
||||
.br
|
||||
\fBint box(WINDOW *win, chtype verch, chtype horch);\fR
|
||||
.br
|
||||
\fBint hline(chtype ch, int n);\fR
|
||||
.br
|
||||
\fBint whline(WINDOW *win, chtype ch, int n);\fR
|
||||
.br
|
||||
\fBint vline(chtype ch, int n);\fR
|
||||
.br
|
||||
\fBint wvline(WINDOW *win, chtype ch, int n);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBborder\fR, \fBwborder\fR and \fBbox\fR routines draw a box around the
|
||||
edges of a window. The argument \fIls\fR is a character and attributes used
|
||||
for the left side of the border, \fIrs\fR - right side, \fIts\fR - top side,
|
||||
\fIbs\fR - bottom side, \fItl\fR - top left-hand corner, \fItr\fR - top
|
||||
right-hand corner, \fIbl\fR - bottom left-hand corner, and \fIbr\fR - bottom
|
||||
right-hand corner. If any of these arguments is zero, then the following
|
||||
default values (defined in \fBncurses.h\fR) are used instead: \fBACS_VLINE,
|
||||
ACS_VLINE, ACS_HLINE, ACS_HLINE, \fBACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER,
|
||||
ACS_LRCORNER.\fR
|
||||
|
||||
\fBbox(\fR\fIwin\fR\gB, \fR\fIverch\fR\fB, \fR\fIhorch\fR\fB)\fR is a shorthand
|
||||
for the following call: \fBwborder(\fR\fIwin\fR\fB,\fR \fIverch\fR\fB,\fR
|
||||
\fIverch\fR\fB,\fR \fIhorch\fR\fB,\fR \fIhorch\fR\fB, 0, 0, 0, 0)\fR.
|
||||
|
||||
The \fBhline\fR and \fBwhline\fR functions draw a horizontal (left to right)
|
||||
line using \fIch\fR starting at the current cursor position in the window. The
|
||||
current cursor position is not changed. The line is at most \fIn\fR characters
|
||||
long, or as many as fit into the window.
|
||||
|
||||
The \fBvline\fR and \fBwvline\fR functions draw a vertical (top to bottom) line
|
||||
using \fIch\fR starting at the current cursor position in the window. The
|
||||
current cursor position is not changed. The line is at most \fIn\fR characters
|
||||
long, or as many as fit into the window.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBOK\fR. The SVr4.0 manual says "or a
|
||||
non-negative integer if \fBimmedok\fR is set", but this appears to be an error.
|
||||
.SH NOTES
|
||||
The borders generated by these functions are \fIinside\fR borders (this
|
||||
is also true of SVr4 curses, though the fact is not documented).
|
||||
|
||||
Note that \fBborder\fR and \fBbox\fR may be macros.
|
||||
.SH BUGS
|
||||
The \fBimmedok\fR function is not yet implemented in ncurses 1.8.6.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_outopts\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,55 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_clear 3 ""
|
||||
.SH NAME
|
||||
\fBerase\fR, \fBwerase\fR, \fBclear\fR,
|
||||
\fBwclear\fR, \fBclrtobot\fR, \fBwclrtobot\fR, \fBclrtoeol\fR,
|
||||
\fBwclrtoeol\fR - clear all or part of a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB# include <ncurses.h>\fR
|
||||
|
||||
\fBint erase(void);\fR
|
||||
.br
|
||||
\fBint werase(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint clear(void);\fR
|
||||
.br
|
||||
\fBint wclear(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint clrtobot(void);\fR
|
||||
.br
|
||||
\fBint wclrtobot(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint clrtoeol(void);\fR
|
||||
.br
|
||||
\fBint wclrtoeol(WINDOW *win);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBerase\fR and \fBwerase\fR routines copy blanks to every
|
||||
position in the window, clearing the screen.
|
||||
|
||||
The \fBclear\fR and \fBwclear\fR routines are like \fBerase\fR and
|
||||
\fBwerase\fR, but they also call \fBclearok\fR, so that the screen is
|
||||
cleared completely on the next call to \fBwrefresh\fR for that window
|
||||
and repainted from scratch.
|
||||
|
||||
The \fBclrtobot\fR and \fBwclrtobot\fR routines erase from the cursor to the
|
||||
end of screen. That is, they erase all lines below the cursor in the window.
|
||||
Also, the current line to the right of the cursor, inclusive, is erased.
|
||||
|
||||
The \fBclrtoeol\fR and \fBwclrtoeol\fR routines erase the current line
|
||||
to the right of the cursor, inclusive.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBOK\fR, or a non-negative integer if
|
||||
\fBimmedok\fR is set.
|
||||
.SH NOTES
|
||||
Note that \fBerase\fR, \fBwerase\fR, \fBclear\fR, \fBwclear\fR,
|
||||
\fBclrtobot\fR, and \fBclrtoeol\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_outopts\fR(3), \fBcurs_refresh\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,140 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_color 3 ""
|
||||
.SH NAME
|
||||
\fBstart_color\fR, \fBinit_pair\fR,
|
||||
\fBinit_color\fR, \fBhas_colors\fR, \fBcan_change_color\fR,
|
||||
\fBcolor_content\fR,
|
||||
\fBpair_content\fR - \fBncurses\fR color manipulation routines
|
||||
.SH SYNOPSIS
|
||||
\fB# include <ncurses.h>\fR
|
||||
.br
|
||||
\fBint start_color(void);\fR
|
||||
.br
|
||||
\fBint init_pair(short pair, short f, short b);\fR
|
||||
.br
|
||||
\fBint init_color(short color, short r, short g, short b);\fR
|
||||
.br
|
||||
\fBbool has_colors(void);\fR
|
||||
.br
|
||||
\fBbool can_change_color(void);\fR
|
||||
.br
|
||||
\fBint color_content(short color, short *r, short *g, short *b);\fR
|
||||
.br
|
||||
\fBint pair_content(short pair, short *f, short *b);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
.SS Overview
|
||||
\fBncurses\fR support color attributes on terminals with that capability. To
|
||||
use these routines \fBstart_color\fR must be called, usually right after
|
||||
\fBinitscr\fR. Colors are always used in pairs (referred to as color-pairs).
|
||||
A color-pair consists of a foreground color (for characters) and a background
|
||||
color (for the blank field on which the characters are displayed). A
|
||||
programmer initializes a color-pair with the routine \fBinit_pair\fR. After it
|
||||
has been initialized, \fBCOLOR_PAIR\fR(\fIn\fR), a macro defined in
|
||||
\fB<ncurses.h>\fR, can be used as a new video attribute.
|
||||
|
||||
If a terminal is capable of redefining colors, the programmer can use the
|
||||
routine \fBinit_color\fR to change the definition of a color. The routines
|
||||
\fBhas_colors\fR and \fBcan_change_color\fR return \fBTRUE\fR or \fBFALSE\fR,
|
||||
depending on whether the terminal has color capabilities and whether the
|
||||
programmer can change the colors. The routine \fBcolor_content\fR allows a
|
||||
programmer to extract the amounts of red, green, and blue components in an
|
||||
initialized color. The routine \fBpair_content\fR allows a programmer to find
|
||||
out how a given color-pair is currently defined.
|
||||
.SS Routine Descriptions
|
||||
The \fBstart_color\fR routine requires no arguments. It must be
|
||||
called if the programmer wants to use colors, and before any other
|
||||
color manipulation routine is called. It is good practice to call
|
||||
this routine right after \fBinitscr\fR. \fBstart_color\fR initializes
|
||||
eight basic colors (black, red, green, yellow, blue, magenta, cyan,
|
||||
and white), and two global variables, \fBCOLORS\fR and
|
||||
\fBCOLOR_PAIRS\fR (respectively defining the maximum number of colors
|
||||
and color-pairs the terminal can support). It also restores the
|
||||
colors on the terminal to the values they had when the terminal was
|
||||
just turned on.
|
||||
|
||||
The \fBinit_pair\fR routine changes the definition of a color-pair. It takes
|
||||
three arguments: the number of the color-pair to be changed, the foreground
|
||||
color number, and the background color number. The value of the first argument
|
||||
must be between \fB1\fR and \fBCOLOR_PAIRS-1\fR. The value of the second and
|
||||
third arguments must be between 0 and \fBCOLORS\fR (the 0 color pair is wired
|
||||
to white on black and cannot be changed). If the color-pair was previously
|
||||
initialized, the screen is refreshed and all occurrences of that color-pair is
|
||||
changed to the new definition.
|
||||
|
||||
The \fBinit_color\fR routine changes the definition of a color. It takes four
|
||||
arguments: the number of the color to be changed followed by three RGB values
|
||||
(for the amounts of red, green, and blue components). The value of the first
|
||||
argument must be between \fB0\fR and \fBCOLORS\fR. (See the section
|
||||
\fBColors\fR for the default color index.) Each of the last three arguments
|
||||
must be a value between 0 and 1000. When \fBinit_color\fR is used, all
|
||||
occurrences of that color on the screen immediately change to the new
|
||||
definition.
|
||||
|
||||
The \fBhas_colors\fR routine requires no arguments. It returns \fBTRUE\fR if
|
||||
the terminal can manipulate colors; otherwise, it returns \fBFALSE\fR. This
|
||||
routine facilitates writing terminal-independent programs. For example, a
|
||||
programmer can use it to decide whether to use color or some other video
|
||||
attribute.
|
||||
|
||||
The \fBcan_change_color\fR routine requires no arguments. It returns
|
||||
\fBTRUE\fR if the terminal supports colors and can change their definitions;
|
||||
other, it returns \fBFALSE\fR. This routine facilitates writing
|
||||
terminal-independent programs.
|
||||
|
||||
The \fBcolor_content\fR routine gives programmers a way to find the intensity
|
||||
of the red, green, and blue (RGB) components in a color. It requires four
|
||||
arguments: the color number, and three addresses of \fBshort\fRs for storing
|
||||
the information about the amounts of red, green, and blue components in the
|
||||
given color. The value of the first argument must be between 0 and
|
||||
\fBCOLORS\fR. The values that are stored at the addresses pointed to by the
|
||||
last three arguments are between 0 (no component) and 1000 (maximum amount of
|
||||
component).
|
||||
|
||||
The \fBpair_content\fR routine allows programmers to find out what colors a
|
||||
given color-pair consists of. It requires three arguments: the color-pair
|
||||
number, and two addresses of \fBshort\fRs for storing the foreground and the
|
||||
background color numbers. The value of the first argument must be between 1
|
||||
and \fBCOLOR_PAIRS-1\fR. The values that are stored at the addresses pointed
|
||||
to by the second and third arguments are between 0 and \fBCOLORS\fR.
|
||||
.SS Colors
|
||||
In \fB<ncurses.h>\fR the following macros are defined. These are the default
|
||||
colors. \fBncurses\fR also assumes that \fBCOLOR_BLACK\fR is the default
|
||||
background color for all terminals.
|
||||
|
||||
.nf
|
||||
\fBCOLOR_BLACK\fR
|
||||
\fBCOLOR_RED\fR
|
||||
\fBCOLOR_GREEN\fR
|
||||
\fBCOLOR_YELLOW\fR
|
||||
\fBCOLOR_BLUE\fR
|
||||
\fBCOLOR_MAGENTA\fR
|
||||
\fBCOLOR_CYAN\fR
|
||||
\fBCOLOR_WHITE\fR
|
||||
.fi
|
||||
.SH RETURN VALUE
|
||||
All routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
|
||||
upon successful completion.
|
||||
.SH NOTES
|
||||
Several caveats apply onn 386 and 486 machines with VGA-compatible graphics:
|
||||
|
||||
COLOR_YELLOW is actually brown. To get yellow, use COLOR_YELLOW combined with
|
||||
the \fBA_BOLD\fR attribute.
|
||||
|
||||
The A_BLINK attribute should in theory cause the background to go bright. This
|
||||
often fails to work, and even some cards for which it mostly works (such as the
|
||||
Paradise and compatibles) do the wrong thing when you try to set a bright
|
||||
"yellow" background (you get a blinking yellow foreground instead).
|
||||
|
||||
Color RGB values are not settable.
|
||||
.SH CAPABILITIES
|
||||
\fBsetf\fR, \fBsetb\fR, \fBsetaf\fR, \fBsetab\fR. The ncurses library uses
|
||||
the second pair by preference, falling back to the first.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_initscr\fR(3), \fBcurs_attr\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
@ -1,36 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_delch 3 ""
|
||||
.SH NAME
|
||||
\fBdelch\fR, \fBwdelch\fR, \fBmvdelch\fR,
|
||||
\fBmvwdelch\fR - delete character under the cursor in a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint delch(void);\fR
|
||||
.br
|
||||
\fBint wdelch(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint mvdelch(int y, int x);\fR
|
||||
.br
|
||||
\fBint mvwdelch(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines delete the character under the cursor; all characters to the
|
||||
right of the cursor on the same line are moved to the left one position and the
|
||||
last character on the line is filled with a blank. The cursor position does
|
||||
not change (after moving to \fIy\fR, \fIx\fR, if specified). (This does not
|
||||
imply use of the hardware delete character feature.)
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that \fBdelch\fR, \fBmvdelch\fR, and \fBmvwdelch\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,52 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_deleteln 3 ""
|
||||
.SH NAME
|
||||
\fBdeleteln\fR, \fBwdeleteln\fR, \fBinsdelln\fR,
|
||||
\fBwinsdelln\fR, \fBinsertln\fR,
|
||||
\fBwinsertln\fR - delete and insert lines in a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint deleteln(void);\fR
|
||||
.br
|
||||
\fBint wdeleteln(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint insdelln(int n);\fR
|
||||
.br
|
||||
\fBint winsdelln(WINDOW *win, int n);\fR
|
||||
.br
|
||||
\fBint insertln(void);\fR
|
||||
.br
|
||||
\fBint winsertln(WINDOW *win);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBdeleteln\fR and \fBwdeleteln\fR routines delete the line under the
|
||||
cursor in the window; all lines below the current line are moved up one line.
|
||||
The bottom line of the window is cleared. The cursor position does not change.
|
||||
|
||||
The \fBinsdelln\fR and \fBwinsdelln\fR routines, for positive \fIn\fR, insert
|
||||
\fIn\fR lines into the specified window above the current line. The \fIn\fR
|
||||
bottom lines are lost. For negative \fIn\fR, delete \fIn\fR lines (starting
|
||||
with the one under the cursor), and move the remaining lines up. The bottom
|
||||
\fIn\fR lines are cleared. The current cursor position remains the same.
|
||||
|
||||
The \fBinsertln\fR and \fBinsertln\fR routines, insert a blank line above the
|
||||
current line and the bottom line is lost.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that all but \fBwinsdelln\fR may be a macros.
|
||||
|
||||
These routines do not require a hardware line delete or insert feature in the
|
||||
terminal. In fact, they won't use hardware line delete/insert unless
|
||||
\fBidlok(..., TRUE)\fR has been set on the current window.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,190 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_getch 3 ""
|
||||
.SH NAME
|
||||
\fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR,
|
||||
\fBmvwgetch\fR,
|
||||
\fBungetch\fR - get (or push back) characters from \fBncurses\fR terminal keyboard
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint getch(void);\fR
|
||||
.br
|
||||
\fBint wgetch(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint mvgetch(int y, int x);\fR
|
||||
.br
|
||||
\fBint mvwgetch(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
\fBint ungetch(int ch);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR and \fBmvwgetch\fR, routines read
|
||||
a character from the window. In no-delay mode, if no input is waiting, the
|
||||
value \fBERR\fR is returned. In delay mode, the program waits until the system
|
||||
passes text through to the program. Depending on the setting of \fBcbreak\fR,
|
||||
this is after one character (cbreak mode), or after the first newline (nocbreak
|
||||
mode). In half-delay mode, the program waits until a character is typed or the
|
||||
specified timeout has been reached. Unless \fBnoecho\fR has been set, the
|
||||
character will also be echoed into the designated window.
|
||||
|
||||
If the window is not a pad, and it has been moved or modified since the last
|
||||
call to \fBwrefresh\fR, \fBwrefresh\fR will be called before another character
|
||||
is read.
|
||||
|
||||
If \fBkeypad\fR is \fBTRUE\fR, and a function key is pressed, the token for
|
||||
that function key is returned instead of the raw characters. Possible function
|
||||
keys are defined in \fB<ncurses.h>\fR as macros with values outside the range
|
||||
of 8-bit characters whose names begin with \fBKEY_.\fR Thus, a variable
|
||||
intended to hold the return value of a function key must be of short size or
|
||||
larger.
|
||||
|
||||
When a character that could be the beginning of a function key is received
|
||||
(which, on modern terminals, means an escape character), \fBncurses\fR sets a
|
||||
timer. If the remainder of the sequence does not come in within the designated
|
||||
time, the character is passed through; otherwise, the function key value is
|
||||
returned. For this reason, many terminals experience a delay between the time
|
||||
a user presses the escape key and the escape is returned to the program.
|
||||
|
||||
The \fBungetch\fR routine places \fIch\fR back onto the input queue to be
|
||||
returned by the next call to \fBwgetch\fR. Note that there is, in effect,
|
||||
just one input queue for all windows.
|
||||
|
||||
.SS Function Keys
|
||||
The following function keys, defined in \fB<ncurses.h>\fR, might be returned by
|
||||
\fBgetch\fR if \fBkeypad\fR has been enabled. Note that not all of these are
|
||||
necessarily supported on any particular terminal.
|
||||
.nf
|
||||
__________________________________________________________________
|
||||
\fIName\fR \fIKey\fR \fIname\fR
|
||||
__________________________________________________________________
|
||||
KEY_BREAK Break key
|
||||
KEY_DOWN The four arrow keys ...
|
||||
KEY_UP
|
||||
KEY_LEFT
|
||||
KEY_RIGHT
|
||||
KEY_HOME Home key (upward+left arrow)
|
||||
KEY_BACKSPACE Backspace
|
||||
KEY_F0 Function keys; space for 64 keys is reserved.
|
||||
KEY_F(\fIn\fR) For 0 \fI<\fR \fIn\fR \fI<\fR 63
|
||||
KEY_DL Delete line
|
||||
KEY_IL Insert line
|
||||
KEY_DC Delete character
|
||||
KEY_IC Insert char or enter insert mode
|
||||
KEY_EIC Exit insert char mode
|
||||
KEY_CLEAR Clear screen
|
||||
KEY_EOS Clear to end of screen
|
||||
KEY_EOL Clear to end of line
|
||||
KEY_SF Scroll 1 line forward
|
||||
KEY_SR Scroll 1 line backward (reverse)
|
||||
KEY_NPAGE Next page
|
||||
KEY_PPAGE Previous page
|
||||
KEY_STAB Set tab
|
||||
KEY_CTAB Clear tab
|
||||
KEY_CATAB Clear all tabs
|
||||
KEY_ENTER Enter or send
|
||||
KEY_SRESET Soft (partial) reset
|
||||
KEY_RESET Reset or hard reset
|
||||
KEY_PRINT Print or copy
|
||||
KEY_LL Home down or bottom (lower left). Keypad is
|
||||
arranged like this:
|
||||
\fBA1\fR \fBup\fR \fBA3\fR
|
||||
\fBleft\fR \fBB2\fR \fBright\fR
|
||||
\fBC1\fR \fBdown\fR \fBC3\fR
|
||||
KEY_A1 Upper left of keypad
|
||||
KEY_A3 Upper right of keypad
|
||||
KEY_B2 Center of keypad
|
||||
KEY_C1 Lower left of keypad
|
||||
KEY_C3 Lower right of keypad
|
||||
KEY_BTAB Back tab key
|
||||
KEY_BEG Beg(inning) key
|
||||
KEY_CANCEL Cancel key
|
||||
KEY_CLOSE Close key
|
||||
KEY_COMMAND Cmd (command) key
|
||||
KEY_COPY Copy key
|
||||
KEY_CREATE Create key
|
||||
KEY_END End key
|
||||
KEY_EXIT Exit key
|
||||
KEY_FIND Find key
|
||||
KEY_HELP Help key
|
||||
KEY_MARK Mark key
|
||||
KEY_MESSAGE Message key
|
||||
KEY_MOVE Move key
|
||||
KEY_NEXT Next object key
|
||||
KEY_OPEN Open key
|
||||
KEY_OPTIONS Options key
|
||||
KEY_PREVIOUS Previous object key
|
||||
KEY_REDO Redo key
|
||||
KEY_REFERENCE Ref(erence) key
|
||||
KEY_REFRESH Refresh key
|
||||
KEY_REPLACE Replace key
|
||||
KEY_RESTART Restart key
|
||||
KEY_RESUME Resume key
|
||||
KEY_SAVE Save key
|
||||
KEY_SBEG Shifted beginning key
|
||||
KEY_SCANCEL Shifted cancel key
|
||||
KEY_SCOMMAND Shifted command key
|
||||
KEY_SCOPY Shifted copy key
|
||||
KEY_SCREATE Shifted create key
|
||||
KEY_SDC Shifted delete char key
|
||||
KEY_SDL Shifted delete line key
|
||||
KEY_SELECT Select key
|
||||
KEY_SEND Shifted end key
|
||||
KEY_SEOL Shifted clear line key
|
||||
KEY_SEXIT Shifted exit key
|
||||
KEY_SFIND Shifted find key
|
||||
KEY_SHELP Shifted help key
|
||||
KEY_SHOME Shifted home key
|
||||
KEY_SIC Shifted input key
|
||||
KEY_SLEFT Shifted left arrow key
|
||||
KEY_SMESSAGE Shifted message key
|
||||
KEY_SMOVE Shifted move key
|
||||
KEY_SNEXT Shifted next key
|
||||
KEY_SOPTIONS Shifted options key
|
||||
KEY_SPREVIOUS Shifted prev key
|
||||
KEY_SPRINT Shifted print key
|
||||
KEY_SREDO Shifted redo key
|
||||
KEY_SREPLACE Shifted replace key
|
||||
KEY_SRIGHT Shifted right arrow
|
||||
KEY_SRSUME Shifted resume key
|
||||
KEY_SSAVE Shifted save key
|
||||
KEY_SSUSPEND Shifted suspend key
|
||||
KEY_SUNDO Shifted undo key
|
||||
KEY_SUSPEND Suspend key
|
||||
KEY_UNDO Undo key
|
||||
.fi
|
||||
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Use of the escape key by a programmer for a single character function is
|
||||
discouraged, as it will cause a delay of up to one second while the
|
||||
keypad code looks for a following function-key sequence.
|
||||
|
||||
When using \fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR, or
|
||||
\fBmvwgetch\fR, nocbreak mode (\fBnocbreak\fR) and echo mode
|
||||
(\fBecho\fR) should not be used at the same time. Depending on the
|
||||
state of the tty driver when each character is typed, the program may
|
||||
produce undesirable results.
|
||||
|
||||
Note that \fBgetch\fR, \fBmvgetch\fR, and \fBmvwgetch\fR may be macros.
|
||||
|
||||
Historically, the set of keypad macros was largely defined by the extremely
|
||||
function-key-rich keyboard of the AT&T 7300, aka 3B1, aka Safari 4. Modern
|
||||
personal computers usually have only a small subset of these. IBM PC-style
|
||||
consoles typically support little more than \fBKEY_UP\fR, \fBKEY_DOWN\fR,
|
||||
\fBKEY_LEFT\fR, \fBKEY_RIGHT\fR, \fBKEY_HOME\fR, \fBKEY_END\fR,
|
||||
\fBKEY_NPAGE\fR, \fBKEY_PPAGE\fR, and function keys 1 through 12. The Ins key
|
||||
is usually mapped to \fBKEY_IC\fR.
|
||||
.SH CAPABILITIES
|
||||
All of the key_* capabilities; also \fBkeypad_local\fR and \fBkeypad_xmit\fR.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_inopts\fR(3), \fBcurs_move\fR(3),
|
||||
\fBcurs_refresh\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,55 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_getstr 3 ""
|
||||
.SH NAME
|
||||
\fBgetstr\fR, \fBwgetstr\fR, \fBmvgetstr\fR,
|
||||
\fBmvwgetstr\fR,
|
||||
\fBwgetnstr\fR - accept character strings from \fBncurses\fR terminal keyboard
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint getstr(char *str);\fR
|
||||
.br
|
||||
\fBint wgetstr(WINDOW *win, char *str);\fR
|
||||
.br
|
||||
\fBint mvgetstr(int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvwgetstr(WINDOW *win, int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint wgetnstr(WINDOW *win, char *str, int n);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The function \fBgetstr\fR is equivalent to a series of calls to \fBgetch\fR,
|
||||
until a newline or carriage return is received (the terminating character is
|
||||
not included in the returned string). The resulting value is placed in the
|
||||
area pointed to by the character pointer \fIstr\fR.
|
||||
|
||||
\fBwgetnstr\fR reads at most \fIn\fR characters, thus preventing a possible
|
||||
overflow of the input buffer. Any attempt to enter more characters (other
|
||||
than the terminating newline or carriage return) causes a beep.
|
||||
|
||||
The user's erase and kill characters are interpreted. If keypad
|
||||
mode is on for the window, \fBKEY_LEFT\fR and \fBKEY_BACKSPACE\fR
|
||||
are both considered equivalent to the user's kill character.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH BUGS
|
||||
When the window is in keypad mode and the user types any special key
|
||||
other than those named above, the `character' value appended to the
|
||||
string by the ncurses implementation is predictable but not useful
|
||||
(being, in fact, the low-order eight bits of the key's KEY_ value).
|
||||
|
||||
The SVr4.0 documentation claims that "special keys (such as function
|
||||
keys, "home" key, "clear" key, \fIetc\fR.) are interpreted" without
|
||||
giving details. It lies. The actual behavior is like that of ncurses.
|
||||
.SH NOTES
|
||||
Note that \fBgetstr\fR, \fBmvgetstr\fR, and \fBmvwgetstr\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_getch\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,43 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_getyx 3 ""
|
||||
.SH NAME
|
||||
\fBgetyx\fR, \fBgetparyx\fR, \fBgetbegyx\fR,
|
||||
\fBgetmaxyx\fR - get \fBncurses\fR cursor and window coordinates
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBvoid getyx(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
\fBvoid getparyx(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
\fBvoid getbegyx(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
\fBvoid getmaxyx(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBgetyx\fR macro places the cursor position of the window in the two
|
||||
integer variables \fIy\fR and \fIx\fR.
|
||||
|
||||
If \fIwin\fR is a subwindow, the \fBgetparyx\fR macro places the beginning
|
||||
coordinates of the subwindow relative to the parent window into two integer
|
||||
variables \fIy\fR and \fIx\fR. Otherwise, \fB-1\fR is placed into \fIy\fR and
|
||||
\fIx\fR.
|
||||
|
||||
Like \fBgetyx\fR, the \fBgetbegyx\fR and \fBgetmaxyx\fR macros store
|
||||
the current beginning coordinates and size of the specified window.
|
||||
.SH RETURN VALUE
|
||||
The return values of these macros are undefined (\fIi\fR.\fIe\fR.,
|
||||
they should not be used as the right-hand side of assignment
|
||||
statements).
|
||||
.SH NOTES
|
||||
All of these interfaces are macros and that "\fB&\fR" is not
|
||||
necessary before the variables \fIy\fR and \fIx\fR.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,42 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_inch 3 ""
|
||||
.SH NAME
|
||||
\fBinch\fR, \fBwinch\fR, \fBmvinch\fR,
|
||||
\fBmvwinch\fR - get a character and attributes from a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBchtype inch(void);\fR
|
||||
.br
|
||||
\fBchtype winch(WINDOW *win);\fR
|
||||
.br
|
||||
\fBchtype mvinch(int y, int x);\fR
|
||||
.br
|
||||
\fBchtype mvwinch(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines return the character, of type \fBchtype\fR, at the current
|
||||
position in the named window. If any attributes are set for that position,
|
||||
their values are OR-ed into the value returned. Constants defined in
|
||||
\fB<ncurses.h>\fR can be used with the \fB&\fR (logical AND) operator to
|
||||
extract the character or attributes alone.
|
||||
|
||||
.SS Attributes
|
||||
The following bit-masks may be AND-ed with characters returned by \fBwinch\fR.
|
||||
|
||||
.nf
|
||||
\fBA_CHARTEXT\fR Bit-mask to extract character
|
||||
\fBA_ATTRIBUTES\fR Bit-mask to extract attributes
|
||||
\fBA_COLOR\fR Bit-mask to extract color-pair field information
|
||||
.fi
|
||||
.SH NOTES
|
||||
Note that all of these routines may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,47 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_inchstr 3 ""
|
||||
.SH NAME
|
||||
\fBinchstr\fR, \fBinchnstr\fR, \fBwinchstr\fR,
|
||||
\fBwinchnstr\fR, \fBmvinchstr\fR, \fBmvinchnstr\fR, \fBmvwinchstr\fR,
|
||||
\fBmvwinchnstr\fR - get a string of characters (and attributes) from a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint inchstr(chtype *chstr);\fR
|
||||
.br
|
||||
\fBint inchnstr(chtype *chstr, int n);\fR
|
||||
.br
|
||||
\fBint winchstr(WINDOW *win, chtype *chstr);\fR
|
||||
.br
|
||||
\fBint winchnstr(WINDOW *win, chtype *chstr, int n);\fR
|
||||
.br
|
||||
\fBint mvinchstr(int y, int x, chtype *chstr);\fR
|
||||
.br
|
||||
\fBint mvinchnstr(int y, int x, chtype *chstr, int n);\fR
|
||||
.br
|
||||
\fBint mvwinchstr(WINDOW *win, int y, int x, chtype *chstr);\fR
|
||||
.br
|
||||
\fBint mvwinchnstr(WINDOW *win, int y, int x, chtype *chstr, int n);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines return a NULL-terminated array of \fBchtype\fR quantities,
|
||||
starting at the current cursor position in the named window and ending at the
|
||||
right margin of the window. The four functions with \fIn\fR as
|
||||
the last argument, return a leading substring at most \fIn\fR characters long.
|
||||
Constants defined in \fB<ncurses.h>\fR can be used with the \fB&\fR (logical
|
||||
AND) operator to extract the character or the attribute alone from any position
|
||||
in the \fIchstr\fR [see curs_inch(3)].
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that all routines except \fBwinchnstr\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_inch\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,86 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_initscr 3 ""
|
||||
.SH NAME
|
||||
\fBinitscr\fR, \fBnewterm\fR, \fBendwin\fR,
|
||||
\fBisendwin\fR, \fBset_term\fR,
|
||||
\fBdelscreen\fR - \fBncurses\fR screen initialization and manipulation routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBWINDOW *initscr(void);\fR
|
||||
.br
|
||||
\fBint endwin(void);\fR
|
||||
.br
|
||||
\fBint isendwin(void);\fR
|
||||
.br
|
||||
\fBSCREEN *newterm(char *type, FILE *outfd, FILE *infd);\fR
|
||||
.br
|
||||
\fBSCREEN *set_term(SCREEN *new);\fR
|
||||
.br
|
||||
\fBvoid delscreen(SCREEN* sp);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
\fBinitscr\fR is normally the first \fBncurses\fR routine to call when
|
||||
initializing a program. A few special routines sometimes need to be
|
||||
called before it; these are \fBslk_init\fR, \fBfilter\fR, \fBripoffline\fR,
|
||||
\fBuse_env\fR. For multiple-terminal applications, or in order to test
|
||||
for the presence of given capabilities, \fBnewterm\fR may be called before
|
||||
\fBinitscr\fR.
|
||||
|
||||
The initscr code determines the terminal type and initializes all \fBncurses\fR
|
||||
data structures. \fBinitscr\fR also causes the first call to \fBrefresh\fR to
|
||||
clear the screen. If errors occur, \fBinitscr\fR writes an appropriate error
|
||||
message to standard error and exits; otherwise, a pointer is returned to
|
||||
\fBstdscr\fR.
|
||||
|
||||
A program that outputs to more than one terminal should use the \fBnewterm\fR
|
||||
routine for each terminal instead of \fBinitscr\fR. A program that needs to
|
||||
inspect capabilities, so it can continue to run in a line-oriented mode if the
|
||||
terminal cannot support a screen-oriented program, would also use
|
||||
\fBnewterm\fR. The routine \fBnewterm\fR should be called once for each
|
||||
terminal. It returns a variable of type \fBSCREEN *\fR which should be saved
|
||||
as a reference to that terminal. The arguments are the \fItype\fR of the
|
||||
terminal to be used in place of \fB$TERM\fR, a file pointer for output to the
|
||||
terminal, and another file pointer for input from the terminal (if \fItype\fR
|
||||
is \fBNULL\fR, \fB$TERM\fR will be used). The program must also call
|
||||
\fBendwin\fR for each terminal being used before exiting from ncurses. If
|
||||
\fBnewterm\fR is called more than once for the same terminal, the first
|
||||
terminal referred to must be the last one for which \fBendwin\fR is called.
|
||||
|
||||
A program should always call \fBendwin\fR before exiting or escaping from
|
||||
\fBncurses\fR mode temporarily. This routine restores tty modes, moves the
|
||||
cursor to the lower left-hand corner of the screen and resets the terminal into
|
||||
the proper non-visual mode. Calling \fBrefresh\fR or \fBdoupdate\fR after a
|
||||
temporary escape causes the program to resume visual mode.
|
||||
|
||||
The \fBisendwin\fR routine returns \fBTRUE\fR if \fBendwin\fR has been
|
||||
called without any subsequent calls to \fBwrefresh\fR, and \fBFALSE\fR
|
||||
otherwise.
|
||||
|
||||
The \fBset_term\fR routine is used to switch between different
|
||||
terminals. The screen reference \fBnew\fR becomes the new current
|
||||
terminal. The previous terminal is returned by the routine. This is
|
||||
the only routine which manipulates \fBSCREEN\fR pointers; all other
|
||||
routines affect only the current terminal.
|
||||
|
||||
The \fBdelscreen\fR routine frees storage associated with the
|
||||
\fBSCREEN\fR data structure. The \fBendwin\fR routine does not do
|
||||
this, so \fBdelscreen\fR should be called after \fBendwin\fR if a
|
||||
particular \fBSCREEN\fR is no longer needed.
|
||||
.SH RETURN VALUE
|
||||
\fBendwin\fR returns the integer \fBERR\fR upon failure and \fBOK\fR
|
||||
upon successful completion.
|
||||
|
||||
Routines that return pointers always return \fBNULL\fR on error.
|
||||
.SH NOTES
|
||||
Note that \fBinitscr\fR and \fBnewterm\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_kernel\fR(3), \fBcurs_refresh\fR(3),
|
||||
\fBcurs_slk\fR(3), \fBcurs_util\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,172 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_inopts 3 ""
|
||||
.SH NAME
|
||||
\fBcbreak\fR, \fBnocbreak\fR, \fBecho\fR,
|
||||
\fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR, \fBkeypad\fR,
|
||||
\fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBraw\fR, \fBnoraw\fR,
|
||||
\fBnoqiflush\fR, \fBqiflush\fR, \fBtimeout\fR, \fBwtimeout\fR,
|
||||
\fBtypeahead\fR - \fBncurses\fR input options
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint cbreak(void);\fR
|
||||
.br
|
||||
\fBint nocbreak(void);\fR
|
||||
.br
|
||||
\fBint echo(void);\fR
|
||||
.br
|
||||
\fBint noecho(void);\fR
|
||||
.br
|
||||
\fBint halfdelay(int tenths);\fR
|
||||
.br
|
||||
\fBint intrflush(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint keypad(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint meta(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint nodelay(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint notimeout(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint raw(void);\fR
|
||||
.br
|
||||
\fBint noraw(void);\fR
|
||||
.br
|
||||
\fBvoid noqiflush(void);\fR
|
||||
.br
|
||||
\fBvoid qiflush(void);\fR
|
||||
.br
|
||||
\fBvoid timeout(int delay);\fR
|
||||
.br
|
||||
\fBvoid wtimeout(WINDOW *win, int delay);\fR
|
||||
.br
|
||||
\fBint typeahead(int fd);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
Normally, the tty driver buffers typed characters until a newline or carriage
|
||||
return is typed. The \fBcbreak\fR routine disables line buffering and
|
||||
erase/kill character-processing (interrupt and flow control characters are
|
||||
unaffected), making characters typed by the user immediately available to the
|
||||
program. The \fBnocbreak\fR routine returns the terminal to normal (cooked)
|
||||
mode.
|
||||
|
||||
Initially the terminal may or may not be in \fBcbreak\fR mode, as the mode is
|
||||
inherited; therefore, a program should call \fBcbreak\fR or \fBnocbreak\fR
|
||||
explicitly. Most interactive programs using \fBncurses\fR set the \fBcbreak\fR
|
||||
mode. Note that \fBcbreak\fR overrides \fBraw\fR. [See curs_getch(3) for a
|
||||
discussion of how these routines interact with \fBecho\fR and \fBnoecho\fR.]
|
||||
|
||||
The \fBecho\fR and \fBnoecho\fR routines control whether characters typed by
|
||||
the user are echoed by \fBgetch\fR as they are typed. Echoing by the tty
|
||||
driver is always disabled, but initially \fBgetch\fR is in echo mode, so
|
||||
characters typed are echoed. Authors of most interactive programs prefer to do
|
||||
their own echoing in a controlled area of the screen, or not to echo at all, so
|
||||
they disable echoing by calling \fBnoecho\fR. [See curs_getch(3) for a
|
||||
discussion of how these routines interact with \fBcbreak\fR and
|
||||
\fBnocbreak\fR.]
|
||||
|
||||
The \fBhalfdelay\fR routine is used for half-delay mode, which is similar to
|
||||
\fBcbreak\fR mode in that characters typed by the user are immediately
|
||||
available to the program. However, after blocking for \fItenths\fR tenths of
|
||||
seconds, ERR is returned if nothing has been typed. The value of \fBtenths\fR
|
||||
must be a number between 1 and 255. Use \fBnocbreak\fR to leave half-delay
|
||||
mode.
|
||||
|
||||
If the \fBintrflush\fR option is enabled, (\fIbf\fR is \fBTRUE\fR), when an
|
||||
interrupt key is pressed on the keyboard (interrupt, break, quit) all output in
|
||||
the tty driver queue will be flushed, giving the effect of faster response to
|
||||
the interrupt, but causing \fBncurses\fR to have the wrong idea of what is on
|
||||
the screen. Disabling (\fIbf\fR is \fBFALSE\fR), the option prevents the
|
||||
flush. The default for the option is inherited from the tty driver settings.
|
||||
The window argument is ignored.
|
||||
|
||||
The \fBkeypad\fR option enables the keypad of the user's terminal. If
|
||||
enabled (\fIbf\fR is \fBTRUE\fR), the user can press a function key
|
||||
(such as an arrow key) and \fBwgetch\fR returns a single value
|
||||
representing the function key, as in \fBKEY_LEFT\fR. If disabled
|
||||
(\fIbf\fR is \fBFALSE\fR), \fBncurses\fR does not treat function keys
|
||||
specially and the program has to interpret the escape sequences
|
||||
itself. If the keypad in the terminal can be turned on (made to
|
||||
transmit) and off (made to work locally), turning on this option
|
||||
causes the terminal keypad to be turned on when \fBwgetch\fR is
|
||||
called. The default value for keypad is false.
|
||||
|
||||
Initially, whether the terminal returns 7 or 8 significant bits on
|
||||
input depends on the control mode of the tty driver [see termios(4)].
|
||||
To force 8 bits to be returned, invoke \fBmeta\fR(\fIwin\fR,
|
||||
\fBTRUE\fR). To force 7 bits to be returned, invoke
|
||||
\fBmeta\fR(\fIwin\fR, \fBFALSE\fR). The window argument, \fIwin\fR,
|
||||
is always ignored. If the terminfo capabilities \fBsmm\fR (meta_on)
|
||||
and \fBrmm\fR (meta_off) are defined for the terminal, \fBsmm\fR is
|
||||
sent to the terminal when \fBmeta\fR(\fIwin\fR, \fBTRUE\fR) is called
|
||||
and \fBrmm\fR is sent when \fBmeta\fR(\fIwin\fR, \fBFALSE\fR) is
|
||||
called.
|
||||
|
||||
The \fBnodelay\fR option causes \fBgetch\fR to be a non-blocking call.
|
||||
If no input is ready, \fBgetch\fR returns \fBERR\fR. If disabled
|
||||
(\fIbf\fR is \fBFALSE\fR), \fBgetch\fR waits until a key is pressed.
|
||||
|
||||
While interpreting an input escape sequence, \fBwgetch\fR sets a timer
|
||||
while waiting for the next character. If \fBnotimeout(\fR\fIwin\fR,
|
||||
\fBTRUE\fR) is called, then \fBwgetch\fR does not set a timer. The
|
||||
purpose of the timeout is to differentiate between sequences received
|
||||
from a function key and those typed by a user.
|
||||
|
||||
With the \fBraw\fR and \fBnoraw\fR routines, the terminal is placed
|
||||
into or out of raw mode. Raw mode is similar to \fBcbreak\fR mode, in
|
||||
that characters typed are immediately passed through to the user
|
||||
program. The differences are that in raw mode, the interrupt, quit,
|
||||
suspend, and flow control characters are all passed through
|
||||
uninterpreted, instead of generating a signal. The behavior of the
|
||||
BREAK key depends on other bits in the tty driver that are not set by
|
||||
\fBncurses\fR.
|
||||
|
||||
When the \fBnoqiflush\fR routine is used, normal flush of input and
|
||||
output queues associated with the \fBINTR\fR, \fBQUIT\fR and
|
||||
\fBSUSP\fR characters will not be done [see termios(4)]. When
|
||||
\fBqiflush\fR is called, the queues will be flushed when these control
|
||||
characters are read.
|
||||
|
||||
The \fBtimeout\fR and \fBwtimeout\fR routines set blocking or
|
||||
non-blocking read for a given window. If \fIdelay\fR is negative,
|
||||
blocking read is used (\fIi\fR.\fIe\fR., waits indefinitely for
|
||||
input). If \fIdelay\fR is zero, then non-blocking read is used
|
||||
(\fIi\fR.\fIe\fR., read returns \fBERR\fR if no input is waiting). If
|
||||
\fIdelay\fR is positive, then read blocks for \fIdelay\fR
|
||||
milliseconds, and returns \fBERR\fR if there is still no input.
|
||||
Hence, these routines provide the same functionality as \fBnodelay\fR,
|
||||
plus the additional capability of being able to block for only
|
||||
\fIdelay\fR milliseconds (where \fIdelay\fR is positive).
|
||||
|
||||
\fBncurses\fR does ``line-breakout optimization'' by looking for
|
||||
typeahead periodically while updating the screen. If input is found,
|
||||
and it is coming from a tty, the current update is postponed until
|
||||
\fBrefresh\fR or \fBdoupdate\fR is called again. This allows faster
|
||||
response to commands typed in advance. Normally, the input FILE
|
||||
pointer passed to \fBnewterm\fR, or \fBstdin\fR in the case that
|
||||
\fBinitscr\fR was used, will be used to do this typeahead checking.
|
||||
The \fBtypeahead\fR routine specifies that the file descriptor
|
||||
\fIfd\fR is to be used to check for typeahead instead. If \fIfd\fR is
|
||||
-1, then no typeahead checking is done.
|
||||
.SH RETURN VALUE
|
||||
All routines that return an integer return \fBERR\fR upon failure and an
|
||||
integer value other than \fBERR\fR upon successful completion, unless otherwise
|
||||
noted in the preceding routine descriptions.
|
||||
.SH NOTES
|
||||
Note that \fBecho\fR, \fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR,
|
||||
\fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBnoqiflush\fR,
|
||||
\fBqiflush\fR, \fBtimeout\fR, and \fBwtimeout\fR may be macros.
|
||||
.SH BUGS
|
||||
The entry points \fBintrflush\fR, \fBqiflush\fR, \fBnoqiflush\fR, and
|
||||
\fBtypeahead\fR are not yet implemented in ncurses 1.8.6. The ncurses
|
||||
code does not do typeahead checking during input as SVr4 curses does.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_getch\fR(3), \fBcurs_initscr\fR(3), \fBtermios\fR(4)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,38 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_insch 3 ""
|
||||
.SH NAME
|
||||
\fBinsch\fR, \fBwinsch\fR, \fBmvinsch\fR,
|
||||
\fBmvwinsch\fR - insert a character before cursor in a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint insch(chtype ch);\fR
|
||||
.br
|
||||
\fBint winsch(WINDOW *win, chtype ch);\fR
|
||||
.br
|
||||
\fBint mvinsch(int y, int x, chtype ch);\fR
|
||||
.br
|
||||
\fBint mvwinsch(WINDOW *win, int y, int x, chtype ch);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines, insert the character \fIch\fR before the character under the
|
||||
cursor. All characters to the right of the cursor are moved one space to the
|
||||
right, with the possibility of the rightmost character on the line being lost.
|
||||
The insertion operation does not change the cursor position.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
These routines do not necessarily imply use of a hardware insert character
|
||||
feature.
|
||||
|
||||
Note that \fBinsch\fR, \fBmvinsch\fR, and \fBmvwinsch\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,59 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_insstr 3 ""
|
||||
.SH NAME
|
||||
\fBinsstr\fR, \fBinsnstr\fR, \fBwinsstr\fR, \fBwinsnstr\fR,
|
||||
\fBmvinsstr\fR, \fBmvinsnstr\fR, \fBmvwinsstr\fR,
|
||||
\fBmvwinsnstr\fR - insert string before cursor a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
.br
|
||||
\fBint insstr(char *str);\fR
|
||||
.br
|
||||
\fBint insnstr(char *str, int n);\fR
|
||||
.br
|
||||
\fBint winsstr(WINDOW *win, char *str);\fR
|
||||
.br
|
||||
\fBint winsnstr(WINDOW *win, char *str, int n);\fR
|
||||
.br
|
||||
\fBint mvinsstr(int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvinsnstr(int y, int x, char *str, int n);\fR
|
||||
.br
|
||||
\fBint mvwinsstr(WINDOW *win, int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvwinsnstr(WINDOW *win, int y, int x, char *str, int n);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines insert a character string (as many characters as will fit on the
|
||||
line) before the character under the cursor. All characters to the right of
|
||||
the cursor are shifted right, with the possibility of the rightmost characters
|
||||
on the line being lost. The cursor position does not change (after moving to
|
||||
\fIy\fR, \fIx\fR, if specified). The four routines with \fIn\fR as the last
|
||||
argument insert a leading substring of at most \fIn\fR characters. If
|
||||
\fIn\fR<=0, then the entire string is inserted.
|
||||
|
||||
If a character in \fIstr\fR is a tab, newline, carriage return or
|
||||
backspace, the cursor is moved appropriately within the window. A
|
||||
newline also does a \fBclrtoeol\fR before moving. Tabs are considered
|
||||
to be at every eighth column. If a character in \fIstr\fR is another
|
||||
control character, it is drawn in the \fB^\fR\fIX\fR notation.
|
||||
Calling \fBwinch\fR after adding a control character (and moving to
|
||||
it, if necessary) does not return the control character, but instead
|
||||
returns a character in the ^-representation of the control character.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH BUGS
|
||||
Entry points for these functions are in ncurses.h but they are not
|
||||
implemented as of ncurses 1.8.6.
|
||||
.SH NOTES
|
||||
Note that all but \fBwinsnstr\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_clear\fR(3), \fBcurs_inch\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,48 +0,0 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_instr 3 ""
|
||||
.SH NAME
|
||||
\fBinstr\fR, \fBinnstr\fR, \fBwinstr\fR, \fBwinnstr\fR,
|
||||
\fBmvinstr\fR, \fBmvinnstr\fR, \fBmvwinstr\fR,
|
||||
\fBmvwinnstr\fR - get a string of characters from a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint instr(char *str);\fR
|
||||
.br
|
||||
\fBint innstr(char *str, int n);\fR
|
||||
.br
|
||||
\fBint winstr(WINDOW *win, char *str);\fR
|
||||
.br
|
||||
\fBint winnstr(WINDOW *win, char *str, int n);\fR
|
||||
.br
|
||||
\fBint mvinstr(int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvinnstr(int y, int x, char *str, int n);\fR
|
||||
.br
|
||||
\fBint mvwinstr(WINDOW *win, int y, int x, char *str);\fR
|
||||
.br
|
||||
\fBint mvwinnstr(WINDOW *win, int y, int x, char *str, int n);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines return a string of characters in \fIstr\fR, extracted starting
|
||||
at the current cursor position in the named window and ending at the right
|
||||
margin of the window. Attributes are stripped from the characters. The four
|
||||
functions with \fIn\fR as the last argument return a leading substring at most
|
||||
\fIn\fR characters long.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that all routines except \fBwinnstr\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"
|
||||
.\"# End:
|
||||
|
@ -1,117 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_kernel 3 ""
|
||||
.SH NAME
|
||||
\fBdef_prog_mode\fR, \fBdef_shell_mode\fR,
|
||||
\fBreset_prog_mode\fR, \fBreset_shell_mode\fR, \fBresetty\fR,
|
||||
\fBsavetty\fR, \fBgetsyx\fR, \fBsetsyx\fR, \fBripoffline\fR,
|
||||
\fBcurs_set\fR, \fBnapms\fR - low-level \fBncurses\fR routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint def_prog_mode(void);\fR
|
||||
.br
|
||||
\fBint def_shell_mode(void);\fR
|
||||
.br
|
||||
\fBint reset_prog_mode(void);\fR
|
||||
.br
|
||||
\fBint reset_shell_mode(void);\fR
|
||||
.br
|
||||
\fBint resetty(void);\fR
|
||||
.br
|
||||
\fBint savetty(void);\fR
|
||||
.br
|
||||
\fBint getsyx(int y, int x);\fR
|
||||
.br
|
||||
\fBint setsyx(int y, int x);\fR
|
||||
.br
|
||||
\fBint ripoffline(int line, int (*init)(WINDOW *, int));\fR
|
||||
.br
|
||||
\fBint curs_set(int visibility);\fR
|
||||
.br
|
||||
\fBint napms(int ms);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The following routines give low-level access to various \fBncurses\fR
|
||||
capabilities. Theses routines typically are used inside library
|
||||
routines.
|
||||
|
||||
The \fBdef_prog_mode\fR and \fBdef_shell_mode\fR routines save the
|
||||
current terminal modes as the "program" (in \fBncurses\fR) or "shell"
|
||||
(not in \fBncurses\fR) state for use by the \fBreset_prog_mode\fR and
|
||||
\fBreset_shell_mode\fR routines. This is done automatically by
|
||||
\fBinitscr\fR.
|
||||
|
||||
The \fBreset_prog_mode\fR and \fBreset_shell_mode\fR routines restore
|
||||
the terminal to "program" (in \fBncurses\fR) or "shell" (out of
|
||||
\fBncurses\fR) state. These are done automatically by \fBendwin\fR
|
||||
and, after an \fBendwin\fR, by \fBdoupdate\fR, so they normally are
|
||||
not called.
|
||||
|
||||
The \fBresetty\fR and \fBsavetty\fR routines save and restore the
|
||||
state of the terminal modes. \fBsavetty\fR saves the current state in
|
||||
a buffer and \fBresetty\fR restores the state to what it was at the
|
||||
last call to \fBsavetty\fR.
|
||||
|
||||
With the \fBgetsyx\fR routine, the current coordinates of the virtual
|
||||
screen cursor are returned in \fIy\fR and \fIx\fR. If \fBleaveok\fR
|
||||
is currently \fBTRUE\fR, then \fB-1\fR,\fB-1\fR is returned. If lines
|
||||
have been removed from the top of the screen, using \fBripoffline\fR,
|
||||
\fIy\fR and \fIx\fR include these lines; therefore, \fIy\fR and
|
||||
\fIx\fR should be used only as arguments for \fBsetsyx\fR.
|
||||
|
||||
With the \fBsetsyx\fR routine, the virtual screen cursor is set to
|
||||
\fIy\fR, \fIx\fR. If \fIy\fR and \fIx\fR are both \fB-1\fR, then
|
||||
\fBleaveok\fR is set. The two routines \fBgetsyx\fR and \fBsetsyx\fR
|
||||
are designed to be used by a library routine, which manipulates
|
||||
\fBncurses\fR windows but does not want to change the current position
|
||||
of the program's cursor. The library routine would call \fBgetsyx\fR
|
||||
at the beginning, do its manipulation of its own windows, do a
|
||||
\fBwnoutrefresh\fR on its windows, call \fBsetsyx\fR, and then call
|
||||
\fBdoupdate\fR.
|
||||
|
||||
The \fBripoffline\fR routine provides access to the same facility that
|
||||
\fBslk_init\fR [see curs_slk(3)] uses to reduce the size of the
|
||||
screen. \fBripoffline\fR must be called before \fBinitscr\fR or
|
||||
\fBnewterm\fR is called. If \fIline\fR is positive, a line is removed
|
||||
from the top of \fBstdscr\fR; if \fIline\fR is negative, a line is
|
||||
removed from the bottom. When this is done inside \fBinitscr\fR, the
|
||||
routine \fBinit\fR (supplied by the user) is called with two
|
||||
arguments: a window pointer to the one-line window that has been
|
||||
allocated and an integer with the number of columns in the window.
|
||||
Inside this initialization routine, the integer variables \fBLINES\fR
|
||||
and \fBCOLS\fR (defined in \fB<ncurses.h>\fR) are not guaranteed to be
|
||||
accurate and \fBwrefresh\fR or \fBdoupdate\fR must not be called. It
|
||||
is allowable to call \fBwnoutrefresh\fR during the initialization
|
||||
routine.
|
||||
|
||||
\fBripoffline\fR can be called up to five times before calling \fBinitscr\fR or
|
||||
\fBnewterm\fR.
|
||||
|
||||
The \fBcurs_set\fR routine sets the cursor state is set to invisible,
|
||||
normal, or very visible for \fBvisibility\fR equal to \fB0\fR,
|
||||
\fB1\fR, or \fB2\fR respectively. If the terminal supports the
|
||||
\fIvisibility\fR requested, the previous \fIcursor\fR state is
|
||||
returned; otherwise, \fBERR\fR is returned.
|
||||
|
||||
The \fBnapms\fR routine is used to sleep for \fIms\fR milliseconds.
|
||||
.SH RETURN VALUE
|
||||
Except for \fBcurs_set\fR, these routines always return \fBOK\fR.
|
||||
\fBcurs_set\fR returns the previous cursor state, or \fBERR\fR if the
|
||||
requested \fIvisibility\fR is not supported.
|
||||
.SH NOTES
|
||||
Note that \fBgetsyx\fR is a macro, so \fB&\fR is not necessary before
|
||||
the variables \fIy\fR and \fIx\fR.
|
||||
|
||||
The SVr4 man pages warn that the return value of \fBcurs_set\fR "is currently
|
||||
incorrect". This implementation gets it right, but it may be unwise to count
|
||||
on the correctness of the return value anywhere else.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_initscr\fR(3), \fBcurs_outopts\fR(3), \fBcurs_refresh\fR(3),
|
||||
\fBcurs_scr_dmp\fR(3), \fBcurs_slk\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,30 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_move 3 ""
|
||||
.SH NAME
|
||||
\fBmove\fR, \fBwmove\fR - move \fBncurses\fR window cursor
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint move(int y, int x);\fR
|
||||
.br
|
||||
\fBint wmove(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines move the cursor associated with the window to line \fIy\fR and
|
||||
column \fIx\fR. This routine does not move the physical cursor of the terminal
|
||||
until \fBrefresh\fR is called. The position specified is relative to the upper
|
||||
left-hand corner of the window, which is (0,0).
|
||||
.SH RETURN VALUE
|
||||
These routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that \fBmove\fR may be a macro.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_refresh\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,117 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_outopts 3 ""
|
||||
.SH NAME
|
||||
\fBclearok\fR, \fBidlok\fR, \fBidcok immedok\fR,
|
||||
\fBleaveok\fR, \fBsetscrreg\fR, \fBwsetscrreg\fR, \fBscrollok\fR,
|
||||
\fBnl\fR, \fBnonl\fR - \fBncurses\fR output options
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint clearok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint idlok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBvoid idcok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBvoid immedok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint leaveok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint setscrreg(int top, int bot);\fR
|
||||
.br
|
||||
\fBint wsetscrreg(WINDOW *win, int top, int bot);\fR
|
||||
.br
|
||||
\fBint scrollok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBint nl(void);\fR
|
||||
.br
|
||||
\fBint nonl(void);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These routines set options that change the style of output within
|
||||
\fBncurses\fR. All options are initially \fBFALSE\fR, unless otherwise stated.
|
||||
It is not necessary to turn these options off before calling \fBendwin\fR.
|
||||
|
||||
With the \fBclearok\fR routine, if enabled (\fIbf\fR is \fBTRUE\fR), the next
|
||||
call to \fBwrefresh\fR with this window will clear the screen completely and
|
||||
redraw the entire screen from scratch. This is useful when the contents of the
|
||||
screen are uncertain, or in some cases for a more pleasing visual effect. If
|
||||
the \fIwin\fR argument to \fBclearok\fR is the global variable \fBcurscr\fR,
|
||||
the next call to \fBwrefresh\fR with any window causes the screen to be cleared
|
||||
and repainted from scratch.
|
||||
|
||||
With the \fBidlok\fR routine, if enabled (\fIbf\fR is \fBTRUE\fR),
|
||||
\fBncurses\fR considers using the hardware insert/delete line feature of
|
||||
terminals so equipped. If disabled (\fIbf\fR is \fBFALSE\fR), \fBncurses\fR
|
||||
very seldom uses this feature. (The insert/delete character feature is always
|
||||
considered.) This option should be enabled only if the application needs
|
||||
insert/delete line, for example, for a screen editor. It is disabled by
|
||||
default because insert/delete line tends to be visually annoying when used in
|
||||
applications where it isn't really needed. If insert/delete line cannot be
|
||||
used, \fBncurses\fR redraws the changed portions of all lines.
|
||||
|
||||
With the \fBidcok\fR routine, if enabled (\fIbf\fR is \fBTRUE\fR),
|
||||
\fBncurses\fR considers using the hardware insert/delete character feature of
|
||||
terminals so equipped. This is enabled by default.
|
||||
|
||||
With the \fBimmedok\fR routine, if enabled (\fIbf\fR is \fBTRUE)\fR, any change
|
||||
in the window image, such as the ones caused by \fBwaddch, wclrtobot, wscrl\fR,
|
||||
\fIetc\fR., automatically cause a call to \fBwrefresh\fR. However, it may
|
||||
degrade the performance considerably, due to repeated calls to \fBwrefresh\fR.
|
||||
It is disabled by default.
|
||||
|
||||
Normally, the hardware cursor is left at the location of the window cursor
|
||||
being refreshed. The \fBleaveok\fR option allows the cursor to be left
|
||||
wherever the update happens to leave it. It is useful for applications where
|
||||
the cursor is not used, since it reduces the need for cursor motions. If
|
||||
possible, the cursor is made invisible when this option is enabled.
|
||||
|
||||
The \fBsetscrreg\fR and \fBwsetscrreg\fR routines allow the application
|
||||
programmer to set a software scrolling region in a window. \fItop\fR and
|
||||
\fIbot\fR are the line numbers of the top and bottom margin of the scrolling
|
||||
region. (Line 0 is the top line of the window.) If this option and
|
||||
\fBscrollok\fR are enabled, an attempt to move off the bottom margin line
|
||||
causes all lines in the scrolling region to scroll up one line. Only the text
|
||||
of the window is scrolled. (Note that this has nothing to do with the use of a
|
||||
physical scrolling region capability in the terminal, like that in the VT100.
|
||||
If \fBidlok\fR is enabled and the terminal has either a scrolling region or
|
||||
insert/delete line capability, they will probably be used by the output
|
||||
routines.)
|
||||
|
||||
The \fBscrollok\fR option controls what happens when the cursor of a window is
|
||||
moved off the edge of the window or scrolling region, either as a result of a
|
||||
newline action on the bottom line, or typing the last character of the last
|
||||
line. If disabled, (\fIbf\fR is \fBFALSE\fR), the cursor is left on the bottom
|
||||
line. If enabled, (\fIbf\fR is \fBTRUE\fR), \fBwrefresh\fR is called on the
|
||||
window, and the physical terminal and window are scrolled up one line. [Note
|
||||
that in order to get the physical scrolling effect on the terminal, it is also
|
||||
necessary to call \fBidlok\fR.]
|
||||
|
||||
The \fBnl\fR and \fBnonl\fR routines control whether newline is translated into
|
||||
carriage return and linefeed on output, and whether return is translated into
|
||||
newline on input. Initially, the translations do occur. By disabling these
|
||||
translations using \fBnonl\fR, \fBncurses\fR is able to make better use of the
|
||||
linefeed capability, resulting in faster cursor motion.
|
||||
.SH RETURN VALUE
|
||||
\fBsetscrreg\fR and \fBwsetscrreg\fR return \fBOK\fR upon success and \fBERR\fR upon failure.
|
||||
All other routines that return an integer always return \fBOK\fR.
|
||||
.SH BUGS
|
||||
The entry points \fBidcok\fR, \fBimmedok\fR are not yet implemented in
|
||||
ncurses 1.8.6. Setting \fIidlok\fR has unfortunate effects on scrolling
|
||||
windows.
|
||||
.SH NOTES
|
||||
Note that \fBclearok\fR, \fBleaveok\fR, \fBscrollok\fR, \fBidcok\fR, \fBnl\fR,
|
||||
\fBnonl\fR and \fBsetscrreg\fR may be macros.
|
||||
|
||||
The \fBimmedok\fR routine is useful for windows that are used as terminal
|
||||
emulators.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_addch\fR(3), \fBcurs_clear\fR(3),
|
||||
\fBcurs_initscr\fR(3), \fBcurs_scroll\fR(3), \fBcurs_refresh\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,43 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_overlay 3 ""
|
||||
.SH NAME
|
||||
\fBoverlay\fR, \fBoverwrite\fR,
|
||||
\fBcopywin\fR - overlay and manipulate overlapped \fBncurses\fR windows
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint overlay(WINDOW *srcwin, WINDOW *dstwin);\fR
|
||||
.br
|
||||
\fBint overwrite(WINDOW *srcwin, WINDOW *dstwin);\fR
|
||||
.br
|
||||
\fBint copywin(WINDOW *srcwin, WINDOW *dstwin, int sminrow,
|
||||
int smincol, int dminrow, int dmincol, int dmaxrow,
|
||||
int dmaxcol, int overlay);\fR
|
||||
.SH DESCRIPTION
|
||||
The \fBoverlay\fR and \fBoverwrite\fR routines overlay \fIsrcwin\fR on
|
||||
top of \fIdstwin\fR. \fIscrwin\fR and \fIdstwin\fR are not required
|
||||
to be the same size; only text where the two windows overlap is
|
||||
copied. The difference is that \fBoverlay\fR is non-destructive
|
||||
(blanks are not copied) whereas \fBoverwrite\fR is destructive.
|
||||
|
||||
The \fBcopywin\fR routine provides a finer granularity of control over the
|
||||
\fBoverlay\fR and \fBoverwrite\fR routines. Like in the \fBprefresh\fR
|
||||
routine, a rectangle is specified in the destination window, (\fIdminrow\fR,
|
||||
\fIdmincol\fR) and (\fIdmaxrow\fR, \fIdmaxcol\fR), and the upper-left-corner
|
||||
coordinates of the source window, (\fIsminrow\fR, \fIsmincol\fR). If the
|
||||
argument \fIoverlay\fR is \fBtrue\fR, then copying is non-destructive, as in
|
||||
\fBoverlay\fR.
|
||||
.SH RETURN VALUE
|
||||
Routines that return an integer return \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that \fBoverlay\fR and \fBoverwrite\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_pad\fR(3), \fBcurs_refresh\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,76 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_pad 3 ""
|
||||
.SH NAME
|
||||
\fBnewpad\fR, \fBsubpad\fR, \fBprefresh\fR,
|
||||
\fBpnoutrefresh\fR, \fBpechochar\fR - create and display \fBncurses\fR pads
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBWINDOW *newpad(int nlines, int ncols);\fR
|
||||
.br
|
||||
\fBWINDOW *subpad(WINDOW *orig, int nlines, int ncols,
|
||||
int begin_y, int begin_x);\fR
|
||||
\fBint prefresh(WINDOW *pad, int pminrow, int pmincol,
|
||||
int sminrow, int smincol, int smaxrow, int smaxcol);\fR
|
||||
\fBint pnoutrefresh(WINDOW *pad, int pminrow, int pmincol,
|
||||
int sminrow, int smincol, int smaxrow, int smaxcol);\fR
|
||||
\fBint pechochar(WINDOW *pad, chtype ch);\fR
|
||||
.SH DESCRIPTION
|
||||
The \fBnewpad\fR routine creates and returns a pointer to a new pad data
|
||||
structure with the given number of lines, \fInlines\fR, and columns,
|
||||
\fIncols\fR. A pad is like a window, except that it is not restricted by the
|
||||
screen size, and is not necessarily associated with a particular part of the
|
||||
screen. Pads can be used when a large window is needed, and only a part of the
|
||||
window will be on the screen at one time. Automatic refreshes of pads
|
||||
(\fIe\fR.\fIg\fR., from scrolling or echoing of input) do not occur. It is not
|
||||
legal to call \fBwrefresh\fR with a \fIpad\fR as an argument; the routines
|
||||
\fBprefresh\fR or \fBpnoutrefresh\fR should be called instead. Note that these
|
||||
routines require additional parameters to specify the part of the pad to be
|
||||
displayed and the location on the screen to be used for the display.
|
||||
|
||||
The \fBsubpad\fR routine creates and returns a pointer to a subwindow within a
|
||||
pad with the given number of lines, \fInlines\fR, and columns, \fIncols\fR.
|
||||
Unlike \fBsubwin\fR, which uses screen coordinates, the window is at position
|
||||
(\fIbegin\fR_\fIx\fR\fB,\fR \fIbegin\fR_\fIy\fR) on the pad. The window is
|
||||
made in the middle of the window \fIorig\fR, so that changes made to one window
|
||||
affect both windows. During the use of this routine, it will often be
|
||||
necessary to call \fBtouchwin\fR or \fBtouchline\fR on \fIorig\fR before
|
||||
calling \fBprefresh\fR.
|
||||
|
||||
The \fBprefresh\fR and \fBpnoutrefresh\fR routines are analogous to
|
||||
\fBwrefresh\fR and \fBwnoutrefresh\fR except that they relate to pads instead
|
||||
of windows. The additional parameters are needed to indicate what part of the
|
||||
pad and screen are involved. \fIpminrow\fR and \fIpmincol\fR specify the upper
|
||||
left-hand corner of the rectangle to be displayed in the pad. \fIsminrow\fR,
|
||||
\fIsmincol\fR, \fIsmaxrow\fR, and \fIsmaxcol\fR specify the edges of the
|
||||
rectangle to be displayed on the screen. The lower right-hand corner of the
|
||||
rectangle to be displayed in the pad is calculated from the screen coordinates,
|
||||
since the rectangles must be the same size. Both rectangles must be entirely
|
||||
contained within their respective structures. Negative values of
|
||||
\fIpminrow\fR, \fIpmincol\fR, \fIsminrow\fR, or \fIsmincol\fR are treated as if
|
||||
they were zero.
|
||||
|
||||
The \fBpechochar\fR routine is functionally equivalent to a call to \fBaddch\fR
|
||||
followed by a call to \fBrefresh\fR, a call to \fBwaddch\fR followed by a call
|
||||
to \fBwrefresh\fR, or a call to \fBwaddch\fR followed by a call to
|
||||
\fBprefresh.\fR The knowledge that only a single character is being output is
|
||||
taken into consideration and, for non-control characters, a considerable
|
||||
performance gain might be seen by using these routines instead of their
|
||||
equivalents. In the case of \fBpechochar\fR, the last location of the pad on
|
||||
the screen is reused for the arguments to \fBprefresh\fR.
|
||||
.SH RETURN VALUE
|
||||
Routines that return an integer return \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion.
|
||||
|
||||
Routines that return pointers return \fBNULL\fR on error.
|
||||
.SH NOTES
|
||||
Note that \fBpechochar\fR may be a macro.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_refresh\fR(3), \fBcurs_touch\fR(3), \fBcurs_addch\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,43 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_printw 3 ""
|
||||
.SH NAME
|
||||
\fBprintw\fR, \fBwprintw\fR, \fBmvprintw\fR,
|
||||
\fBmvwprintw\fR, \fBvwprintw\fR - print formatted output in \fBncurses\fR windows
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint printw(char *fmt\fR [\fB, arg\fR] \fB...);\fR
|
||||
.br
|
||||
\fBint wprintw(WINDOW *win, char *fmt\fR [\fB, arg\fR] \fB...);\fR
|
||||
.br
|
||||
\fBint mvprintw(int y, int x, char *fmt\fR [\fB, arg\fR] \fB...);\fR
|
||||
.br
|
||||
\fBint mvwprintw(WINDOW *win, int y, int x,
|
||||
\fBchar *fmt\fR [\fB, arg]\fR ...);
|
||||
|
||||
\fB#include <varargs.h>\fR
|
||||
.br
|
||||
\fBint vwprintw(WINDOW *win, char *fmt, varglist);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBprintw\fR, \fBwprintw\fR, \fBmvprintw\fR and \fBmvwprintw\fR
|
||||
routines are analogous to \fBprintf\fR [see \fBprintf\fR(3)]. In
|
||||
effect, the string that would be output by \fBprintf\fR is output
|
||||
instead as though \fBwaddstr\fR were used on the given window.
|
||||
|
||||
The \fBvwprintw\fR routine is analogous to \fBvprintf\fR [see
|
||||
\fBprintf\fR(3)] and performs a \fBwprintw\fR using a variable
|
||||
argument list. The third argument is a \fBva_list\fR, a pointer to a
|
||||
list of arguments, as defined in \fB<varargs.h>\fR.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBprintf\fR(3), \fBvprintf(3)\fR
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,71 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_refresh 3 ""
|
||||
.SH NAME
|
||||
\fBrefresh\fR, \fBwrefresh\fR, \fBwnoutrefresh\fR,
|
||||
\fBdoupdate\fR, \fBredrawwin\fR,
|
||||
\fBwredrawln\fR - refresh \fBncurses\fR windows and lines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint refresh(void);\fR
|
||||
.br
|
||||
\fBint wrefresh(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint wnoutrefresh(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint doupdate(void);\fR
|
||||
.br
|
||||
\fBint redrawwin(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint wredrawln(WINDOW *win, int beg_line, int num_lines);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBrefresh\fR and \fBwrefresh\fR routines (or \fBwnoutrefresh\fR and
|
||||
\fBdoupdate\fR) must be called to get actual output to the terminal, as other
|
||||
routines merely manipulate data structures. The routine \fBwrefresh\fR copies
|
||||
the named window to the physical terminal screen, taking into account what is
|
||||
already there in order to do optimizations. The \fBrefresh\fR routine is the
|
||||
same, using \fBstdscr\fR as the default window. Unless \fBleaveok\fR has been
|
||||
enabled, the physical cursor of the terminal is left at the location of the
|
||||
cursor for that window.
|
||||
|
||||
The \fBwnoutrefresh\fR and \fBdoupdate\fR routines allow multiple updates with
|
||||
more efficiency than \fBwrefresh\fR alone. In addition to all the window
|
||||
structures, \fBncurses\fR keeps two data structures representing the terminal
|
||||
screen: a physical screen, describing what is actually on the screen, and a
|
||||
virtual screen, describing what the programmer wants to have on the screen.
|
||||
|
||||
The routine \fBwrefresh\fR works by first calling \fBwnoutrefresh\fR, which
|
||||
copies the named window to the virtual screen, and then calling \fBdoupdate\fR,
|
||||
which compares the virtual screen to the physical screen and does the actual
|
||||
update. If the programmer wishes to output several windows at once, a series
|
||||
of calls to \fBwrefresh\fR results in alternating calls to \fBwnoutrefresh\fR
|
||||
and \fBdoupdate\fR, causing several bursts of output to the screen. By first
|
||||
calling \fBwnoutrefresh\fR for each window, it is then possible to call
|
||||
\fBdoupdate\fR once, resulting in only one burst of output, with fewer total
|
||||
characters transmitted and less CPU time used. If the \fIwin\fR argument to
|
||||
\fBwrefresh\fR is the global variable \fBcurscr\fR, the screen is immediately
|
||||
cleared and repainted from scratch.
|
||||
|
||||
The \fBredrawwin\fR routine indicates to \fBncurses\fR that some screen lines
|
||||
are corrupted and should be thrown away before anything is written over them.
|
||||
These routines could be used for programs such as editors, which want a command
|
||||
to redraw some part of the screen or the entire screen. The routine
|
||||
\fBredrawln\fR is preferred over \fBredrawwin\fR where a noisy communication
|
||||
line exists and redrawing the entire window could be subject to even more
|
||||
communication noise. Just redrawing several lines offers the possibility that
|
||||
they would show up unblemished.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that \fBrefresh\fR and \fBredrawwin\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_outopts\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,45 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_scanw 3 ""
|
||||
.SH NAME
|
||||
\fBscanw\fR, \fBwscanw\fR, \fBmvscanw\fR,
|
||||
\fBmvwscanw\fR, \fBvwscanw\fR - convert formatted input from a \fBncurses\fR widow
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint scanw(char *fmt\fR [\fB, arg\fR] \fB...);\fR
|
||||
.br
|
||||
\fBint wscanw(WINDOW *win, char *fmt\fR [\fB, arg\fR] \fB...);\fR
|
||||
.br
|
||||
\fBint mvscanw(int y, int x, char *fmt\fR [\fB, arg\fR] \fB...);\fR
|
||||
.br
|
||||
\fBint mvwscanw(WINDOW *win, int y, int x,
|
||||
char *fmt\fR [\fB, arg]\fR \fB...);\fR
|
||||
.br
|
||||
\fBint vwscanw(WINDOW *win, char *fmt, va_list varglist);\fR
|
||||
.SH DESCRIPTION
|
||||
The \fBscanw\fR, \fBwscanw\fR and \fBmvscanw\fR routines are analogous to
|
||||
\fBscanf\fR [see \fBscanf\fR(3)]. The effect of these routines is as though
|
||||
\fBwgetstr\fR were called on the window, and the resulting line used as input
|
||||
for \fBsscanf\fR(3). Fields which do not map to a variable in the \fIfmt\fR
|
||||
field are lost.
|
||||
|
||||
The \fBvwscanw\fR routine is similar to \fBvwprintw\fR in that it performs a
|
||||
\fBwscanw\fR using a variable argument list. The third argument is a
|
||||
\fIva\fR_\fIlist\fR, a pointer to a list of arguments, as defined in
|
||||
\fB<varargs.h>\fR.
|
||||
.SH RETURN VALUE
|
||||
\fBvwscanw\fR returns \fBERR\fR on failure and an integer equal to the
|
||||
number of fields scanned on success.
|
||||
|
||||
Applications may use the return value from the \fBscanw\fR, \fBwscanw\fR,
|
||||
\fBmvscanw\fR and \fBmvwscanw\fR routines to determine the number of fields
|
||||
which were mapped in the call.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_getstr\fR(3), \fBcurs_printw\fR(3), \fBscanf\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,60 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_scr_dump 3 ""
|
||||
.SH NAME
|
||||
\fBscr_dump\fR, \fBscr_restore\fR,
|
||||
\fBscr_init\fR,
|
||||
\fBscr_set\fR - read (write) a \fBncurses\fR screen from (to) a file
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint scr_dump(char *filename);\fR
|
||||
.br
|
||||
\fBint scr_restore(char *filename);\fR
|
||||
.br
|
||||
\fBint scr_init(char *filename);\fR
|
||||
.br
|
||||
\fBint scr_set(char *filename);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBscr_dump\fR routine dumps the current contents of the virtual screen
|
||||
to the file \fIfilename\fR.
|
||||
|
||||
The \fBscr_restore\fR routine sets the virtual screen to the contents
|
||||
of \fIfilename\fR, which must have been written using \fBscr_dump\fR. The next
|
||||
call to \fBdoupdate\fR restores the screen to the way it looked in the dump
|
||||
file.
|
||||
|
||||
The \fBscr_init\fR routine reads in the contents of \fIfilename\fR and uses
|
||||
them to initialize the \fBncurses\fR data structures about what the terminal
|
||||
currently has on its screen. If the data is determined to be valid,
|
||||
\fBncurses\fR bases its next update of the screen on this information rather
|
||||
than clearing the screen and starting from scratch. \fBscr_init\fR is used
|
||||
after \fBinitscr\fR or a \fBsystem\fR [see \fBsystem\fR(BA_LIB)] call to share
|
||||
the screen with another process which has done a \fBscr_dump\fR after its
|
||||
\fBendwin\fR call. The data is declared invalid if the time-stamp of the tty
|
||||
is old or the terminfo capabilities \fBrmcup\fR and \fBnrrmc\fR exist.
|
||||
|
||||
The \fBscr_set\fR routine is a combination of \fBscr_restore\fR and
|
||||
\fBscr_init\fR. It tells the program that the information in \fIfilename\fR is
|
||||
what is currently on the screen, and also what the program wants on the screen.
|
||||
This can be thought of as a screen inheritance function.
|
||||
|
||||
To read (write) a window from (to) a file, use the \fBgetwin\fR and
|
||||
\fBputwin\fR routines [see \fBcurs_util\fR(3)].
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and \fBOK\fR
|
||||
upon success.
|
||||
.SH NOTES
|
||||
Note that \fBscr_init\fR, \fBscr_set\fR, and \fBscr_restore\fR may be macros.
|
||||
.BUGS
|
||||
The time-stamp and rmcup/nrrmc checks are not implemented in \fBncurses\fR(3).
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_initscr\fR(3), \fBcurs_refresh\fR(3),
|
||||
\fBcurs_util\fR(3), \fBsystem\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,39 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_scroll 3 ""
|
||||
.SH NAME
|
||||
\fBscroll\fR, \fBscrl\fR, \fBwscrl\fR - scroll a \fBncurses\fR window
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint scroll(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint scrl(int n);\fR
|
||||
.br
|
||||
\fBint wscrl(WINDOW *win, int n);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBscroll\fR routine scrolls the window up one line. This involves moving
|
||||
the lines in the window data structure. As an optimization, if the scrolling
|
||||
region of the window is the entire screen, the physical screen is scrolled at
|
||||
the same time.
|
||||
|
||||
With the \fBscrl\fR and \fBwscrl\fR routines, for positive \fIn\fR scroll the
|
||||
window up \fIn\fR lines (line \fIi\fR+\fIn\fR becomes \fIi\fR); otherwise
|
||||
scroll the window down \fIn\fR lines. This involves moving the lines in the
|
||||
window character image structure. The current cursor position is not changed.
|
||||
|
||||
For these functions to work, scrolling must be enabled via \fBscrollok\fR.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that \fBscrl\fR and \fBscroll\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_outopts\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,87 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_slk 3 ""
|
||||
.SH NAME
|
||||
\fBslk_init\fR, \fBslk_set\fR, \fBslk_refresh\fR,
|
||||
\fBslk_noutrefresh\fR, \fBslk_label\fR, \fBslk_clear\fR, \fBslk_restore\fR,
|
||||
\fBslk_touch\fR, \fBslk_attron\fR, \fBslk_attrset\fR,
|
||||
\fBslk_attroff\fR - \fBncurses\fR soft label routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint slk_init(int fmt);\fR
|
||||
.br
|
||||
\fBint slk_set(int labnum, char *label, int fmt);\fR
|
||||
.br
|
||||
\fBint slk_refresh(void);\fR
|
||||
.br
|
||||
\fBint slk_noutrefresh(void);\fR
|
||||
.br
|
||||
\fBchar *slk_label(int labnum);\fR
|
||||
.br
|
||||
\fBint slk_clear(void);\fR
|
||||
.br
|
||||
\fBint slk_restore(void);\fR
|
||||
.br
|
||||
\fBint slk_touch(void);\fR
|
||||
.br
|
||||
\fBint slk_attron(chtype attrs);\fR
|
||||
.br
|
||||
\fBint slk_attrset(chtype attrs);\fR
|
||||
.br
|
||||
\fBint slk_attroff(chtype attrs);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The slk* functions manipulate the set of soft function-key labels that exist on
|
||||
many terminals. For those terminals that do not have soft labels,
|
||||
\fBncurses\fR takes over the bottom line of \fBstdscr\fR, reducing the size of
|
||||
\fBstdscr\fR and the variable \fBLINES\fR. \fBncurses\fR standardizes on eight
|
||||
labels of up to eight characters each.
|
||||
|
||||
The \fBslk_init\fR routine must be called before \fBinitscr\fR or \fBnewterm\fR
|
||||
is called. If \fBinitscr\fR eventually uses a line from \fBstdscr\fR to
|
||||
emulate the soft labels, then \fIfmt\fR determines how the labels are arranged
|
||||
on the screen. Setting \fIfmt\fR to \fB0\fR indicates a 3-2-3 arrangement of
|
||||
the labels; \fB1\fR indicates a 4-4 arrangement.
|
||||
|
||||
With the \fBslk_set\fR routine, \fIlabnum\fR is the label number, from \fB1\fR
|
||||
to \fB8\fR. \fIlabel\fR is the string to be put on the label, up to eight
|
||||
characters in length. A null string or a null pointer sets up a blank label.
|
||||
\fIfmt\fR is either \fB0\fR, \fB1\fR, or \fB2\fR, indicating whether the label
|
||||
is to be left-justified, centered, or right-justified, respectively, within the
|
||||
label.
|
||||
|
||||
The \fBslk_refresh\fR and \fBslk_noutrefresh\fR routines correspond to
|
||||
the \fBwrefresh\fR and \fBwnoutrefresh\fR routines.
|
||||
|
||||
The \fBslk_label\fR routine returns the current label for label number
|
||||
\fIlabnum\fR, with leading and trailing blanks stripped.
|
||||
|
||||
The \fBslk_clear\fR routine clears the soft labels from the screen.
|
||||
|
||||
The \fBslk_restore\fR routine, restores the soft labels to the screen
|
||||
after a \fBslk_clear\fR has been performed.
|
||||
|
||||
The \fBslk_touch\fR routine forces all the soft labels to be output
|
||||
the next time a \fBslk_noutrefresh\fR is performed.
|
||||
|
||||
The \fBslk_attron\fR, \fBslk_attrset\fR and \fBslk_attroff\fR routines
|
||||
correspond to \fBattron\fR, \fBattrset\fR, and \fBattroff\fR. They
|
||||
have an effect only if soft labels are simulated on the bottom line of
|
||||
the screen.
|
||||
.SH RETURN VALUE
|
||||
Routines that return an integer return \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion.
|
||||
|
||||
\fBslk_label\fR returns \fBNULL\fR on error.
|
||||
.SH NOTES
|
||||
Most applications would use \fBslk_noutrefresh\fR because a
|
||||
\fBwrefresh\fR is likely to follow soon.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_attr\fR(3), \fBcurs_initscr\fR(3), \fBcurs_refresh\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,76 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_termattrs 3 ""
|
||||
.SH NAME
|
||||
\fBbaudrate\fR, \fBerasechar\fR, \fBhas_ic\fR,
|
||||
\fBhas_il\fR, \fBkillchar\fR, \fBlongname\fR, \fBtermattrs\fR,
|
||||
\fBtermname\fR - \fBncurses\fR environment query routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBint baudrate(void);\fR
|
||||
.br
|
||||
\fBchar erasechar(void);\fR
|
||||
.br
|
||||
\fBint has_ic(void);\fR
|
||||
.br
|
||||
\fBint has_il(void);\fR
|
||||
.br
|
||||
\fBchar killchar(void);\fR
|
||||
.br
|
||||
\fBchar *longname(void);\fR
|
||||
.br
|
||||
\fBchtype termattrs(void);\fR
|
||||
.br
|
||||
\fBchar *termname(void);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBbaudrate\fR routine returns the output speed of the terminal. The
|
||||
number returned is in bits per second, for example \fB9600\fR, and is an
|
||||
integer.
|
||||
|
||||
The \fBerasechar\fR routine returns the user's current erase character.
|
||||
|
||||
The \fBhas_ic\fR routine is true if the terminal has insert- and delete-
|
||||
character capabilities.
|
||||
|
||||
The \fBhas_il\fR routine is true if the terminal has insert- and delete-line
|
||||
capabilities, or can simulate them using scrolling regions. This might
|
||||
be used to determine if it would be appropriate to turn on physical
|
||||
scrolling using \fBscrollok\fR.
|
||||
|
||||
The \fBkillchar\fR routine returns the user's current line kill character.
|
||||
|
||||
The \fBlongname\fR routine returns a pointer to a static area
|
||||
containing a verbose description of the current terminal. The maximum
|
||||
length of a verbose description is 128 characters. It is defined only
|
||||
after the call to \fBinitscr\fR or \fBnewterm\fR. The area is
|
||||
overwritten by each call to \fBnewterm\fR and is not restored by
|
||||
\fBset_term\fR, so the value should be saved between calls to
|
||||
\fBnewterm\fR if \fBlongname\fR is going to be used with multiple
|
||||
terminals.
|
||||
|
||||
If a given terminal doesn't support a video attribute that an
|
||||
application program is trying to use, \fBncurses\fR may substitute a
|
||||
different video attribute for it. The \fBtermattrs\fR function
|
||||
returns a logical \fBOR\fR of all video attributes supported by the
|
||||
terminal. This information is useful when a \fBncurses\fR program
|
||||
needs complete control over the appearance of the screen.
|
||||
|
||||
The \fBtermname\fR routine returns the value of the environment
|
||||
variable \fBTERM\fR (truncated to 14 characters).
|
||||
.SH RETURN VALUE
|
||||
\fBlongname\fR and \fBtermname\fR return \fBNULL\fR on error.
|
||||
|
||||
Routines that return an integer return \fBERR\fR upon failure and an integer
|
||||
value other than \fBERR\fR upon successful completion.
|
||||
.SH NOTES
|
||||
Note that \fBtermattrs\fR may be a macro.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_initscr\fR(3), \fBcurs_outopts\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,193 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_terminfo 3 ""
|
||||
.ds n 5
|
||||
.SH NAME
|
||||
\fBsetupterm\fR, \fBsetterm\fR,
|
||||
\fBset_curterm\fR, \fBdel_curterm\fR, \fBrestartterm\fR, \fBtparm\fR,
|
||||
\fBtputs\fR, \fBputp\fR, \fBvidputs\fR, \fBvidattr\fR, \fBmvcur\fR,
|
||||
\fBtigetflag\fR, \fBtigetnum\fR,
|
||||
\fBtigetstr\fR - \fBncurses\fR interfaces to terminfo database
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
.br
|
||||
\fB#include <term.h>\fR
|
||||
|
||||
\fBint setupterm(char *term, int fildes, int *errret);\fR
|
||||
.br
|
||||
\fBint setterm(char *term);\fR
|
||||
.br
|
||||
\fBint set_curterm(TERMINAL *nterm);\fR
|
||||
.br
|
||||
\fBint del_curterm(TERMINAL *oterm);\fR
|
||||
.br
|
||||
\fBint restartterm(char *term, int fildes, int *errret);\fR
|
||||
.br
|
||||
\fBchar *tparm(char *str, long int p1, long int p2,
|
||||
long int p3, long int p4, long int p5, long int p6,
|
||||
long int p7, long int p8, long int p9);\fR
|
||||
.br
|
||||
\fBint tputs(char *str, int affcnt, int (*putc)(char));\fR
|
||||
.br
|
||||
\fBint putp(char *str);\fR
|
||||
.br
|
||||
\fBint vidputs(chtype attrs, int (*putc)(char));\fR
|
||||
.br
|
||||
\fBint vidattr(chtype attrs);\fR
|
||||
.br
|
||||
\fBint mvcur(int oldrow, int oldcol, int newrow, int newcol);\fR
|
||||
.br
|
||||
\fBint tigetflag(char *capname);\fR
|
||||
.br
|
||||
\fBint tigetnum(char *capname);\fR
|
||||
.br
|
||||
\fBchar *tigetstr(char *capname);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
These low-level routines must be called by programs that have to deal
|
||||
directly with the \fBterminfo\fR database to handle certain terminal
|
||||
capabilities, such as programming function keys. For all other
|
||||
functionality, \fBncurses\fR routines are more suitable and their use is
|
||||
recommended.
|
||||
|
||||
Initially, \fBsetupterm\fR should be called. Note that
|
||||
\fBsetupterm\fR is automatically called by \fBinitscr\fR and
|
||||
\fBnewterm\fR. This defines the set of terminal-dependent variables
|
||||
[listed in \fBterminfo\fR(5)]. The \fBterminfo\fR variables
|
||||
\fBlines\fR and \fBcolumns\fR are initialized by \fBsetupterm\fR as
|
||||
follows: If \fBuse_env(FALSE)\fR has been called, values for
|
||||
\fBlines\fR and \fBcolumns\fR specified in \fBterminfo\fR are used.
|
||||
Otherwise, if the environment variables \fBLINES\fR and \fBCOLUMNS\fR
|
||||
exist, their values are used. If these environment variables do not
|
||||
exist and the program is running in a window, the current window size
|
||||
is used. Otherwise, if the environment variables do not exist, the
|
||||
values for \fBlines\fR and \fBcolumns\fR specified in the
|
||||
\fBterminfo\fR database are used.
|
||||
|
||||
The header files \fBncurses.h\fR and \fBnterm.h\fR should be included (in this
|
||||
order) to get the definitions for these strings, numbers, and flags (these
|
||||
correspond to the SVr4 headers \fBcurses.h\fR and \fBterm.h\fR). Parameterized
|
||||
strings should be passed through \fBtparm\fR to instantiate them. All
|
||||
\fBterminfo\fR strings [including the output of \fBtparm\fR] should be printed
|
||||
with \fBtputs\fR or \fBputp\fR. Call the \fBreset_shell_mode\fR to restore the
|
||||
tty modes before exiting [see \fBcurs_kernel\fR(3)]. Programs which use
|
||||
cursor addressing should output \fBenter_ca_mode\fR upon startup and should
|
||||
output \fBexit_ca_mode\fR before exiting. Programs desiring shell escapes
|
||||
should call
|
||||
|
||||
\fBreset_shell_mode\fR and output \fBexit_ca_mode\fR before the shell
|
||||
is called and should output \fBenter_ca_mode\fR and call
|
||||
\fBreset_prog_mode\fR after returning from the shell.
|
||||
|
||||
The \fBsetupterm\fR routine reads in the \fBterminfo\fR database,
|
||||
initializing the \fBterminfo\fR structures, but does not set up the
|
||||
output virtualization structures used by \fBncurses\fR. The terminal
|
||||
type is the character string \fIterm\fR; if \fIterm\fR is null, the
|
||||
environment variable \fBTERM\fR is used. All output is to file
|
||||
descriptor \fBfildes\fR which is initialized for output. If
|
||||
\fIerrret\fR is not null, then \fBsetupterm\fR returns \fBOK\fR or
|
||||
\fBERR\fR and stores a status value in the integer pointed to by
|
||||
\fIerrret\fR. A status of \fB1\fR in \fIerrret\fR is normal, \fB0\fR
|
||||
means that the terminal could not be found, and \fB-1\fR means that
|
||||
the \fBterminfo\fR database could not be found. If \fIerrret\fR is
|
||||
null, \fBsetupterm\fR prints an error message upon finding an error
|
||||
and exits. Thus, the simplest call is:
|
||||
|
||||
\fBsetupterm((char *)0, 1, (int *)0);\fR,
|
||||
|
||||
which uses all the defaults and sends the output to \fBstdout\fR.
|
||||
|
||||
The \fBsetterm\fR routine is being replaced by \fBsetupterm\fR. The call:
|
||||
|
||||
\fBsetupterm(\fR\fIterm\fR\fB, 1, (int *)0)\fR
|
||||
|
||||
provides the same functionality as \fBsetterm(\fR\fIterm\fR\fB)\fR.
|
||||
The \fBsetterm\fR routine is included here for BSD compatibility, and
|
||||
is not recommended for new programs.
|
||||
|
||||
The \fBset_curterm\fR routine sets the variable \fBcur_term\fR to
|
||||
\fInterm\fR, and makes all of the \fBterminfo\fR boolean, numeric, and
|
||||
string variables use the values from \fInterm\fR.
|
||||
|
||||
The \fBdel_curterm\fR routine frees the space pointed to by
|
||||
\fIoterm\fR and makes it available for further use. If \fIoterm\fR is
|
||||
the same as \fBcur_term\fR, references to any of the \fBterminfo\fR
|
||||
boolean, numeric, and string variables thereafter may refer to invalid
|
||||
memory locations until another \fBsetupterm\fR has been called.
|
||||
|
||||
The \fBrestartterm\fR routine is similar to \fBsetupterm\fR and
|
||||
\fBinitscr\fR, except that it is called after restoring memory to a
|
||||
previous state. It assumes that the windows and the input and output
|
||||
options are the same as when memory was saved, but the terminal type
|
||||
and baud rate may be different.
|
||||
|
||||
The \fBtparm\fR routine instantiates the string \fIstr\fR with
|
||||
parameters \fIpi\fR. A pointer is returned to the result of \fIstr\fR
|
||||
with the parameters applied.
|
||||
|
||||
The \fBtputs\fR routine applies padding information to the string
|
||||
\fIstr\fR and outputs it. The \fIstr\fR must be a terminfo string
|
||||
variable or the return value from \fBtparm\fR, \fBtgetstr\fR, or
|
||||
\fBtgoto\fR. \fIaffcnt\fR is the number of lines affected, or 1 if
|
||||
not applicable. \fIputc\fR is a \fBputchar\fR-like routine to which
|
||||
the characters are passed, one at a time.
|
||||
|
||||
The \fBputp\fR routine calls \fBtputs(\fR\fIstr\fR\fB, 1, putchar)\fR.
|
||||
Note that the output of \fBputp\fR always goes to \fBstdout\fR, not to
|
||||
the \fIfildes\fR specified in \fBsetupterm\fR.
|
||||
|
||||
The \fBvidputs\fR routine displays the string on the terminal in the
|
||||
video attribute mode \fIattrs\fR, which is any combination of the
|
||||
attributes listed in \fBncurses\fR(3). The characters are passed to
|
||||
the \fBputchar\fR-like routine \fIputc\fR.
|
||||
|
||||
The \fBvidattr\fR routine is like the \fBvidputs\fR routine, except
|
||||
that it outputs through \fBputchar\fR.
|
||||
|
||||
The \fBmvcur\fR routine provides low-level cursor motion. It takes
|
||||
effect immediately (rather than at the next refresh).
|
||||
|
||||
The \fBtigetflag\fR, \fBtigetnum\fR and \fBtigetstr\fR routines return
|
||||
the value of the capability corresponding to the \fBterminfo\fR
|
||||
\fIcapname\fR passed to them, such as \fBxenl\fR.
|
||||
|
||||
With the \fBtigetflag\fR routine, the value \fB-1\fR is returned if
|
||||
\fIcapname\fR is not a boolean capability.
|
||||
|
||||
With the \fBtigetnum\fR routine, the value \fB-2\fR is returned if
|
||||
\fIcapname\fR is not a numeric capability.
|
||||
|
||||
With the \fBtigetstr\fR routine, the value \fB(char *)-1\fR is
|
||||
returned if \fIcapname\fR is not a string capability.
|
||||
|
||||
The \fIcapname\fR for each capability is given in the table column entitled
|
||||
\fIcapname\fR code in the capabilities section of \fBterminfo\fR(5).
|
||||
|
||||
\fBchar *boolnames\fR, \fB*boolcodes\fR, \fB*boolfnames\fR
|
||||
|
||||
\fBchar *numnames\fR, \fB*numcodes\fR, \fB*numfnames\fR
|
||||
|
||||
\fBchar *strnames\fR, \fB*strcodes\fR, \fB*strfnames\fR
|
||||
|
||||
These null-terminated arrays contain the \fIcapnames\fR, the
|
||||
\fBtermcap\fR codes, and the full C names, for each of the
|
||||
\fBterminfo\fR variables.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion, unless otherwise noted in the
|
||||
preceding routine descriptions.
|
||||
|
||||
Routines that return pointers always return \fBNULL\fR on error.
|
||||
.SH NOTES
|
||||
The \fBsetupterm\fR routine should be used in place of \fBsetterm\fR.
|
||||
|
||||
Note that \fBvidattr\fR and \fBvidputs\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_initscr\fR(3), \fBcurs_kernel\fR(3),
|
||||
\fBputc\fR(3), \fBterminfo\fR(5)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,59 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_touch 3 ""
|
||||
.SH NAME
|
||||
\fBtouchwin\fR, \fBtouchline\fR, \fBuntouchwin\fR,
|
||||
\fBwtouchln\fR, \fBis_linetouched\fR,
|
||||
\fBis_wintouched\fR - \fBncurses\fR refresh control routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
.br
|
||||
\fBint touchwin(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint touchline(WINDOW *win, int start, int count);\fR
|
||||
.br
|
||||
\fBint untouchwin(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint wtouchln(WINDOW *win, int y, int n, int changed);\fR
|
||||
.br
|
||||
\fBint is_linetouched(WINDOW *win, int line);\fR
|
||||
.br
|
||||
\fBint is_wintouched(WINDOW *win);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBtouchwin\fR and \fBtouchline\fR routines throw away all
|
||||
optimization information about which parts of the window have been
|
||||
touched, by pretending that the entire window has been drawn on. This
|
||||
is sometimes necessary when using overlapping windows, since a change
|
||||
to one window affects the other window, but the records of which lines
|
||||
have been changed in the other window do not reflect the change. The
|
||||
routine \fBtouchline\fR only pretends that \fIcount\fR lines have been
|
||||
changed, beginning with line \fIstart\fR.
|
||||
|
||||
The \fBuntouchwin\fR routine marks all lines in the window as unchanged since
|
||||
the last call to \fBwrefresh\fR.
|
||||
|
||||
The \fBwtouchln\fR routine makes \fIn\fR lines in the window, starting
|
||||
at line \fIy\fR, look as if they have (\fIchanged\fR\fB=1\fR) or have
|
||||
not (\fIchanged\fR\fB=0\fR) been changed since the last call to
|
||||
\fBwrefresh\fR.
|
||||
|
||||
The \fBis_linetouched\fR and \fBis_wintouched\fR routines return
|
||||
\fBTRUE\fR if the specified line/window was modified since the last
|
||||
call to \fBwrefresh\fR; otherwise they return \fBFALSE\fR. In
|
||||
addition, \fBis_linetouched\fR returns \fBERR\fR if \fIline\fR is not
|
||||
valid for the given window.
|
||||
.SH RETURN VALUE
|
||||
All routines return the integer \fBERR\fR upon failure and an integer value
|
||||
other than \fBERR\fR upon successful completion, unless otherwise noted in the
|
||||
preceding routine descriptions.
|
||||
.SH NOTES
|
||||
Note that all routines except \fBwtouchln\fR may be macros.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_refresh\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,83 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_util 3 ""
|
||||
.SH NAME
|
||||
\fBunctrl\fR, \fBkeyname\fR, \fBfilter\fR,
|
||||
\fBuse_env\fR, \fBputwin\fR, \fBgetwin\fR, \fBdelay_output\fR,
|
||||
\fBflushinp\fR - miscellaneous \fBncurses\fR utility routines
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBchar *unctrl(chtype c);\fR
|
||||
.br
|
||||
\fBchar *keyname(int c);\fR
|
||||
.br
|
||||
\fBint filter(void);\fR
|
||||
.br
|
||||
\fBvoid use_env(char bool);\fR
|
||||
.br
|
||||
\fBint putwin(WINDOW *win, FILE *filep);\fR
|
||||
.br
|
||||
\fBWINDOW *getwin(FILE *filep);\fR
|
||||
.br
|
||||
\fBint delay_output(int ms);\fR
|
||||
.br
|
||||
\fBint flushinp(void);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBunctrl\fR macro expands to a character string which is a printable
|
||||
representation of the character \fIc\fR. Control characters are displayed in
|
||||
the \fB^\fR\fIX\fR notation. Printing characters are displayed as is.
|
||||
|
||||
The \fBkeyname\fR routine returns a character string corresponding to
|
||||
the key \fIc\fR.
|
||||
|
||||
The \fBfilter\fR routine, if used, must be called before \fBinitscr\fR or
|
||||
\fBnewterm\fR are called. It makes \fBncurses\fR think that there is a
|
||||
one-line screen. \fBncurses\fR does not use any terminal capabilities
|
||||
that assume that they know on what line of the screen the cursor is
|
||||
positioned.
|
||||
|
||||
The \fBuse_env\fR routine, if used, is called before \fBinitscr\fR or
|
||||
\fBnewterm\fR are called. When called with \fBFALSE\fR as an
|
||||
argument, the values of \fBlines\fR and \fBcolumns\fR specified in the
|
||||
\fIterminfo\fR database will be used, even if environment variables
|
||||
\fBLINES\fR and \fBCOLUMNS\fR (used by default) are set, or if
|
||||
\fBncurses\fR is running in a window (in which case default behavior
|
||||
would be to use the window size if \fBLINES\fR and \fBCOLUMNS\fR are
|
||||
not set).
|
||||
|
||||
The \fBputwin\fR routine writes all data associated with window \fIwin\fR into
|
||||
the file to which \fIfilep\fR points. This information can be later retrieved
|
||||
using the \fBgetwin\fR function.
|
||||
|
||||
The \fBgetwin\fR routine reads window related data stored in the file by
|
||||
\fBputwin\fR. The routine then creates and initializes a new window using that
|
||||
data. It returns a pointer to the new window.
|
||||
|
||||
The \fBdelay_output\fR routine inserts an \fIms\fR millisecond pause
|
||||
in output. This routine should not be used extensively because
|
||||
padding characters are used rather than a CPU pause.
|
||||
|
||||
The \fBflushinp\fR routine throws away any typeahead that has been typed by the
|
||||
user and has not yet been read by the program.
|
||||
.SH RETURN VALUE
|
||||
Except for \fBflushinp\fR, routines that return an integer return
|
||||
\fBERR\fR upon failure and an integer value other than \fBERR\fR upon
|
||||
successful completion.
|
||||
|
||||
\fBflushinp\fR always returns \fBOK\fR.
|
||||
|
||||
Routines that return pointers return \fBNULL\fR on error.
|
||||
.SH BUGS
|
||||
The \fBfilter\fR entry point is not yet supported.
|
||||
.SH NOTES
|
||||
Note that \fBunctrl\fR is a macro, which is defined in <\fBunctrl.h\fR>.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_initscr\fR(3), \fBcurs_scr_dmp\fR(3).
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,125 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.TH curs_window 3 ""
|
||||
.SH NAME
|
||||
\fBnewwin\fR, \fBdelwin\fR, \fBmvwin\fR,
|
||||
\fBsubwin\fR, \fBderwin\fR, \fBmvderwin\fR, \fBdupwin\fR,
|
||||
\fBwsyncup\fR, \fBsyncok\fR, \fBwcursyncup\fR,
|
||||
\fBwsyncdown\fR - create \fBncurses\fR windows
|
||||
.SH SYNOPSIS
|
||||
\fB#include <ncurses.h>\fR
|
||||
|
||||
\fBWINDOW *newwin(int nlines, int ncols, int begin_y,\fR
|
||||
\fBintbegin_x);\fR
|
||||
|
||||
\fBint delwin(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint mvwin(WINDOW *win, int y, int x);\fR
|
||||
.br
|
||||
\fBWINDOW *subwin(WINDOW *orig, int nlines, int ncols,
|
||||
int begin_y, int begin_x);\fR
|
||||
\fBWINDOW *derwin(WINDOW *orig, int nlines, int ncols,
|
||||
int begin_y, int begin_x);\fR
|
||||
\fBint mvderwin(WINDOW *win, int par_y, int par_x);\fR
|
||||
.br
|
||||
\fBWINDOW *dupwin(WINDOW *win);\fR
|
||||
.br
|
||||
\fBvoid wsyncup(WINDOW *win);\fR
|
||||
.br
|
||||
\fBint syncok(WINDOW *win, bool bf);\fR
|
||||
.br
|
||||
\fBvoid wcursyncup(WINDOW *win);\fR
|
||||
.br
|
||||
\fBvoid wsyncdown(WINDOW *win);\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
The \fBnewwin\fR routine creates and returns a pointer to a new window with the
|
||||
given number of lines and columns. The upper left-hand corner of the window is
|
||||
at line \fIbegin\fR_\fIy\fR, column \fIbegin\fR_\fIx\fR. If either
|
||||
\fInlines\fR or \fIncols\fR is zero, they default to \fBLINES -\fR
|
||||
\fIbegin\fR_\fIy\fR and \fBCOLS -\fR \fIbegin\fR_\fIx\fR. A new full-screen
|
||||
window is created by calling \fBnewwin(0,0,0,0)\fR.
|
||||
|
||||
The \fBdelwin\fR routine deletes the named window, freeing all memory
|
||||
associated with it (it does not actually erase the window's screen
|
||||
image). Subwindows must be deleted before the main window can be
|
||||
deleted.
|
||||
|
||||
The \fBmvwin\fR routine moves the window so that the upper left-hand
|
||||
corner is at position (\fIx\fR, \fIy\fR). If the move would cause the
|
||||
window to be off the screen, it is an error and the window is not
|
||||
moved. Moving subwindows is allowed, but should be avoided.
|
||||
|
||||
The \fBsubwin\fR routine creates and returns a pointer to a new window
|
||||
with the given number of lines, \fInlines\fR, and columns,
|
||||
\fIncols\fR. The window is at position (\fIbegin\fR_\fIy\fR,
|
||||
\fIbegin\fR_\fIx\fR) on the screen. (This position is relative to the
|
||||
screen, and not to the window \fIorig\fR.) The window is made in the
|
||||
middle of the window \fIorig\fR, so that changes made to one window
|
||||
will affect both windows. The subwindow shares memory with the window
|
||||
\fIorig\fR. When using this routine, it is necessary to call
|
||||
\fBtouchwin\fR or \fBtouchline\fR on \fIorig\fR before calling
|
||||
\fBwrefresh\fR on the subwindow.
|
||||
|
||||
The \fBderwin\fR routine is the same as \fBsubwin,\fR except that
|
||||
\fIbegin\fR_\fIy\fR and \fIbegin\fR_\fIx\fR are relative to the origin
|
||||
of the window \fIorig\fR rather than the screen. There is no
|
||||
difference between the subwindows and the derived windows.
|
||||
|
||||
The \fBmvderwin\fR routine moves a derived window (or subwindow)
|
||||
inside its parent window. The screen-relative parameters of the
|
||||
window are not changed. This routine is used to display different
|
||||
parts of the parent window at the same physical position on the
|
||||
screen.
|
||||
|
||||
The \fBdupwin\fR routine creates an exact duplicate of the window \fIwin\fR.
|
||||
|
||||
Each \fBncurses\fR window maintains two data structures: the character
|
||||
image structure and the status structure. The character image
|
||||
structure is shared among all windows in the window hierarchy
|
||||
(\fIi\fR.\fIe\fR., the window with all subwindows). The status
|
||||
structure, which contains information about individual line changes in
|
||||
the window, is private to each window. The routine \fBwrefresh\fR
|
||||
uses the status data structure when performing screen updating. Since
|
||||
status structures are not shared, changes made to one window in the
|
||||
hierarchy may not be properly reflected on the screen.
|
||||
|
||||
The routine \fBwsyncup\fR causes the changes in the status structure
|
||||
of a window to be reflected in the status structures of its ancestors.
|
||||
If \fBsyncok\fR is called with second argument \fBTRUE\fR then
|
||||
\fBwsyncup\fR is called automatically whenever there is a change in
|
||||
the window.
|
||||
|
||||
The routine \fBwcursyncup\fR updates the current cursor position of all the
|
||||
ancestors of the window to reflect the current cursor position of the
|
||||
window.
|
||||
|
||||
The routine \fBwsyncdown\fR updates the status structure of the window
|
||||
to reflect the changes in the status structures of its ancestors.
|
||||
Applications seldom call this routine because it is called
|
||||
automatically by \fBwrefresh\fR.
|
||||
.SH RETURN VALUE
|
||||
Routines that return an integer return the integer \fBERR\fR upon failure and
|
||||
an integer value other than \fBERR\fR upon successful completion.
|
||||
|
||||
\fBdelwin\fR returns the integer \fBERR\fR upon failure and \fBOK\fR
|
||||
upon successful completion.
|
||||
|
||||
Routines that return pointers return \fBNULL\fR on error.
|
||||
.SH NOTES
|
||||
If many small changes are made to the window, the \fBwsyncup\fR option could
|
||||
degrade performance.
|
||||
|
||||
Note that \fBsyncok\fR may be a macro.
|
||||
.SH BUGS
|
||||
The subwindow functions (\fIsubwin\fR, \fIderwin\fR, etc.) are flaky,
|
||||
incompletely implemented, and not well tested, especially in their
|
||||
interaction with scrolling.
|
||||
.SH SEE ALSO
|
||||
\fBncurses\fR(3), \fBcurs_refresh\fR(3), \fBcurs_touch\fR(3)
|
||||
.\"#
|
||||
.\"# The following sets edit modes for GNU EMACS
|
||||
.\"# Local Variables:
|
||||
.\"# mode:nroff
|
||||
.\"# fill-column:79
|
||||
.\"# End:
|
@ -1,553 +0,0 @@
|
||||
|
||||
/***************************************************************************
|
||||
* COPYRIGHT NOTICE *
|
||||
****************************************************************************
|
||||
* ncurses is copyright (C) 1992, 1993, 1994 *
|
||||
* by Zeyd M. Ben-Halim *
|
||||
* zmbenhal@netcom.com *
|
||||
* *
|
||||
* Permission is hereby granted to reproduce and distribute ncurses *
|
||||
* by any means and for any fee, whether alone or as part of a *
|
||||
* larger distribution, in source or in binary form, PROVIDED *
|
||||
* this notice is included with any such distribution, not removed *
|
||||
* from header files, and is reproduced in any documentation *
|
||||
* accompanying it or the applications linked with it. *
|
||||
* *
|
||||
* ncurses comes AS IS with no warranty, implied or expressed. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __NCURSES_H
|
||||
#define __NCURSES_H
|
||||
#define CURSES 1
|
||||
#define CURSES_H 1
|
||||
|
||||
/* This is defined in more than one ncurses header, for identification */
|
||||
#undef NCURSES_VERSION
|
||||
#define NCURSES_VERSION "1.8.6/ache"
|
||||
|
||||
typedef unsigned long chtype;
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#ifndef NOTERMIOS
|
||||
#include <termios.h>
|
||||
#ifndef TERMIOS
|
||||
#define TERMIOS 1
|
||||
#endif
|
||||
#else
|
||||
#include <sgtty.h>
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#include <unctrl.h>
|
||||
|
||||
#define bool char
|
||||
|
||||
/* attributes */
|
||||
#define A_ATTRIBUTES 0xffffff00
|
||||
#define A_NORMAL 0x00000000
|
||||
#define A_STANDOUT 0x00010000
|
||||
#define A_UNDERLINE 0x00020000
|
||||
#define A_REVERSE 0x00040000
|
||||
#define A_BLINK 0x00080000
|
||||
#define A_DIM 0x00100000
|
||||
#define A_BOLD 0x00200000
|
||||
#define A_ALTCHARSET 0x00400000
|
||||
#define A_INVIS 0x00800000
|
||||
#define A_PROTECT 0x01000000
|
||||
#define A_CHARTEXT 0x000000ff
|
||||
#define A_COLOR 0x0000ff00
|
||||
#define COLOR_PAIR(n) (n << 8)
|
||||
#define PAIR_NUMBER(a) ((a & A_COLOR) >> 8)
|
||||
|
||||
/* colors */
|
||||
extern int COLORS;
|
||||
extern int COLOR_PAIRS;
|
||||
extern unsigned char *color_pairs;
|
||||
|
||||
#define COLOR_BLACK 0
|
||||
#define COLOR_RED 1
|
||||
#define COLOR_GREEN 2
|
||||
#define COLOR_YELLOW 3
|
||||
#define COLOR_BLUE 4
|
||||
#define COLOR_MAGENTA 5
|
||||
#define COLOR_CYAN 6
|
||||
#define COLOR_WHITE 7
|
||||
|
||||
/* line graphics */
|
||||
|
||||
extern chtype acs_map[];
|
||||
|
||||
|
||||
#define ACS_ULCORNER (acs_map['l'])
|
||||
#define ACS_LLCORNER (acs_map['m'])
|
||||
#define ACS_URCORNER (acs_map['k'])
|
||||
#define ACS_LRCORNER (acs_map['j'])
|
||||
#define ACS_RTEE (acs_map['u'])
|
||||
#define ACS_LTEE (acs_map['t'])
|
||||
#define ACS_BTEE (acs_map['v'])
|
||||
#define ACS_TTEE (acs_map['w'])
|
||||
#define ACS_HLINE (acs_map['q'])
|
||||
#define ACS_VLINE (acs_map['x'])
|
||||
#define ACS_PLUS (acs_map['n'])
|
||||
#define ACS_S1 (acs_map['o']) /* scan line 1 */
|
||||
#define ACS_S9 (acs_map['s']) /* scan line 9 */
|
||||
#define ACS_DIAMOND (acs_map['`']) /* diamond */
|
||||
#define ACS_CKBOARD (acs_map['a']) /* checker board (stipple) */
|
||||
#define ACS_DEGREE (acs_map['f']) /* degree symbol */
|
||||
#define ACS_PLMINUS (acs_map['g']) /* plus/minus */
|
||||
#define ACS_BULLET (acs_map['~']) /* bullet */
|
||||
#define ACS_LARROW (acs_map[',']) /* arrow pointing left */
|
||||
#define ACS_RARROW (acs_map['+']) /* arrow pointing right */
|
||||
#define ACS_DARROW (acs_map['.']) /* arrow pointing down */
|
||||
#define ACS_UARROW (acs_map['-']) /* arrow pointing up */
|
||||
#define ACS_BOARD (acs_map['h']) /* board of squares */
|
||||
#define ACS_LANTERN (acs_map['I']) /* lantern symbol */
|
||||
#define ACS_BLOCK (acs_map['0']) /* solid square block */
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE (1)
|
||||
# define FALSE (0)
|
||||
#endif
|
||||
|
||||
#define ERR (-1)
|
||||
#define OK (0)
|
||||
|
||||
#define _SUBWIN 0x01
|
||||
#define _ENDLINE 0x02
|
||||
#define _FULLWIN 0x04
|
||||
#define _SCROLLWIN 0x08
|
||||
#define _ISPAD 0x10
|
||||
#define _HASMOVED 0x20
|
||||
|
||||
#define _NOCHANGE -1
|
||||
|
||||
typedef struct screen SCREEN;
|
||||
typedef struct _win_st WINDOW;
|
||||
|
||||
struct _win_st {
|
||||
short _cury, _curx; /* current cursor position */
|
||||
short _maxy, _maxx; /* maximum values of x and y NOT the screen dimensions */
|
||||
short _begy, _begx;
|
||||
short _flags;
|
||||
chtype _attrs;
|
||||
chtype _bkgd;
|
||||
|
||||
/* The following should be consolidated into one bitset */
|
||||
bool _notimeout;
|
||||
bool _use_idc;
|
||||
bool _clear;
|
||||
bool _leave;
|
||||
bool _scroll;
|
||||
bool _idlok;
|
||||
bool _immed;
|
||||
bool _sync;
|
||||
bool _use_keypad; /* 0=no, 1=yes */
|
||||
bool _use_meta; /* T=use the meta key */
|
||||
|
||||
int _delay; /* 0 = nodelay
|
||||
<0 = blocking
|
||||
>0 = delay */
|
||||
chtype **_line;
|
||||
short *_firstchar; /* First changed character in the line */
|
||||
short *_lastchar; /* Last changed character in the line */
|
||||
short _regtop; /* Top and bottom of scrolling region */
|
||||
short _regbottom;
|
||||
int _parx;
|
||||
int _pary;
|
||||
WINDOW *_parent; /* parent if a sub-window */
|
||||
};
|
||||
|
||||
extern WINDOW *stdscr, *curscr, *newscr;
|
||||
|
||||
extern int LINES, COLS;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int resizeterm (int, int);
|
||||
|
||||
#if 0 /* MYTINFO not have it */
|
||||
extern char ttytype[]; /* needed for backward compatibility */
|
||||
#endif
|
||||
|
||||
extern int tigetflag(char *);
|
||||
extern int tigetnum(char *);
|
||||
extern char *tigetstr(char *);
|
||||
|
||||
/* Debugging : use with libdcurses.a */
|
||||
|
||||
extern void _init_trace(void);
|
||||
extern void _tracef(char *, ...);
|
||||
extern char *_traceattr(int mode);
|
||||
extern char *_tracechar(const unsigned char mode);
|
||||
extern void trace(const unsigned int tracelevel);
|
||||
|
||||
/* trace masks */
|
||||
#define TRACE_DISABLE 0x00 /* turn off tracing */
|
||||
#define TRACE_ORDINARY 0x01 /* ordinary trace mode */
|
||||
#define TRACE_CHARPUT 0x02 /* also trace all character outputs */
|
||||
#define TRACE_MAXIMUM 0x0f /* maximum trace level */
|
||||
|
||||
/* function prototypes */
|
||||
|
||||
extern int baudrate(void);
|
||||
extern int beep(void);
|
||||
extern int cbreak(void);
|
||||
extern int clearok(WINDOW *,int);
|
||||
extern int copywin(WINDOW *,WINDOW *,int,int,int,int,int,int,int);
|
||||
extern int curs_set(int);
|
||||
extern int def_prog_mode(void);
|
||||
extern int def_shell_mode(void);
|
||||
extern int delwin(WINDOW *);
|
||||
extern WINDOW *derwin(WINDOW *,int,int,int,int);
|
||||
extern int doupdate(void);
|
||||
extern WINDOW *dupwin(WINDOW *);
|
||||
extern int echo(void);
|
||||
extern int endwin(void);
|
||||
extern char erasechar(void);
|
||||
extern int flash(void);
|
||||
extern int flushinp(void);
|
||||
extern int halfdelay(int);
|
||||
extern int idlok(WINDOW *,int);
|
||||
extern int intrflush(WINDOW *,bool);
|
||||
extern int is_linetouched(WINDOW *,int);
|
||||
extern int is_wintouched(WINDOW *);
|
||||
extern WINDOW *initscr(void);
|
||||
extern int isendwin(void);
|
||||
extern char *keyname(int);
|
||||
extern int keypad(WINDOW *,int);
|
||||
extern char killchar(void);
|
||||
extern int leaveok(WINDOW *,int);
|
||||
extern char *longname(void);
|
||||
extern int meta(WINDOW *,int);
|
||||
extern int mvcur(int,int,int,int);
|
||||
extern int mvprintw(int,int,char *,...);
|
||||
extern int mvscanw(int,int,char *,...);
|
||||
extern int mvwin(WINDOW *,int,int);
|
||||
extern int mvwprintw(WINDOW *,int,int,char *,...);
|
||||
extern int mvwscanw(WINDOW *,int,int,char *,...);
|
||||
extern WINDOW *newpad(int,int);
|
||||
extern SCREEN *newterm(char *,FILE *,FILE *);
|
||||
extern WINDOW *newwin(int,int,int,int);
|
||||
extern int nl(void);
|
||||
extern int nocbreak(void);
|
||||
extern int nodelay(WINDOW *,int);
|
||||
extern int noecho(void);
|
||||
extern int nonl(void);
|
||||
extern int noraw(void);
|
||||
extern int notimeout(WINDOW *,bool);
|
||||
extern int overlay(WINDOW *,WINDOW *);
|
||||
extern int overwrite(WINDOW *,WINDOW *);
|
||||
extern int pnoutrefresh(WINDOW *,int,int,int,int,int,int);
|
||||
extern int prefresh(WINDOW *,int,int,int,int,int,int);
|
||||
extern int printw(char *,...);
|
||||
extern int putp(char *);
|
||||
extern int raw(void);
|
||||
extern int reset_prog_mode(void);
|
||||
extern int reset_shell_mode(void);
|
||||
extern int resetty(void);
|
||||
extern int ripoffline(int line, int (*init)(WINDOW *, int));
|
||||
extern int savetty(void);
|
||||
extern int scanw(char *,...);
|
||||
extern int scrollok(WINDOW *,int);
|
||||
extern SCREEN *set_term(SCREEN *);
|
||||
extern int setupterm(char *,int,int *);
|
||||
extern WINDOW *subwin(WINDOW *,int,int,int,int);
|
||||
extern int timeout(int);
|
||||
extern char *tparm(const char *, ...);
|
||||
extern int tputs(const char *,int,int (*)(int));
|
||||
extern int typeahead(int);
|
||||
extern int ungetch(int);
|
||||
extern int vidattr(chtype);
|
||||
extern int vidputs(chtype,int (*)(int));
|
||||
extern int vwscanw(WINDOW *,char *,va_list);
|
||||
extern int vwprintw(WINDOW *,char *,va_list);
|
||||
extern int waddch(WINDOW *,chtype);
|
||||
extern int waddchnstr(WINDOW *,chtype *,int);
|
||||
extern int waddnstr(WINDOW *,char *,int);
|
||||
extern int wattron(WINDOW *,chtype);
|
||||
extern int wattroff(WINDOW *,chtype);
|
||||
extern int wbkgd(WINDOW *,chtype);
|
||||
extern int wborder(WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype);
|
||||
extern int wclear(WINDOW *);
|
||||
extern int wclrtobot(WINDOW *);
|
||||
extern int wclrtoeol(WINDOW *);
|
||||
extern int wdelch(WINDOW *);
|
||||
extern int wechochar(WINDOW *, chtype);
|
||||
extern int werase(WINDOW *);
|
||||
extern int wgetch(WINDOW *);
|
||||
extern int wgetnstr(WINDOW *,char *,int maxlen);
|
||||
extern int whline(WINDOW *,chtype,int);
|
||||
extern int winnstr(WINDOW *, char *, int);
|
||||
extern int winsch(WINDOW *,chtype);
|
||||
extern int winsdelln(WINDOW *,int);
|
||||
extern int winsnstr(WINDOW *,char *,int);
|
||||
extern int wmove(WINDOW *,int,int);
|
||||
extern int wnoutrefresh(WINDOW *);
|
||||
extern int wprintw(WINDOW *,char *,...);
|
||||
extern int wredrawln(WINDOW *,int,int);
|
||||
extern int wrefresh(WINDOW *);
|
||||
extern int wscanw(WINDOW *,char *,...);
|
||||
extern int wscrl(WINDOW *,int);
|
||||
extern int wsetscrreg(WINDOW *,int,int);
|
||||
extern int wtimeout(WINDOW *,int);
|
||||
extern int wtouchln(WINDOW *,int,int,int);
|
||||
extern int wvline(WINDOW *,chtype,int);
|
||||
|
||||
extern bool can_change_color(void);
|
||||
extern int color_content(short,short *,short *, short *);
|
||||
extern int has_colors(void);
|
||||
extern int init_color(short,short,short,short);
|
||||
extern int init_pair(short,short,short);
|
||||
extern int pair_content(short,short*,short*);
|
||||
extern int start_color(void);
|
||||
|
||||
extern int slk_init(int);
|
||||
extern int slk_set(int,char *,int);
|
||||
extern int slk_refresh(void);
|
||||
extern int slk_noutrefresh(void);
|
||||
extern char *slk_label(int);
|
||||
extern int slk_clear(void);
|
||||
extern int slk_restore(void);
|
||||
extern int slk_touch(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* pseudo functions
|
||||
*/
|
||||
#define wgetstr(w, s) wgetnstr(w, s, -1)
|
||||
|
||||
#define napms(x) usleep(1000*x)
|
||||
#define setterm(term) setupterm(term, 1, (int *)0)
|
||||
|
||||
#define fixterm() reset_prog_mode()
|
||||
#define resetterm() reset_shell_mode()
|
||||
#define saveterm() def_prog_mode()
|
||||
#define crmode() cbreak()
|
||||
#define nocrmode() nocbreak()
|
||||
#define gettmode()
|
||||
|
||||
#define getyx(win,y,x) (y = (win)->_cury, x = (win)->_curx)
|
||||
#define getbegyx(win,y,x) (y = (win)->_begy, x = (win)->_begx)
|
||||
#define getmaxyx(win,y,x) (y = (win)->_maxy + 1, x = (win)->_maxx + 1)
|
||||
#define getsyx(y,x) getyx(stdscr, y, x)
|
||||
#define setsyx(y,x) (stdscr->_cury = y, stdscr->_curx = x)
|
||||
|
||||
#define wbkgdset(win,ch) ((win)->_bkgd = ch)
|
||||
|
||||
/* It seems older SYSV curses define these */
|
||||
#define getattrs(win) (win->_attrs)
|
||||
#define getmaxx(win) ((win)->_maxx + 1)
|
||||
#define getmaxy(win) ((win)->_maxy + 1)
|
||||
|
||||
#define winch(win) ((win)->_line[(win)->_cury][(win)->_curx])
|
||||
#define wstandout(win) (wattrset(win,A_STANDOUT))
|
||||
#define wstandend(win) (wattrset(win,A_NORMAL))
|
||||
#define wattrset(win,at) ((win)->_attrs = (at))
|
||||
|
||||
#define subpad(p,l,c,y,x) derwin(p,l,c,y,x)
|
||||
#define scroll(win) wscrl(win,1)
|
||||
|
||||
#define touchwin(win) wtouchln((win), 0, (win)->_maxy + 1, 1)
|
||||
#define touchline(win, s, c) wtouchln((win), s, c, 1)
|
||||
#define untouchwin(win) wtouchln((win), 0, (win)->_maxy + 1, 0)
|
||||
|
||||
#define box(win, v, h) wborder(win, v, v, h, h, 0, 0, 0, 0)
|
||||
#define border(ls, rs, ts, bs, tl, tr, bl, br) wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br)
|
||||
#define hline(ch, n) whline(stdscr, ch, n)
|
||||
#define vline(ch, n) wvline(stdscr, ch, n)
|
||||
|
||||
#define winsstr(w, s) winsnstr(w, s, 0)
|
||||
#define winstr(w, s) winnstr(w, s, -1)
|
||||
|
||||
#define redrawwin(w) wredrawln(w, 0, w->_maxy+1)
|
||||
#define waddstr(win,str) waddnstr(win,str,-1)
|
||||
#define waddchstr(win,str) waddchnstr(win,str,-1)
|
||||
|
||||
/*
|
||||
* pseudo functions for standard screen
|
||||
*/
|
||||
|
||||
#define bkgdset(ch) wbkgdset(stdscr,ch)
|
||||
#define bkgd(ch) wbkgd(stdscr,ch)
|
||||
#define inch() winch(stdscr)
|
||||
#define standout() wstandout(stdscr)
|
||||
#define standend() wstandend(stdscr)
|
||||
#define attron(at) wattron(stdscr,at)
|
||||
#define attroff(at) wattroff(stdscr,at)
|
||||
#define attrset(at) wattrset(stdscr,at)
|
||||
#define addch(ch) waddch(stdscr,ch)
|
||||
#define echochar(c) wechochar(stdscr, c)
|
||||
#define getch() wgetch(stdscr)
|
||||
#define addstr(str) waddnstr(stdscr,str,-1)
|
||||
#define getstr(str) wgetstr(stdscr,str)
|
||||
#define move(y, x) wmove(stdscr,y,x)
|
||||
#define clear() wclear(stdscr)
|
||||
#define erase() werase(stdscr)
|
||||
#define clrtobot() wclrtobot(stdscr)
|
||||
#define clrtoeol() wclrtoeol(stdscr)
|
||||
#define insertln() winsdelln(stdscr, 1)
|
||||
#define winsertln(w) winsdelln(w, 1)
|
||||
#define deleteln() winsdelln(stdscr, -1)
|
||||
#define wdeleteln(w) winsdelln(w, -1)
|
||||
#define refresh() wrefresh(stdscr)
|
||||
#define innstr(s,n) winnstr(stdscr,s,n)
|
||||
#define insch(c) winsch(stdscr,c)
|
||||
#define delch() wdelch(stdscr)
|
||||
#define setscrreg(t,b) wsetscrreg(stdscr,t,b)
|
||||
#define scrl(n) wscrl(stdscr,n)
|
||||
#define timeout(delay) wtimeout(stdscr, delay)
|
||||
#define addnstr(str,n) waddnstr(stdscr,str,n)
|
||||
#define addchstr(str) waddchstr(stdscr,str)
|
||||
#define addchnstr(str,n) waddchnstr(stdscr,str, n)
|
||||
#define insdelln(n) winsdelln(stdscr, n)
|
||||
#define insstr(s) winsstr(stdscr, s)
|
||||
#define insnstr(s,n) winsnstr(stdscr, s, n)
|
||||
|
||||
/*
|
||||
* mv functions
|
||||
*/
|
||||
|
||||
#define mvwaddch(win,y,x,ch) (wmove(win,y,x) == ERR ? ERR : waddch(win,ch))
|
||||
#define mvwgetch(win,y,x) (wmove(win,y,x) == ERR ? ERR : wgetch(win))
|
||||
#define mvwaddchnstr(win,y,x,str,n) (wmove(win,y,x) == ERR ? ERR : waddchnstr(win,str,n))
|
||||
#define mvwaddchstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : waddchnstr(win,str,-1))
|
||||
#define mvwaddnstr(win,y,x,str,n) (wmove(win,y,x) == ERR ? ERR : waddnstr(win,str,n))
|
||||
#define mvwaddstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : waddnstr(win,str,-1))
|
||||
#define mvwgetstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : wgetstr(win,str))
|
||||
#define mvwinch(win,y,x) (wmove(win,y,x) == ERR ? ERR : winch(win))
|
||||
#define mvwdelch(win,y,x) (wmove(win,y,x) == ERR ? ERR : wdelch(win))
|
||||
#define mvwinnstr(win,y,x,s,n) (wmove(win,y,x) == ERR ? ERR : winnstr(win,s,n))
|
||||
#define mvwinsch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : winsch(win,c))
|
||||
#define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
|
||||
#define mvgetch(y,x) mvwgetch(stdscr,y,x)
|
||||
#define mvaddnstr(y,x,str,n) mvwaddnstr(stdscr,y,x,str,n)
|
||||
#define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str)
|
||||
#define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str)
|
||||
#define mvinch(y,x) mvwinch(stdscr,y,x)
|
||||
#define mvdelch(y,x) mvwdelch(stdscr,y,x)
|
||||
#define mvinnstr(y,x,s,n) mvwinnstr(stdscr,y,x,s,n)
|
||||
#define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c)
|
||||
#define mvwinsstr(w, y, x, s) (wmove(w,y,x) == ERR ? ERR : winsstr(w,s))
|
||||
#define mvwinsnstr(w, y, x, s, n) (wmove(w,y,x) == ERR ? ERR : winsnstr(w,s,n))
|
||||
#define mvinsstr(y,x,s) mvwinsstr(stdscr,y,x,s)
|
||||
#define mvinsnstr(y,x,s,n) mvwinsnstr(stdscr,y,x,s,n)
|
||||
|
||||
/*
|
||||
* XSI curses macros for XPG4 conformance.
|
||||
*/
|
||||
|
||||
#define attr_get() wattr_get(stdscr)
|
||||
#define getbkgd(win) ((win)->_bkgd)
|
||||
|
||||
#define vid_attr(a) vidattr(a)
|
||||
#define wattr_get(win) ((win)->_attrs)
|
||||
|
||||
/* Funny "characters" enabled for various special function keys for input */
|
||||
/* Whether such a key exists depend if its definition is in the terminfo entry */
|
||||
|
||||
#define KEY_MIN 0401 /* Minimum curses key */
|
||||
#define KEY_BREAK 0401 /* break key (unreliable) */
|
||||
#define KEY_DOWN 0402 /* The four arrow keys ... */
|
||||
#define KEY_UP 0403
|
||||
#define KEY_LEFT 0404
|
||||
#define KEY_RIGHT 0405 /* ... */
|
||||
#define KEY_HOME 0406 /* Home key (upward+left arrow) */
|
||||
#define KEY_BACKSPACE 0407 /* backspace (unreliable) */
|
||||
#define KEY_F0 0410 /* Function keys. Space for 64 */
|
||||
#define KEY_F(n) (KEY_F0+(n)) /* keys is reserved. */
|
||||
#define KEY_DL 0510 /* Delete line */
|
||||
#define KEY_IL 0511 /* Insert line */
|
||||
#define KEY_DC 0512 /* Delete character */
|
||||
#define KEY_IC 0513 /* Insert char or enter insert mode */
|
||||
#define KEY_EIC 0514 /* Exit insert char mode */
|
||||
#define KEY_CLEAR 0515 /* Clear screen */
|
||||
#define KEY_EOS 0516 /* Clear to end of screen */
|
||||
#define KEY_EOL 0517 /* Clear to end of line */
|
||||
#define KEY_SF 0520 /* Scroll 1 line forward */
|
||||
#define KEY_SR 0521 /* Scroll 1 line backwards (reverse) */
|
||||
#define KEY_NPAGE 0522 /* Next page */
|
||||
#define KEY_PPAGE 0523 /* Previous page */
|
||||
#define KEY_STAB 0524 /* Set tab */
|
||||
#define KEY_CTAB 0525 /* Clear tab */
|
||||
#define KEY_CATAB 0526 /* Clear all tabs */
|
||||
#define KEY_ENTER 0527 /* Enter or send (unreliable) */
|
||||
#define KEY_SRESET 0530 /* soft (partial) reset (unreliable) */
|
||||
#define KEY_RESET 0531 /* reset or hard reset (unreliable) */
|
||||
#define KEY_PRINT 0532 /* print or copy */
|
||||
#define KEY_LL 0533 /* home down or bottom (lower left) */
|
||||
|
||||
/* The keypad is arranged like this: */
|
||||
/* a1 up a3 */
|
||||
/* left b2 right */
|
||||
/* c1 down c3 */
|
||||
|
||||
#define KEY_A1 0534 /* Upper left of keypad */
|
||||
#define KEY_A3 0535 /* Upper right of keypad */
|
||||
#define KEY_B2 0536 /* Center of keypad */
|
||||
#define KEY_C1 0537 /* Lower left of keypad */
|
||||
#define KEY_C3 0540 /* Lower right of keypad */
|
||||
#define KEY_BTAB 0541 /* Back tab key */
|
||||
#define KEY_BEG 0542 /* beg(inning) key */
|
||||
#define KEY_CANCEL 0543 /* cancel key */
|
||||
#define KEY_CLOSE 0544 /* close key */
|
||||
#define KEY_COMMAND 0545 /* cmd (command) key */
|
||||
#define KEY_COPY 0546 /* copy key */
|
||||
#define KEY_CREATE 0547 /* create key */
|
||||
#define KEY_END 0550 /* end key */
|
||||
#define KEY_EXIT 0551 /* exit key */
|
||||
#define KEY_FIND 0552 /* find key */
|
||||
#define KEY_HELP 0553 /* help key */
|
||||
#define KEY_MARK 0554 /* mark key */
|
||||
#define KEY_MESSAGE 0555 /* message key */
|
||||
#define KEY_MOVE 0556 /* move key */
|
||||
#define KEY_NEXT 0557 /* next object key */
|
||||
#define KEY_OPEN 0560 /* open key */
|
||||
#define KEY_OPTIONS 0561 /* options key */
|
||||
#define KEY_PREVIOUS 0562 /* previous object key */
|
||||
#define KEY_REDO 0563 /* redo key */
|
||||
#define KEY_REFERENCE 0564 /* ref(erence) key */
|
||||
#define KEY_REFRESH 0565 /* refresh key */
|
||||
#define KEY_REPLACE 0566 /* replace key */
|
||||
#define KEY_RESTART 0567 /* restart key */
|
||||
#define KEY_RESUME 0570 /* resume key */
|
||||
#define KEY_SAVE 0571 /* save key */
|
||||
#define KEY_SBEG 0572 /* shifted beginning key */
|
||||
#define KEY_SCANCEL 0573 /* shifted cancel key */
|
||||
#define KEY_SCOMMAND 0574 /* shifted command key */
|
||||
#define KEY_SCOPY 0575 /* shifted copy key */
|
||||
#define KEY_SCREATE 0576 /* shifted create key */
|
||||
#define KEY_SDC 0577 /* shifted delete char key */
|
||||
#define KEY_SDL 0600 /* shifted delete line key */
|
||||
#define KEY_SELECT 0601 /* select key */
|
||||
#define KEY_SEND 0602 /* shifted end key */
|
||||
#define KEY_SEOL 0603 /* shifted clear line key */
|
||||
#define KEY_SEXIT 0604 /* shifted exit key */
|
||||
#define KEY_SFIND 0605 /* shifted find key */
|
||||
#define KEY_SHELP 0606 /* shifted help key */
|
||||
#define KEY_SHOME 0607 /* shifted home key */
|
||||
#define KEY_SIC 0610 /* shifted input key */
|
||||
#define KEY_SLEFT 0611 /* shifted left arrow key */
|
||||
#define KEY_SMESSAGE 0612 /* shifted message key */
|
||||
#define KEY_SMOVE 0613 /* shifted move key */
|
||||
#define KEY_SNEXT 0614 /* shifted next key */
|
||||
#define KEY_SOPTIONS 0615 /* shifted options key */
|
||||
#define KEY_SPREVIOUS 0616 /* shifted prev key */
|
||||
#define KEY_SPRINT 0617 /* shifted print key */
|
||||
#define KEY_SREDO 0620 /* shifted redo key */
|
||||
#define KEY_SREPLACE 0621 /* shifted replace key */
|
||||
#define KEY_SRIGHT 0622 /* shifted right arrow */
|
||||
#define KEY_SRSUME 0623 /* shifted resume key */
|
||||
#define KEY_SSAVE 0624 /* shifted save key */
|
||||
#define KEY_SSUSPEND 0625 /* shifted suspend key */
|
||||
#define KEY_SUNDO 0626 /* shifted undo key */
|
||||
#define KEY_SUSPEND 0627 /* suspend key */
|
||||
#define KEY_UNDO 0630 /* undo key */
|
||||
#define KEY_MAX 0777 /* Maximum curses key */
|
||||
|
||||
#endif
|
@ -1,137 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
* curses.priv.h
|
||||
*
|
||||
* Header file for curses library objects which are private to
|
||||
* the library.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define inline
|
||||
#endif
|
||||
|
||||
#ifndef NOACTION
|
||||
#include <unistd.h>
|
||||
typedef struct sigaction sigaction_t;
|
||||
#else
|
||||
#include "SigAction.h"
|
||||
#endif
|
||||
|
||||
#include "curses.h"
|
||||
|
||||
#define min(a,b) ((a) > (b) ? (b) : (a))
|
||||
#define max(a,b) ((a) < (b) ? (b) : (a))
|
||||
|
||||
#define FG(n) ((n) & 0x0f)
|
||||
#define BG(n) (((n) & 0xf0) >> 4)
|
||||
|
||||
#define TextOf(c) ((c) & (chtype)A_CHARTEXT)
|
||||
#define AttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
|
||||
|
||||
#define BLANK (' '|A_NORMAL)
|
||||
|
||||
#define CHANGED -1
|
||||
|
||||
#define ALL_BUT_COLOR ((chtype)~(A_COLOR))
|
||||
|
||||
/* Macro to put together character and attribute info and return it.
|
||||
If colors are in the attribute, they have precedence. */
|
||||
#define ch_or_attr(ch,at) \
|
||||
((PAIR_NUMBER(at) > 0) ? \
|
||||
((((chtype)ch) & ALL_BUT_COLOR) | (at)) : ((((chtype)ch) | (at))))
|
||||
|
||||
extern WINDOW *newscr;
|
||||
|
||||
#ifdef TRACE
|
||||
#define T(a) if (_tracing & TRACE_ORDINARY) _tracef a
|
||||
#define TR(n, a) if (_tracing & (n)) _tracef a
|
||||
extern int _tracing;
|
||||
extern char *visbuf(const char *);
|
||||
#else
|
||||
#define T(a)
|
||||
#define TR(n, a)
|
||||
#endif
|
||||
|
||||
extern int _outch(int);
|
||||
extern void init_acs(void);
|
||||
extern void tstp(int);
|
||||
extern WINDOW *makenew(int, int, int, int);
|
||||
extern int timed_wait(int fd, int wait, int *timeleft);
|
||||
extern chtype _nc_background(WINDOW *);
|
||||
extern chtype _nc_render(WINDOW *, chtype);
|
||||
extern int _nc_keypad(bool);
|
||||
extern void _nc_scroll_window(WINDOW *, int, short const, short const, chtype);
|
||||
|
||||
struct try {
|
||||
struct try *child; /* ptr to child. NULL if none */
|
||||
struct try *sibling; /* ptr to sibling. NULL if none */
|
||||
unsigned char ch; /* character at this node */
|
||||
unsigned short value; /* code of string so far. 0 if none. */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure for soft labels.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
char dirty; /* all labels have changed */
|
||||
char hidden; /* soft lables are hidden */
|
||||
WINDOW *win;
|
||||
struct slk_ent {
|
||||
char text[9]; /* text for the label */
|
||||
char form_text[9]; /* formatted text (left/center/...) */
|
||||
int x; /* x coordinate of this field */
|
||||
char dirty; /* this label has changed */
|
||||
char visible; /* field is visible */
|
||||
} ent[8];
|
||||
} SLK;
|
||||
|
||||
#define FIFO_SIZE 32
|
||||
|
||||
struct screen {
|
||||
FILE *_ifp; /* input file ptr for this terminal */
|
||||
FILE *_ofp; /* output file ptr for this terminal */
|
||||
int _checkfd;
|
||||
#ifdef MYTINFO
|
||||
struct _terminal *_term;
|
||||
#else
|
||||
struct term *_term; /* used by terminfo stuff */
|
||||
#endif
|
||||
WINDOW *_curscr; /* windows specific to a given terminal */
|
||||
WINDOW *_newscr;
|
||||
WINDOW *_stdscr;
|
||||
struct try *_keytry; /* "Try" for use with keypad mode */
|
||||
unsigned int _fifo[FIFO_SIZE]; /* Buffer for pushed back characters */
|
||||
signed char _fifohead,
|
||||
_fifotail,
|
||||
_fifopeek;
|
||||
bool _endwin;
|
||||
chtype _current_attr;
|
||||
bool _coloron;
|
||||
int _cursor; /* visibility of the cursor */
|
||||
int _cursrow; /* Row and column of physical cursor */
|
||||
int _curscol;
|
||||
bool _nl; /* True if NL -> CR/NL is on */
|
||||
bool _raw; /* True if in raw mode */
|
||||
int _cbreak; /* 1 if in cbreak mode */
|
||||
/* > 1 if in halfdelay mode */
|
||||
bool _echo; /* True if echo on */
|
||||
bool _nlmapping; /* True if terminal is really doing */
|
||||
/* NL mapping (fn of raw and nl) */
|
||||
SLK *_slk; /* ptr to soft key struct / NULL */
|
||||
int _costs[9]; /* costs of cursor movements for mvcur */
|
||||
int _costinit; /* flag wether costs[] is initialized */
|
||||
};
|
||||
|
||||
extern struct screen *SP;
|
||||
|
||||
extern int _slk_format; /* format specified in slk_init() */
|
||||
|
||||
#define MAXCOLUMNS 135
|
||||
#define MAXLINES 66
|
||||
#define UNINITIALISED ((struct try * ) -1)
|
@ -1,71 +0,0 @@
|
||||
|
||||
5.10. Color Manipulation
|
||||
|
||||
Ncurses provides support for the use of color on terminals
|
||||
that are capable of display it. Note the BSD and older SYSV
|
||||
curses don't support color. Color support in the PC version
|
||||
is not compatible with SYSR4.
|
||||
|
||||
has_colors()
|
||||
this function returns TRUE if the terminal supports color,
|
||||
FALSE otherwise. Other color handling funtions will return
|
||||
ERR if has_colors() is FALSE. You should always check before
|
||||
using color and use other video attributes to replace color.
|
||||
|
||||
can_change_color()
|
||||
This function returns TRUE if the terminal is capable of
|
||||
redefining colors using the init_color function, FALSE if it
|
||||
can't. Don't use init_color and color_content if it returns
|
||||
FALSE.
|
||||
|
||||
start_color()
|
||||
This function must be called before any other color handling
|
||||
function is called. It initializes the 8 basic colors (see
|
||||
appendix I) and sets the global variables COLORS and COLOR_
|
||||
PAIRS to the maximum number of colors and color-pairs a
|
||||
terminal can handle.
|
||||
|
||||
init_pair(pair, fg, bg)
|
||||
This function changes the definition of a color-pair, pair.
|
||||
Each pair has a foregroung color fg, and a background color
|
||||
bg. Both values must be between 0 and COLORS-1. pair must be
|
||||
between 1 and COLOR_PAIRS-1.
|
||||
[If a pair is changed from a previous definition, the screen
|
||||
is refreshed and all occurances of the color-pair are
|
||||
changed to reflect the change.]
|
||||
|
||||
pair_content(pair, f, b)
|
||||
This function stores the foreground and background colors of
|
||||
the color-pair pair into the variables pointed to by f, b.
|
||||
pair should be between 1 and COLOR_PAIRS-1.
|
||||
|
||||
init_color(color, r, g, b)
|
||||
This function changes the value of a given color. A color is
|
||||
defined by its red, green, and blue components, r, g, and b.
|
||||
These values must be between 0 and 1000. color should be
|
||||
between 0 and COLORS-1.
|
||||
|
||||
color_content(color, r, g, b)
|
||||
This function puts the red, green, and blue components of
|
||||
color into the variable pointed to by r, g, b respectively.
|
||||
color should be between 0 and COLORS-1.
|
||||
|
||||
COLOR_PAIR(n) set color-pair to that stored in n
|
||||
PAIR_NUMBER(a) get color-pair stored in attribute a
|
||||
|
||||
|
||||
Appendix II: COLORS
|
||||
-------------------
|
||||
|
||||
Colors are defined in <ncurses.h> are used with init_pair().
|
||||
|
||||
COLOR_BLACK 0
|
||||
COLOR_RED 1
|
||||
COLOR_GREEN 2
|
||||
COLOR_YELLOW 3
|
||||
COLOR_BLUE 4
|
||||
COLOR_MAGENTA 5
|
||||
COLOR_CYAN 6
|
||||
COLOR_WHITE 7
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,149 +0,0 @@
|
||||
key_a1 KEY_A1
|
||||
key_a3 KEY_A3
|
||||
key_b2 KEY_B2
|
||||
key_backspace KEY_BACKSPACE
|
||||
key_beg KEY_BEG
|
||||
key_btab KEY_BTAB
|
||||
key_c1 KEY_C1
|
||||
key_c3 KEY_C3
|
||||
key_cancel KEY_CANCEL
|
||||
key_catab KEY_CATAB
|
||||
key_clear KEY_CLEAR
|
||||
key_close KEY_CLOSE
|
||||
key_command KEY_COMMAND
|
||||
key_copy KEY_COPY
|
||||
key_create KEY_CREATE
|
||||
key_ctab KEY_CTAB
|
||||
key_dc KEY_DC
|
||||
key_dl KEY_DL
|
||||
key_down KEY_DOWN
|
||||
key_eic KEY_EIC
|
||||
key_end KEY_END
|
||||
key_enter KEY_ENTER
|
||||
key_eol KEY_EOL
|
||||
key_eos KEY_EOS
|
||||
key_exit KEY_EXIT
|
||||
key_f0 KEY_F(0)
|
||||
key_f1 KEY_F(1)
|
||||
key_f2 KEY_F(2)
|
||||
key_f3 KEY_F(3)
|
||||
key_f4 KEY_F(4)
|
||||
key_f5 KEY_F(5)
|
||||
key_f6 KEY_F(6)
|
||||
key_f7 KEY_F(7)
|
||||
key_f8 KEY_F(8)
|
||||
key_f9 KEY_F(9)
|
||||
key_f10 KEY_F(10)
|
||||
key_f11 KEY_F(11)
|
||||
key_f12 KEY_F(12)
|
||||
key_f13 KEY_F(13)
|
||||
key_f14 KEY_F(14)
|
||||
key_f15 KEY_F(15)
|
||||
key_f16 KEY_F(16)
|
||||
key_f17 KEY_F(17)
|
||||
key_f18 KEY_F(18)
|
||||
key_f19 KEY_F(19)
|
||||
key_f20 KEY_F(20)
|
||||
key_f21 KEY_F(21)
|
||||
key_f22 KEY_F(22)
|
||||
key_f23 KEY_F(23)
|
||||
key_f24 KEY_F(24)
|
||||
key_f25 KEY_F(25)
|
||||
key_f26 KEY_F(26)
|
||||
key_f27 KEY_F(27)
|
||||
key_f28 KEY_F(28)
|
||||
key_f29 KEY_F(29)
|
||||
key_f30 KEY_F(30)
|
||||
key_f31 KEY_F(31)
|
||||
key_f32 KEY_F(32)
|
||||
key_f33 KEY_F(33)
|
||||
key_f34 KEY_F(34)
|
||||
key_f35 KEY_F(35)
|
||||
key_f36 KEY_F(36)
|
||||
key_f37 KEY_F(37)
|
||||
key_f38 KEY_F(38)
|
||||
key_f39 KEY_F(39)
|
||||
key_f40 KEY_F(40)
|
||||
key_f41 KEY_F(41)
|
||||
key_f42 KEY_F(42)
|
||||
key_f43 KEY_F(43)
|
||||
key_f44 KEY_F(44)
|
||||
key_f45 KEY_F(45)
|
||||
key_f46 KEY_F(46)
|
||||
key_f47 KEY_F(47)
|
||||
key_f48 KEY_F(48)
|
||||
key_f49 KEY_F(49)
|
||||
key_f50 KEY_F(50)
|
||||
key_f51 KEY_F(51)
|
||||
key_f52 KEY_F(52)
|
||||
key_f53 KEY_F(53)
|
||||
key_f54 KEY_F(54)
|
||||
key_f55 KEY_F(55)
|
||||
key_f56 KEY_F(56)
|
||||
key_f57 KEY_F(57)
|
||||
key_f58 KEY_F(58)
|
||||
key_f59 KEY_F(59)
|
||||
key_f60 KEY_F(60)
|
||||
key_f61 KEY_F(61)
|
||||
key_f62 KEY_F(62)
|
||||
key_f63 KEY_F(63)
|
||||
key_find KEY_FIND
|
||||
key_help KEY_HELP
|
||||
key_home KEY_HOME
|
||||
key_ic KEY_IC
|
||||
key_il KEY_IL
|
||||
key_left KEY_LEFT
|
||||
key_ll KEY_LL
|
||||
key_mark KEY_MARK
|
||||
key_message KEY_MESSAGE
|
||||
key_move KEY_MOVE
|
||||
key_next KEY_NEXT
|
||||
key_npage KEY_NPAGE
|
||||
key_open KEY_OPEN
|
||||
key_options KEY_OPTIONS
|
||||
key_ppage KEY_PPAGE
|
||||
key_previous KEY_PREVIOUS
|
||||
key_print KEY_PRINT
|
||||
key_redo KEY_REDO
|
||||
key_reference KEY_REFERENCE
|
||||
key_refresh KEY_REFRESH
|
||||
key_replace KEY_REPLACE
|
||||
key_restart KEY_RESTART
|
||||
key_resume KEY_RESUME
|
||||
key_right KEY_RIGHT
|
||||
key_save KEY_SAVE
|
||||
key_sbeg KEY_SBEG
|
||||
key_scancel KEY_SCANCEL
|
||||
key_scommand KEY_SCOMMAND
|
||||
key_scopy KEY_SCOPY
|
||||
key_screate KEY_SCREATE
|
||||
key_sdc KEY_SDC
|
||||
key_sdl KEY_SDL
|
||||
key_select KEY_SELECT
|
||||
key_send KEY_SEND
|
||||
key_seol KEY_SEOL
|
||||
key_sexit KEY_SEXIT
|
||||
key_sf KEY_SF
|
||||
key_sfind KEY_SFIND
|
||||
key_shelp KEY_SHELP
|
||||
key_shome KEY_SHOME
|
||||
key_sic KEY_SIC
|
||||
key_sleft KEY_SLEFT
|
||||
key_smessage KEY_SMESSAGE
|
||||
key_smove KEY_SMOVE
|
||||
key_snext KEY_SNEXT
|
||||
key_soptions KEY_SOPTIONS
|
||||
key_sprevious KEY_SPREVIOUS
|
||||
key_sprint KEY_SPRINT
|
||||
key_sr KEY_SR
|
||||
key_sredo KEY_SREDO
|
||||
key_sreplace KEY_SREPLACE
|
||||
key_sright KEY_SRIGHT
|
||||
key_srsume KEY_SRSUME
|
||||
key_ssave KEY_SSAVE
|
||||
key_ssuspend KEY_SSUSPEND
|
||||
key_stab KEY_STAB
|
||||
key_sundo KEY_SUNDO
|
||||
key_suspend KEY_SUSPEND
|
||||
key_undo KEY_UNDO
|
||||
key_up KEY_UP
|
@ -1,98 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include "terminfo.h"
|
||||
#include <string.h>
|
||||
|
||||
/* line graphics */
|
||||
|
||||
|
||||
chtype acs_map[128];
|
||||
|
||||
void init_acs()
|
||||
{
|
||||
|
||||
/*
|
||||
ACS_ULCORNER (acs_map['l'])
|
||||
ACS_LLCORNER (acs_map['m'])
|
||||
ACS_URCORNER (acs_map['k'])
|
||||
ACS_LRCORNER (acs_map['j'])
|
||||
ACS_RTEE (acs_map['u'])
|
||||
ACS_LTEE (acs_map['t'])
|
||||
ACS_BTEE (acs_map['v'])
|
||||
ACS_TTEE (acs_map['w'])
|
||||
ACS_HLINE (acs_map['q'])
|
||||
ACS_VLINE (acs_map['x'])
|
||||
ACS_PLUS (acs_map['n'])
|
||||
ACS_S1 (acs_map['o']) scan line 1
|
||||
ACS_S9 (acs_map['s']) scan line 9
|
||||
ACS_DIAMOND (acs_map['`']) diamond
|
||||
ACS_CKBOARD (acs_map['a']) checker board (stipple)
|
||||
ACS_DEGREE (acs_map['f']) degree symbol
|
||||
ACS_PLMINUS (acs_map['g']) plus/minus
|
||||
ACS_BULLET (acs_map['~']) bullet
|
||||
ACS_LARROW (acs_map[',']) arrow pointing left
|
||||
ACS_RARROW (acs_map['+']) arrow pointing right
|
||||
ACS_DARROW (acs_map['.']) arrow pointing down
|
||||
ACS_UARROW (acs_map['-']) arrow pointing up
|
||||
ACS_BOARD (acs_map['h']) board of squares
|
||||
ACS_LANTERN (acs_map['I']) lantern symbol
|
||||
ACS_BLOCK (acs_map['0']) solid square block
|
||||
*/
|
||||
|
||||
T(("initializing ACS map"));
|
||||
|
||||
acs_map['l'] = acs_map['m'] = acs_map['k'] = acs_map['j'] =
|
||||
acs_map['u'] = acs_map['t'] = acs_map['v'] = acs_map['w'] = (chtype)'+' & A_CHARTEXT;
|
||||
acs_map['q'] = (chtype)'-' & A_CHARTEXT;
|
||||
acs_map['x'] = (chtype)'|' & A_CHARTEXT;
|
||||
acs_map['n'] = (chtype)'+' & A_CHARTEXT;
|
||||
acs_map['o'] = (chtype)'~' & A_CHARTEXT;
|
||||
acs_map['s'] = (chtype)'_' & A_CHARTEXT;
|
||||
acs_map['`'] = (chtype)'+' & A_CHARTEXT;
|
||||
acs_map['a'] = (chtype)':' & A_CHARTEXT;
|
||||
acs_map['f'] = (chtype)'\'' & A_CHARTEXT;
|
||||
acs_map['g'] = (chtype)'#' & A_CHARTEXT;
|
||||
acs_map['~'] = (chtype)'o' & A_CHARTEXT;
|
||||
acs_map[','] = (chtype)'<' & A_CHARTEXT;
|
||||
acs_map['+'] = (chtype)'>' & A_CHARTEXT;
|
||||
acs_map['.'] = (chtype)'v' & A_CHARTEXT;
|
||||
acs_map['-'] = (chtype)'^' & A_CHARTEXT;
|
||||
acs_map['h'] = (chtype)'#' & A_CHARTEXT;
|
||||
acs_map['I'] = (chtype)'#' & A_CHARTEXT;
|
||||
acs_map['0'] = (chtype)'#' & A_CHARTEXT;
|
||||
|
||||
if (ena_acs != NULL)
|
||||
putp(ena_acs);
|
||||
|
||||
if (acs_chars != NULL) {
|
||||
int i = 0;
|
||||
int length = strlen(acs_chars);
|
||||
|
||||
while (i < length)
|
||||
switch (acs_chars[i]) {
|
||||
case 'l':case 'm':case 'k':case 'j':
|
||||
case 'u':case 't':case 'v':case 'w':
|
||||
case 'q':case 'x':case 'n':case 'o':
|
||||
case 's':case '`':case 'a':case 'f':
|
||||
case 'g':case '~':case ',':case '+':
|
||||
case '.':case '-':case 'h':case 'I':
|
||||
case '0':
|
||||
acs_map[(unsigned int)(unsigned char)acs_chars[i]] =
|
||||
(acs_chars[++i] & A_CHARTEXT) | A_ALTCHARSET;
|
||||
default:
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef TRACE
|
||||
else {
|
||||
T(("acsc not defined, using default mapping"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1,127 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_addch.c
|
||||
**
|
||||
** The routine waddch().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include "unctrl.h"
|
||||
|
||||
static inline chtype render_char(WINDOW *win, chtype ch)
|
||||
/* compute a rendition of the given char correct for the current context */
|
||||
{
|
||||
if (TextOf(ch) == ' ')
|
||||
ch = ch_or_attr(ch, win->_bkgd);
|
||||
else if (!(ch & A_ATTRIBUTES))
|
||||
ch = ch_or_attr(ch, (win->_bkgd & A_ATTRIBUTES));
|
||||
TR(TRACE_CHARPUT, ("bkg = %#lx -> ch = %#lx", win->_bkgd, ch));
|
||||
|
||||
return(ch);
|
||||
}
|
||||
|
||||
chtype _nc_background(WINDOW *win)
|
||||
/* make render_char() visible while still allowing us to inline it below */
|
||||
{
|
||||
return(render_char(win, BLANK));
|
||||
}
|
||||
|
||||
chtype _nc_render(WINDOW *win, chtype ch)
|
||||
/* make render_char() visible while still allowing us to inline it below */
|
||||
{
|
||||
chtype c = render_char(win,ch);
|
||||
return (ch_or_attr(c,win->_attrs));
|
||||
}
|
||||
|
||||
static int
|
||||
wladdch(WINDOW *win, chtype c, bool literal)
|
||||
{
|
||||
int x, y;
|
||||
int newx;
|
||||
chtype ch = c;
|
||||
|
||||
x = win->_curx;
|
||||
y = win->_cury;
|
||||
|
||||
if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0)
|
||||
return(ERR);
|
||||
|
||||
/* ugly, but necessary --- and, bizarrely enough, even portable! */
|
||||
if (literal)
|
||||
goto noctrl;
|
||||
|
||||
switch (ch&A_CHARTEXT) {
|
||||
case '\t':
|
||||
for (newx = x + (8 - (x & 07)); x < newx; x++)
|
||||
if (waddch(win, ' ') == ERR)
|
||||
return(ERR);
|
||||
return(OK);
|
||||
case '\n':
|
||||
wclrtoeol(win);
|
||||
x = 0;
|
||||
goto newline;
|
||||
case '\r':
|
||||
x = 0;
|
||||
break;
|
||||
case '\b':
|
||||
if (--x < 0)
|
||||
x = 0;
|
||||
break;
|
||||
default:
|
||||
if (ch < ' ')
|
||||
return(waddstr(win, unctrl(ch)));
|
||||
|
||||
/* FALL THROUGH */
|
||||
noctrl:
|
||||
T(("win attr = %x", win->_attrs));
|
||||
ch = render_char(win, ch);
|
||||
ch = ch_or_attr(ch,win->_attrs);
|
||||
|
||||
if (win->_line[y][x] != ch) {
|
||||
if (win->_firstchar[y] == _NOCHANGE)
|
||||
win->_firstchar[y] = win->_lastchar[y] = x;
|
||||
else if (x < win->_firstchar[y])
|
||||
win->_firstchar[y] = x;
|
||||
else if (x > win->_lastchar[y])
|
||||
win->_lastchar[y] = x;
|
||||
|
||||
}
|
||||
|
||||
T(("char %d of line %d is %x", x, y, ch));
|
||||
win->_line[y][x++] = ch;
|
||||
if (x > win->_maxx) {
|
||||
x = 0;
|
||||
newline:
|
||||
y++;
|
||||
if (y > win->_regbottom) {
|
||||
y--;
|
||||
if (win->_scroll)
|
||||
scroll(win);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
win->_curx = x;
|
||||
win->_cury = y;
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
||||
int waddch(WINDOW *win, chtype ch)
|
||||
{
|
||||
TR(TRACE_CHARPUT, ("waddch(%x,%c (%x)) called", win, ch&A_CHARTEXT, ch));
|
||||
return wladdch(win, ch, FALSE);
|
||||
}
|
||||
|
||||
int wechochar(WINDOW *win, chtype ch)
|
||||
{
|
||||
T(("wechochar(%x,%c (%x)) called", win, ch&A_CHARTEXT, ch));
|
||||
|
||||
return wladdch(win, ch, TRUE);
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_addstr.c
|
||||
*
|
||||
** The routines waddnstr(), waddchnstr().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int
|
||||
waddnstr(WINDOW *win, char *str, int n)
|
||||
{
|
||||
T(("waddnstr(%x,\"%s\",%d) called", win, visbuf(str), n));
|
||||
|
||||
if (str == NULL)
|
||||
return ERR;
|
||||
|
||||
if (n < 0) {
|
||||
while (*str != '\0') {
|
||||
if (waddch(win, (chtype)(unsigned char)*str++) == ERR)
|
||||
return(ERR);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
while((n-- > 0) && (*str != '\0')) {
|
||||
if (waddch(win, (chtype)(unsigned char)*str++) == ERR)
|
||||
return ERR;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
waddchnstr(WINDOW *win, chtype *str, int n)
|
||||
{
|
||||
T(("waddchnstr(%x,%x,%d) called", win, str, n));
|
||||
|
||||
if (n < 0) {
|
||||
while (*str) {
|
||||
if (waddch(win, (chtype)(unsigned char)*str++) == ERR)
|
||||
return(ERR);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
while(n-- > 0) {
|
||||
if (waddch(win, (chtype)(unsigned char)*str++) == ERR)
|
||||
return ERR;
|
||||
}
|
||||
return OK;
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
* beep.c
|
||||
*
|
||||
* Routines beep() and flash()
|
||||
*
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include "terminfo.h"
|
||||
|
||||
/*
|
||||
* beep()
|
||||
*
|
||||
* Sound the current terminal's audible bell if it has one. If not,
|
||||
* flash the screen if possible.
|
||||
*
|
||||
*/
|
||||
|
||||
int beep()
|
||||
{
|
||||
T(("beep() called"));
|
||||
|
||||
/* should make sure that we are not in altchar mode */
|
||||
if (bell)
|
||||
return(putp(bell));
|
||||
else if (flash_screen)
|
||||
return(putp(flash_screen));
|
||||
else
|
||||
return(ERR);
|
||||
}
|
||||
|
||||
/*
|
||||
* flash()
|
||||
*
|
||||
* Flash the current terminal's screen if possible. If not,
|
||||
* sound the audible bell if one exists.
|
||||
*
|
||||
*/
|
||||
|
||||
int flash()
|
||||
{
|
||||
T(("flash() called"));
|
||||
|
||||
/* should make sure that we are not in altchar mode */
|
||||
if (flash_screen)
|
||||
return(putp(flash_screen));
|
||||
else if (bell)
|
||||
return(putp(bell));
|
||||
else
|
||||
return(ERR);
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
|
||||
/***************************************************************************
|
||||
* COPYRIGHT NOTICE *
|
||||
****************************************************************************
|
||||
* ncurses is copyright (C) 1992, 1993, 1994 *
|
||||
* by Zeyd M. Ben-Halim *
|
||||
* zmbenhal@netcom.com *
|
||||
* *
|
||||
* Permission is hereby granted to reproduce and distribute ncurses *
|
||||
* by any means and for any fee, whether alone or as part of a *
|
||||
* larger distribution, in source or in binary form, PROVIDED *
|
||||
* this notice is included with any such distribution, not removed *
|
||||
* from header files, and is reproduced in any documentation *
|
||||
* accompanying it or the applications linked with it. *
|
||||
* *
|
||||
* ncurses comes AS IS with no warranty, implied or expressed. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "curses.h"
|
||||
#include "curses.priv.h"
|
||||
|
||||
int wbkgd(WINDOW *win, chtype ch)
|
||||
{
|
||||
int x, y;
|
||||
chtype old_bkgd = getbkgd(win);
|
||||
chtype new_bkgd = ch;
|
||||
|
||||
T(("wbkgd(%x, %x) called", win, ch));
|
||||
|
||||
if (TextOf(new_bkgd) == 0)
|
||||
new_bkgd |= BLANK;
|
||||
wbkgdset(win, new_bkgd);
|
||||
wattrset(win, AttrOf(new_bkgd));
|
||||
|
||||
for (y = 0; y <= win->_maxy; y++) {
|
||||
for (x = 0; x <= win->_maxx; x++) {
|
||||
if (win->_line[y][x] == old_bkgd)
|
||||
win->_line[y][x] = new_bkgd;
|
||||
else
|
||||
win->_line[y][x] =
|
||||
TextOf(win->_line[y][x])
|
||||
| AttrOf(new_bkgd);
|
||||
}
|
||||
}
|
||||
touchwin(win);
|
||||
return OK;
|
||||
}
|
||||
|
@ -1,131 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_box.c
|
||||
**
|
||||
** line drawing routines:
|
||||
** wborder()
|
||||
** whline()
|
||||
** wvline()
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts,
|
||||
chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
|
||||
{
|
||||
int i;
|
||||
int endx, endy;
|
||||
|
||||
T(("wborder() called"));
|
||||
|
||||
if (ls == 0) ls = ACS_VLINE;
|
||||
if (rs == 0) rs = ACS_VLINE;
|
||||
if (ts == 0) ts = ACS_HLINE;
|
||||
if (bs == 0) bs = ACS_HLINE;
|
||||
if (tl == 0) tl = ACS_ULCORNER;
|
||||
if (tr == 0) tr = ACS_URCORNER;
|
||||
if (bl == 0) bl = ACS_LLCORNER;
|
||||
if (br == 0) br = ACS_LRCORNER;
|
||||
|
||||
ls = _nc_render(win, ls);
|
||||
rs = _nc_render(win, rs);
|
||||
ts = _nc_render(win, ts);
|
||||
bs = _nc_render(win, bs);
|
||||
tl = _nc_render(win, tl);
|
||||
tr = _nc_render(win, tr);
|
||||
bl = _nc_render(win, bl);
|
||||
br = _nc_render(win, br);
|
||||
|
||||
T(("using %x, %x, %x, %x, %x, %x, %x, %x", ls, rs, ts, bs, tl, tr, bl, br));
|
||||
|
||||
endx = win->_maxx;
|
||||
endy = win->_maxy;
|
||||
|
||||
for (i = 0; i <= endx; i++) {
|
||||
win->_line[0][i] = ts;
|
||||
win->_line[endy][i] = bs;
|
||||
}
|
||||
win->_firstchar[endy] = win->_firstchar[0] = 0;
|
||||
win->_lastchar[endy] = win->_lastchar[0] = endx;
|
||||
|
||||
for (i = 0; i <= endy; i++) {
|
||||
win->_line[i][0] = ls;
|
||||
win->_line[i][endx] = rs;
|
||||
win->_firstchar[i] = 0;
|
||||
win->_lastchar[i] = endx;
|
||||
}
|
||||
win->_line[0][0] = tl;
|
||||
win->_line[0][endx] = tr;
|
||||
win->_line[endy][0] = bl;
|
||||
win->_line[endy][endx] = br;
|
||||
|
||||
#if 0
|
||||
if (! win->_scroll && (win->_flags & _SCROLLWIN))
|
||||
fp[0] = fp[endx] = lp[0] = lp[endx] = ' ';
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int whline(WINDOW *win, chtype ch, int n)
|
||||
{
|
||||
int line;
|
||||
int start;
|
||||
int end;
|
||||
|
||||
T(("whline(%x,%x,%d) called", win, ch, n));
|
||||
|
||||
line = win->_cury;
|
||||
start = win->_curx;
|
||||
end = start + n - 1;
|
||||
if (end > win->_maxx)
|
||||
end = win->_maxx;
|
||||
|
||||
if (win->_firstchar[line] == _NOCHANGE || win->_firstchar[line] > start)
|
||||
win->_firstchar[line] = start;
|
||||
if (win->_lastchar[line] == _NOCHANGE || win->_lastchar[line] < start)
|
||||
win->_lastchar[line] = end;
|
||||
|
||||
if (ch == 0)
|
||||
ch = ACS_HLINE;
|
||||
while ( end >= start) {
|
||||
win->_line[line][end] = ch | win->_attrs;
|
||||
end--;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int wvline(WINDOW *win, chtype ch, int n)
|
||||
{
|
||||
int row, col;
|
||||
int end;
|
||||
|
||||
T(("wvline(%x,%x,%d) called", win, ch, n));
|
||||
|
||||
row = win->_cury;
|
||||
col = win->_curx;
|
||||
end = row + n - 1;
|
||||
if (end > win->_maxy)
|
||||
end = win->_maxy;
|
||||
|
||||
if (ch == 0)
|
||||
ch = ACS_VLINE;
|
||||
|
||||
while(end >= row) {
|
||||
win->_line[end][col] = ch | win->_attrs;
|
||||
if (win->_firstchar[end] == _NOCHANGE || win->_firstchar[end] > col)
|
||||
win->_firstchar[end] = col;
|
||||
if (win->_lastchar[end] == _NOCHANGE || win->_lastchar[end] < col)
|
||||
win->_lastchar[end] = col;
|
||||
end--;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_clear.c
|
||||
**
|
||||
** The routine wclear().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int wclear(WINDOW *win)
|
||||
{
|
||||
T(("wclear(%x) called", win));
|
||||
|
||||
werase(win);
|
||||
|
||||
win->_clear = TRUE;
|
||||
|
||||
return OK;
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_clrbot.c
|
||||
**
|
||||
** The routine wclrtobot().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int wclrtobot(WINDOW *win)
|
||||
{
|
||||
chtype *ptr, *end, *maxx = NULL;
|
||||
int y, startx, minx;
|
||||
|
||||
T(("wclrtobot(%x) called", win));
|
||||
|
||||
startx = win->_curx;
|
||||
|
||||
T(("clearing from y = %d to y = %d with maxx = %d", win->_cury, win->_maxy, win->_maxx));
|
||||
|
||||
for (y = win->_cury; y <= win->_maxy; y++) {
|
||||
minx = _NOCHANGE;
|
||||
end = &win->_line[y][win->_maxx];
|
||||
|
||||
for (ptr = &win->_line[y][startx]; ptr <= end; ptr++) {
|
||||
chtype blank = _nc_background(win);
|
||||
|
||||
if (*ptr != blank) {
|
||||
maxx = ptr;
|
||||
if (minx == _NOCHANGE)
|
||||
minx = ptr - win->_line[y];
|
||||
*ptr = blank;
|
||||
}
|
||||
}
|
||||
|
||||
if (minx != _NOCHANGE) {
|
||||
if (win->_firstchar[y] > minx
|
||||
|| win->_firstchar[y] == _NOCHANGE)
|
||||
win->_firstchar[y] = minx;
|
||||
|
||||
if (win->_lastchar[y] < maxx - win->_line[y])
|
||||
win->_lastchar[y] = maxx - win->_line[y];
|
||||
}
|
||||
|
||||
startx = 0;
|
||||
}
|
||||
return OK;
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_clreol.c
|
||||
**
|
||||
** The routine wclrtoeol().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int wclrtoeol(WINDOW *win)
|
||||
{
|
||||
chtype *maxx, *ptr, *end;
|
||||
int y, x, minx;
|
||||
|
||||
T(("wclrtoeol(%x) called", win));
|
||||
|
||||
y = win->_cury;
|
||||
x = win->_curx;
|
||||
|
||||
end = &win->_line[y][win->_maxx];
|
||||
minx = _NOCHANGE;
|
||||
maxx = &win->_line[y][x];
|
||||
|
||||
for (ptr = maxx; ptr <= end; ptr++) {
|
||||
chtype blank = _nc_background(win);
|
||||
|
||||
if (*ptr != blank) {
|
||||
maxx = ptr;
|
||||
if (minx == _NOCHANGE)
|
||||
minx = ptr - win->_line[y];
|
||||
*ptr = blank;
|
||||
}
|
||||
}
|
||||
|
||||
if (minx != _NOCHANGE) {
|
||||
if (win->_firstchar[y] > minx || win->_firstchar[y] == _NOCHANGE)
|
||||
win->_firstchar[y] = minx;
|
||||
|
||||
if (win->_lastchar[y] < maxx - win->_line[y])
|
||||
win->_lastchar[y] = maxx - win->_line[y];
|
||||
}
|
||||
return(OK);
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
/* This work is copyrighted. See COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/* lib_color.c
|
||||
*
|
||||
* Handles color emulation of SYS V curses
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "curses.priv.h"
|
||||
#include "terminfo.h"
|
||||
|
||||
int COLOR_PAIRS;
|
||||
int COLORS;
|
||||
unsigned char *color_pairs;
|
||||
|
||||
int start_color()
|
||||
{
|
||||
T(("start_color() called."));
|
||||
|
||||
if (orig_pair != NULL)
|
||||
putp(orig_pair);
|
||||
else return ERR;
|
||||
if (max_pairs != -1)
|
||||
COLOR_PAIRS = max_pairs;
|
||||
else return ERR;
|
||||
color_pairs = malloc(max_pairs);
|
||||
if (max_colors != -1)
|
||||
COLORS = max_colors;
|
||||
else return ERR;
|
||||
SP->_coloron = 1;
|
||||
|
||||
T(("started color: COLORS = %d, COLOR_PAIRS = %d", COLORS, COLOR_PAIRS));
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int init_pair(short pair, short f, short b)
|
||||
{
|
||||
T(("init_pair( %d, %d, %d )", pair, f, b));
|
||||
|
||||
if ((pair < 1) || (pair >= COLOR_PAIRS))
|
||||
return ERR;
|
||||
if ((f < 0) || (f >= COLORS) || (b < 0) || (b >= COLORS))
|
||||
return ERR;
|
||||
|
||||
/* still to do:
|
||||
if pair was initialized before a screen update is performed
|
||||
replacing original pair colors with the new ones
|
||||
*/
|
||||
|
||||
color_pairs[pair] = ( (f & 0x0f) | (b & 0x0f) << 4 );
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int init_color(short color, short r, short g, short b)
|
||||
{
|
||||
if (initialize_color != NULL) {
|
||||
if (color < 0 || color >= COLORS)
|
||||
return ERR;
|
||||
if (hue_lightness_saturation == TRUE)
|
||||
if (r < 0 || r > 360 || g < 0 || g > 100 || b < 0 || b > 100)
|
||||
return ERR;
|
||||
if (hue_lightness_saturation == FALSE)
|
||||
if (r < 0 || r > 1000 || g < 0 || g > 1000 || b < 0 || b > 1000)
|
||||
return ERR;
|
||||
|
||||
putp(tparm(initialize_color, color, r, g, b));
|
||||
return OK;
|
||||
}
|
||||
|
||||
return ERR;
|
||||
}
|
||||
|
||||
bool can_change_color()
|
||||
{
|
||||
return can_change;
|
||||
}
|
||||
|
||||
int has_colors()
|
||||
{
|
||||
return ((orig_pair != NULL) && (max_colors != -1) && (max_pairs != -1)
|
||||
&&
|
||||
(((set_foreground != NULL) && (set_background != NULL)) ||
|
||||
((set_a_foreground != NULL) && (set_a_background != NULL)))
|
||||
);
|
||||
}
|
||||
|
||||
int color_content(short color, short *r, short *g, short *b)
|
||||
{
|
||||
return ERR;
|
||||
}
|
||||
|
||||
int pair_content(short pair, short *f, short *b)
|
||||
{
|
||||
|
||||
if ((pair < 1) || (pair > COLOR_PAIRS))
|
||||
return ERR;
|
||||
*f = color_pairs[pair] & 0x0f;
|
||||
*b = color_pairs[pair] & 0xf0;
|
||||
*b >>= 4;
|
||||
return OK;
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_delch.c
|
||||
**
|
||||
** The routine wdelch().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include "terminfo.h"
|
||||
|
||||
int wdelch(WINDOW *win)
|
||||
{
|
||||
chtype *temp1, *temp2;
|
||||
chtype *end;
|
||||
chtype blank = _nc_background(win);
|
||||
|
||||
T(("wdelch(%x) called", win));
|
||||
|
||||
end = &win->_line[win->_cury][win->_maxx];
|
||||
temp2 = &win->_line[win->_cury][win->_curx + 1];
|
||||
temp1 = temp2 - 1;
|
||||
|
||||
while (temp1 < end)
|
||||
*temp1++ = *temp2++;
|
||||
|
||||
*temp1 = blank;
|
||||
|
||||
win->_lastchar[win->_cury] = win->_maxx;
|
||||
|
||||
if (win->_firstchar[win->_cury] == _NOCHANGE
|
||||
|| win->_firstchar[win->_cury] > win->_curx)
|
||||
win->_firstchar[win->_cury] = win->_curx;
|
||||
return OK;
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_delwin.c
|
||||
**
|
||||
** The routine delwin().
|
||||
**
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "curses.priv.h"
|
||||
|
||||
int delwin(WINDOW *win)
|
||||
{
|
||||
int i;
|
||||
|
||||
T(("delwin(%x) called", win));
|
||||
|
||||
if (! (win->_flags & _SUBWIN)) {
|
||||
for (i = 0; i < win->_maxy && win->_line[i]; i++)
|
||||
free(win->_line[i]);
|
||||
}
|
||||
|
||||
free(win->_firstchar);
|
||||
free(win->_lastchar);
|
||||
free(win->_line);
|
||||
|
||||
touchwin((win->_flags & _SUBWIN) ? win->_parent : curscr);
|
||||
|
||||
free(win);
|
||||
|
||||
return(OK);
|
||||
}
|
@ -1,593 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
*
|
||||
* lib_doupdate.c
|
||||
*
|
||||
* The routine doupdate() and its dependents
|
||||
*
|
||||
*-----------------------------------------------------------------*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#ifdef SYS_SELECT
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include "curses.priv.h"
|
||||
#include "terminfo.h"
|
||||
#ifdef SVR4_ACTION
|
||||
#define _POSIX_SOURCE
|
||||
#endif
|
||||
#include <signal.h>
|
||||
|
||||
static void ClrUpdate( WINDOW *scr );
|
||||
static void TransformLine( int lineno );
|
||||
static void NoIDcTransformLine( int lineno );
|
||||
static void IDcTransformLine( int lineno );
|
||||
static void ClearScreen( void );
|
||||
static void InsStr( chtype *line, int count );
|
||||
static void DelChar( int count );
|
||||
|
||||
static inline void PutAttrChar(chtype ch)
|
||||
{
|
||||
TR(TRACE_CHARPUT, ("PutAttrChar(%s, %s)",
|
||||
_tracechar(ch & A_CHARTEXT),
|
||||
_traceattr((ch & (chtype)A_ATTRIBUTES))));
|
||||
if (curscr->_attrs != (ch & (chtype)A_ATTRIBUTES)) {
|
||||
curscr->_attrs = ch & (chtype)A_ATTRIBUTES;
|
||||
vidputs(curscr->_attrs, _outch);
|
||||
}
|
||||
putc(ch & A_CHARTEXT, SP->_ofp);
|
||||
}
|
||||
|
||||
static int LRCORNER = FALSE;
|
||||
|
||||
static inline void PutChar(chtype ch)
|
||||
{
|
||||
if (LRCORNER == TRUE && SP->_curscol == columns-1) {
|
||||
int i = lines -1;
|
||||
int j = columns -1;
|
||||
|
||||
LRCORNER = FALSE;
|
||||
if ( (!enter_insert_mode || !exit_insert_mode)
|
||||
&& !insert_character
|
||||
)
|
||||
return;
|
||||
if (cursor_left)
|
||||
putp(cursor_left);
|
||||
else
|
||||
mvcur(-1, -1, i, j);
|
||||
PutAttrChar(ch);
|
||||
if (cursor_left)
|
||||
putp(cursor_left);
|
||||
else
|
||||
mvcur(-1, -1, i, j);
|
||||
if (enter_insert_mode && exit_insert_mode) {
|
||||
putp(enter_insert_mode);
|
||||
PutAttrChar(newscr->_line[i][j-1]);
|
||||
putp(exit_insert_mode);
|
||||
} else if (insert_character) {
|
||||
putp(insert_character);
|
||||
PutAttrChar(newscr->_line[i][j-1]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
PutAttrChar(ch);
|
||||
SP->_curscol++;
|
||||
if (SP->_curscol >= columns) {
|
||||
if (auto_right_margin) {
|
||||
SP->_curscol = 0;
|
||||
SP->_cursrow++;
|
||||
} else {
|
||||
SP->_curscol--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void GoTo(int row, int col)
|
||||
{
|
||||
mvcur(SP->_cursrow, SP->_curscol, row, col);
|
||||
SP->_cursrow = row;
|
||||
SP->_curscol = col;
|
||||
}
|
||||
|
||||
int _outch(int ch)
|
||||
{
|
||||
if (SP != NULL)
|
||||
putc(ch, SP->_ofp);
|
||||
else
|
||||
putc(ch, stdout);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int doupdate(void)
|
||||
{
|
||||
int i;
|
||||
sigaction_t act, oact;
|
||||
|
||||
T(("doupdate() called"));
|
||||
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
sigaction(SIGTSTP, &act, &oact);
|
||||
|
||||
if (SP->_endwin == TRUE) {
|
||||
T(("coming back from shell mode"));
|
||||
reset_prog_mode();
|
||||
if (enter_ca_mode)
|
||||
putp(enter_ca_mode);
|
||||
/* is this necessary? */
|
||||
if (enter_alt_charset_mode)
|
||||
init_acs();
|
||||
newscr->_clear = TRUE;
|
||||
SP->_endwin = FALSE;
|
||||
}
|
||||
|
||||
#if 0 /* Not works for output-only pgms */
|
||||
/* check for pending input */
|
||||
{
|
||||
fd_set fdset;
|
||||
struct timeval timeout = {0,0};
|
||||
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(SP->_checkfd, &fdset);
|
||||
if (select(SP->_checkfd+1, &fdset, NULL, NULL, &timeout) != 0) {
|
||||
fflush(SP->_ofp);
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (curscr->_clear) { /* force refresh ? */
|
||||
T(("clearing and updating curscr"));
|
||||
ClrUpdate(newscr); /* yes, clear all & update */
|
||||
curscr->_clear = FALSE; /* reset flag */
|
||||
} else if (newscr->_clear) {
|
||||
T(("clearing and updating newscr"));
|
||||
ClrUpdate(newscr);
|
||||
newscr->_clear = FALSE;
|
||||
} else {
|
||||
T(("Transforming lines"));
|
||||
for (i = 0; i < lines ; i++) {
|
||||
if(newscr->_firstchar[i] != _NOCHANGE)
|
||||
TransformLine(i);
|
||||
}
|
||||
}
|
||||
T(("marking screen as updated"));
|
||||
for (i = 0; i < lines; i++) {
|
||||
newscr->_firstchar[i] = _NOCHANGE;
|
||||
newscr->_lastchar[i] = _NOCHANGE;
|
||||
}
|
||||
|
||||
curscr->_curx = newscr->_curx;
|
||||
curscr->_cury = newscr->_cury;
|
||||
|
||||
GoTo(curscr->_cury, curscr->_curx);
|
||||
|
||||
/* perhaps we should turn attributes off here */
|
||||
|
||||
if (curscr->_attrs != A_NORMAL)
|
||||
vidattr(curscr->_attrs = A_NORMAL);
|
||||
|
||||
fflush(SP->_ofp);
|
||||
|
||||
sigaction(SIGTSTP, &oact, NULL);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int move_right_cost = -1;
|
||||
|
||||
static int countc(int c)
|
||||
{
|
||||
return(move_right_cost++);
|
||||
}
|
||||
|
||||
/*
|
||||
** ClrUpdate(scr)
|
||||
**
|
||||
** Update by clearing and redrawing the entire screen.
|
||||
**
|
||||
*/
|
||||
|
||||
static void ClrUpdate(WINDOW *scr)
|
||||
{
|
||||
int i = 0, j = 0;
|
||||
int lastNonBlank;
|
||||
|
||||
T(("ClrUpdate(%x) called", scr));
|
||||
if (back_color_erase && curscr->_attrs != A_NORMAL) {
|
||||
T(("back_color_erase, turning attributes off"));
|
||||
vidattr(curscr->_attrs = A_NORMAL);
|
||||
}
|
||||
ClearScreen();
|
||||
|
||||
if ((move_right_cost == -1) && parm_right_cursor) {
|
||||
move_right_cost = 0;
|
||||
tputs(tparm(parm_right_cursor, 10), 1, countc);
|
||||
}
|
||||
|
||||
T(("updating screen from scratch"));
|
||||
for (i = 0; i < min(lines, scr->_maxy + 1); i++) {
|
||||
lastNonBlank = scr->_maxx;
|
||||
|
||||
while (lastNonBlank >= 0 && scr->_line[i][lastNonBlank] == BLANK)
|
||||
lastNonBlank--;
|
||||
|
||||
/* check if we are at the lr corner */
|
||||
if (i == lines-1)
|
||||
if ((auto_right_margin) && !(eat_newline_glitch) &&
|
||||
(lastNonBlank == columns-1))
|
||||
{
|
||||
T(("Lower-right corner needs special handling"));
|
||||
LRCORNER = TRUE;
|
||||
}
|
||||
|
||||
for (j = 0; j <= lastNonBlank; j++) {
|
||||
if (parm_right_cursor) {
|
||||
static int inspace = 0;
|
||||
|
||||
if ((scr->_line[i][j]) == BLANK) {
|
||||
inspace++;
|
||||
continue;
|
||||
} else if(inspace) {
|
||||
if (inspace < move_right_cost) {
|
||||
for (; inspace > 0; inspace--)
|
||||
PutChar(scr->_line[i][j-1]);
|
||||
} else {
|
||||
T(("trying to use parm_right_cursor"));
|
||||
putp(tparm(parm_right_cursor, inspace));
|
||||
SP->_curscol += inspace;
|
||||
inspace = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
PutChar(scr->_line[i][j]);
|
||||
}
|
||||
/* move cursor to the next line */
|
||||
if ((!auto_right_margin) || (lastNonBlank < columns - 1) ||
|
||||
(auto_right_margin && eat_newline_glitch && lastNonBlank == columns-1))
|
||||
{
|
||||
SP->_curscol = (lastNonBlank < 0) ? 0 : lastNonBlank;
|
||||
SP->_cursrow++;
|
||||
GoTo(i+1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (scr != curscr) {
|
||||
for (i = 0; i < lines ; i++)
|
||||
for (j = 0; j < columns; j++)
|
||||
curscr->_line[i][j] = scr->_line[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** TransformLine(lineno)
|
||||
**
|
||||
** Call either IDcTransformLine or NoIDcTransformLine to do the
|
||||
** update, depending upon availability of insert/delete character.
|
||||
*/
|
||||
|
||||
static void TransformLine(int lineno)
|
||||
{
|
||||
|
||||
T(("TransformLine(%d) called",lineno));
|
||||
|
||||
if ( (insert_character || (enter_insert_mode && exit_insert_mode))
|
||||
&& delete_character)
|
||||
IDcTransformLine(lineno);
|
||||
else
|
||||
NoIDcTransformLine(lineno);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** NoIDcTransformLine(lineno)
|
||||
**
|
||||
** Transform the given line in curscr to the one in newscr, without
|
||||
** using Insert/Delete Character.
|
||||
**
|
||||
** firstChar = position of first different character in line
|
||||
** lastChar = position of last different character in line
|
||||
**
|
||||
** overwrite all characters between firstChar and lastChar.
|
||||
**
|
||||
*/
|
||||
|
||||
static void NoIDcTransformLine(int lineno)
|
||||
{
|
||||
int firstChar, lastChar;
|
||||
chtype *newLine = newscr->_line[lineno];
|
||||
chtype *oldLine = curscr->_line[lineno];
|
||||
int k;
|
||||
int attrchanged = 0;
|
||||
|
||||
T(("NoIDcTransformLine(%d) called", lineno));
|
||||
|
||||
firstChar = 0;
|
||||
while (firstChar < columns - 1 && newLine[firstChar] == oldLine[firstChar]) {
|
||||
if(ceol_standout_glitch) {
|
||||
if((newLine[firstChar] & (chtype)A_ATTRIBUTES) != (oldLine[firstChar] & (chtype)A_ATTRIBUTES))
|
||||
attrchanged = 1;
|
||||
}
|
||||
firstChar++;
|
||||
}
|
||||
|
||||
T(("first char at %d is %x", firstChar, newLine[firstChar]));
|
||||
if (firstChar > columns)
|
||||
return;
|
||||
|
||||
if(ceol_standout_glitch && attrchanged) {
|
||||
firstChar = 0;
|
||||
lastChar = columns - 1;
|
||||
GoTo(lineno, firstChar);
|
||||
if(clr_eol) {
|
||||
if (back_color_erase && curscr->_attrs != A_NORMAL) {
|
||||
T(("back_color_erase, turning attributes off"));
|
||||
vidattr(curscr->_attrs = A_NORMAL);
|
||||
}
|
||||
putp(clr_eol);
|
||||
}
|
||||
} else {
|
||||
lastChar = columns - 1;
|
||||
while (lastChar > firstChar && newLine[lastChar] == oldLine[lastChar])
|
||||
lastChar--;
|
||||
GoTo(lineno, firstChar);
|
||||
}
|
||||
|
||||
/* check if we are at the lr corner */
|
||||
if (lineno == lines-1)
|
||||
if ((auto_right_margin) && !(eat_newline_glitch) &&
|
||||
(lastChar == columns-1))
|
||||
{
|
||||
T(("Lower-right corner needs special handling"));
|
||||
LRCORNER = TRUE;
|
||||
}
|
||||
|
||||
T(("updating chars %d to %d", firstChar, lastChar));
|
||||
for (k = firstChar; k <= lastChar; k++) {
|
||||
PutChar(newLine[k]);
|
||||
oldLine[k] = newLine[k];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** IDcTransformLine(lineno)
|
||||
**
|
||||
** Transform the given line in curscr to the one in newscr, using
|
||||
** Insert/Delete Character.
|
||||
**
|
||||
** firstChar = position of first different character in line
|
||||
** oLastChar = position of last different character in old line
|
||||
** nLastChar = position of last different character in new line
|
||||
**
|
||||
** move to firstChar
|
||||
** overwrite chars up to min(oLastChar, nLastChar)
|
||||
** if oLastChar < nLastChar
|
||||
** insert newLine[oLastChar+1..nLastChar]
|
||||
** else
|
||||
** delete oLastChar - nLastChar spaces
|
||||
*/
|
||||
|
||||
static void IDcTransformLine(int lineno)
|
||||
{
|
||||
int firstChar, oLastChar, nLastChar;
|
||||
chtype *newLine = newscr->_line[lineno];
|
||||
chtype *oldLine = curscr->_line[lineno];
|
||||
int k, n;
|
||||
int attrchanged = 0;
|
||||
|
||||
T(("IDcTransformLine(%d) called", lineno));
|
||||
|
||||
if(ceol_standout_glitch && clr_eol) {
|
||||
firstChar = 0;
|
||||
while(firstChar < columns) {
|
||||
if((newLine[firstChar] & (chtype)A_ATTRIBUTES) != (oldLine[firstChar] & (chtype)A_ATTRIBUTES))
|
||||
attrchanged = 1;
|
||||
firstChar++;
|
||||
}
|
||||
}
|
||||
|
||||
firstChar = 0;
|
||||
|
||||
if (attrchanged) {
|
||||
GoTo(lineno, firstChar);
|
||||
if (back_color_erase && curscr->_attrs != A_NORMAL) {
|
||||
T(("back_color_erase, turning attributes off"));
|
||||
vidattr(curscr->_attrs = A_NORMAL);
|
||||
}
|
||||
putp(clr_eol);
|
||||
|
||||
/* check if we are at the lr corner */
|
||||
if (lineno == lines-1)
|
||||
if ((auto_right_margin) && !(eat_newline_glitch))
|
||||
{
|
||||
T(("Lower-right corner needs special handling"));
|
||||
LRCORNER = TRUE;
|
||||
}
|
||||
|
||||
for( k = 0 ; k <= (columns-1) ; k++ )
|
||||
PutChar(newLine[k]);
|
||||
} else {
|
||||
while (firstChar < columns &&
|
||||
newLine[firstChar] == oldLine[firstChar])
|
||||
firstChar++;
|
||||
|
||||
if (firstChar >= columns)
|
||||
return;
|
||||
|
||||
oLastChar = columns - 1;
|
||||
while (oLastChar > firstChar && oldLine[oLastChar] == BLANK)
|
||||
oLastChar--;
|
||||
|
||||
nLastChar = columns - 1;
|
||||
while (nLastChar > firstChar && newLine[nLastChar] == BLANK)
|
||||
nLastChar--;
|
||||
|
||||
if((nLastChar == firstChar) && clr_eol) {
|
||||
GoTo(lineno, firstChar);
|
||||
if (back_color_erase && curscr->_attrs != A_NORMAL) {
|
||||
T(("back_color_erase, turning attributes off"));
|
||||
vidattr(curscr->_attrs = A_NORMAL);
|
||||
}
|
||||
putp(clr_eol);
|
||||
|
||||
if(newLine[firstChar] != BLANK ) {
|
||||
/* check if we are at the lr corner */
|
||||
if (lineno == lines-1)
|
||||
if ((auto_right_margin) && !(eat_newline_glitch) &&
|
||||
(firstChar == columns-1))
|
||||
{
|
||||
T(("Lower-right corner needs special handling"));
|
||||
LRCORNER = TRUE;
|
||||
}
|
||||
PutChar(newLine[firstChar]);
|
||||
}
|
||||
} else if( newLine[nLastChar] != oldLine[oLastChar] ) {
|
||||
n = max( nLastChar , oLastChar );
|
||||
|
||||
GoTo(lineno, firstChar);
|
||||
|
||||
/* check if we are at the lr corner */
|
||||
if (lineno == lines-1)
|
||||
if ((auto_right_margin) && !(eat_newline_glitch) &&
|
||||
(n == columns-1))
|
||||
{
|
||||
T(("Lower-right corner needs special handling"));
|
||||
LRCORNER = TRUE;
|
||||
}
|
||||
|
||||
for( k=firstChar ; k <= n ; k++ )
|
||||
PutChar(newLine[k]);
|
||||
} else {
|
||||
while (newLine[nLastChar] == oldLine[oLastChar]) {
|
||||
nLastChar--;
|
||||
oLastChar--;
|
||||
}
|
||||
|
||||
n = min(oLastChar, nLastChar);
|
||||
|
||||
GoTo(lineno, firstChar);
|
||||
|
||||
/* check if we are at the lr corner */
|
||||
if (lineno == lines-1)
|
||||
if ((auto_right_margin) && !(eat_newline_glitch) &&
|
||||
(n == columns-1))
|
||||
{
|
||||
T(("Lower-right corner needs special handling"));
|
||||
LRCORNER = TRUE;
|
||||
}
|
||||
|
||||
for (k=firstChar; k <= n; k++)
|
||||
PutChar(newLine[k]);
|
||||
|
||||
if (oLastChar < nLastChar)
|
||||
InsStr(&newLine[k], nLastChar - oLastChar);
|
||||
|
||||
else if (oLastChar > nLastChar )
|
||||
DelChar(oLastChar - nLastChar);
|
||||
}
|
||||
}
|
||||
for (k = firstChar; k < columns; k++)
|
||||
oldLine[k] = newLine[k];
|
||||
}
|
||||
|
||||
/*
|
||||
** ClearScreen()
|
||||
**
|
||||
** Clear the physical screen and put cursor at home
|
||||
**
|
||||
*/
|
||||
|
||||
static void ClearScreen()
|
||||
{
|
||||
|
||||
T(("ClearScreen() called"));
|
||||
|
||||
if (clear_screen) {
|
||||
putp(clear_screen);
|
||||
SP->_cursrow = SP->_curscol = 0;
|
||||
} else if (clr_eos) {
|
||||
SP->_cursrow = SP->_curscol = -1;
|
||||
GoTo(0,0);
|
||||
|
||||
putp(clr_eos);
|
||||
} else if (clr_eol) {
|
||||
SP->_cursrow = SP->_curscol = -1;
|
||||
|
||||
while (SP->_cursrow < lines) {
|
||||
GoTo(SP->_cursrow, 0);
|
||||
putp(clr_eol);
|
||||
}
|
||||
GoTo(0,0);
|
||||
}
|
||||
T(("screen cleared"));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** InsStr(line, count)
|
||||
**
|
||||
** Insert the count characters pointed to by line.
|
||||
**
|
||||
*/
|
||||
|
||||
static void InsStr(chtype *line, int count)
|
||||
{
|
||||
T(("InsStr(%x,%d) called", line, count));
|
||||
|
||||
if (enter_insert_mode && exit_insert_mode) {
|
||||
putp(enter_insert_mode);
|
||||
while (count) {
|
||||
PutChar(*line);
|
||||
line++;
|
||||
count--;
|
||||
}
|
||||
putp(exit_insert_mode);
|
||||
} else if (parm_ich) {
|
||||
putp(tparm(parm_ich, count));
|
||||
while (count) {
|
||||
PutChar(*line);
|
||||
line++;
|
||||
count--;
|
||||
}
|
||||
} else {
|
||||
while (count) {
|
||||
putp(insert_character);
|
||||
PutChar(*line);
|
||||
line++;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** DelChar(count)
|
||||
**
|
||||
** Delete count characters at current position
|
||||
**
|
||||
*/
|
||||
|
||||
static void DelChar(int count)
|
||||
{
|
||||
T(("DelChar(%d) called", count));
|
||||
|
||||
if (back_color_erase && curscr->_attrs != A_NORMAL) {
|
||||
T(("back_color_erase, turning attributes off"));
|
||||
vidattr(curscr->_attrs = A_NORMAL);
|
||||
}
|
||||
if (parm_dch) {
|
||||
putp(tparm(parm_dch, count));
|
||||
} else {
|
||||
while (count--)
|
||||
putp(delete_character);
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_endwin.c
|
||||
**
|
||||
** The routine endwin().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "terminfo.h"
|
||||
#include "curses.priv.h"
|
||||
|
||||
int isendwin()
|
||||
{
|
||||
if (SP == NULL)
|
||||
return FALSE;
|
||||
return SP->_endwin;
|
||||
}
|
||||
|
||||
int
|
||||
endwin()
|
||||
{
|
||||
T(("endwin() called"));
|
||||
|
||||
SP->_endwin = TRUE;
|
||||
|
||||
if (change_scroll_region)
|
||||
putp(tparm(change_scroll_region, 0, lines - 1));
|
||||
|
||||
mvcur(-1, -1, lines - 1, 0);
|
||||
|
||||
if (exit_ca_mode)
|
||||
putp(exit_ca_mode);
|
||||
|
||||
if (SP->_coloron == TRUE)
|
||||
putp(orig_pair);
|
||||
|
||||
if (curscr && (curscr->_attrs != A_NORMAL))
|
||||
vidattr(curscr->_attrs = A_NORMAL);
|
||||
|
||||
if (SP->_cursor != 1)
|
||||
putp(cursor_normal);
|
||||
|
||||
fflush(SP->_ofp);
|
||||
|
||||
return(reset_shell_mode());
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_erase.c
|
||||
**
|
||||
** The routine werase().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include "terminfo.h"
|
||||
|
||||
int werase(WINDOW *win)
|
||||
{
|
||||
int y;
|
||||
chtype *sp, *end, *start, *maxx = NULL;
|
||||
int minx;
|
||||
|
||||
T(("werase(%x) called", win));
|
||||
|
||||
for (y = win->_regtop; y <= win->_regbottom; y++) {
|
||||
minx = _NOCHANGE;
|
||||
start = win->_line[y];
|
||||
end = &start[win->_maxx];
|
||||
|
||||
maxx = start;
|
||||
for (sp = start; sp <= end; sp++) {
|
||||
maxx = sp;
|
||||
if (minx == _NOCHANGE)
|
||||
minx = sp - start;
|
||||
*sp = _nc_background(win);
|
||||
}
|
||||
|
||||
if (minx != _NOCHANGE) {
|
||||
if (win->_firstchar[y] > minx ||
|
||||
win->_firstchar[y] == _NOCHANGE)
|
||||
win->_firstchar[y] = minx;
|
||||
|
||||
if (win->_lastchar[y] < maxx - win->_line[y])
|
||||
win->_lastchar[y] = maxx - win->_line[y];
|
||||
}
|
||||
}
|
||||
win->_curx = win->_cury = 0;
|
||||
return OK;
|
||||
}
|
@ -1,224 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_getch.c
|
||||
**
|
||||
** The routine getch().
|
||||
**
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#if defined(BRAINDEAD)
|
||||
extern int errno;
|
||||
#endif
|
||||
#include "curses.priv.h"
|
||||
|
||||
#define head SP->_fifohead
|
||||
#define tail SP->_fifotail
|
||||
#define peek SP->_fifopeek
|
||||
|
||||
#define h_inc() { head == FIFO_SIZE-1 ? head = 0 : head++; if (head == tail) head = -1, tail = 0;}
|
||||
#define h_dec() { head == 0 ? head = FIFO_SIZE-1 : head--; if (head == tail) tail = -1;}
|
||||
#define t_inc() { tail == FIFO_SIZE-1 ? tail = 0 : tail++; if (tail == head) tail = -1;}
|
||||
#define p_inc() { peek == FIFO_SIZE-1 ? peek = 0 : peek++;}
|
||||
|
||||
static int fifo_peek()
|
||||
{
|
||||
T(("peeking at %d", peek+1));
|
||||
return SP->_fifo[++peek];
|
||||
}
|
||||
|
||||
static inline void fifo_dump()
|
||||
{
|
||||
int i;
|
||||
T(("head = %d, tail = %d, peek = %d", head, tail, peek));
|
||||
for (i = 0; i < 10; i++)
|
||||
T(("char %d = %d (%c)", i, SP->_fifo[i], (unsigned char)SP->_fifo[i]));
|
||||
}
|
||||
|
||||
static inline int fifo_pull()
|
||||
{
|
||||
int ch;
|
||||
ch = SP->_fifo[head];
|
||||
T(("pulling %d from %d", ch, head));
|
||||
|
||||
h_inc();
|
||||
fifo_dump();
|
||||
return ch;
|
||||
}
|
||||
|
||||
int ungetch(int ch)
|
||||
{
|
||||
if (tail == -1)
|
||||
return ERR;
|
||||
if (head == -1) {
|
||||
head = 0;
|
||||
t_inc()
|
||||
} else
|
||||
h_dec();
|
||||
|
||||
SP->_fifo[head] = ch;
|
||||
T(("ungetch ok"));
|
||||
fifo_dump();
|
||||
return OK;
|
||||
}
|
||||
|
||||
static inline int fifo_push()
|
||||
{
|
||||
int n;
|
||||
unsigned char ch;
|
||||
|
||||
if (tail == -1) return ERR;
|
||||
again:
|
||||
n = read(fileno(SP->_ifp), &ch, 1);
|
||||
if (n == -1 && errno == EINTR)
|
||||
goto again;
|
||||
T(("read %d characters", n));
|
||||
SP->_fifo[tail] = ch;
|
||||
if (head == -1) head = tail;
|
||||
t_inc();
|
||||
T(("pushed %d at %d", ch, tail));
|
||||
fifo_dump();
|
||||
return ch;
|
||||
}
|
||||
|
||||
static inline void fifo_clear()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < FIFO_SIZE; i++)
|
||||
SP->_fifo[i] = 0;
|
||||
head = -1; tail = peek = 0;
|
||||
}
|
||||
|
||||
static int kgetch(WINDOW *);
|
||||
|
||||
int
|
||||
wgetch(WINDOW *win)
|
||||
{
|
||||
bool setHere = FALSE; /* cbreak mode was set here */
|
||||
int ch;
|
||||
|
||||
T(("wgetch(%x) called", win));
|
||||
|
||||
/* this should be eliminated */
|
||||
if (! win->_scroll && (SP->_echo) && (win->_flags & _FULLWIN)
|
||||
&& win->_curx == win->_maxx && win->_cury == win->_maxy)
|
||||
return(ERR);
|
||||
|
||||
if ((is_wintouched(win) || (win->_flags & _HASMOVED)) &&
|
||||
!(win->_flags & _ISPAD))
|
||||
wrefresh(win);
|
||||
|
||||
if (SP->_echo && ! (SP->_raw || SP->_cbreak)) {
|
||||
cbreak();
|
||||
setHere = TRUE;
|
||||
}
|
||||
|
||||
if (win->_delay >= 0 || SP->_cbreak > 1) {
|
||||
int delay;
|
||||
|
||||
T(("timed delay in wgetch()"));
|
||||
if (SP->_cbreak > 1)
|
||||
delay = (SP->_cbreak-1) * 100;
|
||||
else
|
||||
delay = win->_delay;
|
||||
|
||||
T(("delay is %d microseconds", delay));
|
||||
|
||||
if (head == -1) /* fifo is empty */
|
||||
if (timed_wait(fileno(SP->_ifp), delay, NULL) == 0)
|
||||
return ERR;
|
||||
/* else go on to read data available */
|
||||
}
|
||||
|
||||
if (win->_use_keypad)
|
||||
ch = kgetch(win);
|
||||
else {
|
||||
if (head == -1)
|
||||
fifo_push();
|
||||
ch = fifo_pull();
|
||||
}
|
||||
|
||||
/* This should be eliminated */
|
||||
/* handle 8-bit input */
|
||||
if (ch & 0x80)
|
||||
if (!win->_use_meta)
|
||||
ch &= 0x7f;
|
||||
|
||||
/* there must be a simpler way of doing this */
|
||||
if (!(win->_flags & _ISPAD) &&
|
||||
SP->_echo && ch < 0400) { /* ch < 0400 => not a keypad key */
|
||||
mvwaddch(curscr, win->_begy + win->_cury,
|
||||
win->_begx + win->_curx, ch | win->_attrs);
|
||||
waddch(win, ch | win->_attrs);
|
||||
}
|
||||
if (setHere)
|
||||
nocbreak();
|
||||
|
||||
T(("wgetch returning : '%c', '0x%x'", ch, ch));
|
||||
|
||||
return(ch);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** int
|
||||
** kgetch()
|
||||
**
|
||||
** Get an input character, but take care of keypad sequences, returning
|
||||
** an appropriate code when one matches the input. After each character
|
||||
** is received, set a one-second alarm call. If no more of the sequence
|
||||
** is received by the time the alarm goes off, pass through the sequence
|
||||
** gotten so far.
|
||||
**
|
||||
*/
|
||||
|
||||
static int
|
||||
kgetch(WINDOW *win)
|
||||
{
|
||||
struct try *ptr;
|
||||
int ch = 0;
|
||||
int timeleft = 1000;
|
||||
|
||||
T(("kgetch(%x) called", win));
|
||||
|
||||
ptr = SP->_keytry;
|
||||
|
||||
if (head == -1) {
|
||||
ch = fifo_push();
|
||||
peek = 0;
|
||||
while (ptr != NULL) {
|
||||
T(("ch = %d", ch));
|
||||
while ((ptr != NULL) && (ptr->ch != (unsigned char)ch))
|
||||
ptr = ptr->sibling;
|
||||
|
||||
if (ptr != NULL)
|
||||
if (ptr->value != 0) { /* sequence terminated */
|
||||
T(("end of sequence"));
|
||||
fifo_clear();
|
||||
return(ptr->value);
|
||||
} else { /* go back for another character */
|
||||
ptr = ptr->child;
|
||||
T(("going back for more"));
|
||||
} else
|
||||
break;
|
||||
|
||||
T(("waiting for rest of sequence"));
|
||||
if (timed_wait(fileno(SP->_ifp), timeleft, &timeleft) < 1) {
|
||||
T(("ran out of time"));
|
||||
return(fifo_pull());
|
||||
} else {
|
||||
T(("got more!"));
|
||||
fifo_push();
|
||||
ch = fifo_peek();
|
||||
}
|
||||
}
|
||||
}
|
||||
return(fifo_pull());
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_getstr.c
|
||||
**
|
||||
** The routine wgetstr().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include "unctrl.h"
|
||||
|
||||
inline void backspace(WINDOW *win)
|
||||
{
|
||||
mvwaddstr(curscr, win->_begy + win->_cury, win->_begx + win->_curx,
|
||||
"\b \b");
|
||||
waddstr(win, "\b \b");
|
||||
fputs("\b \b", SP->_ofp);
|
||||
fflush(SP->_ofp);
|
||||
SP->_curscol--;
|
||||
}
|
||||
|
||||
int wgetnstr(WINDOW *win, char *str, int maxlen)
|
||||
{
|
||||
bool oldnl, oldecho, oldraw, oldcbreak, oldkeypad;
|
||||
char erasec;
|
||||
char killc;
|
||||
char *oldstr;
|
||||
int ch;
|
||||
|
||||
T(("wgetnstr(%x,%x, %d) called", win, str, maxlen));
|
||||
|
||||
oldnl = SP->_nl;
|
||||
oldecho = SP->_echo;
|
||||
oldraw = SP->_raw;
|
||||
oldcbreak = SP->_cbreak;
|
||||
oldkeypad = win->_use_keypad;
|
||||
nl();
|
||||
noecho();
|
||||
noraw();
|
||||
cbreak();
|
||||
keypad(win, TRUE);
|
||||
|
||||
erasec = erasechar();
|
||||
killc = killchar();
|
||||
|
||||
oldstr = str;
|
||||
|
||||
vidattr(win->_attrs);
|
||||
if (is_wintouched(win) || (win->_flags & _HASMOVED))
|
||||
wrefresh(win);
|
||||
|
||||
while ((ch = wgetch(win)) != ERR) {
|
||||
if (ch == '\n' || ch == '\r')
|
||||
break;
|
||||
if (ch == erasec || ch == KEY_LEFT || ch == KEY_BACKSPACE) {
|
||||
if (str > oldstr) {
|
||||
str--;
|
||||
backspace(win);
|
||||
}
|
||||
} else if (ch == killc) {
|
||||
while (str > oldstr) {
|
||||
str--;
|
||||
backspace(win);
|
||||
}
|
||||
} else if (maxlen >= 0 && str - oldstr >= maxlen) {
|
||||
beep();
|
||||
} else {
|
||||
mvwaddstr(curscr, win->_begy + win->_cury,
|
||||
win->_begx + win->_curx, unctrl(ch));
|
||||
waddstr(win, unctrl(ch));
|
||||
if (oldecho == TRUE) {
|
||||
fputs(unctrl(ch), SP->_ofp);
|
||||
fflush(SP->_ofp);
|
||||
}
|
||||
SP->_curscol++;
|
||||
*str++ = ch;
|
||||
}
|
||||
}
|
||||
|
||||
win->_curx = 0;
|
||||
if (win->_cury < win->_maxy)
|
||||
win->_cury++;
|
||||
wrefresh(win);
|
||||
|
||||
if (oldnl == FALSE)
|
||||
nonl();
|
||||
|
||||
if (oldecho == TRUE)
|
||||
echo();
|
||||
|
||||
if (oldraw == TRUE)
|
||||
raw();
|
||||
|
||||
if (oldcbreak == FALSE)
|
||||
nocbreak();
|
||||
|
||||
if (oldkeypad == FALSE)
|
||||
keypad(win, FALSE);
|
||||
|
||||
if (ch == ERR) {
|
||||
*str = '\0';
|
||||
return ERR;
|
||||
}
|
||||
*str = '\0';
|
||||
|
||||
T(("wgetnstr returns \"%s\"", visbuf(oldstr)));
|
||||
|
||||
return(OK);
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_inchstr.c
|
||||
**
|
||||
** The routine winchnstr().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int winchnstr(WINDOW *win, chtype *chstr, int i)
|
||||
{
|
||||
chtype *point, *end;
|
||||
|
||||
T(("winschnstr(%x,'%x',%d) called", win, chstr, i));
|
||||
|
||||
point = &win->_line[win->_cury][win->_curx];
|
||||
end = &win->_line[win->_cury][win->_maxx];
|
||||
if (point + i - 1 < end)
|
||||
end = point + i - 1;
|
||||
|
||||
chstr = (chtype *)malloc((end - point + 1)*sizeof(chtype));
|
||||
chstr[end - point] = '\0';
|
||||
return OK;
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_initscr.c
|
||||
**
|
||||
** The routine initscr().
|
||||
**
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "curses.priv.h"
|
||||
|
||||
WINDOW *initscr()
|
||||
{
|
||||
static bool initialized = FALSE;
|
||||
char *name;
|
||||
#ifdef TRACE
|
||||
_init_trace();
|
||||
|
||||
T(("initscr() called"));
|
||||
#endif
|
||||
|
||||
/* Portable applications must not call initscr() more than once */
|
||||
if (!initialized) {
|
||||
initialized = TRUE;
|
||||
|
||||
if ((name = getenv("TERM")) == 0)
|
||||
name = "unknown";
|
||||
if (newterm(name, stdout, stdin) == 0) {
|
||||
fprintf(stderr, "Error opening terminal: %s.\n", name);
|
||||
exit(1);
|
||||
}
|
||||
/* def_shell_mode - done in newterm */
|
||||
def_prog_mode();
|
||||
}
|
||||
return(stdscr);
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_insch.c
|
||||
**
|
||||
** The routine winsch().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int winsch(WINDOW *win, chtype c)
|
||||
{
|
||||
chtype *temp1, *temp2;
|
||||
chtype *end;
|
||||
|
||||
T(("winsch(%x,'%x') called", win, c));
|
||||
|
||||
end = &win->_line[win->_cury][win->_curx];
|
||||
temp1 = &win->_line[win->_cury][win->_maxx];
|
||||
temp2 = temp1 - 1;
|
||||
|
||||
while (temp1 > end)
|
||||
*temp1-- = *temp2--;
|
||||
|
||||
*temp1 = _nc_render(win, c);
|
||||
|
||||
win->_lastchar[win->_cury] = win->_maxx;
|
||||
if (win->_firstchar[win->_cury] == _NOCHANGE
|
||||
|| win->_firstchar[win->_cury] > win->_curx)
|
||||
win->_firstchar[win->_cury] = win->_curx;
|
||||
return OK;
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_insdel.c
|
||||
**
|
||||
** The routine winsdel(win, n).
|
||||
** positive n insert n lines above current line
|
||||
** negative n delete n lines starting from current line
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int
|
||||
winsdelln(WINDOW *win, int n)
|
||||
{
|
||||
int code = ERR;
|
||||
|
||||
T(("winsdel(%x,%d) called", win, n));
|
||||
|
||||
if (win) {
|
||||
if (n != 0) {
|
||||
_nc_scroll_window(win, -n, win->_cury, win->_maxy, _nc_background(win));
|
||||
}
|
||||
code = OK;
|
||||
}
|
||||
return code;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_insstr.c
|
||||
**
|
||||
** The routine winsnstr().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int winsnstr(WINDOW *win, char *str, int n)
|
||||
{
|
||||
|
||||
T(("winsstr(%x,'%x',%d) called", win, str, n));
|
||||
|
||||
return OK;
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
|
||||
/***************************************************************************
|
||||
* COPYRIGHT NOTICE *
|
||||
****************************************************************************
|
||||
* ncurses is copyright (C) 1992-1995 *
|
||||
* Zeyd M. Ben-Halim *
|
||||
* zmbenhal@netcom.com *
|
||||
* Eric S. Raymond *
|
||||
* esr@snark.thyrsus.com *
|
||||
* *
|
||||
* Permission is hereby granted to reproduce and distribute ncurses *
|
||||
* by any means and for any fee, whether alone or as part of a *
|
||||
* larger distribution, in source or in binary form, PROVIDED *
|
||||
* this notice is included with any such distribution, and is not *
|
||||
* removed from any of its header files. Mention of ncurses in any *
|
||||
* applications linked with it is highly appreciated. *
|
||||
* *
|
||||
* ncurses comes AS IS with no warranty, implied or expressed. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
** lib_instr.c
|
||||
**
|
||||
** The routine winnstr().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int winnstr(WINDOW *win, char *str, int n)
|
||||
{
|
||||
int i, row, col;
|
||||
|
||||
T(("winnstr(%p,%p,%d) called", win, str, n));
|
||||
|
||||
getyx(win, row, col);
|
||||
|
||||
if (n < 0)
|
||||
n = win->_maxx - win->_curx + 1;
|
||||
|
||||
for (i = 0; i < n;) {
|
||||
str[i++] = TextOf(win->_line[row][col]);
|
||||
if (++col > win->_maxx) {
|
||||
col = 0;
|
||||
if (++row > win->_maxy)
|
||||
break;
|
||||
}
|
||||
}
|
||||
str[i] = '\0'; /* SVr4 does not seem to count the null */
|
||||
|
||||
return (i);
|
||||
}
|
@ -1,324 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
* lib_kernel.c
|
||||
*
|
||||
* Misc. low-level routines:
|
||||
* reset_prog_mode()
|
||||
* reset_shell_mode()
|
||||
* baudrate()
|
||||
* erasechar()
|
||||
* killchar()
|
||||
* flushinp()
|
||||
* savetty()
|
||||
* resetty()
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include "terminfo.h"
|
||||
|
||||
int wattron(WINDOW *win, chtype at)
|
||||
{
|
||||
T(("wattron(%x,%s) current = %s", win, _traceattr(at), _traceattr(win->_attrs)));
|
||||
if (PAIR_NUMBER(at) > 0x00) {
|
||||
win->_attrs = (win->_attrs & ~A_COLOR) | at ;
|
||||
T(("new attribute is %s", _traceattr(win->_attrs)));
|
||||
} else {
|
||||
win->_attrs |= at;
|
||||
T(("new attribute is %s", _traceattr(win->_attrs)));
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int wattroff(WINDOW *win, chtype at)
|
||||
{
|
||||
#define IGNORE_COLOR_OFF FALSE
|
||||
|
||||
T(("wattroff(%x,%s) current = %s", win, _traceattr(at), _traceattr(win->_attrs)));
|
||||
if (IGNORE_COLOR_OFF == TRUE) {
|
||||
if (PAIR_NUMBER(at) == 0xff) /* turn off color */
|
||||
win->_attrs &= ~at;
|
||||
else /* leave color alone */
|
||||
win->_attrs &= ~(at & ~A_COLOR);
|
||||
} else {
|
||||
if (PAIR_NUMBER(at) > 0x00) /* turn off color */
|
||||
win->_attrs &= ~at;
|
||||
else /* leave color alone */
|
||||
win->_attrs &= ~(at & ~A_COLOR);
|
||||
}
|
||||
T(("new attribute is %s", _traceattr(win->_attrs)));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int reset_prog_mode()
|
||||
{
|
||||
int ret = ERR;
|
||||
|
||||
T(("reset_prog_mode() called"));
|
||||
|
||||
if (cur_term != 0) {
|
||||
if (tcsetattr(cur_term->fd, TCSADRAIN, &cur_term->prog_mode)==0)
|
||||
ret = OK;
|
||||
if (SP && stdscr && stdscr->_use_keypad)
|
||||
_nc_keypad(TRUE);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int reset_shell_mode()
|
||||
{
|
||||
int ret = ERR;
|
||||
|
||||
T(("reset_shell_mode() called"));
|
||||
|
||||
if (cur_term != 0) {
|
||||
if (SP)
|
||||
{
|
||||
fflush(SP->_ofp);
|
||||
_nc_keypad(FALSE);
|
||||
}
|
||||
if (tcsetattr(cur_term->fd, TCSADRAIN, &cur_term->shell_mode)==0)
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int curs_set(int vis)
|
||||
{
|
||||
int cursor = SP->_cursor;
|
||||
|
||||
T(("curs_set(%d)", vis));
|
||||
|
||||
if (vis < 0 || vis > 2)
|
||||
return ERR;
|
||||
|
||||
switch(vis) {
|
||||
case 2:
|
||||
if (cursor_visible)
|
||||
putp(cursor_visible);
|
||||
break;
|
||||
case 1:
|
||||
if (cursor_normal)
|
||||
putp(cursor_normal);
|
||||
break;
|
||||
case 0:
|
||||
if (cursor_invisible)
|
||||
putp(cursor_invisible);
|
||||
break;
|
||||
}
|
||||
SP->_cursor = vis;
|
||||
return cursor;
|
||||
}
|
||||
|
||||
int delay_output(int ms)
|
||||
{
|
||||
int speed = 0;
|
||||
|
||||
T(("delay_output(%d) called", ms));
|
||||
|
||||
if (!no_pad_char && (speed = baudrate()) == ERR)
|
||||
return(ERR);
|
||||
else {
|
||||
register int nullcount;
|
||||
|
||||
if (!no_pad_char)
|
||||
for (nullcount = ms * 1000 / speed; nullcount > 0; nullcount--)
|
||||
putc(*pad_char, SP->_ofp);
|
||||
(void) fflush(SP->_ofp);
|
||||
if (no_pad_char)
|
||||
napms(ms);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* erasechar()
|
||||
*
|
||||
* Return erase character as given in cur_term->Ottyb.
|
||||
*
|
||||
*/
|
||||
|
||||
char
|
||||
erasechar()
|
||||
{
|
||||
T(("erasechar() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
return(cur_term->Ottyb.c_cc[VERASE]);
|
||||
#else
|
||||
return(cur_term->Ottyb.sg_erase);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* killchar()
|
||||
*
|
||||
* Return kill character as given in cur_term->Ottyb.
|
||||
*
|
||||
*/
|
||||
|
||||
char
|
||||
killchar()
|
||||
{
|
||||
T(("killchar() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
return(cur_term->Ottyb.c_cc[VKILL]);
|
||||
#else
|
||||
return(cur_term->Ottyb.sg_kill);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* flushinp()
|
||||
*
|
||||
* Flush any input on cur_term->Filedes
|
||||
*
|
||||
*/
|
||||
|
||||
int flushinp()
|
||||
{
|
||||
T(("flushinp() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
tcflush(cur_term->Filedes, TCIFLUSH);
|
||||
#else
|
||||
ioctl(cur_term->Filedes, TIOCFLUSH, 0);
|
||||
#endif
|
||||
if (SP) {
|
||||
SP->_fifohead = -1;
|
||||
SP->_fifotail = 0;
|
||||
SP->_fifopeek = 0;
|
||||
}
|
||||
return OK;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* int
|
||||
* baudrate()
|
||||
*
|
||||
* Returns the current terminal's baud rate.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TERMIOS
|
||||
struct speed {
|
||||
speed_t s;
|
||||
int sp;
|
||||
};
|
||||
|
||||
static struct speed speeds[] = {
|
||||
{B0, 0},
|
||||
{B50, 50},
|
||||
{B75, 75},
|
||||
{B110, 110},
|
||||
{B134, 134},
|
||||
{B150, 150},
|
||||
{B200, 200},
|
||||
{B300, 300},
|
||||
{B600, 600},
|
||||
{B1200, 1200},
|
||||
{B1800, 1800},
|
||||
{B2400, 2400},
|
||||
{B4800, 4800},
|
||||
{B9600, 9600}
|
||||
#define MAX_BAUD B9600
|
||||
#ifdef B19200
|
||||
#undef MAX_BAUD
|
||||
#define MAX_BAUD B19200
|
||||
,{B19200, 19200}
|
||||
#endif
|
||||
#ifdef B38400
|
||||
#undef MAX_BAUD
|
||||
#define MAX_BAUD B38400
|
||||
,{B38400, 38400}
|
||||
#endif
|
||||
#ifdef B57600
|
||||
#undef MAX_BAUD
|
||||
#define MAX_BAUD B57600
|
||||
,{B57600, 57600}
|
||||
#endif
|
||||
#ifdef B115200
|
||||
#undef MAX_BAUD
|
||||
#define MAX_BAUD B115200
|
||||
,{B115200, 115200}
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
int
|
||||
baudrate()
|
||||
{
|
||||
#ifndef TERMIOS
|
||||
int i, ret;
|
||||
#endif
|
||||
|
||||
T(("baudrate() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
return cfgetospeed(&cur_term->Nttyb);
|
||||
#else
|
||||
ret = cur_term->Nttyb.sg_ospeed;
|
||||
if(ret < 0 || ret > MAX_BAUD)
|
||||
return ERR;
|
||||
for (i = 0; i < (sizeof(speeds) / sizeof(struct speed)); i++)
|
||||
if (speeds[i].s == ret)
|
||||
return speeds[i].sp;
|
||||
return ERR;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** savetty() and resetty()
|
||||
**
|
||||
*/
|
||||
|
||||
static TTY buf;
|
||||
|
||||
int savetty()
|
||||
{
|
||||
T(("savetty() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
tcgetattr(cur_term->Filedes, &buf);
|
||||
#else
|
||||
gtty(cur_term->Filedes, &buf);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int resetty()
|
||||
{
|
||||
T(("resetty() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
tcsetattr(cur_term->Filedes, TCSANOW, &buf);
|
||||
#else
|
||||
stty(cur_term->Filedes, &buf);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
resizeterm(int ToLines, int ToCols)
|
||||
{
|
||||
return OK;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_longname.c
|
||||
**
|
||||
** The routine longname().
|
||||
**
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "curses.priv.h"
|
||||
#include "terminfo.h"
|
||||
|
||||
char *
|
||||
longname()
|
||||
{
|
||||
#ifndef MYTINFO
|
||||
char *ptr;
|
||||
#endif
|
||||
|
||||
T(("longname() called"));
|
||||
|
||||
#ifdef MYTINFO
|
||||
return cur_term->name_long;
|
||||
#else
|
||||
for (ptr = ttytype + strlen(ttytype); ptr > ttytype; ptr--)
|
||||
if (*ptr == '|')
|
||||
return(ptr + 1);
|
||||
|
||||
return(ttytype);
|
||||
#endif
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_move.c
|
||||
**
|
||||
** The routine wmove().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
|
||||
int
|
||||
wmove(WINDOW *win, int y, int x)
|
||||
{
|
||||
T(("wmove(%x,%d,%d) called", win, y, x));
|
||||
|
||||
if (x >= 0 && x <= win->_maxx &&
|
||||
y >= 0 && y <= win->_maxy)
|
||||
{
|
||||
win->_curx = x;
|
||||
win->_cury = y;
|
||||
|
||||
win->_flags |= _HASMOVED;
|
||||
return(OK);
|
||||
} else
|
||||
return(ERR);
|
||||
}
|
@ -1,700 +0,0 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
*
|
||||
* lib_mvcur.c
|
||||
*
|
||||
* The routine mvcur() etc.
|
||||
*
|
||||
* last edit-date: [Wed Jun 16 14:13:22 1993]
|
||||
*
|
||||
* -hm conversion from termcap -> terminfo
|
||||
* -hm optimization debugging
|
||||
* -hm zeyd's ncurses 0.7 update
|
||||
* -hm eat_newline_glitch bugfix
|
||||
* -hm hpux lint'ing ..
|
||||
*
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "terminfo.h"
|
||||
#include "curses.priv.h"
|
||||
|
||||
#ifndef OPT_MVCUR
|
||||
/*
|
||||
**
|
||||
** mvcur(oldrow, oldcol, newrow, newcol)
|
||||
** A hack for terminals that are smart enough
|
||||
** to know how to move cursor.
|
||||
** There is still a bug in the alternative long-
|
||||
** winded code.
|
||||
**
|
||||
*/
|
||||
|
||||
int mvcur(int oldrow, int oldcol, int newrow, int newcol)
|
||||
{
|
||||
T(("mvcur(%d,%d,%d,%d) called", oldrow, oldcol, newrow, newcol));
|
||||
|
||||
if(!cursor_address)
|
||||
return ERR;
|
||||
|
||||
newrow %= lines;
|
||||
newcol %= columns;
|
||||
|
||||
if (cursor_address)
|
||||
putp(tparm(cursor_address, newrow, newcol));
|
||||
return OK;
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define BUFSIZE 128 /* size of strategy buffer */
|
||||
|
||||
struct Sequence
|
||||
{
|
||||
int vec[BUFSIZE]; /* vector of operations */
|
||||
int *end; /* end of vector */
|
||||
int cost; /* cost of vector */
|
||||
};
|
||||
|
||||
static void row(struct Sequence *outseq, int orow, int nrow);
|
||||
static void column(struct Sequence *outseq, int ocol, int ncol);
|
||||
static void simp_col(struct Sequence *outseq, int oc, int nc);
|
||||
static void zero_seq(struct Sequence *seq);
|
||||
static void add_seq(struct Sequence *seq1, struct Sequence *seq2);
|
||||
static void out_seq(struct Sequence *seq);
|
||||
static void update_ops(void);
|
||||
static void init_costs(int costs[]);
|
||||
static int countc(char ch);
|
||||
static void add_op(struct Sequence *seq, int op, ...);
|
||||
static char *sequence(int op);
|
||||
|
||||
static int c_count; /* used for counting tputs output */
|
||||
|
||||
#define INFINITY 1000 /* biggest, impossible sequence cost */
|
||||
#define NUM_OPS 16 /* num. term. control sequences */
|
||||
#define NUM_NPARM 9 /* num. ops wo/ parameters */
|
||||
|
||||
/* operator indexes into op_info */
|
||||
|
||||
#define CARRIAGE_RETURN 0 /* watch out for nl mapping */
|
||||
#define CURS_DOWN 1
|
||||
#define CURS_HOME 2
|
||||
#define CURS_LEFT 3
|
||||
#define CURS_RIGHT 4
|
||||
#define CURS_TO_LL 5
|
||||
#define CURS_UP 6
|
||||
#define TAB 7
|
||||
#define BACK_TAB 8
|
||||
#define ROW_ADDR 9
|
||||
#define COL_ADDR 10
|
||||
#define P_DOWN_CURS 11
|
||||
#define P_LEFT_CURS 12
|
||||
#define P_RIGHT_CURS 13
|
||||
#define P_UP_CURS 14
|
||||
#define CURS_ADDR 15
|
||||
|
||||
static bool loc_init = FALSE; /* set if op_info is init'ed */
|
||||
|
||||
static bool rel_ok; /* set if we really know where we are */
|
||||
|
||||
/*
|
||||
* op_info[NUM_OPS]
|
||||
*
|
||||
* op_info[] contains for operations with no parameters
|
||||
* the cost of the operation. These ops should be first in the array.
|
||||
* For operations with parameters, op_info[] contains
|
||||
* the negative of the number of parameters.
|
||||
*/
|
||||
|
||||
static int op_info[NUM_OPS] = {
|
||||
0, /* carriage_return */
|
||||
0, /* cursor_down */
|
||||
0, /* cursor_home */
|
||||
0, /* cursor_left */
|
||||
0, /* cursor_right */
|
||||
0, /* cursor_to_ll */
|
||||
0, /* cursor_up */
|
||||
0, /* tab */
|
||||
0, /* back_tab */
|
||||
-1, /* row_address */
|
||||
-1, /* column_address */
|
||||
-1, /* parm_down_cursor */
|
||||
-1, /* parm_left_cursor */
|
||||
-1, /* parm_right_cursor */
|
||||
-1, /* parm_up_cursor */
|
||||
-2 /* cursor_address */
|
||||
};
|
||||
|
||||
/*
|
||||
** Make_seq_best(best, try)
|
||||
**
|
||||
** Make_seq_best() copies try to best if try->cost < best->cost
|
||||
**
|
||||
** fixed the old version, now it really runs .. (-hm/08.04.93)
|
||||
**
|
||||
*/
|
||||
|
||||
inline void Make_seq_best(struct Sequence *best, struct Sequence *try)
|
||||
{
|
||||
if (best->cost > try->cost) {
|
||||
register int *sptr;
|
||||
|
||||
sptr = try->vec; /* src ptr */
|
||||
best->end = best->vec; /* dst ptr */
|
||||
while(sptr != try->end) /* copy src -> dst */
|
||||
*(best->end++) = *(sptr++);
|
||||
best->cost = try->cost; /* copy cost */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
**
|
||||
** mvcur(oldrow, oldcol, newrow, newcol)
|
||||
**
|
||||
** mvcur() optimally moves the cursor from the position
|
||||
** specified by (oldrow, oldcol) to (newrow, newcol). If
|
||||
** (oldrow, oldcol) == (-1, -1), mvcur() does not use relative
|
||||
** cursor motions. If the coordinates are otherwise
|
||||
** out of bounds, it mods them into range.
|
||||
**
|
||||
** Revisions needed:
|
||||
** eat_newline_glitch, auto_right_margin
|
||||
*/
|
||||
|
||||
int mvcur(int oldrow, int oldcol, int newrow, int newcol)
|
||||
{
|
||||
struct Sequence seqA, seqB, /* allocate work structures */
|
||||
col0seq, /* sequence to get from col0 to nc */
|
||||
*best, /* best sequence so far */
|
||||
*try; /* next try */
|
||||
bool nlstat = SP->_nl; /* nl-output-mapping in effect ?*/
|
||||
|
||||
T(("=============================\nmvcur(%d,%d,%d,%d) called",
|
||||
oldrow, oldcol, newrow, newcol));
|
||||
|
||||
if ((oldrow == newrow) && (oldcol == newcol))
|
||||
return OK;
|
||||
|
||||
if (oldcol == columns-1 && eat_newline_glitch && auto_right_margin) {
|
||||
putp(tparm(cursor_address, newrow, newcol));
|
||||
return OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (nlstat)
|
||||
nonl();
|
||||
#endif
|
||||
update_ops(); /* make sure op_info[] is current */
|
||||
|
||||
if (oldrow < 0 || oldcol < 0 || (eat_newline_glitch && oldcol == 0 )) {
|
||||
rel_ok = FALSE; /* relative ops ok? */
|
||||
} else {
|
||||
rel_ok = TRUE;
|
||||
oldrow %= lines; /* mod values into range */
|
||||
oldcol %= columns;
|
||||
}
|
||||
|
||||
newrow %= lines;
|
||||
newcol %= columns;
|
||||
|
||||
best = &seqA;
|
||||
try = &seqB;
|
||||
|
||||
/* try out direct cursor addressing */
|
||||
|
||||
zero_seq(best);
|
||||
add_op(best, CURS_ADDR, newrow, newcol);
|
||||
|
||||
/* try out independent row/column addressing */
|
||||
|
||||
if(rel_ok) {
|
||||
zero_seq(try);
|
||||
row(try, oldrow, newrow);
|
||||
column(try, oldcol, newcol);
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
|
||||
zero_seq(&col0seq); /* store seq. to get from c0 to nc */
|
||||
column(&col0seq, 0, newcol);
|
||||
|
||||
if(col0seq.cost < INFINITY) { /* can get from col0 to newcol */
|
||||
|
||||
/* try out homing and then row/column */
|
||||
|
||||
if (! rel_ok || newcol < oldcol || newrow < oldrow) {
|
||||
zero_seq(try);
|
||||
add_op(try, CURS_HOME, 1);
|
||||
row(try, 0, newrow);
|
||||
add_seq(try, &col0seq);
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
|
||||
/* try out homing to last line and then row/column */
|
||||
|
||||
if (! rel_ok || newcol < oldcol || newrow > oldrow) {
|
||||
zero_seq(try);
|
||||
add_op(try, CURS_TO_LL, 1);
|
||||
row(try, lines - 1, newrow);
|
||||
add_seq(try, &col0seq);
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
}
|
||||
|
||||
out_seq(best);
|
||||
#if 0
|
||||
if(nlstat)
|
||||
nl();
|
||||
#endif
|
||||
|
||||
T(("==================================="));
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** row(outseq, oldrow, newrow)
|
||||
**
|
||||
** row() adds the best sequence for moving
|
||||
** the cursor from oldrow to newrow to seq.
|
||||
** row() considers row_address, parm_up/down_cursor
|
||||
** and cursor_up/down.
|
||||
*/
|
||||
|
||||
static void
|
||||
row(struct Sequence *outseq, /* where to put the output */
|
||||
int orow, int nrow) /* old, new cursor locations */
|
||||
{
|
||||
struct Sequence seqA, seqB,
|
||||
*best, /* best sequence so far */
|
||||
*try; /* next try */
|
||||
|
||||
int parm_cursor, one_step;
|
||||
|
||||
best = &seqA;
|
||||
try = &seqB;
|
||||
|
||||
if (nrow == orow)
|
||||
return;
|
||||
|
||||
if (nrow < orow) {
|
||||
parm_cursor = P_UP_CURS;
|
||||
one_step = CURS_UP;
|
||||
} else {
|
||||
parm_cursor = P_DOWN_CURS;
|
||||
one_step = CURS_DOWN;
|
||||
}
|
||||
|
||||
/* try out direct row addressing */
|
||||
|
||||
zero_seq(best);
|
||||
add_op(best, ROW_ADDR, nrow);
|
||||
|
||||
/* try out paramaterized up or down motion */
|
||||
|
||||
if (rel_ok) {
|
||||
zero_seq(try);
|
||||
add_op(try, parm_cursor, abs(orow - nrow));
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
|
||||
/* try getting there one step at a time... */
|
||||
|
||||
if (rel_ok) {
|
||||
zero_seq(try);
|
||||
add_op(try, one_step, abs(orow-nrow));
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
|
||||
add_seq(outseq, best);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** column(outseq, oldcol, newcol)
|
||||
**
|
||||
** column() adds the best sequence for moving
|
||||
** the cursor from oldcol to newcol to outseq.
|
||||
** column() considers column_address, parm_left/right_cursor,
|
||||
** simp_col(), and carriage_return followed by simp_col().
|
||||
*/
|
||||
|
||||
static void column(struct Sequence *outseq, /* where to put the output */
|
||||
int ocol, int ncol) /* old, new cursor column */
|
||||
{
|
||||
struct Sequence seqA, seqB,
|
||||
*best, *try;
|
||||
int parm_cursor; /* set to either parm_up/down_cursor */
|
||||
|
||||
best = &seqA;
|
||||
try = &seqB;
|
||||
|
||||
if (ncol == ocol)
|
||||
return;
|
||||
|
||||
if (ncol < ocol)
|
||||
parm_cursor = P_LEFT_CURS;
|
||||
else
|
||||
parm_cursor = P_RIGHT_CURS;
|
||||
|
||||
/* try out direct column addressing */
|
||||
|
||||
zero_seq(best);
|
||||
add_op(best, COL_ADDR, ncol);
|
||||
|
||||
/* try carriage_return then simp_col() */
|
||||
|
||||
if(! rel_ok || (ncol < ocol)) {
|
||||
zero_seq(try);
|
||||
add_op(try, CARRIAGE_RETURN, 1);
|
||||
simp_col(try, 0, ncol);
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
if(rel_ok) {
|
||||
/* try out paramaterized left or right motion */
|
||||
|
||||
zero_seq(try);
|
||||
add_op(try, parm_cursor, abs(ocol - ncol));
|
||||
Make_seq_best(best, try);
|
||||
|
||||
/* try getting there with simp_col() */
|
||||
|
||||
zero_seq(try);
|
||||
simp_col(try, ocol, ncol);
|
||||
Make_seq_best(best, try);
|
||||
}
|
||||
|
||||
add_seq(outseq, best);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** simp_col(outseq, oldcol, newcol)
|
||||
**
|
||||
** simp_col() adds the best simple sequence for getting
|
||||
** from oldcol to newcol to outseq.
|
||||
** simp_col() considers (back_)tab and cursor_left/right.
|
||||
**
|
||||
** Revisions needed:
|
||||
** Simp_col asssumes that the cost of a (back_)tab
|
||||
** is less then the cost of one-stepping to get to the same column.
|
||||
** Should sometimes use overprinting instead of cursor_right.
|
||||
*/
|
||||
|
||||
static void
|
||||
simp_col( struct Sequence *outseq, /* place to put sequence */
|
||||
int oc, int nc) /* old column, new column */
|
||||
{
|
||||
struct Sequence seqA, seqB, tabseq,
|
||||
*best, *try;
|
||||
int mytab, tabs, onepast,
|
||||
one_step, opp_step;
|
||||
|
||||
onepast = -1;
|
||||
|
||||
if (oc == nc)
|
||||
return;
|
||||
|
||||
if(! rel_ok) {
|
||||
outseq->cost = INFINITY;
|
||||
return;
|
||||
}
|
||||
|
||||
best = &seqA;
|
||||
try = &seqB;
|
||||
|
||||
if(oc < nc) {
|
||||
mytab = TAB;
|
||||
|
||||
if (init_tabs > 0 && op_info[TAB] < INFINITY) {
|
||||
tabs = (nc / init_tabs) - (oc / init_tabs);
|
||||
onepast = ((nc / init_tabs) + 1) * init_tabs;
|
||||
if (tabs)
|
||||
oc = onepast - init_tabs; /* consider it done */
|
||||
} else {
|
||||
tabs = 0;
|
||||
}
|
||||
one_step = CURS_RIGHT;
|
||||
opp_step = CURS_LEFT;
|
||||
} else {
|
||||
mytab = BACK_TAB;
|
||||
if (init_tabs > 0 && op_info[BACK_TAB] < INFINITY) {
|
||||
tabs = (oc / init_tabs) - (nc / init_tabs);
|
||||
onepast = ((nc - 1) / init_tabs) * init_tabs;
|
||||
if (tabs)
|
||||
oc = onepast + init_tabs; /* consider it done */
|
||||
} else {
|
||||
tabs = 0;
|
||||
}
|
||||
one_step = CURS_LEFT;
|
||||
opp_step = CURS_RIGHT;
|
||||
}
|
||||
|
||||
/* tab as close as possible to nc */
|
||||
|
||||
zero_seq(&tabseq);
|
||||
add_op(&tabseq, mytab, tabs);
|
||||
|
||||
/* try extra tab and backing up */
|
||||
|
||||
zero_seq(best);
|
||||
|
||||
if (onepast >= 0 && onepast < columns) {
|
||||
add_op(best, mytab, 1);
|
||||
add_op(best, opp_step, abs(onepast - nc));
|
||||
} else {
|
||||
best->cost = INFINITY; /* make sure of next swap */
|
||||
}
|
||||
|
||||
/* try stepping to nc */
|
||||
|
||||
zero_seq(try);
|
||||
add_op(try, one_step, abs(nc - oc));
|
||||
Make_seq_best(best, try);
|
||||
|
||||
if (tabseq.cost < INFINITY)
|
||||
add_seq(outseq, &tabseq);
|
||||
add_seq(outseq, best);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** zero_seq(seq) empties seq.
|
||||
** add_seq(seq1, seq2) adds seq1 to seq2.
|
||||
** out_seq(seq) outputs a sequence.
|
||||
*/
|
||||
|
||||
static void
|
||||
zero_seq(seq)
|
||||
struct Sequence *seq;
|
||||
{
|
||||
seq->end = seq->vec;
|
||||
seq->cost = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
add_seq(struct Sequence *seq1, struct Sequence *seq2)
|
||||
{
|
||||
int *vptr;
|
||||
|
||||
T(("add_seq(%x, %x)", seq1, seq2));
|
||||
|
||||
if(seq1->cost >= INFINITY || seq2->cost >= INFINITY)
|
||||
seq1->cost = INFINITY;
|
||||
else {
|
||||
vptr = seq2->vec;
|
||||
while (vptr != seq2->end)
|
||||
*(seq1->end++) = *(vptr++);
|
||||
seq1->cost += seq2->cost;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
out_seq(struct Sequence *seq)
|
||||
{
|
||||
int *opptr, prm[9], ps, p, op;
|
||||
int count;
|
||||
char *sequence();
|
||||
|
||||
T(("out_seq(%x)", seq));
|
||||
|
||||
if (seq->cost >= INFINITY)
|
||||
return;
|
||||
|
||||
for (opptr = seq->vec; opptr < seq->end; opptr++) {
|
||||
op = *opptr; /* grab operator */
|
||||
ps = -op_info[op];
|
||||
if(ps > 0) { /* parameterized */
|
||||
for (p = 0; p < ps; p++) /* fill in needed parms */
|
||||
prm[p] = *(++opptr);
|
||||
|
||||
putp(tparm(sequence(op),
|
||||
prm[0], prm[1], prm[2], prm[3], prm[4],
|
||||
prm[5], prm[6], prm[7], prm[8]));
|
||||
} else {
|
||||
count = *(++opptr);
|
||||
/*rev should save tputs output instead of mult calls */
|
||||
while (count--) /* do count times */
|
||||
putp(sequence(op));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** update_ops()
|
||||
**
|
||||
** update_ops() makes sure that
|
||||
** the op_info[] array is updated and initializes
|
||||
** the cost array for SP if needed.
|
||||
*/
|
||||
|
||||
static void
|
||||
update_ops()
|
||||
{
|
||||
T(("update_ops()"));
|
||||
|
||||
if (SP) { /* SP structure exists */
|
||||
int op;
|
||||
|
||||
if (! SP->_costinit) { /* this term not yet assigned costs */
|
||||
loc_init = FALSE; /* if !SP in the future, new term */
|
||||
init_costs(SP->_costs); /* fill term costs */
|
||||
SP->_costinit = TRUE;
|
||||
}
|
||||
|
||||
for (op = 0; op < NUM_NPARM; op++)
|
||||
op_info[op] = SP->_costs[op]; /* set up op_info */
|
||||
|
||||
/* check for newline that might be mapped... */
|
||||
|
||||
if (SP->_nlmapping && index(sequence(CURS_DOWN), '\n'))
|
||||
op_info[CURS_DOWN] = INFINITY;
|
||||
} else {
|
||||
if (! loc_init) { /* using local costs */
|
||||
loc_init = TRUE;
|
||||
init_costs(op_info); /* set up op_info */
|
||||
}
|
||||
|
||||
/* check for newline that might be mapped... */
|
||||
|
||||
if (index(sequence(CURS_DOWN), '\n'))
|
||||
op_info[CURS_DOWN] = INFINITY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** init_costs(costs)
|
||||
**
|
||||
** init_costs() fills the array costs[NUM_NPARM]
|
||||
** with costs calculated by doing tputs() calls.
|
||||
*/
|
||||
|
||||
static void
|
||||
init_costs(int costs[])
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_NPARM; i++) {
|
||||
if (sequence(i) != (char *) 0) {
|
||||
c_count = 0;
|
||||
tputs(sequence(i), 1, countc);
|
||||
costs[i] = c_count;
|
||||
} else
|
||||
costs[i] = INFINITY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** countc() increments global var c_count.
|
||||
*/
|
||||
|
||||
static int countc(char ch)
|
||||
{
|
||||
return(c_count++);
|
||||
}
|
||||
|
||||
/*
|
||||
** add_op(seq, op, p0, p1, ... , p8)
|
||||
**
|
||||
** add_op() adds the operator op and the appropriate
|
||||
** number of paramaters to seq. It also increases the
|
||||
** cost appropriately.
|
||||
** if op has no parameters, p0 is taken to be a count.
|
||||
*/
|
||||
|
||||
static void add_op(struct Sequence *seq, int op, ...)
|
||||
{
|
||||
va_list argp;
|
||||
int num_ps, p;
|
||||
|
||||
T(("adding op %d to sequence", op));
|
||||
|
||||
va_start(argp, op);
|
||||
|
||||
num_ps = - op_info[op]; /* get parms or -cost */
|
||||
|
||||
*(seq->end++) = op;
|
||||
|
||||
if (num_ps == (- INFINITY) || sequence(op) == (char *) 0) {
|
||||
seq->cost = INFINITY;
|
||||
} else if (num_ps <= 0) { /* no parms, -cost */
|
||||
int i = va_arg(argp, int);
|
||||
seq->cost -= i * num_ps; /* ADD count * cost */
|
||||
*(seq->end++) = i;
|
||||
} else {
|
||||
int prm[9];
|
||||
|
||||
for (p = 0; p < num_ps; p++)
|
||||
*(seq->end++) = prm[p] = va_arg(argp, int);
|
||||
|
||||
c_count = 0;
|
||||
|
||||
tputs(tparm(sequence(op), prm[0], prm[1], prm[2], prm[3], prm[4],
|
||||
prm[5], prm[6], prm[7], prm[8]), 1, countc);
|
||||
|
||||
seq->cost += c_count;
|
||||
}
|
||||
va_end(argp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** char *sequence(op)
|
||||
**
|
||||
** sequence() returns a pointer to the op's
|
||||
** terminal control sequence.
|
||||
*/
|
||||
|
||||
static char *sequence(int op)
|
||||
{
|
||||
T(("sequence(%d)", op));
|
||||
|
||||
switch(op) {
|
||||
case CARRIAGE_RETURN:
|
||||
return (carriage_return);
|
||||
case CURS_DOWN:
|
||||
return (cursor_down);
|
||||
case CURS_HOME:
|
||||
return (cursor_home);
|
||||
case CURS_LEFT:
|
||||
return (cursor_left);
|
||||
case CURS_RIGHT:
|
||||
return (cursor_right);
|
||||
case CURS_TO_LL:
|
||||
return (cursor_to_ll);
|
||||
case CURS_UP:
|
||||
return (cursor_up);
|
||||
case TAB:
|
||||
return (tab);
|
||||
case BACK_TAB:
|
||||
return (back_tab);
|
||||
case ROW_ADDR:
|
||||
return (row_address);
|
||||
case COL_ADDR:
|
||||
return (column_address);
|
||||
case P_DOWN_CURS:
|
||||
return (parm_down_cursor);
|
||||
case P_LEFT_CURS:
|
||||
return (parm_left_cursor);
|
||||
case P_RIGHT_CURS:
|
||||
return (parm_right_cursor);
|
||||
case P_UP_CURS:
|
||||
return (parm_up_cursor);
|
||||
case CURS_ADDR:
|
||||
return (cursor_address);
|
||||
default:
|
||||
return ((char *) 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,29 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_mvwin.c
|
||||
**
|
||||
** The routine mvwin().
|
||||
**
|
||||
*/
|
||||
|
||||
#include "curses.priv.h"
|
||||
#include "terminfo.h"
|
||||
|
||||
int mvwin(WINDOW *win, int by, int bx)
|
||||
{
|
||||
T(("mvwin(%x,%d,%d) called", win, by, bx));
|
||||
|
||||
if (by + win->_maxy > lines - 1 || bx + win->_maxx > columns - 1)
|
||||
return(ERR);
|
||||
|
||||
win->_begy = by;
|
||||
win->_begx = bx;
|
||||
|
||||
touchwin(win);
|
||||
|
||||
return(OK);
|
||||
}
|
@ -1,177 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_newterm.c
|
||||
**
|
||||
** The newterm() function.
|
||||
**
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "curses.priv.h"
|
||||
#include "terminfo.h"
|
||||
#ifdef SVR4_ACTION
|
||||
#define _POSIX_SOURCE
|
||||
#endif
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef MYTINFO
|
||||
int LINES, COLS;
|
||||
#endif
|
||||
|
||||
static void cleanup(int sig)
|
||||
{
|
||||
|
||||
if (sig == SIGSEGV)
|
||||
fprintf(stderr, "Got a segmentation violation signal, cleaning up and exiting\n");
|
||||
endwin();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
size_change(int sig)
|
||||
{
|
||||
struct ttysize ws;
|
||||
|
||||
if (ioctl(0, TIOCGSIZE, &ws) != -1) {
|
||||
LINES = ws.ts_lines;
|
||||
COLS = ws.ts_cols;
|
||||
}
|
||||
}
|
||||
|
||||
WINDOW *stdscr, *curscr, *newscr;
|
||||
SCREEN *SP;
|
||||
|
||||
struct ripoff_t
|
||||
{
|
||||
int line;
|
||||
int (*hook)();
|
||||
}
|
||||
rippedoff[5], *rsp = rippedoff;
|
||||
|
||||
SCREEN * newterm(char *term, FILE *ofp, FILE *ifp)
|
||||
{
|
||||
sigaction_t act;
|
||||
int errret;
|
||||
int stolen, topstolen;
|
||||
extern char _ncurses_copyright[];
|
||||
char *use_it = _ncurses_copyright;
|
||||
|
||||
use_it = use_it; /* shut up compiler */
|
||||
#ifdef TRACE
|
||||
_init_trace();
|
||||
T(("newterm(\"%s\",%x,%x) called", term, ofp, ifp));
|
||||
#endif
|
||||
|
||||
#ifdef MYTINFO
|
||||
if (setupterm(term, fileno(ofp), &errret) != OK)
|
||||
return NULL;
|
||||
COLS = columns;
|
||||
LINES = lines;
|
||||
#else
|
||||
if (setupterm(term, fileno(ofp), &errret) != 1)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
if ((SP = (SCREEN *) malloc(sizeof *SP)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (ofp == stdout && ifp == stdin) {
|
||||
SP->_ofp = stdout;
|
||||
SP->_ifp = stdin;
|
||||
} else {
|
||||
SP->_ofp = ofp;
|
||||
SP->_ifp = ofp;
|
||||
}
|
||||
SP->_term = cur_term;
|
||||
SP->_cursrow = -1;
|
||||
SP->_curscol = -1;
|
||||
SP->_keytry = UNINITIALISED;
|
||||
SP->_nl = TRUE;
|
||||
SP->_raw = FALSE;
|
||||
SP->_cbreak = FALSE;
|
||||
SP->_echo = TRUE;
|
||||
SP->_nlmapping = TRUE;
|
||||
SP->_fifohead = -1;
|
||||
SP->_fifotail = 0;
|
||||
SP->_fifopeek = 0;
|
||||
SP->_endwin = FALSE;
|
||||
SP->_checkfd = fileno(ifp);
|
||||
typeahead(fileno(ifp));
|
||||
|
||||
if (enter_ca_mode)
|
||||
putp(enter_ca_mode);
|
||||
|
||||
init_acs();
|
||||
|
||||
T(("creating newscr"));
|
||||
if ((newscr = newwin(lines, columns, 0, 0)) == (WINDOW *)NULL)
|
||||
return(NULL);
|
||||
|
||||
T(("creating curscr"));
|
||||
if ((curscr = newwin(lines, columns, 0, 0)) == (WINDOW *)NULL)
|
||||
return(NULL);
|
||||
|
||||
SP->_newscr = newscr;
|
||||
SP->_curscr = curscr;
|
||||
|
||||
newscr->_clear = TRUE;
|
||||
curscr->_clear = FALSE;
|
||||
|
||||
stolen = topstolen = 0;
|
||||
for (rsp = rippedoff; rsp->line; rsp++) {
|
||||
if (rsp->hook) {
|
||||
if (rsp->line < 0)
|
||||
rsp->hook(newwin(1,COLS, LINES-1,0), COLS);
|
||||
else
|
||||
rsp->hook(newwin(1,COLS, topstolen++,0), COLS);
|
||||
}
|
||||
--LINES;
|
||||
stolen++;
|
||||
}
|
||||
|
||||
act.sa_handler = tstp;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
sigaction(SIGTSTP, &act, NULL);
|
||||
act.sa_handler = cleanup;
|
||||
sigaction(SIGINT, &act, NULL);
|
||||
sigaction(SIGTERM, &act, NULL);
|
||||
#if 0
|
||||
sigaction(SIGSEGV, &act, NULL);
|
||||
#endif
|
||||
act.sa_handler = size_change;
|
||||
act.sa_flags = SA_RESTART;
|
||||
sigaction(SIGWINCH, &act, NULL); /* this must restart read() */
|
||||
if ((stdscr = newwin(lines - stolen, columns, topstolen, 0)) == NULL)
|
||||
return(NULL);
|
||||
|
||||
SP->_stdscr = stdscr;
|
||||
|
||||
def_shell_mode();
|
||||
def_prog_mode();
|
||||
|
||||
T(("newterm returns %x", SP));
|
||||
|
||||
return(SP);
|
||||
}
|
||||
|
||||
int
|
||||
ripoffline(int line, int (*init)(WINDOW *, int))
|
||||
{
|
||||
if (line == 0)
|
||||
return(OK);
|
||||
|
||||
if (rsp >= rippedoff + sizeof(rippedoff)/sizeof(rippedoff[0]))
|
||||
return(ERR);
|
||||
|
||||
rsp->line = line;
|
||||
rsp->hook = init;
|
||||
rsp++;
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
@ -1,185 +0,0 @@
|
||||
|
||||
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
||||
* details. If they are missing then this copy is in violation of *
|
||||
* the copyright conditions. */
|
||||
|
||||
/*
|
||||
** lib_newwin.c
|
||||
**
|
||||
** The routines newwin(), subwin() and their dependent
|
||||
**
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "terminfo.h"
|
||||
#include "curses.priv.h"
|
||||
|
||||
WINDOW * newwin(int num_lines, int num_columns, int begy, int begx)
|
||||
{
|
||||
WINDOW *win;
|
||||
chtype *ptr;
|
||||
int i, j;
|
||||
|
||||
T(("newwin(%d,%d,%d,%d) called", num_lines, num_columns, begy, begx));
|
||||
|
||||
if (num_lines == 0)
|
||||
num_lines = lines - begy;
|
||||
|
||||
if (num_columns == 0)
|
||||
num_columns = columns - begx;
|
||||
|
||||
if (num_columns + begx > columns || num_lines + begy > lines)
|
||||
return NULL;
|
||||
|
||||
if ((win = makenew(num_lines, num_columns, begy, begx)) == NULL)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < num_lines; i++) {
|
||||
if ((win->_line[i] = (chtype *) calloc(num_columns, sizeof(chtype))) == NULL) {
|
||||
for (j = 0; j < i; j++)
|
||||
free(win->_line[j]);
|
||||
|
||||
free(win->_firstchar);
|
||||
free(win->_lastchar);
|
||||
free(win->_line);
|
||||
free(win);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
for (ptr = win->_line[i]; ptr < win->_line[i] + num_columns; )
|
||||
*ptr++ = ' ';
|
||||
}
|
||||
|
||||
T(("newwin: returned window is %x", win));
|
||||
|
||||
return(win);
|
||||
}
|
||||
|
||||
WINDOW * derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
|
||||
{
|
||||
WINDOW *win;
|
||||
int i;
|
||||
|
||||
T(("derwin(%x, %d,%d,%d,%d) called", orig, num_lines, num_columns, begy, begx));
|
||||
|
||||
/*
|
||||
** make sure window fits inside the original one
|
||||
*/
|
||||
if ( begy < 0 || begx < 0)
|
||||
return NULL;
|
||||
if ( begy + num_lines > orig->_maxy + 1
|
||||
|| begx + num_columns > orig->_maxx + 1)
|
||||
return NULL;
|
||||
|
||||
if (num_lines == 0)
|
||||
num_lines = orig->_maxy - orig->_begy - begy;
|
||||
|
||||
if (num_columns == 0)
|
||||
num_columns = orig->_maxx - orig->_begx - begx;
|
||||
|
||||
if ((win = makenew(num_lines, num_columns, orig->_begy + begy, orig->_begx + begx)) == NULL)
|
||||
return NULL;
|
||||
|
||||
win->_pary = begy;
|
||||
win->_parx = begx;
|
||||
win->_attrs = orig->_attrs;
|
||||
win->_bkgd = orig->_bkgd;
|
||||
|
||||
for (i = 0; i < num_lines; i++)
|
||||
win->_line[i] = &orig->_line[begy++][begx];
|
||||
|
||||
win->_flags = _SUBWIN;
|
||||
win->_parent = orig;
|
||||
|
||||
T(("derwin: returned window is %x", win));
|
||||
|
||||
return(win);
|
||||
}
|
||||
|
||||
|
||||
WINDOW *subwin(WINDOW *w, int l, int c, int y, int x)
|
||||
{
|
||||
T(("subwin(%x, %d, %d, %d, %d) called", w, l, c, y, x));
|
||||
T(("parent has begy = %d, begx = %d", w->_begy, w->_begx));
|
||||
|
||||
return derwin(w, l, c, y - w->_begy, x - w->_begx);
|
||||
}
|
||||
|
||||
WINDOW *
|
||||
makenew(int num_lines, int num_columns, int begy, int begx)
|
||||
{
|
||||
int i;
|
||||
WINDOW *win;
|
||||
|
||||
T(("makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx));
|
||||
|
||||
if ((win = (WINDOW *) malloc(sizeof(WINDOW))) == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((win->_line = (chtype **) calloc(num_lines, sizeof (chtype *))) == NULL) {
|
||||
free(win);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((win->_firstchar = calloc(num_lines, sizeof(short))) == NULL) {
|
||||
free(win);
|
||||
free(win->_line);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((win->_lastchar = calloc(num_lines, sizeof(short))) == NULL) {
|
||||
free(win);
|
||||
free(win->_line);
|
||||
free(win->_firstchar);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
win->_curx = 0;
|
||||
win->_cury = 0;
|
||||
win->_maxy = num_lines - 1;
|
||||
win->_maxx = num_columns - 1;
|
||||
win->_begy = begy;
|
||||
win->_begx = begx;
|
||||
|
||||
win->_flags = 0;
|
||||
win->_attrs = A_NORMAL;
|
||||
win->_bkgd = BLANK;
|
||||
|
||||
win->_clear = (num_lines == lines && num_columns == columns);
|
||||
win->_idlok = FALSE;
|
||||
win->_use_idc = TRUE;
|
||||
win->_scroll = FALSE;
|
||||
win->_leave = FALSE;
|
||||
win->_use_keypad = FALSE;
|
||||
#ifdef TERMIOS
|
||||
win->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
|
||||
!(cur_term->Ottyb.c_iflag & ISTRIP));
|
||||
#else
|
||||
win->_use_meta = FALSE;
|
||||
#endif
|
||||
win->_delay = -1;
|
||||
win->_immed = FALSE;
|
||||
win->_sync = 0;
|
||||
win->_parx = 0;
|
||||
win->_pary = 0;
|
||||
win->_parent = (WINDOW *)NULL;
|
||||
|
||||
win->_regtop = 0;
|
||||
win->_regbottom = num_lines - 1;
|
||||
|
||||
for (i = 0; i < num_lines; i++)
|
||||
win->_firstchar[i] = win->_lastchar[i] = _NOCHANGE;
|
||||
|
||||
if (begx + num_columns == columns) {
|
||||
win->_flags |= _ENDLINE;
|
||||
|
||||
if (begx == 0 && num_lines == lines && begy == 0)
|
||||
win->_flags |= _FULLWIN;
|
||||
|
||||
if (begy + num_lines == lines)
|
||||
win->_flags |= _SCROLLWIN;
|
||||
}
|
||||
|
||||
return(win);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user