GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libcurses/tinfo/init_keytry.c Lines: 0 15 0.0 %
Date: 2017-11-07 Branches: 0 16 0.0 %

Line Branch Exec Source
1
/* $OpenBSD: init_keytry.c,v 1.6 2010/01/12 23:22:06 nicm Exp $ */
2
3
/****************************************************************************
4
 * Copyright (c) 1999-2006,2008 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>
34
/* keypad_xmit, keypad_local, meta_on, meta_off */
35
/* cursor_visible,cursor_normal,cursor_invisible */
36
37
#include <tic.h>		/* struct tinfo_fkeys */
38
39
#include <term_entry.h>
40
41
MODULE_ID("$Id: init_keytry.c,v 1.6 2010/01/12 23:22:06 nicm Exp $")
42
43
/*
44
**      _nc_init_keytry()
45
**
46
**      Construct the try for the current terminal's keypad keys.
47
**
48
*/
49
50
/*
51
 * Internal entrypoints use SCREEN* parameter to obtain capabilities rather
52
 * than cur_term.
53
 */
54
#undef CUR
55
#define CUR (sp->_term)->type.
56
57
#if	BROKEN_LINKER
58
#undef	_nc_tinfo_fkeys
59
#endif
60
61
/* LINT_PREPRO
62
#if 0*/
63
#include <init_keytry.h>
64
/* LINT_PREPRO
65
#endif*/
66
67
#if	BROKEN_LINKER
68
const struct tinfo_fkeys *
69
_nc_tinfo_fkeysf(void)
70
{
71
    return _nc_tinfo_fkeys;
72
}
73
#endif
74
75
NCURSES_EXPORT(void)
76
_nc_init_keytry(SCREEN *sp)
77
{
78
    size_t n;
79
80
    /* The sp->_keytry value is initialized in newterm(), where the sp
81
     * structure is created, because we can not tell where keypad() or
82
     * mouse_activate() (which will call keyok()) are first called.
83
     */
84
85
    if (sp != 0) {
86
	for (n = 0; _nc_tinfo_fkeys[n].code; n++) {
87
	    if (_nc_tinfo_fkeys[n].offset < STRCOUNT) {
88
		(void) _nc_add_to_try(&(sp->_keytry),
89
				      CUR Strings[_nc_tinfo_fkeys[n].offset],
90
				      _nc_tinfo_fkeys[n].code);
91
	    }
92
	}
93
#if NCURSES_XNAMES
94
	/*
95
	 * Add any of the extended strings to the tries if their name begins
96
	 * with 'k', i.e., they follow the convention of other terminfo key
97
	 * names.
98
	 */
99
	{
100
	    TERMTYPE *tp = &(sp->_term->type);
101
	    for (n = STRCOUNT; n < NUM_STRINGS(tp); ++n) {
102
		const char *name = ExtStrname(tp, n, strnames);
103
		char *value = tp->Strings[n];
104
		if (name != 0
105
		    && *name == 'k'
106
		    && value != 0
107
		    && key_defined(value) == 0) {
108
		    (void) _nc_add_to_try(&(sp->_keytry),
109
					  value,
110
					  n - STRCOUNT + KEY_MAX);
111
		}
112
	    }
113
	}
114
#endif
115
#ifdef TRACE
116
	_nc_trace_tries(sp->_keytry);
117
#endif
118
    }
119
}