File: key_press.c

package info (click to toggle)
garlic 1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 4,516 kB
  • sloc: ansic: 52,465; makefile: 2,254
file content (584 lines) | stat: -rw-r--r-- 18,703 bytes parent folder | download | duplicates (5)
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
/* Copyright (C) 2000 Damir Zucic */

/*=============================================================================

				key_press.c

Purpose:
	Handle KeyPress events.

Input:
	(1) Pointer to MolComplexS structure, with macromol. complexes.
	(2) Number of macromolecular complexes.
	(3) Pointer to the next macromolecular complex identifier.
	(4) Pointer to RuntimeS structure, with some runtime data.
	(5) Pointer to ConfigS structure, with configuration data.
	(6) Pointer to GUIS structure, with GUI data.
	(7) Pointer to pointer to NearestAtomS structure.
	(8) Pointer to the number of pixels in the main window free area.
	(9) Pointer to refreshI.
       (10) Pointer to XKeyEvent structure.

Output:
	(1) Some action performed.
	(2) Return value.

Return value:
	(1) Positive or zero on success. If positive value is returned,
	    it should be  interpreted  as command code  returned by the
	    function ExecuteCommand1_ ().
	(2) Negative, if ExecuteCommand1_ () function failes. The value
	    should be interpreted as (internal) error code.

Notes:
	(1) The value of refreshI  (*refreshIP)  may be changed in this
	    function.  It is checked in  EventLoop_ (see event_loop.c).
	    It is assumed that refreshI is updated no more than once in
	    each event handling function.  If this is not the case, the
	    care should be taken to avoid refreshI overflow.

========includes:============================================================*/

#include <stdio.h>

#include <ctype.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>

#include <X11/keysym.h>

#include "defines.h"
#include "typedefs.h"

/*======function prototypes:=================================================*/

double		RotationAngle_ (ConfigS *, GUIS *, double);
int		Rotate_ (MolComplexS *, int,
			 RuntimeS *, ConfigS *, double, int);
size_t		MainRefresh_ (MolComplexS *, int,
			      RuntimeS *, ConfigS *, GUIS *,
			      NearestAtomS *, size_t, unsigned int);
int		ControlRefresh_ (MolComplexS *, ConfigS *, GUIS *);
int		DockingRefresh_ (RuntimeS *, GUIS *);
double		TranslationShift_ (ConfigS *, GUIS *, double);
void		Translate_ (MolComplexS *, int,
			    RuntimeS *, ConfigS *, double, int);
double		SlabShift_ (ConfigS *, GUIS *, double);
void		MoveBackSlab_ (MolComplexS *, int, ConfigS *, double);
void		MoveFrontSlab_ (MolComplexS *, int, ConfigS *, double);
double		FadingShift_ (ConfigS *, GUIS *, double);
void		MoveBackFading_ (MolComplexS *, int, ConfigS *, double);
void		MoveFrontFading_ (MolComplexS *, int, ConfigS *, double);
int		AddCharToCommand_ (RuntimeS *, GUIS *, int);
int		InputRefresh_ (GUIS *, RuntimeS *);
int		EatLeftChar_ (RuntimeS *);
int		EatRightChar_ (RuntimeS *);
int		ExecuteCommand1_ (MolComplexS *, int *, int *,
				  RuntimeS *, ConfigS *, GUIS *,
				  NearestAtomS **, size_t *, unsigned int *);
int		TruncateCommand_ (RuntimeS *);
int		ReplaceCommand_ (RuntimeS *, int, GUIS *);
void		InitNearest_ (NearestAtomS *, size_t);

/*======handle KeyPress events:==============================================*/

int KeyPress_ (MolComplexS *mol_complexSP, int *mol_complexesNP,
	       int *next_mol_complexIDP,
	       RuntimeS *runtimeSP, ConfigS *configSP, GUIS *guiSP,
	       NearestAtomS **nearest_atomSPP, size_t *pixelsNP,
	       unsigned int *refreshIP,
	       XKeyEvent *key_eventSP)
{
static char		stringA[STRINGSIZE];
static KeySym		key_symID;
static XComposeStatus	compose_statusS;
static double		rotation_angle;
static double		shift;
static int		carriage_pos, comm_length;
static int		new_char;
static int		command_code;
static int		n;

/* Get the KeySym: */
XLookupString (key_eventSP, stringA, STRINGSIZE, &key_symID, &compose_statusS);

/* Select the proper action for a given KeySym: */
switch (key_symID)
	{

/*------modifiers:-----------------------------------------------------------*/

	/* Shift key pressed: */
	case XK_Shift_L:
	case XK_Shift_R:
		guiSP->shift_pressedF = 1;
		break;

	/* Control key pressed: */
	case XK_Control_L:
	case XK_Control_R:
		guiSP->control_pressedF = 1;
		break;

	/* Alt or meta key pressed: */
	case XK_Alt_L:
	case XK_Alt_R:
	case XK_Meta_L:
	case XK_Meta_R:
		guiSP->alt_pressedF = 1;
		break;

/*------rotations:-----------------------------------------------------------*/

	/* Right-handed (positive) rotation about x: */
	case XK_KP_2:
	case XK_KP_Down:
		(*refreshIP)++;
		rotation_angle = RotationAngle_ (configSP, guiSP, 1.0);
		Rotate_ (mol_complexSP, *mol_complexesNP,
			 runtimeSP, configSP, rotation_angle, 1);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
		break;


	/* Left-handed (negative) rotation about x: */
	case XK_KP_8:
	case XK_KP_Up:
		(*refreshIP)++;
		rotation_angle = RotationAngle_ (configSP, guiSP, -1.0);
		Rotate_ (mol_complexSP, *mol_complexesNP,
			 runtimeSP, configSP, rotation_angle, 1);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
		break;

	/* Right-handed (positive) rotation about y: */
	case XK_KP_4:
	case XK_KP_Left:
		(*refreshIP)++;
		rotation_angle = RotationAngle_ (configSP, guiSP, +1.0);
		Rotate_ (mol_complexSP, *mol_complexesNP,
			 runtimeSP, configSP, rotation_angle, 2);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
		break;

	/* Left-handed (negative) rotation about y: */
	case XK_KP_6:
	case XK_KP_Right:
		(*refreshIP)++;
		rotation_angle = RotationAngle_ (configSP, guiSP, -1.0);
		Rotate_ (mol_complexSP, *mol_complexesNP,
			 runtimeSP, configSP, rotation_angle, 2);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
		break;

	/* Right-handed (positive) rotation about z: */
	case XK_KP_9:
	case XK_KP_Prior:
		(*refreshIP)++;
		rotation_angle = RotationAngle_ (configSP, guiSP, +1.0);
		Rotate_ (mol_complexSP, *mol_complexesNP,
			 runtimeSP, configSP, rotation_angle, 3);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
		break;

	/* Left-handed (negative) rotation about z: */
	case XK_KP_7:
	case XK_KP_Home:
		(*refreshIP)++;
		rotation_angle = RotationAngle_ (configSP, guiSP, -1.0);
		Rotate_ (mol_complexSP, *mol_complexesNP,
			 runtimeSP, configSP, rotation_angle, 3);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
		break;

/*------translations:--------------------------------------------------------*/

	/* Positive translation along x: */
	case XK_KP_Multiply:
	case XK_KP_F4:
		(*refreshIP)++;
		shift = TranslationShift_ (configSP, guiSP, +1.0);
		Translate_ (mol_complexSP, *mol_complexesNP,
			    runtimeSP, configSP, shift, 1);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
		break;

	/* Negative translation along x: */
	case XK_KP_Divide:
	case XK_KP_F3:
		(*refreshIP)++;
		shift = TranslationShift_ (configSP, guiSP, -1.0);
		Translate_ (mol_complexSP, *mol_complexesNP,
			    runtimeSP, configSP, shift, 1);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
		break;

	/* Positive translation along y: */
	case XK_KP_Add:
	case XK_KP_Separator:
		(*refreshIP)++;
		shift = TranslationShift_ (configSP, guiSP, +1.0);
		Translate_ (mol_complexSP, *mol_complexesNP,
			    runtimeSP, configSP, shift, 2);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
		break;

	/* Negative translation along y: */
	case XK_KP_Subtract:
		(*refreshIP)++;
		shift = TranslationShift_ (configSP, guiSP, -1.0);
		Translate_ (mol_complexSP, *mol_complexesNP,
			    runtimeSP, configSP, shift, 2);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
		break;

	/* Positive translation along z: */
	case XK_KP_5:
	case XK_KP_Begin:
		(*refreshIP)++;
		shift = TranslationShift_ (configSP, guiSP, +1.0);
		Translate_ (mol_complexSP, *mol_complexesNP,
			    runtimeSP, configSP, shift, 3);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
		break;

	/* Negative translation along z: */
	case XK_KP_0:
	case XK_KP_Insert:
		(*refreshIP)++;
		shift = TranslationShift_ (configSP, guiSP, -1.0);
		Translate_ (mol_complexSP, *mol_complexesNP,
			    runtimeSP, configSP, shift, 3);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
		break;

/*------slab:----------------------------------------------------------------*/

	/* Push the back slab surface farther: */
	case XK_KP_1:
	case XK_KP_End:
		(*refreshIP)++;
		shift = SlabShift_ (configSP, guiSP, 1.0);
		MoveBackSlab_ (mol_complexSP, *mol_complexesNP,
			       configSP, shift);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		break;

	/* Pull the back slab surface closer: */
	case XK_KP_3:
	case XK_KP_Next:
		(*refreshIP)++;
		shift = SlabShift_ (configSP, guiSP, -1.0);
		MoveBackSlab_ (mol_complexSP, *mol_complexesNP,
			       configSP, shift);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		break;

	/* Push the front slab surface farther: */
	case XK_KP_Delete:
	case XK_KP_Decimal:
		(*refreshIP)++;
		shift = SlabShift_ (configSP, guiSP, 1.0);
		MoveFrontSlab_ (mol_complexSP, *mol_complexesNP,
				configSP, shift);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		break;

	/* Pull the front slab surface closer: */
	case XK_KP_Enter:
		(*refreshIP)++;
		shift = SlabShift_ (configSP, guiSP, -1.0);
		MoveFrontSlab_ (mol_complexSP, *mol_complexesNP,
				configSP, shift);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		break;

/*------fading:--------------------------------------------------------------*/

	/* Push the back fading surface farther: */
	case XK_F1:
		(*refreshIP)++;
		shift = FadingShift_ (configSP, guiSP, 1.0);
		MoveBackFading_ (mol_complexSP, *mol_complexesNP,
				 configSP, shift);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		break;

	/* Pull the back fading surface closer: */
	case XK_F2:
		(*refreshIP)++;
		shift = FadingShift_ (configSP, guiSP, -1.0);
		MoveBackFading_ (mol_complexSP, *mol_complexesNP,
				 configSP, shift);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		break;

	/* Push the front fading surface farther: */
	case XK_F3:
		(*refreshIP)++;
		shift = FadingShift_ (configSP, guiSP, 1.0);
		MoveFrontFading_ (mol_complexSP, *mol_complexesNP,
				  configSP, shift);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		break;

	/* Pull the front fading surface closer: */
	case XK_F4:
		(*refreshIP)++;
		shift = FadingShift_ (configSP, guiSP, -1.0);
		MoveFrontFading_ (mol_complexSP, *mol_complexesNP,
				  configSP, shift);
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		break;

/*------line editing:--------------------------------------------------------*/

	/* Move the input window carriage (keyboard cursor) to the left: */
	case XK_Left:
		carriage_pos = runtimeSP->carriage_position;
		carriage_pos--;
		if (carriage_pos >= 0)
			{
			runtimeSP->carriage_position = carriage_pos;
			InputRefresh_ (guiSP, runtimeSP);
			}
		break;

	/* Move the input window carriage (keyboard cursor) to the right: */
	case XK_Right:
		carriage_pos = runtimeSP->carriage_position;
		comm_length = runtimeSP->command_length;
		carriage_pos++;
		if (carriage_pos <= comm_length)
			{
			runtimeSP->carriage_position = carriage_pos;
			InputRefresh_ (guiSP, runtimeSP);
			}
		break;

	/* Replace the current command with the previous one, if available: */
	case XK_Up:
		n = ReplaceCommand_ (runtimeSP, -1, guiSP);
		if (n < 0) break;
		InputRefresh_ (guiSP, runtimeSP);
		break;

	/* Replace the current command with the next one (if available): */
	case XK_Down:
		n = ReplaceCommand_ (runtimeSP, +1, guiSP);
		if (n < 0) break;
		InputRefresh_ (guiSP, runtimeSP);
		break;

	/* Move the input window carriage to the beginning of command line: */
	case XK_Home:
		runtimeSP->carriage_position = 0;
		InputRefresh_ (guiSP, runtimeSP);
		break;

	/* Move the input window carrriage to the end of command line: */
	case XK_End:
		runtimeSP->carriage_position = runtimeSP->command_length;
		InputRefresh_ (guiSP, runtimeSP);
		break;

	/* Remove one character on the left side: */
	case XK_BackSpace:
		EatLeftChar_ (runtimeSP);
		InputRefresh_ (guiSP, runtimeSP);
		break;

	/* Remove one character on the right side: */
	case XK_Delete:
		EatRightChar_ (runtimeSP);
		InputRefresh_ (guiSP, runtimeSP);
		break;

/*------command execution:---------------------------------------------------*/

	/* Print command string to log file (if requested), */
	/* execute command,  truncate command string, reset */
	/* the string length and  refresh the input window. */
	/* If some kind  of error occurs,  the return  code */
	/* should  be  negative.  In  that case,  print the */
	/* error message to  log file (if it is requested). */
	case XK_Return:
		/** Print command to log file, if requested: **/
		if (configSP->log_fileF)
			{
			fprintf (configSP->log_fileP, "%s\n",
				 runtimeSP->curr_commandA);
			fflush (configSP->log_fileP);
			}

		/** Parse command string and execute command: **/
		command_code = ExecuteCommand1_ (
					mol_complexSP, mol_complexesNP,
					next_mol_complexIDP,
					runtimeSP, configSP, guiSP,
					nearest_atomSPP, pixelsNP, refreshIP);

		/** Print the latest message to log file, if requested: **/
		if ((command_code < 0) && (configSP->log_fileF))
			{
			fprintf (configSP->log_fileP, "#%s\n",
				 runtimeSP->messageA);
			fflush (configSP->log_fileP);
			}

		/** Truncate the command string: **/
		TruncateCommand_ (runtimeSP);

		/** Refresh (redraw) the input window: **/
		InputRefresh_ (guiSP, runtimeSP);

		/** Update and check the command index **/
		/** and the  total number of commands: **/
		runtimeSP->next_commandI++;
		if (runtimeSP->next_commandI >= MAXCOMMSTRINGS - 1)
			{
			runtimeSP->next_commandI = 0;
			}
		if (runtimeSP->highest_commandI < MAXCOMMSTRINGS - 1)
			{
			runtimeSP->highest_commandI++;
			}

		/** Update the old_commandI: **/
		runtimeSP->old_commandI = runtimeSP->next_commandI;

		/** Return command code to the caller: **/
		return command_code;
		break;

/*------escape key causes return to the main drawing mode:-------------------*/

	/* Reset main window drawing mode and refresh the main window: */
	case XK_Escape:
		/* Reset drawing mode index: */
		guiSP->main_window_modeI = 0;

		/* Reinitialize the NearestAtomS array: */
		InitNearest_ (*nearest_atomSPP, *pixelsNP);
		*refreshIP = 1;

		/* Refresh the main window: */
		(*refreshIP)++;
		MainRefresh_ (mol_complexSP, *mol_complexesNP,
			      runtimeSP, configSP, guiSP,
			      *nearest_atomSPP, *pixelsNP, *refreshIP);

		/* Refresh the control window: */
		ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
				 configSP, guiSP);
		break;

/*------character input:-----------------------------------------------------*/

	/* All other keys should belong to the current command string: */
	default:
		/** Check the character: **/
		new_char = stringA[0];
		if (!isprint (new_char)) break;

		/** Append the character to the command string: **/
		if (AddCharToCommand_ (runtimeSP, guiSP, new_char) < 0) break;

		/** Refresh the input window: **/
		InputRefresh_ (guiSP, runtimeSP);
		;

/*---------------------------------------------------------------------------*/

	}

/* Return zero if this point is reached: */
return 0;
}

/*===========================================================================*/