xref: /openbsd-src/lib/libcurses/tinfo/init_keytry.c (revision a28daedfc357b214be5c701aa8ba8adb29a7f1c2)
1 /*	$OpenBSD: init_keytry.c,v 1.5 2001/01/22 18:01:51 millert Exp $	*/
2 
3 /****************************************************************************
4  * Copyright (c) 1999,2000 Free Software Foundation, Inc.                   *
5  *                                                                          *
6  * Permission is hereby granted, free of charge, to any person obtaining a  *
7  * copy of this software and associated documentation files (the            *
8  * "Software"), to deal in the Software without restriction, including      *
9  * without limitation the rights to use, copy, modify, merge, publish,      *
10  * distribute, distribute with modifications, sublicense, and/or sell       *
11  * copies of the Software, and to permit persons to whom the Software is    *
12  * furnished to do so, subject to the following conditions:                 *
13  *                                                                          *
14  * The above copyright notice and this permission notice shall be included  *
15  * in all copies or substantial portions of the Software.                   *
16  *                                                                          *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24  *                                                                          *
25  * Except as contained in this notice, the name(s) of the above copyright   *
26  * holders shall not be used in advertising or otherwise to promote the     *
27  * sale, use or other dealings in this Software without prior written       *
28  * authorization.                                                           *
29  ****************************************************************************/
30 
31 #include <curses.priv.h>
32 
33 #include <term.h>		/* keypad_xmit, keypad_local, meta_on, meta_off */
34 			/* cursor_visible,cursor_normal,cursor_invisible */
35 #include <tic.h>		/* struct tinfo_fkeys */
36 
37 MODULE_ID("$From: init_keytry.c,v 1.5 2000/12/10 02:55:07 tom Exp $")
38 
39 /*
40 **      _nc_init_keytry()
41 **
42 **      Construct the try for the current terminal's keypad keys.
43 **
44 */
45 
46 #if	BROKEN_LINKER
47 #undef	_nc_tinfo_fkeys
48 #endif
49 
50 /* LINT_PREPRO
51 #if 0*/
52 #include <init_keytry.h>
53 /* LINT_PREPRO
54 #endif*/
55 
56 #if	BROKEN_LINKER
57 struct tinfo_fkeys *
58 _nc_tinfo_fkeysf(void)
59 {
60     return _nc_tinfo_fkeys;
61 }
62 #endif
63 
64 NCURSES_EXPORT(void)
65 _nc_init_keytry(void)
66 {
67     size_t n;
68 
69     /* The SP->_keytry value is initialized in newterm(), where the SP
70      * structure is created, because we can not tell where keypad() or
71      * mouse_activate() (which will call keyok()) are first called.
72      */
73 
74     for (n = 0; _nc_tinfo_fkeys[n].code; n++)
75 	if (_nc_tinfo_fkeys[n].offset < STRCOUNT)
76 	    _nc_add_to_try(&(SP->_keytry),
77 			   CUR Strings[_nc_tinfo_fkeys[n].offset],
78 			   _nc_tinfo_fkeys[n].code);
79 #ifdef TRACE
80     _nc_trace_tries(SP->_keytry);
81 #endif
82 }
83