1 /****************************************************************************
2 * Copyright (c) 1999-2005,2006 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 #include <curses.priv.h>
32 /* keypad_xmit, keypad_local, meta_on, meta_off */
33 /* cursor_visible,cursor_normal,cursor_invisible */
35 #include <tic.h> /* struct tinfo_fkeys */
37 #include <term_entry.h>
39 MODULE_ID("$Id: init_keytry.c,v 1.10 2007/04/29 22:57:50 tom Exp $")
44 ** Construct the try for the current terminal's keypad keys.
49 #undef _nc_tinfo_fkeys
54 #include <init_keytry.h>
59 const struct tinfo_fkeys *
60 _nc_tinfo_fkeysf(void)
62 return _nc_tinfo_fkeys;
71 /* The SP->_keytry value is initialized in newterm(), where the SP
72 * structure is created, because we can not tell where keypad() or
73 * mouse_activate() (which will call keyok()) are first called.
77 for (n = 0; _nc_tinfo_fkeys[n].code; n++) {
78 if (_nc_tinfo_fkeys[n].offset < STRCOUNT) {
79 (void) _nc_add_to_try(&(SP->_keytry),
80 CUR Strings[_nc_tinfo_fkeys[n].offset],
81 _nc_tinfo_fkeys[n].code);
86 * Add any of the extended strings to the tries if their name begins
87 * with 'k', i.e., they follow the convention of other terminfo key
91 TERMTYPE *tp = &(SP->_term->type);
92 for (n = STRCOUNT; n < NUM_STRINGS(tp); ++n) {
93 const char *name = ExtStrname(tp, n, strnames);
94 char *value = tp->Strings[n];
98 && key_defined(value) == 0) {
99 (void) _nc_add_to_try(&(SP->_keytry),
101 n - STRCOUNT + KEY_MAX);
107 _nc_trace_tries(SP->_keytry);