File: appKeystrokeMotif.c

package info (click to toggle)
ted 2.16-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 13,944 kB
  • ctags: 20,273
  • sloc: ansic: 167,980; makefile: 12,518; sh: 263
file content (166 lines) | stat: -rw-r--r-- 4,123 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#   include	"appFrameConfig.h"

#   include	<stdlib.h>
#   include	<stdio.h>

#   include	"appFrame.h"

#   ifdef USE_MOTIF

#   include	<X11/Xatom.h>
#   include	<X11/keysym.h>

#   include	<charnames.h>
#   include	<appDebugon.h>

		/* old typo */
#   ifndef	XK_Greek_IOTAdieresis
#	define	XK_Greek_IOTAdieresis	XK_Greek_IOTAdiaeresis
#   endif

static int appGuiKeysymCludge(		unsigned char *		buf,
					APP_KEY_VALUE		key )
    {
    /*  Latin 2  */
    if  ( ( key & 0xffffff00 ) == 0x100 )
	{ buf[0]= key & 0xff; buf[1]= '\0'; return 1; }

    /*  Greek  */
    if  ( ( key & 0xffffff00 ) == 0x700 )
	{
	if  ( key >= 0xc1 )
	    { buf[0]= key & 0xff; buf[1]= '\0'; return 1; }

	switch( key )
	    {
	    case XK_Greek_ALPHAaccent:
		 buf[0]= ISO7_Alphatonos; buf[1]= '\0'; return 1;
	    case XK_Greek_EPSILONaccent:
		 buf[0]= ISO7_Epsilontonos; buf[1]= '\0'; return 1;
	    case XK_Greek_ETAaccent:
		 buf[0]= ISO7_Etatonos; buf[1]= '\0'; return 1;
	    case XK_Greek_IOTAaccent:
		 buf[0]= ISO7_Iotatonos; buf[1]= '\0'; return 1;
	    case XK_Greek_IOTAdieresis:
		 buf[0]= ISO7_Iotadieresis; buf[1]= '\0'; return 1;
	    case XK_Greek_OMICRONaccent:
		 buf[0]= ISO7_Omicrontonos; buf[1]= '\0'; return 1;
	    case XK_Greek_UPSILONaccent:
		 buf[0]= ISO7_Upsilontonos; buf[1]= '\0'; return 1;
	    case XK_Greek_UPSILONdieresis:
		 buf[0]= ISO7_Upsilondieresis; buf[1]= '\0'; return 1;
	    case XK_Greek_OMEGAaccent:
		 buf[0]= ISO7_Omegatonos; buf[1]= '\0'; return 1;

	    case XK_Greek_accentdieresis:
		 buf[0]= ISO7_dieresistonos; buf[1]= '\0'; return 1;

	    case XK_Greek_alphaaccent:
		 buf[0]= ISO7_alphatonos; buf[1]= '\0'; return 1;
	    case XK_Greek_epsilonaccent:
		 buf[0]= ISO7_epsilontonos; buf[1]= '\0'; return 1;
	    case XK_Greek_etaaccent:
		 buf[0]= ISO7_etatonos; buf[1]= '\0'; return 1;
	    case XK_Greek_iotaaccent:
		 buf[0]= ISO7_iotatonos; buf[1]= '\0'; return 1;
	    case XK_Greek_iotadieresis:
		 buf[0]= ISO7_iotadieresis; buf[1]= '\0'; return 1;
	    case XK_Greek_iotaaccentdieresis:
		 buf[0]= ISO7_iotadieresistonos; buf[1]= '\0'; return 1;
	    case XK_Greek_omicronaccent:
		 buf[0]= ISO7_omicrontonos; buf[1]= '\0'; return 1;
	    case XK_Greek_upsilonaccent:
		 buf[0]= ISO7_upsilontonos; buf[1]= '\0'; return 1;
	    case XK_Greek_upsilondieresis:
		 buf[0]= ISO7_upsilondieresis; buf[1]= '\0'; return 1;
	    case XK_Greek_upsilonaccentdieresis:
		 buf[0]= ISO7_upsilondieresistonos; buf[1]= '\0'; return 1;
	    case XK_Greek_omegaaccent:
		 buf[0]= ISO7_omegatonos; buf[1]= '\0'; return 1;
	    default:
		break;
	    }
	}

    return 0;
    }

void appGuiGetStringFromKeyboardEvent(	APP_INPUT_CONTEXT	ic,
					APP_WIDGET		w,
					APP_EVENT *		event,
					int *			pGotString,
					int *			pGotKey,
					unsigned int *		pState,
					unsigned char *		buf,
					int			capacity,
					APP_KEY_VALUE *		pKey )
    {
    int			gotString;
    XKeyPressedEvent *	keyEvent= &(event->xkey);

    if  ( event->type != KeyPress )
	{ LLDEB(event->type,KeyPress); *pGotString= 0; return;	}

    if  ( ic )
	{
	Status	status;

	gotString= XmbLookupString( ic, keyEvent, (char *)buf, capacity- 1,
							    pKey, &status );
	switch( status )
	    {
	    case XBufferOverflow:
		LDEB(status);
		*pGotString= 0;
		*pGotKey= 0;
		return;

	    case XLookupNone:
		*pGotString= 0;
		*pGotKey= 0;
		return;

	    case XLookupBoth:
		buf[gotString]= '\0';
		*pGotString= gotString;
		*pGotKey= 1;
		*pState= keyEvent->state;
		return;

	    case XLookupChars:
		buf[gotString]= '\0';
		*pGotString= gotString;
		*pGotKey= 0;
		*pState= keyEvent->state;
		return;

	    case XLookupKeySym:
		*pGotString= 0;
		*pGotKey= 1;
		*pState= keyEvent->state;

		if  ( appGuiKeysymCludge( buf, *pKey ) )
		    { *pGotString= 1; }

		return;
	    }
	}
    else{
	gotString= XLookupString( keyEvent, (char *)buf, capacity- 1,
					    pKey, (XComposeStatus *)0 );

	if  ( gotString > 0 )
	    { buf[gotString]= '\0';	}
	*pGotString= gotString;
	*pGotKey= 1;
	*pState= keyEvent->state;

	if  ( ! gotString && appGuiKeysymCludge( buf, *pKey ) )
	    { *pGotString= 1; }

	return;
	}

    }

#   endif