2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 #ifdef VERBOSE_REV_INFO
25 static char rcs_id[] = "$XConsortium: TermFunctionKey.c /main/1 1996/04/21 19:15:53 drk $";
26 #endif /* VERBOSE_REV_INFO */
30 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
31 * (c) Copyright 1993, 1994 International Business Machines Corp. *
32 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
33 * (c) Copyright 1993, 1994 Novell, Inc. *
36 #include "TermHeader.h"
38 #include "TermPrimI.h"
40 /* #include "TermFunctionKeyP.h" */
41 /* #include "TermPrimFunction.h" */
42 #include "TermSendEsc.h"
44 #define NO_SUN_FUNC_KEYS 35
45 #define NO_VT_FUNC_KEYS 20
47 static char *functionKey[] = { F1_VT,F2_VT,F3_VT,F4_VT,F5_VT,F6_VT,F7_VT,F8_VT,F9_VT,F10_VT,F11_VT,F12_VT,F13_VT,F14_VT,F15_VT,F16_VT,F17_VT,F18_VT,F19_VT,F20_VT};
48 static char *sunFunctionKey[] = { F1_VT_SUN,F2_VT_SUN,F3_VT_SUN,F4_VT_SUN,F5_VT_SUN,F6_VT_SUN,F7_VT_SUN,F8_VT_SUN,F9_VT_SUN,F10_VT_SUN,F11_VT_SUN,F12_VT_SUN,F13_VT_SUN,F14_VT_SUN,F15_VT_SUN,F16_VT_SUN,F17_VT_SUN,F18_VT_SUN,F19_VT_SUN,F20_VT_SUN,F21_VT_SUN,F22_VT_SUN,F23_VT_SUN,F24_VT_SUN,F25_VT_SUN,F26_VT_SUN,F27_VT_SUN,F28_VT_SUN,F29_VT_SUN,F30_VT_SUN,F31_VT_SUN,F32_VT_SUN,F33_VT_SUN,F34_VT_SUN,F35_VT_SUN};
51 /* NOTE: the following function assumes that the keys start at 0
52 * (i.e., F1 == 0, F2 == 1, etc)...
55 _DtTermFunctionKeyExecute(
61 DtTermWidget tw = (DtTermWidget) w;
62 DtTermData td = tw->vt.td;
64 if (!shift || tw->vt.sunFunctionKeys == True ) {
65 if ( tw->vt.sunFunctionKeys == True ) {
66 if ( --keyNumber < NO_SUN_FUNC_KEYS )
67 (void) _DtTermWriteEscSeq(w, sunFunctionKey[keyNumber]);
70 if ( --keyNumber < NO_VT_FUNC_KEYS )
71 (void) _DtTermWriteEscSeq(w, functionKey[keyNumber]);
74 (void) _DtTermFunctionKeyUserKeyExecute(w, keyNumber, shift);
78 /* NOTE: the following function assumes that the keys start at 0
79 * (i.e., F1 == 0, F2 == 1, etc)...
82 _DtTermFunctionKeyUserKeyExecute(
88 DtTermWidget tw = (DtTermWidget) w;
89 DtTermData td = tw->vt.td;
91 keyno -= 6 ; /* valid keys are F6-F20 */
92 if ( keyno >= 0 && keyno <= NO_USER_KEY_STRINGS
93 && td->userKeyString[keyno] )
94 _DtTermPrimSendInput(w,td->userKeyString[keyno],
95 strlen((char *)td->userKeyString[keyno])) ;
99 _DtTermFunctionKeyStringStore( /* store the label for the given key number */
105 DtTermWidget tw = (DtTermWidget) w;
106 DtTermData td = tw->vt.td;
110 case 17: ukey = 0 ; break;
111 case 18: ukey = 1 ; break;
112 case 19: ukey = 2 ; break;
113 case 20: ukey = 3 ; break;
114 case 21: ukey = 4 ; break;
115 case 23: ukey = 5 ; break;
116 case 24: ukey = 6 ; break;
117 case 25: ukey = 7 ; break;
118 case 26: ukey = 8 ; break;
119 case 28: ukey = 9; break;
120 case 29: ukey = 10 ; break;
121 case 31: ukey = 11 ; break;
122 case 32: ukey = 12 ; break;
123 case 33: ukey = 13 ; break;
124 case 34: ukey = 14 ; break;
125 default: ukey = -1 ; break;
127 if (ukey == -1) return ;
128 if (td->userKeyString[ukey]) free(td->userKeyString[ukey]) ;
129 td->userKeyString[ukey] = malloc(strlen(string)+1) ;
130 strcpy((char *)td->userKeyString[ukey],string) ;
134 _DtTermFunctionKeyClear(
138 DtTermWidget tw = (DtTermWidget) w;
139 DtTermData td = tw->vt.td;
142 for (i=0; i<=NO_USER_KEY_STRINGS ; i++) {
143 if (td->userKeyString[i]) {
144 free(td->userKeyString[i]) ;
145 td->userKeyString[i] = 0;
150 _DtTermFunctionKeyInit(
154 DtTermWidget tw = (DtTermWidget) w;
155 DtTermData td = tw->vt.td;
158 for (i=0; i<=NO_USER_KEY_STRINGS ; i++) {
159 td->userKeyString[i] = 0;