diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1999-02-24 06:31:12 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1999-02-24 06:31:12 +0000 |
commit | e9a62161121e4d9f0aa46ddcff0a3a0f8879d0ed (patch) | |
tree | f70dac47630b69f5bfa3c5d7afcb1b5fe9133f54 | |
parent | 4ac175997c3d2ab53080a9546cb1fda25fc147f5 (diff) |
ncurses-4.2-990220; this is a pre-release of 5.0
-rw-r--r-- | lib/libcurses/Makefile | 24 | ||||
-rw-r--r-- | lib/libcurses/base/MKkeyname.awk | 53 | ||||
-rw-r--r-- | lib/libcurses/base/define_key.c | 9 | ||||
-rw-r--r-- | lib/libcurses/base/keybound.c | 47 | ||||
-rw-r--r-- | lib/libcurses/base/keyok.c | 11 | ||||
-rw-r--r-- | lib/libcurses/base/lib_set_term.c | 6 | ||||
-rw-r--r-- | lib/libcurses/base/tries.c | 44 | ||||
-rw-r--r-- | lib/libcurses/curses.h | 7 | ||||
-rw-r--r-- | lib/libcurses/curses.priv.h | 11 | ||||
-rw-r--r-- | lib/libcurses/doc/hackguide.html | 2 | ||||
-rw-r--r-- | lib/libcurses/doc/ncurses-intro.html | 2 | ||||
-rw-r--r-- | lib/libcurses/keybound.3 | 69 | ||||
-rw-r--r-- | lib/libcurses/term_entry.h | 22 | ||||
-rw-r--r-- | lib/libcurses/tic.h | 23 | ||||
-rw-r--r-- | lib/libcurses/tinfo/comp_parse.c | 74 | ||||
-rw-r--r-- | lib/libcurses/tinfo/init_keytry.c | 69 | ||||
-rw-r--r-- | lib/libcurses/tinfo/lib_acs.c | 6 | ||||
-rw-r--r-- | lib/libcurses/tinfo/lib_options.c | 34 | ||||
-rw-r--r-- | lib/libcurses/tinfo/make_keys.c | 11 | ||||
-rw-r--r-- | lib/libcurses/trace/trace_tries.c | 76 |
20 files changed, 443 insertions, 157 deletions
diff --git a/lib/libcurses/Makefile b/lib/libcurses/Makefile index 0aa29bae110..8e7e1426958 100644 --- a/lib/libcurses/Makefile +++ b/lib/libcurses/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.35 1999/01/18 19:30:36 millert Exp $ +# $OpenBSD: Makefile,v 1.36 1999/02/24 06:31:06 millert Exp $ # Uncomment this to enable tracing in libcurses #CURSESTRACE=-DTRACE @@ -16,7 +16,7 @@ LIB= curses SRCS= codes.c comp_captab.c expanded.c fallback.c lib_gen.c lib_keyname.c \ names.c unctrl.c # base -SRCS+= define_key.c keyok.c lib_adabind.c lib_addch.c lib_addstr.c \ +SRCS+= define_key.c keybound.c keyok.c lib_adabind.c lib_addch.c lib_addstr.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_delch.c lib_delwin.c lib_dft_fgbg.c \ @@ -37,7 +37,7 @@ SRCS+= define_key.c keyok.c lib_adabind.c lib_addch.c lib_addstr.c \ # tinfo SRCS+= access.c add_tries.c alloc_entry.c captoinfo.c comp_error.c \ comp_expand.c comp_hash.c comp_parse.c comp_scan.c doalloc.c \ - getenv_num.c home_terminfo.c lib_acs.c lib_baudrate.c \ + getenv_num.c home_terminfo.c init_keytry.c lib_acs.c lib_baudrate.c \ lib_cur_term.c lib_data.c lib_has_cap.c lib_kernel.c \ lib_longname.c lib_napms.c lib_options.c lib_print.c lib_raw.c \ lib_setup.c lib_termcap.c lib_termname.c lib_ti.c lib_tparm.c \ @@ -46,7 +46,7 @@ SRCS+= access.c add_tries.c alloc_entry.c captoinfo.c comp_error.c \ setbuf.c write_entry.c # trace SRCS+= lib_trace.c lib_traceatr.c lib_tracebits.c lib_tracechr.c \ - lib_tracedmp.c lib_tracemse.c trace_buf.c + lib_tracedmp.c lib_tracemse.c trace_buf.c trace_tries.c # tty SRCS+= hardscroll.c hashmap.c lib_mvcur.c lib_tstp.c lib_twait.c \ lib_vidattr.c tty_update.c @@ -60,8 +60,8 @@ MAN= curs_addch.3 curs_addchstr.3 curs_addstr.3 curs_attr.3 curs_beep.3 \ curs_overlay.3 curs_pad.3 curs_print.3 curs_printw.3 curs_refresh.3 \ curs_scanw.3 curs_scr_dump.3 curs_scroll.3 curs_slk.3 curs_termattrs.3 \ curs_touch.3 curs_util.3 curs_window.3 curses.3 define_key.3 \ - dft_fgbg.3 keyok.3 resizeterm.3 wresize.3 termcap.3 terminfo.3 \ - terminfo.5 term.5 term.7 + dft_fgbg.3 keybound.3 keyok.3 resizeterm.3 wresize.3 termcap.3 \ + terminfo.3 terminfo.5 term.5 term.7 MLINKS+=curses.3 ncurses.3 MLINKS+=curs_addch.3 addch.3 curs_addch.3 waddch.3 curs_addch.3 mvaddch.3 \ curs_addch.3 mvwaddch.3 curs_addch.3 echochar.3 curs_addch.3 \ @@ -162,15 +162,15 @@ MLINKS+= terminfo.3 setupterm.3 terminfo.3 setterm.3 terminfo.3 set_curterm.3 \ MLINKS+= termcap.3 tgetent.3 termcap.3 tgetflag.3 termcap.3 tgetnum.3 \ termcap.3 tgetstr.3 termcap.3 tgoto.3 termcap.3 tputs.3 -CLEANFILES+= nomacros.h codes.c comp_captab.c expanded.c fallback.c lib_gen.c \ - lib_keyname.c names.c unctrl.c keys.tries make_hash make_keys +CLEANFILES+= init_keytry.h nomacros.h codes.c comp_captab.c expanded.c \ + fallback.c lib_gen.c lib_keyname.c names.c unctrl.c make_hash make_keys .if make(install) SUBDIR+= doc .endif -beforedepend: nomacros.h codes.c comp_captab.c expanded.c fallback.c lib_gen.c \ - lib_keyname.c names.c unctrl.c keys.tries make_hash make_keys +beforedepend: init_keytry.h nomacros.h codes.c comp_captab.c expanded.c \ + fallback.c lib_gen.c lib_keyname.c names.c unctrl.c make_hash make_keys includes: @cmp -s ${DESTDIR}/usr/include/ncurses.h ${.CURDIR}/curses.h || \ @@ -190,7 +190,7 @@ lib_gen.c: ${.CURDIR}/curses.h ${.CURDIR}/base/MKlib_gen.sh nomacros.h: ${.CURDIR}/base/MKlib_gen.sh lib_gen.c fgrep undef lib_gen.c > ${.TARGET} -keys.tries: make_keys ${.CURDIR}/tinfo/keys.list +init_keytry.h: make_keys ${.CURDIR}/tinfo/keys.list ./make_keys ${.CURDIR}/tinfo/keys.list > ${.TARGET} make_keys: ${.CURDIR}/tinfo/make_keys.c names.c @@ -227,4 +227,4 @@ afterinstall: .include <bsd.lib.mk> -lib_options.o lib_options.so lib_options.po lib_options.ln: keys.tries +lib_options.o lib_options.so lib_options.po lib_options.ln: init_keytry.h diff --git a/lib/libcurses/base/MKkeyname.awk b/lib/libcurses/base/MKkeyname.awk index 64a27a09895..df70e9b89d3 100644 --- a/lib/libcurses/base/MKkeyname.awk +++ b/lib/libcurses/base/MKkeyname.awk @@ -1,5 +1,32 @@ -# $OpenBSD: MKkeyname.awk,v 1.1 1999/01/18 19:09:31 millert Exp $ -# $From: MKkeyname.awk,v 1.15 1999/01/16 22:56:44 tom Exp $ +# $OpenBSD: MKkeyname.awk,v 1.2 1999/02/24 06:31:07 millert Exp $ +# $From: MKkeyname.awk,v 1.17 1999/02/18 11:18:06 tom Exp $ +############################################################################## +# Copyright (c) 1999 Free Software Foundation, Inc. # +# # +# Permission is hereby granted, free of charge, to any person obtaining a # +# copy of this software and associated documentation files (the "Software"), # +# to deal in the Software without restriction, including without limitation # +# the rights to use, copy, modify, merge, publish, distribute, distribute # +# with modifications, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the # +# following conditions: # +# # +# The above copyright notice and this permission notice shall be included in # +# all copies or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # +# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # +# DEALINGS IN THE SOFTWARE. # +# # +# Except as contained in this notice, the name(s) of the above copyright # +# holders shall not be used in advertising or otherwise to promote the sale, # +# use or other dealings in this Software without prior written # +# authorization. # +############################################################################## BEGIN { print "/* generated by MKkeyname.awk */" print "" @@ -7,32 +34,27 @@ BEGIN { print "#include <stdlib.h>" print "#include <string.h>" print "#include <curses.h>" + print "#include <tic.h>" print "" - print "struct kn {" - print "\tconst char *name;" - print "\tint code;" - print "};" - print "" - print "static const struct kn key_names[] = {" + print "const struct kn _nc_key_names[] = {" } /^[^#]/ { -# printf "\t{ \"%s\",%*s%s },\n", $1, 16-length($1), " ", $1; - printf "\t{ \"%s\",%s },\n", $1, $1; + printf "\t{ \"%s\", %s },\n", $1, $1; } END { - print "};" + printf "\t{ 0, 0 }};\n" print "" print "NCURSES_CONST char *keyname(int c)" print "{" - print "int i, size = sizeof(key_names)/sizeof(struct kn);" + print "int i;" print "static char name[20];" print "char *p;" print "" - print "\tfor (i = 0; i < size; i++)" - print "\t\tif (key_names[i].code == c)" - print "\t\t\treturn (NCURSES_CONST char *)key_names[i].name;" + print "\tfor (i = 0; _nc_key_names[i].name != 0; i++)" + print "\t\tif (_nc_key_names[i].code == c)" + print "\t\t\treturn (NCURSES_CONST char *)_nc_key_names[i].name;" print "\tif (c >= 256) return \"UNKNOWN KEY\";" print "\tp = name;" print "\tif (c >= 128) {" @@ -50,5 +72,4 @@ END { print "\t\tsprintf(p, \"%c\", c);" print "\treturn (NCURSES_CONST char *)name;" print "}" - print "" } diff --git a/lib/libcurses/base/define_key.c b/lib/libcurses/base/define_key.c index ac73c578212..81578027796 100644 --- a/lib/libcurses/base/define_key.c +++ b/lib/libcurses/base/define_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: define_key.c,v 1.1 1999/01/18 19:09:33 millert Exp $ */ +/* $OpenBSD: define_key.c,v 1.2 1999/02/24 06:31:07 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -34,7 +34,7 @@ #include <curses.priv.h> -MODULE_ID("$From: define_key.c,v 1.2 1998/02/11 12:13:54 tom Exp $") +MODULE_ID("$From: define_key.c,v 1.3 1999/02/19 11:53:02 tom Exp $") int define_key(char *str, int keycode) @@ -44,13 +44,16 @@ define_key(char *str, int keycode) T((T_CALLED("define_key(%s,%d)"), _nc_visbuf(str), keycode)); if (keycode > 0) { if (has_key(keycode)) { - if (_nc_remove_key(&(SP->_keytry), keycode)) + while (_nc_remove_key(&(SP->_keytry), keycode)) code = OK; } if (str != 0) { (void) _nc_add_to_try(&(SP->_keytry), str, keycode); code = OK; } + } else { + while (_nc_remove_string(&(SP->_keytry), str)) + code = OK; } returnCode(code); } diff --git a/lib/libcurses/base/keybound.c b/lib/libcurses/base/keybound.c new file mode 100644 index 00000000000..c1c8506a4a5 --- /dev/null +++ b/lib/libcurses/base/keybound.c @@ -0,0 +1,47 @@ +/* $OpenBSD: keybound.c,v 1.1 1999/02/24 06:31:07 millert Exp $ */ + +/**************************************************************************** + * Copyright (c) 1999 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Thomas E. Dickey <dickey@clark.net> 1999 * + ****************************************************************************/ + +#include <curses.priv.h> + +MODULE_ID("$From: keybound.c,v 1.1 1999/02/19 11:55:56 tom Exp $") + +/* + * Returns the count'th string definition which is associated with the + * given keycode. The result is malloc'd, must be freed by the caller. + */ + +char *keybound(int code, int count) +{ + return _nc_expand_try(SP->_key_ok, code, &count, 0); +} diff --git a/lib/libcurses/base/keyok.c b/lib/libcurses/base/keyok.c index fb343b12162..24736fe8d93 100644 --- a/lib/libcurses/base/keyok.c +++ b/lib/libcurses/base/keyok.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keyok.c,v 1.1 1999/01/18 19:09:34 millert Exp $ */ +/* $OpenBSD: keyok.c,v 1.2 1999/02/24 06:31:08 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -34,7 +34,7 @@ #include <curses.priv.h> -MODULE_ID("$From: keyok.c,v 1.2 1998/02/11 12:13:54 tom Exp $") +MODULE_ID("$From: keyok.c,v 1.3 1999/02/19 11:29:48 tom Exp $") /* * Enable (or disable) ncurses' interpretation of a keycode by adding (or @@ -49,22 +49,25 @@ MODULE_ID("$From: keyok.c,v 1.2 1998/02/11 12:13:54 tom Exp $") int keyok(int c, bool flag) { int code = ERR; + int count = 0; char *s; T((T_CALLED("keyok(%d,%d)"), c, flag)); if (flag) { - if ((s = _nc_expand_try(SP->_key_ok, c, 0)) != 0 + while ((s = _nc_expand_try(SP->_key_ok, c, &count, 0)) != 0 && _nc_remove_key(&(SP->_key_ok), c)) { _nc_add_to_try(&(SP->_keytry), s, c); free(s); code = OK; + count = 0; } } else { - if ((s = _nc_expand_try(SP->_keytry, c, 0)) != 0 + while ((s = _nc_expand_try(SP->_keytry, c, &count, 0)) != 0 && _nc_remove_key(&(SP->_keytry), c)) { _nc_add_to_try(&(SP->_key_ok), s, c); free(s); code = OK; + count = 0; } } returnCode(code); diff --git a/lib/libcurses/base/lib_set_term.c b/lib/libcurses/base/lib_set_term.c index b08fb6a1af7..3dcf382d002 100644 --- a/lib/libcurses/base/lib_set_term.c +++ b/lib/libcurses/base/lib_set_term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_set_term.c,v 1.1 1999/01/18 19:09:59 millert Exp $ */ +/* $OpenBSD: lib_set_term.c,v 1.2 1999/02/24 06:31:08 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -46,7 +46,7 @@ #include <term.h> /* cur_term */ -MODULE_ID("$From: lib_set_term.c,v 1.43 1998/11/08 00:58:25 tom Exp $") +MODULE_ID("$From: lib_set_term.c,v 1.44 1999/02/18 11:31:47 tom Exp $") SCREEN * set_term(SCREEN *screen) { @@ -216,7 +216,7 @@ size_t i; acs_chars = 0; #endif } - init_acs(); + _nc_init_acs(); memcpy(SP->_acs_map, acs_map, sizeof(chtype)*ACS_LEN); _nc_idcok = TRUE; diff --git a/lib/libcurses/base/tries.c b/lib/libcurses/base/tries.c index 522bc6542bd..245446b3599 100644 --- a/lib/libcurses/base/tries.c +++ b/lib/libcurses/base/tries.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tries.c,v 1.1 1999/01/18 19:10:07 millert Exp $ */ +/* $OpenBSD: tries.c,v 1.2 1999/02/24 06:31:08 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -41,25 +41,28 @@ #include <curses.priv.h> -MODULE_ID("$From: tries.c,v 1.8 1998/11/07 22:54:48 tom Exp $") +MODULE_ID("$From: tries.c,v 1.10 1999/02/19 11:52:11 tom Exp $") /* * Expand a keycode into the string that it corresponds to, returning null if * no match was found, otherwise allocating a string of the result. */ -char *_nc_expand_try(struct tries *tree, unsigned short code, size_t len) +char *_nc_expand_try(struct tries *tree, unsigned short code, int *count, size_t len) { struct tries *ptr = tree; char *result = 0; if (code != 0) { while (ptr != 0) { - if ((result = _nc_expand_try(ptr->child, code, len + 1)) != 0) { + if ((result = _nc_expand_try(ptr->child, code, count, len + 1)) != 0) { break; } if (ptr->value == code) { - result = typeCalloc(char, len+2); - break; + *count -= 1; + if (*count == -1) { + result = typeCalloc(char, len+2); + break; + } } ptr = ptr->sibling; } @@ -103,3 +106,32 @@ int _nc_remove_key(struct tries **tree, unsigned short code) } return FALSE; } + +/* + * Remove a string from the specified tree, freeing the unused nodes. Returns + * true if the string was found/removed. + */ +int _nc_remove_string(struct tries **tree, char *string) +{ + if (string == 0 || *string == 0) + return FALSE; + + while (*tree != 0) { + if (_nc_remove_string(&(*tree)->child, string+1)) { + return TRUE; + } + if ((unsigned char)(*tree)->ch == (unsigned char)*string) { + if((*tree)->child) { + /* don't cut the whole sub-tree */ + (*tree)->value = 0; + } else { + struct tries *to_free = *tree; + *tree = (*tree)->sibling; + free(to_free); + } + return TRUE; + } + tree = &(*tree)->sibling; + } + return FALSE; +} diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h index d3be128caa2..ec30439f614 100644 --- a/lib/libcurses/curses.h +++ b/lib/libcurses/curses.h @@ -1,4 +1,4 @@ -/* $OpenBSD: curses.h,v 1.19 1999/02/24 05:36:09 millert Exp $ */ +/* $OpenBSD: curses.h,v 1.20 1999/02/24 06:31:06 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -33,7 +33,7 @@ * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ -/* $From: curses.h.in,v 1.78 1999/01/10 03:21:11 tom Exp $ */ +/* $From: curses.h.in,v 1.79 1999/02/19 12:03:06 tom Exp $ */ #ifndef __NCURSES_H #define __NCURSES_H @@ -50,7 +50,7 @@ /* These are defined only in curses.h, and are used for conditional compiles */ #define NCURSES_VERSION_MAJOR 4 #define NCURSES_VERSION_MINOR 2 -#define NCURSES_VERSION_PATCH 990213 +#define NCURSES_VERSION_PATCH 990220 /* This is defined in more than one ncurses header, for identification */ #undef NCURSES_VERSION @@ -320,6 +320,7 @@ extern int TABSIZE; */ extern int ESCDELAY; /* ESC expire time in milliseconds */ +extern char *keybound (int, int); extern int define_key (char *, int); extern int keyok (int, bool); extern int resizeterm (int, int); diff --git a/lib/libcurses/curses.priv.h b/lib/libcurses/curses.priv.h index c09a0a1db58..1dbb0781336 100644 --- a/lib/libcurses/curses.priv.h +++ b/lib/libcurses/curses.priv.h @@ -1,4 +1,4 @@ -/* $OpenBSD: curses.priv.h,v 1.12 1999/02/24 05:36:10 millert Exp $ */ +/* $OpenBSD: curses.priv.h,v 1.13 1999/02/24 06:31:07 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -35,7 +35,7 @@ /* - * $From: curses.priv.h,v 1.127 1999/02/09 23:24:52 tom Exp $ + * $From: curses.priv.h,v 1.131 1999/02/19 11:38:48 tom Exp $ * * curses.priv.h * @@ -641,7 +641,7 @@ extern void _nc_linedump(void); #endif /* lib_acs.c */ -extern void init_acs(void); /* no prefix, this name is traditional */ +extern void _nc_init_acs(void); /* corresponds to traditional 'init_acs()' */ extern int _nc_msec_cost(const char *const, int); /* used by 'tack' program */ /* lib_mvcur.c */ @@ -665,8 +665,9 @@ extern char * _nc_printf_string(const char *fmt, va_list ap); /* tries.c */ extern void _nc_add_to_try(struct tries **tree, char *str, unsigned short code); -extern char *_nc_expand_try(struct tries *tree, unsigned short code, size_t len); +extern char *_nc_expand_try(struct tries *tree, unsigned short code, int *count, size_t len); extern int _nc_remove_key(struct tries **tree, unsigned short code); +extern int _nc_remove_string(struct tries **tree, char *string); /* elsewhere ... */ extern WINDOW *_nc_makenew(int, int, int, int, int); @@ -687,6 +688,7 @@ extern void _nc_do_color(int, bool, int (*)(int)); extern void _nc_freeall(void); extern void _nc_freewin(WINDOW *win); extern void _nc_hash_map(void); +extern void _nc_init_keytry(void); extern void _nc_keep_tic_dir(const char *); extern void _nc_make_oldhash(int i); extern void _nc_outstr(const char *str); @@ -696,6 +698,7 @@ extern void _nc_scroll_window(WINDOW *, int const, short const, short const, cht extern void _nc_set_buffer(FILE *ofp, bool buffered); extern void _nc_signal_handler(bool); extern void _nc_synchook(WINDOW *win); +extern void _nc_trace_tries(struct tries *tree); #if USE_SIZECHANGE extern void _nc_update_screensize(void); diff --git a/lib/libcurses/doc/hackguide.html b/lib/libcurses/doc/hackguide.html index aa010f393db..f2e08f16e87 100644 --- a/lib/libcurses/doc/hackguide.html +++ b/lib/libcurses/doc/hackguide.html @@ -1,6 +1,6 @@ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN"> <!-- - $Id: hackguide.html,v 1.1 1999/01/18 19:25:56 millert Exp $ + $From: hackguide.html,v 1.23 1999/01/17 00:15:48 tom Exp $ --> <HTML> <HEAD> diff --git a/lib/libcurses/doc/ncurses-intro.html b/lib/libcurses/doc/ncurses-intro.html index b4d14538ad1..a432e242b98 100644 --- a/lib/libcurses/doc/ncurses-intro.html +++ b/lib/libcurses/doc/ncurses-intro.html @@ -1,6 +1,6 @@ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN"> <!-- - $Id: ncurses-intro.html,v 1.1 1999/01/18 19:25:57 millert Exp $ + $From: ncurses-intro.html,v 1.30 1999/01/17 00:17:03 tom Exp $ --> <HTML> <HEAD> diff --git a/lib/libcurses/keybound.3 b/lib/libcurses/keybound.3 new file mode 100644 index 00000000000..f98ec445d07 --- /dev/null +++ b/lib/libcurses/keybound.3 @@ -0,0 +1,69 @@ +.\" $OpenBSD: keybound.3,v 1.1 1999/02/24 06:31:07 millert Exp $ +.\" +.\"*************************************************************************** +.\" Copyright (c) 1999 Free Software Foundation, Inc. * +.\" * +.\" Permission is hereby granted, free of charge, to any person obtaining a * +.\" copy of this software and associated documentation files (the * +.\" "Software"), to deal in the Software without restriction, including * +.\" without limitation the rights to use, copy, modify, merge, publish, * +.\" distribute, distribute with modifications, sublicense, and/or sell * +.\" copies of the Software, and to permit persons to whom the Software is * +.\" furnished to do so, subject to the following conditions: * +.\" * +.\" The above copyright notice and this permission notice shall be included * +.\" in all copies or substantial portions of the Software. * +.\" * +.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * +.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * +.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * +.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * +.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * +.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * +.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * +.\" * +.\" Except as contained in this notice, the name(s) of the above copyright * +.\" holders shall not be used in advertising or otherwise to promote the * +.\" sale, use or other dealings in this Software without prior written * +.\" authorization. * +.\"*************************************************************************** +.\" +.\" Author: Thomas E. Dickey <dickey@clark.net> 1999 +.\" +.\" $From: keybound.3x,v 1.1 1999/02/19 11:59:24 tom Exp $ +.TH keyok 3 "" +.SH NAME +\fBkeybound\fP \- return definition of keycode +.. +.SH SYNOPSIS +\fB#include <curses.h>\fP + +\fBint keybound(int keycode, int count);\fP +.. +.SH DESCRIPTION +This is an extension to the curses library. +It permits an application to determine the string which is defined +in the terminfo for specific keycodes. +.. +.SH RETURN VALUE +The keycode must be greater than zero, else NULL is returned. +If it does not correspond to a defined key, then NULL is returned. +Otherwise, the function returns a string, which must be freed by the caller. +.. +.SH PORTABILITY +These routines are specific to ncurses. They were not supported on +Version 7, BSD or System V implementations. It is recommended that +any code depending on them be conditioned using NCURSES_VERSION. +.. +.SH SEE ALSO +\fBdefine_key\fR(3), +\fBkeyok\fR(3). +.. +.SH AUTHOR +Thomas Dickey. +.\"# +.\"# The following sets edit modes for GNU EMACS +.\"# Local Variables: +.\"# mode:nroff +.\"# fill-column:79 +.\"# End: diff --git a/lib/libcurses/term_entry.h b/lib/libcurses/term_entry.h index 85236c000e1..e949c429a8c 100644 --- a/lib/libcurses/term_entry.h +++ b/lib/libcurses/term_entry.h @@ -1,4 +1,4 @@ -/* $OpenBSD: term_entry.h,v 1.5 1999/02/01 20:55:40 millert Exp $ */ +/* $OpenBSD: term_entry.h,v 1.6 1999/02/24 06:31:07 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -70,6 +70,24 @@ extern ENTRY *_nc_head, *_nc_tail; #define NULLHOOK (bool(*)(ENTRY *))0 +/* + * Note that WANTED and PRESENT are not simple inverses! If a capability + * has been explicitly cancelled, it's not considered WANTED. + */ +#define WANTED(s) ((s) == ABSENT_STRING) +#define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING)) + +#define ANDMISSING(p,q) \ + {if (PRESENT(p) && !PRESENT(q)) _nc_warning(#p " but no " #q);} + +#define PAIRED(p,q) \ + { \ + if (PRESENT(q) && !PRESENT(p)) \ + _nc_warning(#q " but no " #p); \ + if (PRESENT(p) && !PRESENT(q)) \ + _nc_warning(#p " but no " #q); \ + } + /* alloc_entry.c: elementary allocation code */ extern void _nc_init_entry(TERMTYPE *const); extern char *_nc_save_str(const char *const); @@ -89,6 +107,8 @@ extern void _nc_read_entry_source(FILE*, char*, int, bool, bool (*)(ENTRY*)); extern bool _nc_entry_match(char *, char *); extern int _nc_resolve_uses(void); extern void _nc_free_entries(ENTRY *); +extern void (*_nc_check_termtype)(TERMTYPE *); + #ifdef __OpenBSD__ /* read_bsd_terminfo.c: terminfo.db reading */ diff --git a/lib/libcurses/tic.h b/lib/libcurses/tic.h index 25e059eeb63..52d68301197 100644 --- a/lib/libcurses/tic.h +++ b/lib/libcurses/tic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tic.h,v 1.3 1999/01/24 20:06:45 millert Exp $ */ +/* $OpenBSD: tic.h,v 1.4 1999/02/24 06:31:07 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -141,6 +141,27 @@ struct token extern struct token _nc_curr_token; /* + * List of keynames with their corresponding code. + */ +struct kn { + const char *name; + int code; +}; + +extern const struct kn _nc_key_names[]; + + /* + * Offsets to string capabilities, with the corresponding functionkey + * codes. + */ +struct tinfo_fkeys { + unsigned offset; + chtype code; + }; + +extern struct tinfo_fkeys _nc_tinfo_fkeys[]; + + /* * The file comp_captab.c contains an array of these structures, one * per possible capability. These are indexed by a hash table array of * pointers to the same structures for use by the parser. diff --git a/lib/libcurses/tinfo/comp_parse.c b/lib/libcurses/tinfo/comp_parse.c index 6416db292ae..954f8e10d37 100644 --- a/lib/libcurses/tinfo/comp_parse.c +++ b/lib/libcurses/tinfo/comp_parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: comp_parse.c,v 1.1 1999/01/18 19:10:14 millert Exp $ */ +/* $OpenBSD: comp_parse.c,v 1.2 1999/02/24 06:31:10 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -57,9 +57,10 @@ #include <term.h> #include <term_entry.h> -MODULE_ID("$From: comp_parse.c,v 1.23 1998/05/30 23:38:15 Todd.Miller Exp $") +MODULE_ID("$From: comp_parse.c,v 1.26 1999/02/19 10:38:13 tom Exp $") static void sanity_check(TERMTYPE *); +void (*_nc_check_termtype)(TERMTYPE *) = sanity_check; /**************************************************************************** * @@ -418,16 +419,18 @@ int _nc_resolve_uses(void) DEBUG(2, ("RESOLUTION FINISHED")); - _nc_curr_col = -1; - for_entry_list(qp) + if (_nc_check_termtype != 0) { - _nc_curr_line = qp->startline; - _nc_set_type(_nc_first_name(qp->tterm.term_names)); - sanity_check(&qp->tterm); + _nc_curr_col = -1; + for_entry_list(qp) + { + _nc_curr_line = qp->startline; + _nc_set_type(_nc_first_name(qp->tterm.term_names)); + _nc_check_termtype(&qp->tterm); + } + DEBUG(2, ("SANITY CHECK FINISHED")); } - DEBUG(2, ("SANITY CHECK FINISHED")); - return(TRUE); } @@ -440,33 +443,12 @@ int _nc_resolve_uses(void) #undef CUR #define CUR tp-> -/* - * Note that WANTED and PRESENT are not simple inverses! If a capability - * has been explicitly cancelled, it's not considered WANTED. - */ -#define WANTED(s) ((s) == ABSENT_STRING) -#define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING)) - -#define ANDMISSING(p,q) \ - {if (PRESENT(p) && !PRESENT(q)) _nc_warning(#p " but no " #q);} - -#define PAIRED(p,q) \ - { \ - if (PRESENT(q) && !PRESENT(p)) \ - _nc_warning(#q " but no " #p); \ - if (PRESENT(p) && !PRESENT(q)) \ - _nc_warning(#p " but no " #q); \ - } - static void sanity_check(TERMTYPE *tp) { -#ifdef __UNUSED__ /* this casts too wide a net */ - bool terminal_entry = !strchr(tp->term_names, '+'); -#endif - if (!PRESENT(exit_attribute_mode)) { #ifdef __UNUSED__ /* this casts too wide a net */ + bool terminal_entry = !strchr(tp->term_names, '+'); if (terminal_entry && (PRESENT(set_attributes) || PRESENT(enter_standout_mode) @@ -484,10 +466,6 @@ static void sanity_check(TERMTYPE *tp) } /* listed in structure-member order of first argument */ -#ifdef __UNUSED__ - ANDMISSING(cursor_invisible, cursor_normal) - ANDMISSING(cursor_visible, cursor_normal) -#endif /* __UNUSED__ */ PAIRED(enter_alt_charset_mode, exit_alt_charset_mode) ANDMISSING(enter_alt_charset_mode, acs_chars) ANDMISSING(exit_alt_charset_mode, acs_chars) @@ -510,30 +488,4 @@ static void sanity_check(TERMTYPE *tp) ANDMISSING(label_off, label_on) PAIRED(display_clock, remove_clock) ANDMISSING(set_color_pair, initialize_pair) - - /* Some checks that we should make, but don't want to confuse people - * with. Put those under the tic -v option so we can still get them. - */ - if (_nc_tracing) { - - /* - * From XSI & O'Reilly, we gather that sc/rc are required if csr is - * given, because the cursor position after the scrolling operation is - * performed is undefined. - */ - ANDMISSING(change_scroll_region, save_cursor) - ANDMISSING(change_scroll_region, restore_cursor) - - /* - * Some non-curses applications (e.g., jove) get confused if we have - * both ich/ich1 and smir/rmir. Let's be nice and warn about that, - * too, even though ncurses handles it. - */ - if ((PRESENT(enter_insert_mode) || PRESENT(exit_insert_mode)) - && (PRESENT(insert_character) || PRESENT(parm_ich))) { - _nc_warning("non-curses applications may be confused by ich/ich1 with smir/rmir"); - } - } -#undef PAIRED -#undef ANDMISSING } diff --git a/lib/libcurses/tinfo/init_keytry.c b/lib/libcurses/tinfo/init_keytry.c new file mode 100644 index 00000000000..312b15d4d0b --- /dev/null +++ b/lib/libcurses/tinfo/init_keytry.c @@ -0,0 +1,69 @@ +/* $OpenBSD: init_keytry.c,v 1.1 1999/02/24 06:31:10 millert Exp $ */ + +/**************************************************************************** + * Copyright (c) 1999 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +#include <curses.priv.h> + +#include <term.h> /* keypad_xmit, keypad_local, meta_on, meta_off */ + /* cursor_visible,cursor_normal,cursor_invisible */ +#include <tic.h> /* struct tinfo_fkeys */ + +MODULE_ID("$From: init_keytry.c,v 1.1 1999/02/18 22:39:11 tom Exp $") + +/* +** _nc_init_keytry() +** +** Construct the try for the current terminal's keypad keys. +** +*/ + +/* LINT_PREPRO +#if 0*/ +#include <init_keytry.h> +/* LINT_PREPRO +#endif*/ + +void _nc_init_keytry(void) +{ + size_t n; + + /* The SP->_keytry value is initialized in newterm(), where the SP + * structure is created, because we can not tell where keypad() or + * mouse_activate() (which will call keyok()) are first called. + */ + + for (n = 0; _nc_tinfo_fkeys[n].code; n++) + if (_nc_tinfo_fkeys[n].offset < STRCOUNT) + _nc_add_to_try(&(SP->_keytry), + CUR Strings[_nc_tinfo_fkeys[n].offset], + _nc_tinfo_fkeys[n].code); +#ifdef TRACE + _nc_trace_tries(SP->_keytry); +#endif +} diff --git a/lib/libcurses/tinfo/lib_acs.c b/lib/libcurses/tinfo/lib_acs.c index ffbd078af01..f0ae29c1742 100644 --- a/lib/libcurses/tinfo/lib_acs.c +++ b/lib/libcurses/tinfo/lib_acs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_acs.c,v 1.1 1999/01/18 19:10:16 millert Exp $ */ +/* $OpenBSD: lib_acs.c,v 1.2 1999/02/24 06:31:11 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -38,11 +38,11 @@ #include <curses.priv.h> #include <term.h> /* ena_acs, acs_chars */ -MODULE_ID("$From: lib_acs.c,v 1.14 1999/01/02 22:37:49 tom Exp $") +MODULE_ID("$From: lib_acs.c,v 1.15 1999/02/18 11:31:43 tom Exp $") chtype acs_map[ACS_LEN]; -void init_acs(void) +void _nc_init_acs(void) { T(("initializing ACS map")); diff --git a/lib/libcurses/tinfo/lib_options.c b/lib/libcurses/tinfo/lib_options.c index 3ab600ab653..af3d67d0b2d 100644 --- a/lib/libcurses/tinfo/lib_options.c +++ b/lib/libcurses/tinfo/lib_options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_options.c,v 1.1 1999/01/18 19:10:18 millert Exp $ */ +/* $OpenBSD: lib_options.c,v 1.2 1999/02/24 06:31:11 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -46,7 +46,7 @@ #include <term.h> /* keypad_xmit, keypad_local, meta_on, meta_off */ /* cursor_visible,cursor_normal,cursor_invisible */ -MODULE_ID("$From: lib_options.c,v 1.32 1998/12/19 23:09:50 tom Exp $") +MODULE_ID("$From: lib_options.c,v 1.34 1999/02/18 11:56:16 tom Exp $") int idlok(WINDOW *win, bool flag) { @@ -233,34 +233,6 @@ int has_key(int keycode) } #endif /* NCURSES_EXT_FUNCS */ -/* -** init_keytry() -** -** Construct the try for the current terminal's keypad keys. -** -*/ - -static void init_keytry(void) -{ -/* LINT_PREPRO -#if 0*/ -#include <keys.tries> -/* LINT_PREPRO -#endif*/ - size_t n; - - /* The SP->_keytry value is initialized in newterm(), where the SP - * structure is created, because we can not tell where keypad() or - * mouse_activate() (which will call keyok()) are first called. - */ - - for (n = 0; n < SIZEOF(table); n++) - if (table[n].offset < STRCOUNT) - _nc_add_to_try(&(SP->_keytry), - CUR Strings[table[n].offset], - table[n].code); -} - /* Turn the keypad on/off * * Note: we flush the output because changing this mode causes some terminals @@ -284,7 +256,7 @@ int _nc_keypad(bool flag) } if (!SP->_tried) { - init_keytry(); + _nc_init_keytry(); SP->_tried = TRUE; } return(OK); diff --git a/lib/libcurses/tinfo/make_keys.c b/lib/libcurses/tinfo/make_keys.c index 70617a42519..876b942cb09 100644 --- a/lib/libcurses/tinfo/make_keys.c +++ b/lib/libcurses/tinfo/make_keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: make_keys.c,v 1.1 1999/01/18 19:10:21 millert Exp $ */ +/* $OpenBSD: make_keys.c,v 1.2 1999/02/24 06:31:11 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -39,7 +39,7 @@ */ #include <curses.priv.h> -MODULE_ID("$From: make_keys.c,v 1.4 1998/02/11 12:13:57 tom Exp $") +MODULE_ID("$From: make_keys.c,v 1.5 1999/02/18 22:38:41 tom Exp $") #include <names.c> @@ -105,14 +105,11 @@ int main(int argc, char *argv[]) "", "/* This file was generated by MAKE_KEYS */", "", - "static const struct {", - "\tunsigned offset;", - "\tchtype code;", - "} table[] = {", + "struct tinfo_fkeys _nc_tinfo_fkeys[] = {", 0 }; static const char *suffix[] = { - "};", + " { 0, 0} };", "", "#endif /* NCU_KEYS_H */", 0 diff --git a/lib/libcurses/trace/trace_tries.c b/lib/libcurses/trace/trace_tries.c new file mode 100644 index 00000000000..27acd6d4ab7 --- /dev/null +++ b/lib/libcurses/trace/trace_tries.c @@ -0,0 +1,76 @@ +/* $OpenBSD: trace_tries.c,v 1.1 1999/02/24 06:31:11 millert Exp $ */ + +/**************************************************************************** + * Copyright (c) 1999 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Thomas E. Dickey <dickey@clark.net> 1999 * + ****************************************************************************/ +/* + * trace_tries.c - Tracing/Debugging buffers (keycode tries-trees) + */ + +#include <curses.priv.h> + +MODULE_ID("$From: trace_tries.c,v 1.3 1999/02/19 04:05:26 tom Exp $") + +#ifdef TRACE +static char *buffer; +static unsigned len; + +static void recur_tries(struct tries *tree, unsigned level) +{ + if (level > len) + buffer = realloc(buffer, len = (level + 1) * 4); + + while (tree != 0) { + if ((buffer[level] = tree->ch) == 0) + buffer[level] = 128; + buffer[level+1] = 0; + if (tree->value != 0) { + _tracef("%5d: %s (%s)", tree->value, _nc_visbuf(buffer), keyname(tree->value)); + } + if (tree->child) + recur_tries(tree->child, level+1); + tree = tree->sibling; + } +} + +void _nc_trace_tries(struct tries *tree) +{ + buffer = malloc(len = 80); + _tracef("BEGIN tries %p", tree); + recur_tries(tree, 0); + _tracef(". . . tries %p", tree); + free(buffer); +} +#else +void _nc_trace_tries(struct tries *tree GCC_UNUSED) +{ +} +#endif |