150276Speter/**************************************************************************** 2178866Srafan * Copyright (c) 1999-2006,2008 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter#include <curses.priv.h> 3050276Speter 31166124Srafan#include <term.h> 32166124Srafan/* keypad_xmit, keypad_local, meta_on, meta_off */ 33166124Srafan/* cursor_visible,cursor_normal,cursor_invisible */ 34166124Srafan 3576726Speter#include <tic.h> /* struct tinfo_fkeys */ 3650276Speter 37166124Srafan#include <term_entry.h> 3850276Speter 39184989SrafanMODULE_ID("$Id: init_keytry.c,v 1.12 2008/05/24 21:44:51 tom Exp $") 40166124Srafan 4150276Speter/* 4250276Speter** _nc_init_keytry() 4350276Speter** 4450276Speter** Construct the try for the current terminal's keypad keys. 4550276Speter** 4650276Speter*/ 4750276Speter 48184989Srafan/* 49184989Srafan * Internal entrypoints use SCREEN* parameter to obtain capabilities rather 50184989Srafan * than cur_term. 51184989Srafan */ 52184989Srafan#undef CUR 53184989Srafan#define CUR (sp->_term)->type. 54184989Srafan 5562449Speter#if BROKEN_LINKER 5656639Speter#undef _nc_tinfo_fkeys 5756639Speter#endif 5856639Speter 5950276Speter/* LINT_PREPRO 6050276Speter#if 0*/ 6150276Speter#include <init_keytry.h> 6250276Speter/* LINT_PREPRO 6350276Speter#endif*/ 6450276Speter 6562449Speter#if BROKEN_LINKER 66174993Srafanconst struct tinfo_fkeys * 6776726Speter_nc_tinfo_fkeysf(void) 6856639Speter{ 6976726Speter return _nc_tinfo_fkeys; 7056639Speter} 7156639Speter#endif 7256639Speter 7376726SpeterNCURSES_EXPORT(void) 74178866Srafan_nc_init_keytry(SCREEN *sp) 7550276Speter{ 7676726Speter size_t n; 7750276Speter 78178866Srafan /* The sp->_keytry value is initialized in newterm(), where the sp 7976726Speter * structure is created, because we can not tell where keypad() or 8076726Speter * mouse_activate() (which will call keyok()) are first called. 8176726Speter */ 8250276Speter 83178866Srafan if (sp != 0) { 84166124Srafan for (n = 0; _nc_tinfo_fkeys[n].code; n++) { 85166124Srafan if (_nc_tinfo_fkeys[n].offset < STRCOUNT) { 86178866Srafan (void) _nc_add_to_try(&(sp->_keytry), 87174993Srafan CUR Strings[_nc_tinfo_fkeys[n].offset], 88174993Srafan _nc_tinfo_fkeys[n].code); 89166124Srafan } 90166124Srafan } 91166124Srafan#if NCURSES_XNAMES 92166124Srafan /* 93166124Srafan * Add any of the extended strings to the tries if their name begins 94166124Srafan * with 'k', i.e., they follow the convention of other terminfo key 95166124Srafan * names. 96166124Srafan */ 97166124Srafan { 98178866Srafan TERMTYPE *tp = &(sp->_term->type); 99166124Srafan for (n = STRCOUNT; n < NUM_STRINGS(tp); ++n) { 100166124Srafan const char *name = ExtStrname(tp, n, strnames); 101166124Srafan char *value = tp->Strings[n]; 102166124Srafan if (name != 0 103166124Srafan && *name == 'k' 104166124Srafan && value != 0 105166124Srafan && key_defined(value) == 0) { 106178866Srafan (void) _nc_add_to_try(&(sp->_keytry), 107174993Srafan value, 108174993Srafan n - STRCOUNT + KEY_MAX); 109166124Srafan } 110166124Srafan } 111166124Srafan } 112166124Srafan#endif 11350276Speter#ifdef TRACE 114178866Srafan _nc_trace_tries(sp->_keytry); 11550276Speter#endif 116166124Srafan } 11750276Speter} 118