head 1.5; access; symbols ISELECT_1_4_0:1.5 ISELECT_1_3_1:1.4 ISELECT_1_3_0:1.3 ISELECT_1_2_0:1.1.1.2 ISELECT_1_1_0:1.1.1.1 vendor:1.1.1; locks; strict; comment @ * @; 1.5 date 2007.07.08.09.28.11; author rse; state Exp; branches; next 1.4; commitid P0IqEKWWbsvcIWos; 1.4 date 2005.10.05.18.19.42; author rse; state Exp; branches; next 1.3; 1.3 date 2004.09.11.15.18.49; author rse; state Exp; branches; next 1.2; 1.2 date 2000.07.25.11.44.00; author rse; state Exp; branches; next 1.1; 1.1 date 98.04.05.14.01.09; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 98.04.05.14.01.09; author rse; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 99.03.31.06.43.01; author rse; state Exp; branches; next ; desc @@ 1.5 log @bump up version and copyright information @ text @/* _ ____ _ _ ** (_) ___| ___| | ___ ___| |_ ** / /\___ \ / _ \ |/ _ \/ __| __| ** / / ___) | __/ | __/ (__| |_ ** (_( |____/ \___|_|\___|\___|\__| ** ** iSelect -- Interactive Selection Tool ** ** iSelect is a Curses-based tool for interactive line selection ** in an ASCII file via a full-screen terminal session. ** ** ====================================================================== ** ** Copyright (c) 1997-2007 Ralf S. Engelschall. ** ** This program is free software; it may be redistributed and/or ** modified only under the terms of the GNU General Public License, ** which may be found in the iSelect source distribution. ** Look at the file COPYING for details. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ** See the the GNU General Public License for more details. ** ** ====================================================================== ** ** iselect_keys.c -- custom Curses Key definition */ #include "config_ac.h" #include "config_sc.h" #include #include #include #include #ifdef USE_NCURSES #include #endif #ifdef USE_SLCURSES #include #endif #ifdef USE_CURSES #include #endif #include "iselect_global.h" #include "iselect_keys.h" CustomKey *KeyList[1024] = { NULL }; typedef struct keydef { char *str; int key; } keydef; keydef KeyDef[] = { { "SPACE", ' ' }, { "RETURN", '\n' }, { "KEY_LEFT", KEY_LEFT }, { "KEY_RIGHT", KEY_RIGHT }, { "KEY_UP", KEY_UP }, { "KEY_DOWN", KEY_DOWN }, { "KEY_NPAGE", KEY_NPAGE }, { "KEY_PPAGE", KEY_PPAGE }, { NULL, 0 } }; char *key2asc(int key) { char ca[1024]; int i; if (key >= 32 && key <= 126) { ca[0] = (char)(key); ca[1] = NUL; return strdup(ca); } else { for (i = 0; KeyDef[i].str != NULL; i++) { if (KeyDef[i].key == key) return strdup(KeyDef[i].str); } } return "UNKNOWN"; } int asc2key(char *str) { int i; if (strlen(str) == 1 && (str[0] >= 32 && str[0] <= 126)) return (int)(str[0]); else { for (i = 0; KeyDef[i].str != NULL; i++) { if (strcmp(KeyDef[i].str, str) == 0) return KeyDef[i].key; } fprintf(stderr, "ERROR\n"); exit(1); } } void configure_custom_key(char *config) { char out[1024]; char in[1024]; char *cp; CustomKey *kc; int i; if ((cp = strchr(config, ':')) != NULL) { strncpy(in, config, cp-config); in[cp-config] = NUL; strcpy(out, cp+1); } else { strcpy(in, config); strcpy(out, "RETURN"); } kc = (CustomKey *)malloc(sizeof(CustomKey)); kc->in = asc2key(in); kc->out = asc2key(out); for (i = 0; KeyList[i] != NULL; i++) ; KeyList[i++] = kc; KeyList[i++] = NULL; return; } int do_custom_key(int key) { int i; for (i = 0; KeyList[i] != NULL; i++) { if (KeyList[i]->in == key) key = KeyList[i]->out; } return key; } /*EOF*/ @ 1.4 log @adjust copyright yearW @ text @d14 1 a14 1 ** Copyright (c) 1997-2005 Ralf S. Engelschall. @ 1.3 log @modernize source tree @ text @d14 1 a14 1 ** Copyright (c) 1997-2004 Ralf S. Engelschall. @ 1.2 log @Merge in pending changes @ text @d14 1 a14 1 ** Copyright (c) 1996-1999 Ralf S. Engelschall. d39 1 a39 1 #include @ 1.1 log @Initial revision @ text @d14 1 a14 1 ** Copyright (c) 1996,1997,1998 Ralf S. Engelschall. d16 9 a24 10 ** This program is free software; it may be redistributed and/or modified ** only under the terms of either the Artistic License or the GNU General ** Public License, which may be found in the ePerl source distribution. ** Look at the files ARTISTIC and COPYING or run ``eperl -l'' to receive ** a built-in copy of both license files. ** ** This program is distributed in the hope that it will be useful, but ** WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the ** Artistic License or the GNU General Public License for more details. d67 1 a67 1 { NULL, NULL } @ 1.1.1.1 log @Import iSelect 1.1.0 @ text @@ 1.1.1.2 log @Import iSelect 1.2.0 @ text @d14 1 a14 1 ** Copyright (c) 1996-1999 Ralf S. Engelschall. d16 10 a25 9 ** This program is free software; it may be redistributed and/or ** modified only under the terms of the GNU General Public License, ** which may be found in the iSelect source distribution. ** Look at the file COPYING for details. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ** See the the GNU General Public License for more details. @