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: TermPrimAction.c /main/1 1996/04/21 19:16:44 drk $";
26 #endif /* VERBOSE_REV_INFO */
30 * (c) Copyright 1993, 1994, 1996 Hewlett-Packard Company *
31 * (c) Copyright 1993, 1994, 1996 International Business Machines Corp. *
32 * (c) Copyright 1993, 1994, 1996 Sun Microsystems, Inc. *
33 * (c) Copyright 1993, 1994, 1996 Novell, Inc. *
34 * (c) Copyright 1996 Digital Equipment Corporation. *
35 * (c) Copyright 1996 FUJITSU LIMITED. *
36 * (c) Copyright 1996 Hitachi. *
39 #include "TermHeader.h"
40 #include "TermPrimDebug.h"
41 #include "TermPrimP.h"
42 #include "TermPrimI.h"
43 #include "TermPrimData.h"
44 #include "TermPrimAction.h"
45 #include "TermPrimFunction.h"
48 invokeAction(Widget w, char *transmitString, TermFunction function, int count)
50 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
51 struct termData *tpd = tw->term.tpd;
53 if (KEYBOARD_LOCKED(tpd->keyboardLocked)) {
54 /* keyboard locked -- ring the bell...
56 (void) _DtTermPrimBell(w);
57 } else if (tpd->transmitFunctions && transmitString) {
58 /* transmit functions mode -- transmit them...
60 (void) _DtTermPrimSendInput(w, (unsigned char *) transmitString,
61 strlen(transmitString));
63 /* perform the function...
65 (*function)(w, count, fromAction);
68 /* we need to wait for the scroll to complete before turning
71 (void) _DtTermPrimScrollComplete(w, True);
73 (void) _DtTermPrimCursorOn(w);
84 stringToEnum(char *c, EnumType *enumTypes, int numEnumTypes)
88 for (i = 0; i < numEnumTypes; i++) {
89 if (!strcmp(enumTypes[i].string, c))
97 /*** INSERT CHAR/LINE *********************************************************
99 * # # # #### ###### ##### #####
101 * # # # # #### ##### # # #
102 * # # # # # # ##### #
104 * # # # #### ###### # # #
107 * #### # # ## ##### # # # # # ######
108 * # # # # # # # # # # # ## # #
109 * # ###### # # # # # # # # # # #####
110 * # # # ###### ##### # # # # # # #
111 * # # # # # # # # # # # # ## #
112 * #### # # # # # # # ###### # # # ######
116 _DtTermPrimActionInsert(Widget w, XEvent *event,
117 String *params, Cardinal *num_params)
119 Debug('i', fprintf(stderr,
120 ">>_DtTermPrimActionInsert: not yet implemented\n"));
125 /*** CURSOR MOTION ************************************************************
127 * #### # # ##### #### #### #####
128 * # # # # # # # # # # #
129 * # # # # # #### # # # #
130 * # # # ##### # # # #####
131 * # # # # # # # # # # # #
132 * #### #### # # #### #### # #
135 * # # #### ##### # #### # #
136 * ## ## # # # # # # ## #
137 * # ## # # # # # # # # # #
138 * # # # # # # # # # # #
139 * # # # # # # # # # ##
140 * # # #### # # #### # #
144 _DtTermPrimActionRedrawDisplay(Widget w, XEvent *event,
145 String *params, Cardinal *num_params)
147 (void) invokeAction(w, NULL, _DtTermPrimFuncRedrawDisplay, 1);
153 _DtTermPrimActionReturn(Widget w, XEvent *event,
154 String *params, Cardinal *num_params)
156 Debug('i', fprintf(stderr,
157 ">>_DtTermPrimActionReturn: not yet implemented\n"));
162 _DtTermPrimActionTab(Widget w, XEvent *event,
163 String *params, Cardinal *num_params)
165 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
166 struct termData *tpd = tw->term.tpd;
167 Boolean shiftedTab = False;
168 Boolean numericTab = False;
171 (void) _DtTermPrimSendInput(w, (unsigned char *) "\t", 1);
176 /*** STRING *******************************************************************
178 * #### ##### ##### # # # ####
180 * #### # # # # # # # #
181 * # # ##### # # # # # ###
182 * # # # # # # # ## # #
183 * #### # # # # # # ####
187 _DtTermPrimActionString(Widget w, XEvent *event, String *params, Cardinal *num_params)
190 unsigned char hexVal;
192 /* this is based on the functionality offered by xterm...
195 if (*num_params != 1)
198 /* process hex values... */
199 if (((*params)[0] == '0') &&
200 (((*params)[1] == 'x') || ((*params)[1] == 'X')) &&
201 ((*params)[2] != '\0')) {
202 for (hexVal = 0, c = (unsigned char *) (*params + 2); *c; c++) {
205 if ((*c >= '0') && (*c <= '9')) {
207 } else if ((*c >= 'a') && (*c <= 'f')) {
208 hexVal += *c - 'a' + 10;
213 /* if we hit the end of the string, send the hex value... */
215 (void) _DtTermPrimSendInput(w, &hexVal, 1);
218 (void) _DtTermPrimSendInput(w, (unsigned char *) *params, strlen(*params));
224 /*** KEYMAP *******************************************************************
226 * # # ###### # # # # ## #####
227 * # # # # # ## ## # # # #
228 * #### ##### # # ## # # # # #
229 * # # # # # # ###### #####
231 * # # ###### # # # # # #
235 _DtTermPrimActionKeymap(Widget w, XEvent *event, String *params, Cardinal *num_params)
237 XtTranslations keymap;
239 static XtTranslations original = (XtTranslations) 0;
240 static XtResource key_resources[] = {
241 {XtNtranslations, XtCTranslations, XtRTranslationTable,
242 sizeof(XtTranslations), 0, XtRTranslationTable, (caddr_t) NULL}
244 char mapName[BUFSIZ];
245 char mapClass[BUFSIZ];
247 if (*num_params != 1) {
251 _DtTermProcessLock();
252 if (original == (XtTranslations) 0) {
253 original = w->core.tm.translations;
255 _DtTermProcessUnlock();
257 if (!strcmp(params[0], "None")) {
258 (void) XtOverrideTranslations(w, original);
262 (void) sprintf(mapName, "%sKeymap", params[0]);
263 (void) strcpy(mapClass, mapName);
264 mapClass[0] = toupper(mapClass[0]);
265 (void) XtGetSubresources(w, (XtPointer) &keymap, mapName, mapClass,
266 key_resources, XtNumber(key_resources), NULL, (Cardinal) 0);
268 if (keymap != NULL) {
269 (void) XtOverrideTranslations(w, keymap);