define_key.c revision 76726
138032Speter/**************************************************************************** 298121Sgshapiro * Copyright (c) 1998,2000 Free Software Foundation, Inc. * 364562Sgshapiro * * 438032Speter * Permission is hereby granted, free of charge, to any person obtaining a * 538032Speter * copy of this software and associated documentation files (the * 638032Speter * "Software"), to deal in the Software without restriction, including * 738032Speter * without limitation the rights to use, copy, modify, merge, publish, * 838032Speter * distribute, distribute with modifications, sublicense, and/or sell * 938032Speter * copies of the Software, and to permit persons to whom the Software is * 1038032Speter * furnished to do so, subject to the following conditions: * 1138032Speter * * 1238032Speter * The above copyright notice and this permission notice shall be included * 1338032Speter * in all copies or substantial portions of the Software. * 1464562Sgshapiro * * 1538032Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1698121Sgshapiro * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1764562Sgshapiro * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1864562Sgshapiro * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1964562Sgshapiro * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2090792Sgshapiro * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2190792Sgshapiro * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2290792Sgshapiro * * 2364562Sgshapiro * Except as contained in this notice, the name(s) of the above copyright * 2490792Sgshapiro * holders shall not be used in advertising or otherwise to promote the * 2590792Sgshapiro * sale, use or other dealings in this Software without prior written * 2638032Speter * authorization. * 2790792Sgshapiro ****************************************************************************/ 2890792Sgshapiro 2990792Sgshapiro/**************************************************************************** 3090792Sgshapiro * Author: Thomas E. Dickey <dickey@clark.net> 1997 * 3190792Sgshapiro ****************************************************************************/ 3290792Sgshapiro 3390792Sgshapiro#include <curses.priv.h> 3490792Sgshapiro 3590792SgshapiroMODULE_ID("$Id: define_key.c,v 1.6 2000/12/10 02:43:26 tom Exp $") 3690792Sgshapiro 3790792SgshapiroNCURSES_EXPORT(int) 3890792Sgshapirodefine_key 3990792Sgshapiro(char *str, int keycode) 4090792Sgshapiro{ 4190792Sgshapiro int code = ERR; 4290792Sgshapiro 4390792Sgshapiro T((T_CALLED("define_key(%s,%d)"), _nc_visbuf(str), keycode)); 4490792Sgshapiro if (keycode > 0) { 4590792Sgshapiro if (str != 0) { 4690792Sgshapiro define_key(str, 0); 4790792Sgshapiro } else if (has_key(keycode)) { 4890792Sgshapiro while (_nc_remove_key(&(SP->_keytry), keycode)) 4990792Sgshapiro code = OK; 5090792Sgshapiro } 5190792Sgshapiro if (str != 0) { 5290792Sgshapiro (void) _nc_add_to_try(&(SP->_keytry), str, keycode); 5390792Sgshapiro code = OK; 5490792Sgshapiro } 5590792Sgshapiro } else { 5690792Sgshapiro while (_nc_remove_string(&(SP->_keytry), str)) 5790792Sgshapiro code = OK; 5890792Sgshapiro } 5990792Sgshapiro returnCode(code); 6090792Sgshapiro} 6190792Sgshapiro