File: tracksplit_parammenu.c

package info (click to toggle)
gramofile 1.6-9
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 864 kB
  • ctags: 527
  • sloc: ansic: 10,238; makefile: 57
file content (755 lines) | stat: -rw-r--r-- 19,591 bytes parent folder | download | duplicates (6)
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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
/* Tracksplitting - Parameters

 * Copyright (C) 1998 J.A. Bezemer
 *
 * Licensed under the terms of the GNU General Public License.
 * ABSOLUTELY NO WARRANTY.
 * See the file `COPYING' in this directory.
 */

#include "tracksplit_parammenu.h"
#include "errorwindow.h"
#include "stringinput.h"
#include "buttons.h"
#include "clrscr.h"
#include "boxes.h"
#include "helpline.h"
#include <stdlib.h>
#include <stdio.h>
#ifndef OLD_CURSES
#include <ncurses.h>
#else
#include <curses.h>
#endif


int
tracksplit_parammenu (int *make_use_rms, int *make_graphs, long *blocklen,
		      int *global_silence_factor,
		      int *local_silence_threshold, int *min_silence_blocks,
		      int *min_track_blocks, int *extra_blocks_start,
		      int *extra_blocks_end)
/* Returns 0: canceled, 1: PrevScreen, 2: NextScreen */
{
  button_t next_button, cancel_button, prev_button;
  button_t make_use_rms_check, make_graphs_check;
  stringinput_t blocklen_string, global_silence_factor_string, local_silence_threshold_string,
    min_silence_blocks_string, min_track_blocks_string, extra_blocks_start_string,
    extra_blocks_end_string;
  int dont_stop = TRUE;
  int returnval = 0;
  int focus = 11;
  int in_ch;
  long templong;

  char *helplines[12] =
  {
    " Save results or use saved results of lengthy computation.      TAB: Next field",
    " For manual (double-)checking/adjustment. Needs a few MB's.     TAB: Next field",
    " Number of samples to compute RMS of; 4410 = 0.1 sec.           TAB: Next field",
    " The relative threshold during the initial search for tracks.   TAB: Next field",
    " Begin/end of track ...% above local (silence) power level.     TAB: Next field",
    " Shorter periods of silence not treated as track separation.    TAB: Next field",
    " Shorter tracks are ignored.                                    TAB: Next field",
    " Correction for fade-in effects that are hard to detect.        TAB: Next field",
    " Correction for fade-out effects that are hard to detect.       TAB: Next field",
    " To Track Splitting - File Name.                                TAB: Next field",
    " Back to main menu.                                             TAB: Next field",
    " Start searching for tracks.                                    TAB: Next field"};

  make_use_rms_check.text = "";	/* see below */
  make_use_rms_check.y = 4;
  make_use_rms_check.x = 2;
  make_use_rms_check.selected = FALSE;

  make_graphs_check.text = "";	/* see below */
  make_graphs_check.y = 6;
  make_graphs_check.x = 2;
  make_graphs_check.selected = FALSE;

  blocklen_string.maxlen = 500;
  blocklen_string.string = (char *) malloc (
				    blocklen_string.maxlen * sizeof (char));
  sprintf (blocklen_string.string, "%ld", *blocklen);
  blocklen_string.y = 8;
  blocklen_string.x = 54;
  blocklen_string.w = 12;
  blocklen_string.cursorpos =
    strlen (blocklen_string.string);
  blocklen_string.firstcharonscreen = 0;

  global_silence_factor_string.maxlen = 500;
  global_silence_factor_string.string = (char *) malloc (
		       global_silence_factor_string.maxlen * sizeof (char));
  sprintf (global_silence_factor_string.string, "%d",
	   *global_silence_factor);
  global_silence_factor_string.y = 10;
  global_silence_factor_string.x = 54;
  global_silence_factor_string.w = 12;
  global_silence_factor_string.cursorpos =
    strlen (global_silence_factor_string.string);
  global_silence_factor_string.firstcharonscreen = 0;

  local_silence_threshold_string.maxlen = 500;
  local_silence_threshold_string.string = (char *) malloc (
		     local_silence_threshold_string.maxlen * sizeof (char));
  sprintf (local_silence_threshold_string.string, "%d",
	   *local_silence_threshold);
  local_silence_threshold_string.y = 11;
  local_silence_threshold_string.x = 54;
  local_silence_threshold_string.w = 12;
  local_silence_threshold_string.cursorpos =
    strlen (local_silence_threshold_string.string);
  local_silence_threshold_string.firstcharonscreen = 0;

  min_silence_blocks_string.maxlen = 500;
  min_silence_blocks_string.string = (char *) malloc (
			  min_silence_blocks_string.maxlen * sizeof (char));
  sprintf (min_silence_blocks_string.string, "%d",
	   *min_silence_blocks);
  min_silence_blocks_string.y = 13;
  min_silence_blocks_string.x = 54;
  min_silence_blocks_string.w = 12;
  min_silence_blocks_string.cursorpos =
    strlen (min_silence_blocks_string.string);
  min_silence_blocks_string.firstcharonscreen = 0;

  min_track_blocks_string.maxlen = 500;
  min_track_blocks_string.string = (char *) malloc (
			    min_track_blocks_string.maxlen * sizeof (char));
  sprintf (min_track_blocks_string.string, "%d",
	   *min_track_blocks);
  min_track_blocks_string.y = 14;
  min_track_blocks_string.x = 54;
  min_track_blocks_string.w = 12;
  min_track_blocks_string.cursorpos =
    strlen (min_track_blocks_string.string);
  min_track_blocks_string.firstcharonscreen = 0;

  extra_blocks_start_string.maxlen = 500;
  extra_blocks_start_string.string = (char *) malloc (
			  extra_blocks_start_string.maxlen * sizeof (char));
  sprintf (extra_blocks_start_string.string, "%d",
	   *extra_blocks_start);
  extra_blocks_start_string.y = 16;
  extra_blocks_start_string.x = 54;
  extra_blocks_start_string.w = 12;
  extra_blocks_start_string.cursorpos =
    strlen (extra_blocks_start_string.string);
  extra_blocks_start_string.firstcharonscreen = 0;

  extra_blocks_end_string.maxlen = 500;
  extra_blocks_end_string.string = (char *) malloc (
			    extra_blocks_end_string.maxlen * sizeof (char));
  sprintf (extra_blocks_end_string.string, "%d",
	   *extra_blocks_end);
  extra_blocks_end_string.y = 17;
  extra_blocks_end_string.x = 54;
  extra_blocks_end_string.w = 12;
  extra_blocks_end_string.cursorpos =
    strlen (extra_blocks_end_string.string);
  extra_blocks_end_string.firstcharonscreen = 0;

  prev_button.text = " < Previous screen ";
  prev_button.y = 20;
  prev_button.x = 5;
  prev_button.selected = FALSE;

  next_button.text = " Start computation ";
  next_button.y = 20;
  next_button.x = 56;
  next_button.selected = FALSE;

  cancel_button.text = " Cancel ";
  cancel_button.y = 20;
  cancel_button.x = 36;
  cancel_button.selected = FALSE;

  clearscreen (TRACKSPLIT_PARAMMENU_HEADERTEXT);

  do
    {
      header (TRACKSPLIT_PARAMMENU_HEADERTEXT);

      if (*make_use_rms)
	make_use_rms_check.text = "[X]";
      else
	make_use_rms_check.text = "[ ]";

      if (*make_graphs)
	make_graphs_check.text = "[X]";
      else
	make_graphs_check.text = "[ ]";

      if (focus == 0)
	make_use_rms_check.selected = TRUE;
      else
	make_use_rms_check.selected = FALSE;

      if (focus == 1)
	make_graphs_check.selected = TRUE;
      else
	make_graphs_check.selected = FALSE;

      if (focus == 9)
	prev_button.selected = TRUE;
      else
	prev_button.selected = FALSE;

      if (focus == 10)
	cancel_button.selected = TRUE;
      else
	cancel_button.selected = FALSE;

      if (focus == 11)
	next_button.selected = TRUE;
      else
	next_button.selected = FALSE;

      stringinput_display (&blocklen_string);
      mvprintw (blocklen_string.y, 2,
		"Length of blocks of signal power data (samples)   :");

      stringinput_display (&global_silence_factor_string);
      mvprintw (global_silence_factor_string.y, 2,
		"Global silence factor (0.1 %)                     :");

      stringinput_display (&local_silence_threshold_string);
      mvprintw (local_silence_threshold_string.y, 2,
		"Local silence factor (%)                          :");

      stringinput_display (&min_silence_blocks_string);
      mvprintw (min_silence_blocks_string.y, 2,
		"Minimal length of inter-track silence (blocks)    :");

      stringinput_display (&min_track_blocks_string);
      mvprintw (min_track_blocks_string.y, 2,
		"Minimal length of tracks (blocks)                 :");

      stringinput_display (&extra_blocks_start_string);
      mvprintw (extra_blocks_start_string.y, 2,
		"Number of extra blocks at track start             :");

      stringinput_display (&extra_blocks_end_string);
      mvprintw (extra_blocks_end_string.y, 2,
		"Number of extra blocks at track end               :");

      button_display (&prev_button);
      mybox (prev_button.y - 1, prev_button.x - 1,
	     3, strlen (prev_button.text) + 2);
      button_display (&cancel_button);
      mybox (cancel_button.y - 1, cancel_button.x - 1,
	     3, strlen (cancel_button.text) + 2);
      button_display (&next_button);
      mybox (next_button.y - 1, next_button.x - 1,
	     3, strlen (next_button.text) + 2);

      button_display (&make_use_rms_check);
      mvprintw (make_use_rms_check.y, make_use_rms_check.x + 4,
		"Save/load signal power (RMS) data to/from .rms file");

      button_display (&make_graphs_check);
      mvprintw (make_graphs_check.y, make_graphs_check.x + 4,
		"Generate graph files");

      helpline (helplines[focus]);

      switch (focus)
	{
	case 2:
	  stringinput_display (&blocklen_string);
	  break;
	case 3:
	  stringinput_display (&global_silence_factor_string);
	  break;
	case 4:
	  stringinput_display (&local_silence_threshold_string);
	  break;
	case 5:
	  stringinput_display (&min_silence_blocks_string);
	  break;
	case 6:
	  stringinput_display (&min_track_blocks_string);
	  break;
	case 7:
	  stringinput_display (&extra_blocks_start_string);
	  break;
	case 8:
	  stringinput_display (&extra_blocks_end_string);
	  break;
	default:
	  move (0, 79);
	}

      refresh ();

      in_ch = getch ();

      switch (focus)
	{
	case 0:		/* Make/use .RMS file */
	  switch (in_ch)
	    {
	    case KEY_ENTER:
	    case 13:
	    case ' ':
	    case 'x':
	    case 'X':
	      *make_use_rms = 1 - *make_use_rms;
	      break;

	    case KEY_LEFT:
	    case KEY_UP:
	      focus--;
	      break;
	    case KEY_RIGHT:
	    case KEY_DOWN:
	      focus++;
	      break;
	    }
	  break;

	case 1:		/* Make graph files */
	  switch (in_ch)
	    {
	    case KEY_ENTER:
	    case 13:
	    case ' ':
	    case 'x':
	    case 'X':
	      *make_graphs = 1 - *make_graphs;
	      break;

	    case KEY_LEFT:
	    case KEY_UP:
	      focus--;
	      break;
	    case KEY_RIGHT:
	    case KEY_DOWN:
	      focus++;
	      break;
	    }
	  break;

	case 2:		/* Block length */
	  stringinput_stdkeys (in_ch, &blocklen_string);
	  switch (in_ch)
	    {
	    case KEY_ENTER:
	    case 13:
	      templong = atol (blocklen_string.string);
	      if (templong < 1)
		{
		  error_window ("Enter a whole number, greater than 0. \
Default: 4410.");
		  blocklen_string.cursorpos =
		    strlen (blocklen_string.string);
		}
	      else
		{
		  *blocklen = templong;
		  sprintf (blocklen_string.string,
			   "%ld", templong);
		  blocklen_string.cursorpos =
		    strlen (blocklen_string.string);
		  focus++;
		}
	      break;

	    case KEY_UP:
	      focus--;
	      break;
	    case KEY_DOWN:
	      focus++;
	      break;
	    }
	  break;

	case 3:		/* Global silence factor */
	  stringinput_stdkeys (in_ch,
			       &global_silence_factor_string);
	  switch (in_ch)
	    {
	    case KEY_ENTER:
	    case 13:
	      templong = atol (
				global_silence_factor_string.string);
	      if (templong < 0 || templong > 10000)
		{
		  error_window ("Enter a whole, positive number, preferably \
less than 1000. Default: 150.");
		  global_silence_factor_string.cursorpos =
		    strlen (
			     global_silence_factor_string.string);
		}
	      else
		{
		  *global_silence_factor = templong;
		  sprintf (global_silence_factor_string.string,
			   "%ld", templong);
		  global_silence_factor_string.cursorpos =
		    strlen (global_silence_factor_string.string);
		  focus++;
		}
	      break;

	    case KEY_UP:
	      focus--;
	      break;
	    case KEY_DOWN:
	      focus++;
	      break;
	    }
	  break;

	case 4:		/* Local silence threshold */
	  stringinput_stdkeys (in_ch,
			       &local_silence_threshold_string);
	  switch (in_ch)
	    {
	    case KEY_ENTER:
	    case 13:
	      templong = atol (
				local_silence_threshold_string.string);
	      if (templong < 0 || templong > 10000)
		{
		  error_window ("Enter a whole, positive number. \
Default: 5.");
		  local_silence_threshold_string.cursorpos =
		    strlen (
			     local_silence_threshold_string.string);
		}
	      else
		{
		  *local_silence_threshold = templong;
		  sprintf (local_silence_threshold_string.string,
			   "%ld", templong);
		  local_silence_threshold_string.cursorpos =
		    strlen (
			     local_silence_threshold_string.string);
		  focus++;
		}
	      break;

	    case KEY_UP:
	      focus--;
	      break;
	    case KEY_DOWN:
	      focus++;
	      break;
	    }
	  break;

	case 5:		/* Min. silence length (blocks) */
	  stringinput_stdkeys (in_ch,
			       &min_silence_blocks_string);
	  switch (in_ch)
	    {
	    case KEY_ENTER:
	    case 13:
	      templong = atol (
				min_silence_blocks_string.string);
	      if (templong < 0 || templong > 10000)
		{
		  error_window ("Enter a whole, positive number. \
Default: 20.");
		  min_silence_blocks_string.cursorpos =
		    strlen (
			     min_silence_blocks_string.string);
		}
	      else
		{
		  *min_silence_blocks = templong;
		  sprintf (min_silence_blocks_string.string,
			   "%ld", templong);
		  min_silence_blocks_string.cursorpos =
		    strlen (
			     min_silence_blocks_string.string);
		  focus++;
		}
	      break;

	    case KEY_UP:
	      focus--;
	      break;
	    case KEY_DOWN:
	      focus++;
	      break;
	    }
	  break;

	case 6:		/* Min. track length (blocks) */
	  stringinput_stdkeys (in_ch,
			       &min_track_blocks_string);
	  switch (in_ch)
	    {
	    case KEY_ENTER:
	    case 13:
	      templong = atol (
				min_track_blocks_string.string);
	      if (templong < 0 || templong > 10000)
		{
		  error_window ("Enter a whole, positive number. \
Default: 50.");
		  min_track_blocks_string.cursorpos =
		    strlen (
			     min_track_blocks_string.string);
		}
	      else
		{
		  *min_track_blocks = templong;
		  sprintf (min_track_blocks_string.string,
			   "%ld", templong);
		  min_track_blocks_string.cursorpos =
		    strlen (
			     min_track_blocks_string.string);
		  focus++;
		}
	      break;

	    case KEY_UP:
	      focus--;
	      break;
	    case KEY_DOWN:
	      focus++;
	      break;
	    }
	  break;

	case 7:		/* Extra blocks at track start */
	  stringinput_stdkeys (in_ch,
			       &extra_blocks_start_string);
	  switch (in_ch)
	    {
	    case KEY_ENTER:
	    case 13:
	      templong = atol (
				extra_blocks_start_string.string);
	      if (templong < 0 || templong > 10000)
		{
		  error_window ("Enter a whole, positive number. \
Default: 3.");
		  extra_blocks_start_string.cursorpos =
		    strlen (
			     extra_blocks_start_string.string);
		}
	      else
		{
		  *extra_blocks_start = templong;
		  sprintf (extra_blocks_start_string.string,
			   "%ld", templong);
		  extra_blocks_start_string.cursorpos =
		    strlen (
			     extra_blocks_start_string.string);
		  focus++;
		}
	      break;

	    case KEY_UP:
	      focus--;
	      break;
	    case KEY_DOWN:
	      focus++;
	      break;
	    }
	  break;

	case 8:		/* Extra blocks at track end */
	  stringinput_stdkeys (in_ch,
			       &extra_blocks_end_string);
	  switch (in_ch)
	    {
	    case KEY_ENTER:
	    case 13:
	      templong = atol (
				extra_blocks_end_string.string);
	      if (templong < 0 || templong > 10000)
		{
		  error_window ("Enter a whole, positive number. \
Default: 6.");
		  extra_blocks_end_string.cursorpos =
		    strlen (
			     extra_blocks_end_string.string);
		}
	      else
		{
		  *extra_blocks_end = templong;
		  sprintf (extra_blocks_end_string.string,
			   "%ld", templong);
		  extra_blocks_end_string.cursorpos =
		    strlen (
			     extra_blocks_end_string.string);
		  focus++;
		}
	      break;

	    case KEY_UP:
	      focus--;
	      break;
	    case KEY_DOWN:
	      focus++;
	      break;
	    }
	  break;

	case 9:		/* < Previous */
	  if (in_ch == KEY_ENTER || in_ch == 13)
	    {
	      returnval = 1;
	      dont_stop = FALSE;
	    }
	  else
	    switch (in_ch)
	      {
	      case KEY_LEFT:
	      case KEY_UP:
		focus--;
		break;
	      case KEY_RIGHT:
	      case KEY_DOWN:
		focus++;
		break;
	      }
	  break;

	case 10:		/* Cancel */
	  if (in_ch == KEY_ENTER || in_ch == 13)
	    {
	      returnval = 0;
	      dont_stop = FALSE;
	    }
	  else
	    switch (in_ch)
	      {
	      case KEY_LEFT:
	      case KEY_UP:
		focus--;
		break;
	      case KEY_RIGHT:
	      case KEY_DOWN:
		focus++;
		break;
	      }
	  break;

	case 11:		/* Next > */
	  if (in_ch == KEY_ENTER || in_ch == 13)
	    {
	      templong = atol (blocklen_string.string);
	      if (templong < 1)
		{
		  error_window ("Enter a whole number, greater than 0, as \
block length. Default: 4410.");
		  blocklen_string.cursorpos =
		    strlen (blocklen_string.string);
		  focus = 2;
		  break;
		}
	      *blocklen = templong;

	      templong = atol (global_silence_factor_string.string);
	      if (templong < 1 || templong > 10000)
		{
		  error_window ("Enter a whole, positive number as \
global silence factor. Default: 150.");
		  global_silence_factor_string.cursorpos =
		    strlen (global_silence_factor_string.string);
		  focus = 3;
		  break;
		}
	      *global_silence_factor = templong;

	      templong = atol (local_silence_threshold_string.string);
	      if (templong < 1 || templong > 10000)
		{
		  error_window ("Enter a whole, positive number as \
local silence factor. Default: 5.");
		  local_silence_threshold_string.cursorpos =
		    strlen (local_silence_threshold_string.string);
		  focus = 4;
		  break;
		}
	      *local_silence_threshold = templong;

	      templong = atol (min_silence_blocks_string.string);
	      if (templong < 1 || templong > 10000)
		{
		  error_window ("Enter a whole, positive number as \
minimal silence duration. Default: 20.");
		  min_silence_blocks_string.cursorpos =
		    strlen (min_silence_blocks_string.string);
		  focus = 5;
		  break;
		}
	      *min_silence_blocks = templong;

	      templong = atol (min_track_blocks_string.string);
	      if (templong < 1 || templong > 10000)
		{
		  error_window ("Enter a whole, positive number as \
minimal track length. Default: 50.");
		  min_track_blocks_string.cursorpos =
		    strlen (min_track_blocks_string.string);
		  focus = 6;
		  break;
		}
	      *min_track_blocks = templong;

	      templong = atol (extra_blocks_start_string.string);
	      if (templong < 1 || templong > 10000)
		{
		  error_window ("Enter a whole, positive number as \
block addition. Default: 3.");
		  extra_blocks_start_string.cursorpos =
		    strlen (extra_blocks_start_string.string);
		  focus = 7;
		  break;
		}
	      *extra_blocks_start = templong;

	      templong = atol (extra_blocks_end_string.string);
	      if (templong < 1 || templong > 10000)
		{
		  error_window ("Enter a whole, positive number as \
block addition. Default: 6.");
		  extra_blocks_end_string.cursorpos =
		    strlen (extra_blocks_end_string.string);
		  focus = 8;
		  break;
		}
	      *extra_blocks_end = templong;

	      returnval = 2;
	      dont_stop = FALSE;
	    }
	  else
	    switch (in_ch)
	      {
	      case KEY_LEFT:
	      case KEY_UP:
		focus--;
		break;
	      case KEY_RIGHT:
	      case KEY_DOWN:
		focus++;
		break;
	      }
	  break;

	}			/* switch(focus) */

      if (in_ch == 9)		/* TAB */
	focus++;

      if (in_ch == 27)
	dont_stop = FALSE;

      if (focus > 11)
	focus = 0;
      if (focus < 0)
	focus = 11;
    }
  while (dont_stop);

  return returnval;
}