~cfuhrman/+junk/netbsd-othersrc-trunk

« back to all changes in this revision

Viewing changes to dist/cdk/alphalist.c

  • Committer: garbled
  • Date: 2001-01-04 19:59:48 UTC
  • Revision ID: svn-v4:288d5a72-fed7-e111-8680-000c29dcf8fe:trunk:174
Initial import of CDK 4.9.9.  The work to port this was performed by
Charles Hannum, and that is the version being imported:
cdk-4.9.9-20000407-myc3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <cdk.h>
 
2
 
 
3
/*
 
4
 * $Author: garbled $
 
5
 * $Date: 2001-01-04 19:58:30 $
 
6
 * $Revision: 1.1.1.1 $
 
7
 */
 
8
 
 
9
/*
 
10
 * Declare file local prototypes.
 
11
 */
 
12
static BINDFN_PROTO(adjustAlphalistCB);
 
13
static BINDFN_PROTO(completeWordCB);
 
14
static int preProcessEntryField (EObjectType cdktype, void *object, void *clientData, chtype input);
 
15
 
 
16
DeclareCDKObjects(my_funcs,Alphalist);
 
17
 
 
18
/*
 
19
 * This creates the alphalist widget.
 
20
 */
 
21
CDKALPHALIST *newCDKAlphalist (CDKSCREEN *cdkscreen, int xplace, int yplace, int height, int width, char *title, char *label, char *list[], int listSize, chtype fillerChar, chtype highlight, boolean Box, boolean shadow)
 
22
{
 
23
   /* Set up some variables. */
 
24
   CDKALPHALIST *alphalist      = newCDKObject(CDKALPHALIST, &my_funcs);
 
25
   chtype *chtypeLabel          = 0;
 
26
   int parentWidth              = getmaxx(cdkscreen->window);
 
27
   int parentHeight             = getmaxy(cdkscreen->window);
 
28
   int boxWidth                 = width;
 
29
   int boxHeight                = height;
 
30
   int xpos                     = xplace;
 
31
   int ypos                     = yplace;
 
32
   int entryWidth               = 0;
 
33
   int labelLen                 = 0;
 
34
   int x, junk2;
 
35
 
 
36
  /*
 
37
   * If the height is a negative value, the height will
 
38
   * be ROWS-height, otherwise, the height will be the
 
39
   * given height.
 
40
   */
 
41
   boxHeight = setWidgetDimension (parentHeight, height, 0);
 
42
 
 
43
  /*
 
44
   * If the width is a negative value, the width will
 
45
   * be COLS-width, otherwise, the width will be the
 
46
   * given width.
 
47
   */
 
48
   boxWidth = setWidgetDimension (parentWidth, width, 0);
 
49
 
 
50
   /* Translate the label char *pointer to a chtype pointer. */
 
51
   if (label != 0)
 
52
   {
 
53
      chtypeLabel = char2Chtype (label, &labelLen, &junk2);
 
54
      freeChtype (chtypeLabel);
 
55
   }
 
56
 
 
57
   /* Rejustify the x and y positions if we need to. */
 
58
   alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
 
59
 
 
60
   /* Make the file selector window. */
 
61
   alphalist->win = newwin (boxHeight + !!shadow, boxWidth + !!shadow, ypos, xpos);
 
62
 
 
63
   if (alphalist->win == 0)
 
64
   {
 
65
      return (0);
 
66
   }
 
67
   keypad (alphalist->win, TRUE);
 
68
 
 
69
   /* Set some variables. */
 
70
   ScreenOf(alphalist)          = cdkscreen;
 
71
   alphalist->parent            = cdkscreen->window;
 
72
   alphalist->highlight         = highlight;
 
73
   alphalist->fillerChar        = fillerChar;
 
74
   alphalist->boxHeight         = boxHeight;
 
75
   alphalist->boxWidth          = boxWidth;
 
76
   alphalist->exitType          = vNEVER_ACTIVATED;
 
77
   ObjOf(alphalist)->box        = Box;
 
78
   alphalist->shadow            = shadow;
 
79
 
 
80
   /* We need to sort the list before we use it. */
 
81
   quickSort (list, 0, listSize-1);
 
82
 
 
83
   /* Copy the list information. */
 
84
   for (x=0; x < listSize; x++)
 
85
   {
 
86
      alphalist->list[x] = copyChar (list[x]);
 
87
   }
 
88
   alphalist->listSize = listSize;
 
89
 
 
90
   /* Create the entry field. */
 
91
   entryWidth = boxWidth - (labelLen + 2);
 
92
   alphalist->entryField = newCDKEntry (cdkscreen,
 
93
                                        getbegx(alphalist->win),
 
94
                                        getbegy(alphalist->win),
 
95
                                        title, label,
 
96
                                        A_NORMAL, fillerChar, 
 
97
                                        vMIXED, entryWidth, 0, 512,
 
98
                                        Box, FALSE);
 
99
   setCDKEntryLLChar (alphalist->entryField, ACS_LTEE);
 
100
   setCDKEntryLRChar (alphalist->entryField, ACS_RTEE);
 
101
 
 
102
   /* Set the key bindings for the entry field. */
 
103
   bindCDKObject (vENTRY, alphalist->entryField, KEY_UP, adjustAlphalistCB, alphalist);
 
104
   bindCDKObject (vENTRY, alphalist->entryField, KEY_DOWN, adjustAlphalistCB, alphalist);
 
105
   bindCDKObject (vENTRY, alphalist->entryField, KEY_NPAGE, adjustAlphalistCB, alphalist);
 
106
   bindCDKObject (vENTRY, alphalist->entryField, CONTROL('F'), adjustAlphalistCB, alphalist);
 
107
   bindCDKObject (vENTRY, alphalist->entryField, KEY_PPAGE, adjustAlphalistCB, alphalist);
 
108
   bindCDKObject (vENTRY, alphalist->entryField, CONTROL('B'), adjustAlphalistCB, alphalist);
 
109
   bindCDKObject (vENTRY, alphalist->entryField, KEY_TAB, completeWordCB, alphalist);
 
110
 
 
111
   /* Set up the post-process function for the entry field. */
 
112
   setCDKEntryPreProcess (alphalist->entryField, preProcessEntryField, alphalist);
 
113
 
 
114
   /* Create the scrolling list. */
 
115
   alphalist->scrollField = newCDKScroll (cdkscreen, 
 
116
                                          getbegx(alphalist->win),
 
117
                                          getbegy(alphalist->win) + (alphalist->entryField)->titleLines + 2,
 
118
                                          RIGHT,
 
119
                                          boxHeight-((alphalist->entryField)->titleLines + 2),
 
120
                                          boxWidth,
 
121
                                          0, list, listSize,
 
122
                                          NONUMBERS, A_REVERSE,
 
123
                                          Box, FALSE);
 
124
   setCDKScrollULChar (alphalist->scrollField, ACS_LTEE);
 
125
   setCDKScrollURChar (alphalist->scrollField, ACS_RTEE);
 
126
 
 
127
   /* Register this baby. */
 
128
   registerCDKObject (cdkscreen, vALPHALIST, alphalist);
 
129
 
 
130
   /* Return the file selector pointer. */
 
131
   return (alphalist);
 
132
}
 
133
 
 
134
/*
 
135
 * This erases the file selector from the screen.
 
136
 */
 
137
static void _eraseCDKAlphalist (CDKOBJS *obj)
 
138
{
 
139
   CDKALPHALIST *alphalist = (CDKALPHALIST *)obj;
 
140
 
 
141
   eraseCDKScroll (alphalist->scrollField);
 
142
   eraseCDKEntry (alphalist->entryField);
 
143
 
 
144
   eraseCursesWindow (alphalist->win);
 
145
}
 
146
 
 
147
/*
 
148
 * This moves the alphalist field to the given location.
 
149
 */
 
150
static void _moveCDKAlphalist (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag)
 
151
{
 
152
   CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
 
153
 
 
154
   /*
 
155
    * If this is a relative move, then we will adjust where we want
 
156
    * to move to.
 
157
    */
 
158
   if (relative)
 
159
   {
 
160
      xplace += getbegx(alphalist->win);
 
161
      yplace += getbegy(alphalist->win);
 
162
   }
 
163
 
 
164
   /* Adjust the window if we need to. */
 
165
   alignxy (WindowOf(alphalist), &xplace, &yplace, alphalist->boxWidth, alphalist->boxHeight);
 
166
 
 
167
   /* Move the window to the new location. */
 
168
   moveCursesWindow(alphalist->win, xplace, yplace);
 
169
 
 
170
   /* Move the sub-widgets. */
 
171
   /* XXXX */
 
172
   moveCDKEntry (alphalist->entryField, xplace, yplace, relative, FALSE);
 
173
   moveCDKScroll (alphalist->scrollField, xplace, yplace, relative, FALSE);
 
174
 
 
175
   /* Redraw the window, if they asked for it. */
 
176
   if (refresh_flag)
 
177
   {
 
178
      drawCDKAlphalist (alphalist, ObjOf(alphalist)->box);
 
179
   }
 
180
}
 
181
 
 
182
/*
 
183
 * This draws the file selector widget.
 
184
 */
 
185
static void _drawCDKAlphalist (CDKOBJS *obj, boolean Box GCC_UNUSED)
 
186
{
 
187
   CDKALPHALIST * alphalist = (CDKALPHALIST *)obj;
 
188
 
 
189
   /* Draw in the entry field. */
 
190
   drawCDKEntry (alphalist->entryField, ObjOf(alphalist->entryField)->box);
 
191
 
 
192
   /* Draw in the scroll field. */
 
193
   drawCDKScroll (alphalist->scrollField, ObjOf(alphalist->scrollField)->box);
 
194
}
 
195
 
 
196
/*
 
197
 * This activates the file selector.
 
198
 */
 
199
char *activateCDKAlphalist (CDKALPHALIST *alphalist, chtype *actions)
 
200
{
 
201
   char *ret = 0;
 
202
 
 
203
   /* Draw the widget. */
 
204
   drawCDKAlphalist (alphalist, ObjOf(alphalist)->box);
 
205
 
 
206
   /* Activate the widget. */
 
207
   ret = activateCDKEntry (alphalist->entryField, actions);
 
208
 
 
209
   /* Copy the exit type from the entry field. */
 
210
   alphalist->exitType = alphalist->entryField->exitType;
 
211
 
 
212
   /* Determine the exit status. */
 
213
   if (alphalist->exitType != vEARLY_EXIT)
 
214
   {
 
215
      return ret;
 
216
   }
 
217
   return 0;
 
218
}
 
219
 
 
220
/*
 
221
 * This injects a single character into the alphalist.
 
222
 */
 
223
char *injectCDKAlphalist (CDKALPHALIST *alphalist, chtype input)
 
224
{
 
225
   char *ret = 0;
 
226
 
 
227
   /* Draw the widget. */
 
228
   drawCDKAlphalist (alphalist, ObjOf(alphalist)->box);
 
229
 
 
230
   /* Inject a character into the widget. */
 
231
   ret = injectCDKEntry (alphalist->entryField, input);
 
232
 
 
233
   /* Copy the exit type from the entry field. */
 
234
   alphalist->exitType = alphalist->entryField->exitType;
 
235
 
 
236
   /* Determine the exit status. */
 
237
   if (alphalist->exitType != vEARLY_EXIT)
 
238
   {
 
239
      return ret;
 
240
   }
 
241
   return 0;
 
242
}
 
243
 
 
244
/*
 
245
 * This sets multiple attributes of the widget.
 
246
 */
 
247
void setCDKAlphalist (CDKALPHALIST *alphalist, char *list[], int listSize, chtype fillerChar, chtype highlight, boolean Box)
 
248
{
 
249
   setCDKAlphalistContents (alphalist, list, listSize);
 
250
   setCDKAlphalistFillerChar (alphalist, fillerChar);
 
251
   setCDKAlphalistHighlight (alphalist, highlight);
 
252
   setCDKAlphalistBox (alphalist, Box);
 
253
}
 
254
 
 
255
/*
 
256
 * This function sets the information inside the file selector.
 
257
 */
 
258
void setCDKAlphalistContents (CDKALPHALIST *alphalist, char *list[], int listSize)
 
259
{
 
260
   /* Declare local variables. */
 
261
   CDKSCROLL *scrollp   = (CDKSCROLL *)alphalist->scrollField;
 
262
   CDKENTRY *entry      = (CDKENTRY *)alphalist->entryField;
 
263
   int x;
 
264
 
 
265
   freeCharList (alphalist->list, alphalist->listSize);
 
266
 
 
267
   /* We need to sort the list before we use it. */
 
268
   quickSort (list, 0, listSize-1);
 
269
 
 
270
   /* Copy in the new information. */
 
271
   alphalist->listSize          = listSize;
 
272
   for (x=0; x < listSize; x++)
 
273
   {
 
274
      alphalist->list[x] = copyChar (list[x]);
 
275
   }
 
276
 
 
277
   /* Set the information in the scrolling list. */
 
278
   setCDKScroll (scrollp, list, listSize, NONUMBERS, scrollp->highlight, ObjOf(scrollp)->box);
 
279
 
 
280
   /* Clean out the entry field. */
 
281
   cleanCDKEntry (entry);
 
282
 
 
283
   /* Redraw the alphalist. */
 
284
   eraseCDKAlphalist (alphalist);
 
285
   drawCDKAlphalist (alphalist, ObjOf(alphalist)->box);
 
286
}
 
287
 
 
288
/*
 
289
 * This returns the contents of the alphalist.
 
290
 */
 
291
char **getCDKAlphalistContents (CDKALPHALIST *alphalist, int *size)
 
292
{
 
293
   (*size) = alphalist->listSize;
 
294
   return alphalist->list;
 
295
}
 
296
 
 
297
/*
 
298
 * This sets the filler character of the entry field of the alphalist.
 
299
 */
 
300
void setCDKAlphalistFillerChar (CDKALPHALIST *alphalist, chtype fillerCharacter)
 
301
{
 
302
   CDKENTRY *entry = (CDKENTRY *)alphalist->entryField;
 
303
 
 
304
   alphalist->fillerChar = fillerCharacter;
 
305
 
 
306
   setCDKEntryFillerChar (entry, fillerCharacter);
 
307
}
 
308
chtype getCDKAlphalistFillerChar (CDKALPHALIST *alphalist)
 
309
{
 
310
   return alphalist->fillerChar;
 
311
}
 
312
 
 
313
/*
 
314
 * This sets the highlight bar attributes.
 
315
 */
 
316
void setCDKAlphalistHighlight (CDKALPHALIST *alphalist, chtype highlight)
 
317
{
 
318
   alphalist->highlight = highlight;
 
319
}
 
320
chtype getCDKAlphalistHighlight (CDKALPHALIST *alphalist)
 
321
{
 
322
   return alphalist->highlight;
 
323
}
 
324
 
 
325
/*
 
326
 * This sets whether or not the widget will be drawn with a box.
 
327
 */
 
328
void setCDKAlphalistBox (CDKALPHALIST *alphalist, boolean Box)
 
329
{
 
330
   ObjOf(alphalist)->box = Box;
 
331
}
 
332
 
 
333
boolean getCDKAlphalistBox (CDKALPHALIST *alphalist)
 
334
{
 
335
   return ObjOf(alphalist)->box;
 
336
}
 
337
 
 
338
/*
 
339
 * These functions set the drawing characters of the widget.
 
340
 */
 
341
void setCDKAlphalistULChar (CDKALPHALIST *alphalist, chtype character)
 
342
{
 
343
   setCDKEntryULChar (alphalist->entryField, character);
 
344
}
 
345
void setCDKAlphalistURChar (CDKALPHALIST *alphalist, chtype character)
 
346
{
 
347
   setCDKEntryURChar (alphalist->entryField, character);
 
348
}
 
349
void setCDKAlphalistLLChar (CDKALPHALIST *alphalist, chtype character)
 
350
{
 
351
   setCDKScrollLLChar (alphalist->scrollField, character);
 
352
}
 
353
void setCDKAlphalistLRChar (CDKALPHALIST *alphalist, chtype character)
 
354
{
 
355
   setCDKScrollLRChar (alphalist->scrollField, character);
 
356
}
 
357
void setCDKAlphalistVerticalChar (CDKALPHALIST *alphalist, chtype character)
 
358
{
 
359
   setCDKEntryVerticalChar (alphalist->entryField, character);
 
360
   setCDKScrollVerticalChar (alphalist->scrollField, character);
 
361
}
 
362
void setCDKAlphalistHorizontalChar (CDKALPHALIST *alphalist, chtype character)
 
363
{
 
364
   setCDKEntryHorizontalChar (alphalist->entryField, character);
 
365
   setCDKScrollHorizontalChar (alphalist->scrollField, character);
 
366
}
 
367
void setCDKAlphalistBoxAttribute (CDKALPHALIST *alphalist, chtype character)
 
368
{
 
369
   setCDKEntryBoxAttribute (alphalist->entryField, character);
 
370
   setCDKScrollBoxAttribute (alphalist->scrollField, character);
 
371
}
 
372
 
 
373
/*
 
374
 * This sets the background color of the widget.
 
375
 */ 
 
376
void setCDKAlphalistBackgroundColor (CDKALPHALIST *alphalist, char *color)
 
377
{
 
378
   if (color != 0)
 
379
   {
 
380
      setCDKEntryBackgroundColor (alphalist->entryField, color);
 
381
      setCDKScrollBackgroundColor (alphalist->scrollField, color);
 
382
   }
 
383
}
 
384
 
 
385
/*
 
386
 * This destroys the file selector.     
 
387
 */
 
388
void destroyCDKAlphalist (CDKALPHALIST *alphalist)
 
389
{
 
390
   /* Erase the file selector. */
 
391
   eraseCDKAlphalist (alphalist);
 
392
 
 
393
   freeCharList (alphalist->list, alphalist->listSize);
 
394
 
 
395
   /* Destroy the other Cdk objects. */
 
396
   destroyCDKEntry (alphalist->entryField);
 
397
   destroyCDKScroll (alphalist->scrollField);
 
398
 
 
399
   /* Free up the window pointers. */
 
400
   deleteCursesWindow (alphalist->win);
 
401
 
 
402
   /* Unregister the object. */
 
403
   unregisterCDKObject (vALPHALIST, alphalist);
 
404
 
 
405
   /* Free up the object pointer. */
 
406
   free (alphalist);
 
407
}
 
408
 
 
409
/*
 
410
 * This function sets the pre-process function.
 
411
 */
 
412
void setCDKAlphalistPreProcess (CDKALPHALIST *alphalist, PROCESSFN callback, void *data)
 
413
{
 
414
   setCDKEntryPreProcess (alphalist->entryField, callback, data);
 
415
}
 
416
 
 
417
/*
 
418
 * This function sets the post-process function.
 
419
 */
 
420
void setCDKAlphalistPostProcess (CDKALPHALIST *alphalist, PROCESSFN callback, void *data)
 
421
{
 
422
   setCDKEntryPostProcess (alphalist->entryField, callback, data);
 
423
}
 
424
 
 
425
/*
 
426
 * Start of callback functions.
 
427
 */
 
428
static void adjustAlphalistCB (EObjectType objectType GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
 
429
{
 
430
   CDKALPHALIST *alphalist      = (CDKALPHALIST *)clientData;
 
431
   CDKSCROLL *scrollp           = (CDKSCROLL*)alphalist->scrollField;
 
432
   CDKENTRY *entry              = (CDKENTRY*)alphalist->entryField;
 
433
   char *current                = 0;
 
434
 
 
435
   /* Adjust the scrolling list. */
 
436
   injectCDKScroll (alphalist->scrollField, (chtype)key);
 
437
 
 
438
   /* Set the value in the entry field. */
 
439
   current = chtype2Char (scrollp->item[scrollp->currentItem]);
 
440
   setCDKEntryValue (entry, current);
 
441
   drawCDKEntry (entry, ObjOf(entry)->box);
 
442
   freeChar (current);
 
443
}
 
444
 
 
445
/*
 
446
 * This is the heart-beat of the widget.
 
447
 */
 
448
static int preProcessEntryField (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype input)
 
449
{
 
450
   CDKALPHALIST *alphalist      = (CDKALPHALIST *)clientData;
 
451
   CDKSCROLL *scrollp           = alphalist->scrollField;
 
452
   CDKENTRY *entry              = alphalist->entryField;
 
453
   int infoLen                  = 0;
 
454
   int Index;
 
455
   char pattern[5000];
 
456
 
 
457
   infoLen = (int)strlen (entry->info);
 
458
 
 
459
   /* Check the input. */
 
460
   if (isalnum (input) || ispunct (input) ||
 
461
        input == DELETE || input == CONTROL('H') || input == KEY_DC)
 
462
   {
 
463
      /* Copy the information from the entry field. */
 
464
      strcpy (pattern, entry->info);
 
465
 
 
466
      /* Truncate/Concatenate to the information in the entry field. */  
 
467
      if (input == DELETE || input == CONTROL('H') || input == KEY_DC)
 
468
      {
 
469
         /* If we had only 1 item in the list; jump back to the top. */
 
470
         if (infoLen <= 1)
 
471
         {
 
472
            setCDKScrollPosition (scrollp, 0);
 
473
            drawCDKScroll (scrollp, ObjOf(scrollp)->box);
 
474
            return 1;
 
475
         }
 
476
 
 
477
         pattern[infoLen - 1] = '\0';
 
478
      }
 
479
      else
 
480
      {
 
481
         pattern[infoLen] = (char)input;
 
482
         pattern[infoLen + 1] = '\0';
 
483
      }
 
484
 
 
485
      /* Look for the pattern in the list. */
 
486
      Index = searchList (alphalist->list, alphalist->listSize, pattern);
 
487
      if (Index >= 0)
 
488
      {
 
489
         setCDKScrollPosition (scrollp, Index);
 
490
         drawCDKScroll (scrollp, ObjOf(scrollp)->box);
 
491
      }
 
492
      else
 
493
      {
 
494
         Beep();
 
495
         return 0;
 
496
      }
 
497
   }
 
498
   return 1;
 
499
}
 
500
 
 
501
/*
 
502
 * This tries to complete the word in the entry field.
 
503
 */
 
504
static void completeWordCB (EObjectType objectType GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key GCC_UNUSED)
 
505
{
 
506
   CDKALPHALIST *alphalist      = (CDKALPHALIST *)clientData;
 
507
   CDKENTRY *entry              = (CDKENTRY*)alphalist->entryField;
 
508
   CDKSCROLL *scrollp           = 0;
 
509
   int currentIndex             = 0;
 
510
   int wordLength               = 0;
 
511
   int selected                 = -1;
 
512
   int altCount                 = 0;
 
513
   int height                   = 0;
 
514
   int match                    = 0;
 
515
   int Index                    = 0;
 
516
   int ret                      = 0;
 
517
   int x                        = 0;
 
518
   char *altWords[MAX_LINES];
 
519
 
 
520
   if (entry->info == 0)
 
521
   {
 
522
      Beep();
 
523
      return;
 
524
   }
 
525
   wordLength = (int)strlen (entry->info);
 
526
 
 
527
   /* If the word length is equal to zero, just leave. */
 
528
   if (wordLength == 0)
 
529
   {
 
530
      Beep();
 
531
      return;
 
532
   }
 
533
 
 
534
   /* Look for a unique word match. */
 
535
   Index = searchList (alphalist->list, alphalist->listSize, entry->info);
 
536
 
 
537
   /* If the index is less than zero, return we didn't find a match. */
 
538
   if (Index < 0)
 
539
   {
 
540
      Beep();
 
541
      return;
 
542
   }
 
543
 
 
544
   /* Did we find the last word in the list? */
 
545
   if (Index == alphalist->listSize-1)
 
546
   {
 
547
      setCDKEntryValue (entry, alphalist->list[Index]);
 
548
      drawCDKEntry (entry, ObjOf(entry)->box);
 
549
      return;
 
550
   }
 
551
 
 
552
   /* Ok, we found a match, is the next item similar? */
 
553
   ret = strncmp (alphalist->list[Index + 1], entry->info, wordLength);
 
554
   if (ret == 0)
 
555
   {
 
556
      currentIndex      = Index;
 
557
      altCount          = 0;
 
558
      height            = 0;
 
559
      match             = 0;
 
560
      selected          = -1;
 
561
 
 
562
      /* Start looking for alternate words. */
 
563
      while ((currentIndex < alphalist->listSize)
 
564
          && (strncmp (alphalist->list[currentIndex], entry->info, wordLength) == 0))
 
565
      {
 
566
         altWords[altCount] = copyChar (alphalist->list[currentIndex]);
 
567
         currentIndex++;
 
568
         altCount++;
 
569
      }
 
570
      
 
571
      /* Determine the height of the scrolling list. */
 
572
      height = MINIMUM (altCount + 3, 11);
 
573
 
 
574
      /* Create a scrolling list of close matches. */
 
575
      scrollp = newCDKScroll (entry->obj.screen, CENTER, CENTER, RIGHT, height, -30,
 
576
                                        "<C></B/5>Possible Matches.",
 
577
                                        altWords, altCount, NUMBERS,
 
578
                                        A_REVERSE, TRUE, FALSE);
 
579
 
 
580
      /* Allow them to select a close match. */
 
581
      match = activateCDKScroll (scrollp, 0);
 
582
      selected = scrollp->currentItem;
 
583
      
 
584
      /* Check how they exited the list. */
 
585
      if (scrollp->exitType == vESCAPE_HIT)
 
586
      {
 
587
         /* Beep at the user. */
 
588
         Beep();
 
589
 
 
590
         /* Destroy the scrolling list. */
 
591
         destroyCDKScroll (scrollp);
 
592
      }
 
593
      else
 
594
      {
 
595
         /* Destroy the scrolling list. */
 
596
         destroyCDKScroll (scrollp);
 
597
 
 
598
         /* Set the entry field to the selected value. */
 
599
         setCDKEntryValue (entry, altWords[match]);
 
600
 
 
601
         /* Move the highlight bar down to the selected value. */
 
602
         for (x=0; x < selected; x++)
 
603
         {
 
604
            injectCDKScroll (alphalist->scrollField, KEY_DOWN);
 
605
         }
 
606
      }
 
607
 
 
608
      /* Clean up. */
 
609
      freeCharList (altWords, altCount);
 
610
 
 
611
      /* Redraw the alphalist. */
 
612
      drawCDKAlphalist (alphalist, ObjOf(alphalist)->box);
 
613
   }
 
614
   else
 
615
   {
 
616
      /* Set the entry field with the found item. */
 
617
      setCDKEntryValue (entry, alphalist->list[Index]);
 
618
      drawCDKEntry (entry, ObjOf(entry)->box);
 
619
   }
 
620
}