w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

sh9.c
Go to the documentation of this file.
1 /*
2  * MS-DOS SHELL - History Processing
3  *
4  * MS-DOS SHELL - Copyright (c) 1990,4 Data Logic Limited
5  *
6  * This code is subject to the following copyright restrictions:
7  *
8  * 1. Redistribution and use in source and binary forms are permitted
9  * provided that the above copyright notice is duplicated in the
10  * source form and the copyright notice in file sh6.c is displayed
11  * on entry to the program.
12  *
13  * 2. The sources (or parts thereof) or objects generated from the sources
14  * (or parts of sources) cannot be sold under any circumstances.
15  *
16  * $Header: /usr/users/istewart/shell/sh2.3/Release/RCS/sh9.c,v 2.18 1994/08/25 20:49:11 istewart Exp $
17  *
18  * $Log: sh9.c,v $
19  * Revision 2.18 1994/08/25 20:49:11 istewart
20  * MS Shell 2.3 Release
21  *
22  * Revision 2.17 1994/02/23 09:23:38 istewart
23  * Beta 233 updates
24  *
25  * Revision 2.16 1994/02/01 10:25:20 istewart
26  * Release 2.3 Beta 2, including first NT port
27  *
28  * Revision 2.15 1994/01/20 14:51:43 istewart
29  * Release 2.3 Beta 1
30  *
31  * Revision 2.14 1994/01/11 17:55:25 istewart
32  * Release 2.3 Beta 0 patches
33  *
34  * Revision 2.13 1993/11/09 10:39:49 istewart
35  * Beta 226 checking
36  *
37  * Revision 2.12 1993/08/25 16:03:57 istewart
38  * Beta 225 - see Notes file
39  *
40  * Revision 2.11 1993/07/02 10:21:35 istewart
41  * 224 Beta fixes
42  *
43  * Revision 2.10 1993/06/16 13:50:00 istewart
44  * Fix defaults for Key initialisation
45  *
46  * Revision 2.9 1993/06/14 11:00:12 istewart
47  * More changes for 223 beta
48  *
49  * Revision 2.8 1993/06/02 09:52:35 istewart
50  * Beta 223 Updates - see Notes file
51  *
52  * Revision 2.7 1993/02/16 16:03:15 istewart
53  * Beta 2.22 Release
54  *
55  * Revision 2.6 1993/01/26 18:35:09 istewart
56  * Release 2.2 beta 0
57  *
58  * Revision 2.5 1992/12/14 10:54:56 istewart
59  * BETA 215 Fixes and 2.1 Release
60  *
61  * Revision 2.4 1992/11/06 10:03:44 istewart
62  * 214 Beta test updates
63  *
64  * Revision 2.3 1992/09/03 18:54:45 istewart
65  * Beta 213 Updates
66  *
67  * Revision 2.2 1992/07/16 14:33:34 istewart
68  * Beta 212 Baseline
69  *
70  * Revision 2.1 1992/07/10 10:52:48 istewart
71  * 211 Beta updates
72  *
73  * Revision 2.0 1992/05/07 21:33:35 Ian_Stewartson
74  * MS-Shell 2.0 Baseline release
75  *
76  */
77 
78 #include <sys/types.h>
79 #include <sys/stat.h>
80 #include <stdio.h>
81 #include <string.h>
82 #include <ctype.h>
83 #include <signal.h>
84 #include <stdlib.h>
85 #include <stddef.h>
86 #include <errno.h>
87 #include <setjmp.h>
88 #include <limits.h>
89 #include <unistd.h>
90 #include <dirent.h>
91 #include "sh.h"
92 
93 #if (OS_TYPE == OS_UNIX)
94 # include <termios.h>
95 #endif
96 
97 #if (OS_TYPE == OS_DOS)
98 # ifndef _NKEYBRD_READ
99 # define _NKEYBRD_READ 0x10 /* read next char from kbd */
100 # define _NKEYBRD_READY 0x11 /* check for keystroke */
101 # define _NKEYBRD_SHIFTSTATUS 0x12 /* get shift key status */
102 # endif
103 
104 # ifndef _KEYBRD_READ
105 # define _KEYBRD_READ 0x00 /* read next char from kbd */
106 # define _KEYBRD_READY 0x01 /* check for keystroke */
107 # define _KEYBRD_SHIFTSTATUS 0x02 /* get shift key status */
108 # endif
109 
110 # if defined (__TURBOC__)
111 # define _bios_keybrd(a) bioskey (a)
112 # elif defined (__EMX__)
113 unsigned int _bios_keybrd (unsigned int);
114 # endif
115 #endif
116 
117 /* Keyboard functions */
118 
119 #define KF_LENGTH ARRAY_SIZE (KF_List)
120 
121 /*
122  * Saved command line structure
123  */
124 
125 struct cmd_history {
126  int number;
127  char *command;
128 };
129 
130 /* Function Declarations */
131 
132 static bool F_LOCAL ProcessAlphaNumericKey (int);
133 static bool F_LOCAL ProcessFunctionKey (int);
134 static bool F_LOCAL Process_History (int);
135 static bool F_LOCAL ScanHistory (void);
136 static void F_LOCAL ReDisplayInputLine (void);
137 static void F_LOCAL PageHistoryRecord (int);
138 static bool F_LOCAL UpdateConsoleInputLine (char *);
139 static bool F_LOCAL ReStartInput (char *);
140 static void F_LOCAL GenerateNewCursorPosition (void);
141 static void F_LOCAL EraseToEndOfLine (void);
142 static bool F_LOCAL CompleteFileName (char *, bool);
143 static void F_LOCAL InitialiseInput (bool);
144 static void F_LOCAL PrintOutHistory (FILE *, bool, struct cmd_history *);
145 static void F_LOCAL ReleaseCommandMemory (struct cmd_history *);
146 static void F_LOCAL SaveCurrentHistory (void);
147 static void F_LOCAL memrcpy (char *, char *, int);
148 static FILE * F_LOCAL OpenHistoryFile (char *);
149 static void F_LOCAL GetLineFromConsole (void);
150 #ifdef KEYDEBUG
151 static void DisplayKeyCode (unsigned int, unsigned int);
152 #else
153 # define DisplayKeyCode(a,b)
154 #endif
155 
156 
157 #if (OS_TYPE != OS_DOS)
158 static void F_LOCAL ChangeKeyboardMode (bool);
159 #else
160 # define ChangeKeyboardMode(a)
161 #endif
162 
163 #if (OS_TYPE == OS_NT)
164 static bool F_LOCAL DoNTKeyMap (KEY_EVENT_RECORD *);
165 #endif
166 
167 #if (OS_TYPE == OS_DOS) && (OS_SIZE == OS_16)
168 static bool DESQviewActive = FALSE;/* Poll keyboard */
169 #endif
170 
171 static bool F_LOCAL InsertACharacter (int);
172 static int F_LOCAL OutputACharacter (int);
173 static int F_LOCAL GetLineFromDevice (void);
174 
175 #if (OS_TYPE == OS_DOS)
176 static void F_LOCAL CheckKeyboardPolling (void);
177  /* Read keyboard parameter */
178 static unsigned int ReadKeyboardOption = _KEYBRD_READ;
179 #else
180 # define CheckKeyboardPolling()
181 #endif
182 
183 static bool InsertMode = FALSE;
184 static char *c_buffer_pos; /* Position in command line */
185 static char *EndOfCurrentLine; /* End of command line */
186 static int m_line = 0; /* Max write line number */
187 static int c_history = -1; /* Current entry */
188 static int l_history = 0; /* End of history array */
189 static int M_length = -1; /* Match length */
190 static int MaxLength = 0; /* Max line length */
191 static int OldMaxLength = 0; /* Previous Max line length */
192 static int CurrentHistorySize = 0; /* Current Length of History */
193  /* Array */
194 static bool AppendHistory = FALSE; /* Append to history */
195 static bool SaveHistory = FALSE; /* Save history */
196 static char *No_prehistory = "No previous commands";
197 static char *No_MatchHistory = "No history match found";
198 static char *No_posthistory = "No more commands";
199 static char *History_2long = "History line too long";
200 
201 #if (OS_TYPE == OS_NT)
202 static HANDLE NT_StdIn; /* Standard Input handler */
203 static HANDLE NT_StdOut; /* Standard Ouput handler */
204 
205 #define CTRL_PRESSED ((LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
206 #define ALT_PRESSED ((LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED))
207 
208 /* Scan codes to ignore on input */
209 
210 extern WORD IgnoreScanCode[];
211 
212 #define IGNORE_CNT 6
213 
214 /* Mapping table because we don't get converted scan codes */
215 
216 
217 struct NT_KFMap {
218  unsigned char Normal; /* Normal scancode */
219  unsigned char Shift; /* shift scancode */
220  unsigned char Control; /* Control scancode */
221  unsigned char Alt; /* Alt scancode */
222 } NT_KFMap [] = {
223  /* Key Normal Shift- Control- Alt- */
224  { /* F1 */ 0x3b, 0x54, 0x5E, 0x68 },
225  { /* F2 */ 0x3c, 0x55, 0x5F, 0x69 },
226  { /* F3 */ 0x3d, 0x56, 0x60, 0x6A },
227  { /* F4 */ 0x3e, 0x57, 0x61, 0x6B },
228  { /* F5 */ 0x3f, 0x58, 0x62, 0x6C },
229  { /* F6 */ 0x40, 0x59, 0x63, 0x6D },
230  { /* F7 */ 0x41, 0x5A, 0x64, 0x6E },
231  { /* F8 */ 0x42, 0x5B, 0x65, 0x6F },
232  { /* F9 */ 0x43, 0x5C, 0x66, 0x70 },
233  { /* F10 */ 0x44, 0x5D, 0x67, 0x71 },
234  { /* F11 */ 0x85, 0x87, 0x89, 0x8b },
235  { /* F12 */ 0x86, 0x88, 0x8a, 0x8c },
236 
237  { /* INSERT */ 0x52, 0x52, 0x00, 0x00 },
238  { /* HOME */ 0x47, 0x47, 0x77, 0x00 },
239  { /* PAGE UP */ 0x49, 0x49, 0x84, 0x00 },
240  { /* DELETE */ 0x53, 0x53, 0x00, 0x00 },
241  { /* END */ 0x4f, 0x4f, 0x75, 0x00 },
242  { /* PAGE DOWN */ 0x51, 0x51, 0x76, 0x00 },
243 
244  { /* UP ARROW */ 0x48, 0x48, 0x00, 0x00 },
245  { /* LEFT ARROW */ 0x4b, 0x4b, 0x73, 0x00 },
246  { /* DOWN ARROW */ 0x50, 0x50, 0x00, 0x00 },
247  { /* RIGHT ARROW */ 0x4d, 0x4d, 0x74, 0x00 },
248 };
249 
250 #define MAX_NT_FKMAP ARRAY_SIZE (NT_KFMap)
251 #endif
252 
253 /* Function Key table */
254 
255 static struct Key_Fun_List {
256  char *kf_name;
257  unsigned char akey;
258  unsigned char fkey;
259  unsigned char fcode;
260 } KF_List[] = {
261  { "ScanBackward", 0, 'I', KF_SCANBACKWARD },
262  { "ScanForeward", 0, 'Q', KF_SCANFOREWARD },
263  { "Previous", 0, 'H', KF_PREVIOUS },
264  { "Next", 0, 'P', KF_NEXT },
265  { "Left", 0, 'K', KF_LEFT },
266  { "Right", 0, 'M', KF_RIGHT },
267  { "WordRight", 0, 't', KF_WORDRIGHT },
268  { "WordLeft", 0, 's', KF_WORDLEFT },
269  { "Start", 0, 'G', KF_START },
270  { "Clear", 0x0ff, 'v', KF_CLEAR },
271  { "Flush", 0, 'u', KF_FLUSH },
272  { "End", 0, 'O', KF_END },
273  { "Insert", 0, 'R', KF_INSERT },
274  { "DeleteRight", 0, 'S', KF_DELETERIGHT },
275  { "DeleteLeft", CHAR_BACKSPACE, 0, KF_DELETELEFT },
276  { "Complete", 0, 'w', KF_COMPLETE },
277  { "Directory", 0, 0x0f, KF_DIRECTORY },
278  { "ClearScreen", 0, 0x84, KF_CLEARSCREEN },
279  { "Jobs", 0, 0x68, KF_JOBS },
280  { "Transpose", 0x14, 0, KF_TRANSPOSE },
281  { "Quote", 0x11, 0, KF_QUOTE },
282 
283 /* End of function keys - flags */
284 
285  { "Bell", 1, 0, KF_RINGBELL },
286  { "HalfHeight", 0, 0, KF_HALFHEIGTH },
287  { "InsertMode", 0, 0, KF_INSERTMODE },
288  { "InsertCursor", 1, 0, KF_INSERTCURSOR },
289  { "RootDrive", 0, 0, KF_ROOTDRIVE },
290  { "EOFKey", 4, 0, KF_EOFKEY },
291 };
292 
293 /* Arrary of history Items */
294 
295 static struct cmd_history *cmd_history = (struct cmd_history *)NULL;
296 
297 /*
298  * Processing standard input. Editting is only supported on OS/2 at the
299  * moment.
300  */
301 
302 int GetConsoleInput (void)
303 {
304  bool console = C2bool (IS_Console (0));
305  int RetVal = 0;
306 
307 /* Has dofc set the flag to say use the console buffer ? */
308 
309  if (UseConsoleBuffer)
310  {
312  SaveHistory = TRUE;
314  SaveHistory = FALSE;
315  }
316 
317 /*
318  * Read in a line from the console
319  */
320 
321  else
322  {
323 
324 /* Set to last history item */
325 
326  if (FL_TEST (FLAG_INTERACTIVE) || (IS_TTY (0) && IS_TTY (1)))
328 
329 /* Zap the line and output the prompt. Save history status info */
330 
332 
333  if (FL_TEST (FLAG_INTERACTIVE) || (IS_TTY (0) && IS_TTY (1)))
334  {
335  bool o_SaveHistory = SaveHistory;
336 
338  SaveHistory = o_SaveHistory;
339  }
340 
341 /* Only if we are working on the console and not via a pipe or file do we
342  * need to set up the console
343  */
344 
345  if (console)
346  {
348 
349  if (ChangeInitLoad)
350  {
352  Configure_Keys ();
353  }
354 
356  }
357 
358 /*
359  * Process the input. If this is not the console, read from standard input
360  */
361 
362  if (!console)
363  RetVal = GetLineFromDevice ();
364 
365  else
366  {
368 
369 #if defined (FLAGS_VI) || defined (FLAGS_EMACS) || defined (FLAGS_GMACS)
371  RetVal = EditorInput ();
372 
373  else
374 #endif
376 
378  }
379 
380  if (LastUserPrompt == PS1)
382 
383 /* Clean up */
384 
385  FlushStreams ();
386 
387  if (console)
389  }
390 
391 /* Return any errors */
392 
393  if (RetVal < 0)
394  return 0;
395 
396 /* If we are reading from the console, check for end of file. From file or
397  * pipe, we detect this differently
398  */
399 
400  if (console)
401  {
402  if (*ConsoleLineBuffer == (char)KF_List[KF_EOFKEY].akey)
403  *ConsoleLineBuffer = 0;
404 
405  else
406  strcat (ConsoleLineBuffer, LIT_NewLine);
407  }
408 
409  return strlen (ConsoleLineBuffer);
410 }
411 
412 /*
413  * Read a line from a file or pipe - well pipe really.
414  */
415 
416 static int F_LOCAL GetLineFromDevice (void)
417 {
418  while (fgets (ConsoleLineBuffer, LINE_MAX, stdin) != (char *)NULL)
419  {
421  return 0;
422 
423  else if (Process_History (0))
424  {
425  puts (ConsoleLineBuffer);
426  return 0;
427  }
428  }
429 
430 /* EOF detected - return that fact */
431 
432  return -1;
433 }
434 
435 /*
436  * Read line from Console
437  */
438 
439 static void F_LOCAL GetLineFromConsole (void)
440 {
441  unsigned char a_key, f_key;
442  int i;
443 
444 /* Process the input */
445 
446  while (TRUE)
447  {
448  InitialiseInput ((bool)KF_List[KF_INSERTMODE].akey);
449 
450  while (((a_key = ReadKeyBoard (&f_key)) != KF_List[KF_EOFKEY].akey) &&
451  (a_key != CHAR_NEW_LINE) && (a_key != CHAR_RETURN))
452  {
453 
454 /* Handle Resize event */
455 
456  if (a_key == KT_RESIZE)
457  {
458  fputchar (CHAR_NEW_LINE);
462  continue;
463  }
464 
465 /* Look up the keystroke to see if it is one of our functions */
466 
467  if (!(i = LookUpKeyBoardFunction (a_key, f_key)))
468  continue;
469 
470  if (((i > 0) ? ProcessAlphaNumericKey (i)
471  : ProcessFunctionKey ((-i) - 1)))
473 
474 /* Handle a special case on insert mode on line 25 */
475 
476  if ((InsertMode) && (MaxLength > OldMaxLength) &&
478  == MaximumLines) &&
481 
482 /* Reposition the cursor */
483 
485 
486 /* Save old line length */
487 
489  }
490 
491 /* Terminate the line */
492 
495  fputchar (CHAR_NEW_LINE);
496  StartCursorPosition = -1;
497  FlushStreams ();
498 
499 /* Line input - check for history */
500 
502  {
503  puts (ConsoleLineBuffer);
504  break;
505  }
506 
507  else if (*ConsoleLineBuffer != CHAR_HISTORY)
508  break;
509  }
510 
511  if (a_key == KF_List[KF_EOFKEY].akey)
513 }
514 
515 /*
516  * Handler Alpha_numeric characters
517  */
518 
520 {
521  bool redisplay = FALSE;
522 
523 /* Normal character processing */
524 
526  return RingWarningBell ();
527 
528  else if (!InsertMode)
529  {
532 
533  else if (iscntrl (*c_buffer_pos) || iscntrl (c))
534  redisplay = TRUE;
535 
536  *(c_buffer_pos++) = (char)c;
537 
538  if (redisplay || (c == CHAR_TAB))
539  return TRUE;
540 
541 /* Output the character */
542 
544  return FALSE;
545  }
546 
547  else
548  return InsertACharacter (c);
549 }
550 
551 /* Process function keys */
552 
553 static bool F_LOCAL ProcessFunctionKey (int fn)
554 {
555  bool fn_search = FALSE;
556  char tmp;
557 
558  switch (fn)
559  {
560  case KF_SCANBACKWARD: /* Scan backwards in history */
561  case KF_SCANFOREWARD: /* Scan forewards in history */
562  *EndOfCurrentLine = 0;
563 
564  if (M_length == -1)
566 
567  PageHistoryRecord ((fn == KF_SCANBACKWARD) ? -1 : 1);
568  return TRUE;
569 
570  case KF_PREVIOUS: /* Previous command */
571  *EndOfCurrentLine = 0;
572  Process_History (-1);
573  return TRUE;
574 
575  case KF_NEXT: /* Next command line */
576  Process_History (1);
577  return TRUE;
578 
579  case KF_LEFT: /* Cursor left */
581  --c_buffer_pos;
582 
583  else
584  RingWarningBell ();
585 
586  return FALSE;
587 
588  case KF_RIGHT: /* Cursor right */
590  ++c_buffer_pos;
591 
592  else
593  RingWarningBell ();
594 
595  return FALSE;
596 
597  case KF_WORDLEFT: /* Cursor left a word */
599  {
600  --c_buffer_pos; /* Reposition on previous char */
601 
602  while (isspace (*c_buffer_pos) &&
604  --c_buffer_pos;
605 
606  while (!isspace (*c_buffer_pos) &&
608  --c_buffer_pos;
609 
611  ++c_buffer_pos;
612  }
613 
614  else
615  RingWarningBell ();
616 
617  return FALSE;
618 
619  case KF_WORDRIGHT: /* Cursor right a word */
621  {
622 
623 /* Skip to the end of the current word */
624 
625  while (!isspace (*c_buffer_pos) &&
627  ++c_buffer_pos;
628 
629 /* Skip over the white space */
630 
631  while (isspace (*c_buffer_pos) &&
633  ++c_buffer_pos;
634  }
635 
636  else
637  RingWarningBell ();
638 
639  return FALSE;
640 
641  case KF_START: /* Cursor home */
643  return FALSE;
644 
645  case KF_CLEAR: /* Erase buffer */
647 
648  case KF_FLUSH: /* Flush to end */
651  return TRUE;
652 
653  case KF_END: /* Cursor end of command */
655  {
656  *EndOfCurrentLine = 0;
657  Process_History (2);
658  return TRUE;
659  }
660 
662  return FALSE;
663 
664  case KF_INSERT: /* Switch insert mode */
667  return FALSE;
668 
669  case KF_CLEARSCREEN: /* Clear the screen */
670  return ClearScreen ();
671 
672  case KF_TRANSPOSE: /* Transpose characters */
674  return RingWarningBell ();
675 
677  --c_buffer_pos;
678 
679  tmp = *(c_buffer_pos - 1);
680  *(c_buffer_pos - 1) = *c_buffer_pos;
681  *c_buffer_pos = tmp;
682 
684  ++c_buffer_pos;
685 
686  return TRUE;
687 
688  case KF_QUOTE: /* Quote characters */
689  return ProcessAlphaNumericKey ((int)ReadKeyBoard ((unsigned char *)&tmp));
690 
691 #if (OS_TYPE != OS_DOS)
692  case KF_JOBS: /* Print Job Tree */
693  fputchar (CHAR_NEW_LINE);
694 # if (OS_TYPE == OS_NT)
695  PrintJobs (TRUE);
696 # else
697  PrintProcessTree (getpid ());
698 # endif
701  return TRUE;
702 #endif
703 
704  case KF_DELETERIGHT: /* Delete right character */
706  return FALSE;
707 
710 
712  {
713  RingWarningBell ();
714  return TRUE;
715  }
716 
718  --c_buffer_pos;
719 
720  return TRUE;
721 
722  case KF_DIRECTORY: /* File name directory */
723  fn_search = TRUE;
724 
725  case KF_COMPLETE: /* File name completion */
726  {
727  *EndOfCurrentLine = 0;
728  return CompleteFileName (c_buffer_pos, fn_search);
729  }
730 
731  case KF_DELETELEFT: /* Delete left character */
733  return RingWarningBell ();
734 
735 /* Decrement current position */
736 
737  --c_buffer_pos;
741  return TRUE;
742  }
743 
744  return FALSE;
745 }
746 
747 /* Set cursor shape */
748 
749 #if (OS_TYPE == OS_OS2)
750 void SetCursorShape (bool mode)
751 {
752  VIOCURSORINFO viociCursor;
753 
754  VioGetCurType (&viociCursor, 0);
755 
756  if (mode && KF_List[KF_INSERTCURSOR].akey)
757  viociCursor.yStart = (USHORT)((KF_List[KF_HALFHEIGTH].akey
758  ? (viociCursor.cEnd / 2) + 1 : 1));
759 
760  else
761  viociCursor.yStart = (USHORT)(viociCursor.cEnd - 1);
762 
763  VioSetCurType (&viociCursor, 0);
764 }
765 #endif
766 
767 /* NT version */
768 
769 #if (OS_TYPE == OS_NT)
770 void SetCursorShape (bool mode)
771 {
772  CONSOLE_CURSOR_INFO ConsoleCursorInfo;
773 
774  GetConsoleCursorInfo (NT_StdOut, &ConsoleCursorInfo);
775 
776  if (mode && KF_List[KF_INSERTCURSOR].akey)
777  ConsoleCursorInfo.dwSize = (KF_List[KF_HALFHEIGTH].akey ? 50 : 90);
778 
779  else
780  ConsoleCursorInfo.dwSize = 10;
781 
782  ConsoleCursorInfo.bVisible = TRUE;
783  SetConsoleCursorInfo (NT_StdOut, &ConsoleCursorInfo);
784 }
785 #endif
786 
787 /* DOS version */
788 
789 #if (OS_TYPE == OS_DOS)
790 void SetCursorShape (bool mode)
791 {
792  union REGS r;
793 
794 /* Get the current cursor position to get the cursor lines */
795 
796  r.h.ah = 0x03;
797  SystemInterrupt (0x10, &r, &r);
798 
799 /* Reset the type */
800 
801  r.h.ah = 0x01;
802 
803  if (mode && KF_List[KF_INSERTCURSOR].akey)
804  r.h.ch = (unsigned char)((KF_List[KF_HALFHEIGTH].akey
805  ? (r.h.cl / 2) + 1 : 1));
806 
807  else
808  r.h.ch = (unsigned char)(r.h.cl - 1);
809 
810  SystemInterrupt (0x10, &r, &r);
811 }
812 #endif
813 
814 /* UNIX version */
815 
816 #if (OS_TYPE == OS_UNIX)
817 void SetCursorShape (bool mode)
818 {
819 }
820 #endif
821 
822 /*
823  * Read Cursor position
824  */
825 
826 #if (OS_TYPE == OS_OS2)
827 int ReadCursorPosition (void)
828 {
829  USHORT usRow;
830  USHORT usColumn;
831 
832  VioGetCurPos (&usRow, &usColumn, 0);
833  return (MaximumColumns * usRow) + usColumn;
834 }
835 #endif
836 
837 /* NT Version */
838 
839 #if (OS_TYPE == OS_NT)
840 int ReadCursorPosition (void)
841 {
842  CONSOLE_SCREEN_BUFFER_INFO CSI;
843 
844  GetConsoleScreenBufferInfo (NT_StdOut, &CSI);
845 
846  return (MaximumColumns * CSI.dwCursorPosition.Y) + CSI.dwCursorPosition.X;
847 }
848 #endif
849 
850 /* DOS Version */
851 
852 #if (OS_TYPE == OS_DOS)
854 {
855  union REGS r;
856 
857  FlushStreams ();
858 
859  r.h.ah = 0x03; /* Read cursor position */
860  r.h.bh = 0; /* Page zero */
861  SystemInterrupt (0x10, &r, &r);
862  return (r.h.dh * MaximumColumns) + r.h.dl;
863 }
864 #endif
865 
866 /*
867  * Re-position the cursor
868  */
869 
870 #if (OS_TYPE == OS_OS2)
871 void SetCursorPosition (int new)
872 {
873  int diff;
874  USHORT usRow;
875  USHORT usColumn;
876 
877  FlushStreams ();
878 
879  usRow = (USHORT)(new / MaximumColumns);
880  usColumn = (USHORT)(new % MaximumColumns);
881 
882 /* Are we at the bottom of the page? */
883 
884  if (usRow >= (unsigned char)MaximumLines)
885  {
886  diff = usRow + 1 - MaximumLines;
887  usRow = (unsigned char)(MaximumLines - 1);
889  }
890 
891  VioSetCurPos (usRow, usColumn, 0);
892 }
893 #endif
894 
895 /* NT Version */
896 
897 #if (OS_TYPE == OS_NT)
898 void SetCursorPosition (int new)
899 {
900  int diff;
901  COORD Cp;
902 
903  FlushStreams ();
904 
905  Cp.Y = (USHORT)(new / MaximumColumns);
906  Cp.X = (USHORT)(new % MaximumColumns);
907 
908 /* Are we at the bottom of the page? */
909 
910  if (Cp.Y >= (unsigned char)MaximumLines)
911  {
912  diff = Cp.Y + 1 - MaximumLines;
913  Cp.Y = (unsigned char)(MaximumLines - 1);
915  }
916 
917  SetConsoleCursorPosition (NT_StdOut, Cp);
918 }
919 #endif
920 
921 /* DOS Version */
922 
923 #if (OS_TYPE == OS_DOS)
924 void SetCursorPosition (int new)
925 {
926  int diff;
927  union REGS r;
928 
929  FlushStreams ();
930 
931  r.h.ah = 0x02; /* Set new position */
932  r.h.bh = 0; /* Page zero */
933  r.h.dh = (unsigned char)(new / MaximumColumns);
934  r.h.dl = (unsigned char)(new % MaximumColumns);
935 
936 /* Are we at the bottom of the page? */
937 
938  if (r.h.dh >= (unsigned char)MaximumLines)
939  {
940  diff = r.h.dh + 1 - MaximumLines;
941  r.h.dh = (unsigned char)(MaximumLines - 1);
943  }
944 
945  SystemInterrupt (0x10, &r, &r);
946 }
947 #endif
948 
949 /* Erase to end of line (avoid need for STUPID ansi.sys memory eater!) */
950 
951 #if (OS_TYPE == OS_OS2)
952 static void F_LOCAL EraseToEndOfLine (void)
953 {
954  BYTE abCell[2];
955  USHORT usRow;
956  USHORT usColumn;
957  USHORT cb = sizeof (abCell);
958 
959  FlushStreams ();
960 
961 /* Read attribute under cursor */
962 
963  VioGetCurPos (&usRow, &usColumn, 0);
964  VioReadCellStr (abCell, &cb , usRow, usColumn, 0);
965 
966  abCell[0] = CHAR_SPACE;
967 
968  if (m_line < (int)usRow)
969  m_line = usRow;
970 
971  if ((cb = MaximumColumns - usColumn +
972  ((m_line - usRow) * MaximumColumns)) > 0)
973  VioWrtNCell (abCell, cb, usRow, usColumn, 0);
974 }
975 #endif
976 
977 /* NT Version */
978 
979 #if (OS_TYPE == OS_NT)
980 static void F_LOCAL EraseToEndOfLine (void)
981 {
982  WORD Atts[2];
983  CONSOLE_SCREEN_BUFFER_INFO CSI;
984  DWORD ActionCount;
985  DWORD cb;
986  WORD *ostring;
987  DWORD i;
988 
989  FlushStreams ();
990 
991 /* Read attribute under cursor */
992 
993  GetConsoleScreenBufferInfo (NT_StdOut, &CSI);
994 
995  ReadConsoleOutputAttribute (NT_StdOut, Atts, 1, CSI.dwCursorPosition,
996  &ActionCount);
997 
998 /* How much to write ? */
999 
1000  if (m_line < (int) CSI.dwCursorPosition.Y)
1001  m_line = CSI.dwCursorPosition.Y;
1002 
1003 /* Write it. What a pain!!! */
1004 
1005  if ((cb = MaximumColumns - CSI.dwCursorPosition.X +
1006  ((m_line - CSI.dwCursorPosition.Y) * MaximumColumns)) > 0)
1007  {
1008  ostring = (WORD *)AllocateMemoryCell (cb * sizeof (WORD));
1009  memset (ostring, CHAR_SPACE, cb);
1010 
1011  WriteConsoleOutputCharacter (NT_StdOut, (char *)ostring, cb,
1012  CSI.dwCursorPosition, &ActionCount);
1013 
1014 /* Set up attributes */
1015 
1016  for (i = 0; i < cb; i++)
1017  ostring[i] = Atts[0];
1018 
1019  WriteConsoleOutputAttribute (NT_StdOut, ostring, cb,
1020  CSI.dwCursorPosition, &ActionCount);
1021  ReleaseMemoryCell (ostring);
1022  }
1023 }
1024 #endif
1025 
1026 /* DOS Version */
1027 
1028 #if (OS_TYPE == OS_DOS)
1029 static void F_LOCAL EraseToEndOfLine (void)
1030 {
1031  union REGS r;
1032  unsigned char backg;
1033 
1034  FlushStreams ();
1035 
1036 /* Get the background attribute of the cursor */
1037 
1038  r.h.ah = 0x08;
1039  r.h.bh = 0;
1040  SystemInterrupt (0x10, &r, &r);
1041  backg = (unsigned char)(r.h.ah & 0x07);
1042 
1043  r.h.ah = 0x03;
1044  r.h.bh = 0;
1045  SystemInterrupt (0x10, &r, &r);
1046 
1047 /* Check that we use the correct m_line */
1048 
1049  if (m_line < (int)r.h.dh)
1050  m_line = r.h.dh;
1051 
1052  if ((r.x.REG_CX = MaximumColumns - r.h.dl +
1053  ((m_line - r.h.dh) * MaximumColumns)) > 0)
1054  {
1055  r.x.REG_AX = 0x0a20;
1056  r.x.REG_BX = backg;
1057  SystemInterrupt (0x10, &r, &r);
1058  }
1059 }
1060 #endif
1061 
1062 /* DOS Version */
1063 
1064 #if (OS_TYPE == OS_UNIX)
1065 static void F_LOCAL EraseToEndOfLine (void)
1066 {
1067  fputs ("UNIX: EraseToEndOfLine NI\n", stderr);
1068 }
1069 #endif
1070 
1071 /*
1072  * Generate the new cursor position
1073  */
1074 
1076 {
1077  char *cp = ConsoleLineBuffer - 1;
1078  int off = StartCursorPosition;
1079 
1080 /* Search to current position */
1081 
1082  while (++cp != c_buffer_pos)
1083  {
1084  if (*cp == CHAR_TAB)
1085  while ((++off) % 8);
1086 
1087  else
1088  off += (iscntrl (*cp)) ? 2 : 1;
1089  }
1090 
1091 /* Position the cursor */
1092 
1094 }
1095 
1096 /* Redisplay the current line */
1097 
1098 static void F_LOCAL ReDisplayInputLine (void)
1099 {
1100 /* Reposition to start of line */
1101 
1103 
1104 /* Output the line */
1105 
1106  *EndOfCurrentLine = 0;
1108 
1109  if ((m_line = ((StartCursorPosition + MaxLength) / MaximumColumns) + 1) >=
1110  MaximumLines)
1111  m_line = MaximumLines - 1;
1112 
1113  EraseToEndOfLine (); /* clear to end of line */
1115 }
1116 
1117 /* Process history command
1118  *
1119  * -1: Previous command
1120  * 1: Next command
1121  * 0: Current command
1122  * 2: Current command with no options processing
1123  */
1124 
1126 {
1127  char *optionals = null;
1128 
1131  c_history += (direction == 2) ? 0 : direction;
1132 
1133  switch (direction)
1134  {
1135  case -1: /* Move up one line */
1136  if (c_history < 0)
1137  {
1138  c_history = -1;
1139  return ReStartInput (No_prehistory);
1140  }
1141 
1142  break;
1143 
1144  case 1: /* Move to next history line */
1145  if (c_history >= l_history)
1146  {
1147  c_history = l_history;
1148  return ReStartInput (No_posthistory);
1149  }
1150 
1151  break;
1152 
1153  case 0: /* Check out ConsoleLineBuffer */
1154  optionals = ConsoleLineBuffer;/* Are there any additions to */
1155  /* the history line */
1156 
1157 /* Find the end of the first part */
1158 
1159  while (!isspace (*optionals) && *optionals)
1160  {
1161  if (*optionals == CHAR_HISTORY)
1162  {
1163 
1164 /* Terminate at !! */
1165 
1166  if (*(optionals + 1) == CHAR_HISTORY)
1167  {
1168  optionals += 2;
1169  break;
1170  }
1171 
1172 /* Terminate at a numeric value */
1173 
1174  else if (isdigit (*(optionals + 1)) ||
1175  (*(optionals + 1) == '-'))
1176  {
1177  optionals += 2;
1178  while (isdigit (*optionals))
1179  ++optionals;
1180 
1181  break;
1182  }
1183  }
1184 
1185  ++optionals;
1186  }
1187 
1188 /* Copy selected item into line buffer */
1189 
1190  case 2:
1191  M_length = (optionals == null) ? strlen (ConsoleLineBuffer) - 1
1192  : optionals - ConsoleLineBuffer - 1;
1193 
1194  if (!ScanHistory ())
1195  return FALSE;
1196 
1197  break;
1198  }
1199 
1200  return UpdateConsoleInputLine (optionals);
1201 }
1202 
1203 /* Ok c_history points to the new line. Move optionals after history
1204  * and the copy in history and add a space
1205  */
1206 
1207 static bool F_LOCAL UpdateConsoleInputLine (char *optionals)
1208 {
1209  int opt_len;
1210 
1212 
1214  (opt_len = strlen (optionals)) + 1) >= LINE_MAX)
1215  return ReStartInput (History_2long);
1216 
1217  if (EndOfCurrentLine > optionals)
1218  memrcpy (EndOfCurrentLine + opt_len, optionals + opt_len, opt_len + 1);
1219 
1220  else
1221  strcpy (EndOfCurrentLine, optionals);
1222 
1227  return TRUE;
1228 }
1229 
1230 /* Scan the line buffer for a history match */
1231 
1232 static bool F_LOCAL ScanHistory (void)
1233 {
1234  char *cp = ConsoleLineBuffer + 1;
1235  char *ep;
1236  int i = (int)strtol (cp, &ep, 10);
1237 
1238 /* Get the previous command ? (single ! or double !!) */
1239 
1240  if ((M_length == 0) || (*cp == CHAR_HISTORY))
1241  {
1242  if (c_history >= l_history)
1243  c_history = l_history - 1;
1244 
1245  if (c_history < 0)
1246  return ReStartInput (No_prehistory);
1247 
1248  return TRUE;
1249  }
1250 
1251 /* Request for special history number item. Check History file empty */
1252 
1253  if (l_history == 0)
1254  return ReStartInput (No_MatchHistory);
1255 
1256 /* Check for number */
1257 
1258  if ((*ConsoleLineBuffer == CHAR_HISTORY) && (ep > cp) && M_length)
1259  {
1260  M_length = -1;
1261 
1262  for (c_history = l_history - 1;
1263  (c_history >= 0) && (cmd_history[c_history].number != i);
1264  --c_history)
1265  continue;
1266  }
1267 
1268 /* No - scan for a match */
1269 
1270  else
1271  {
1272  for (c_history = l_history - 1;
1273  (c_history >= 0) &&
1275  --c_history)
1276  continue;
1277  }
1278 
1279 /* Anything found ? */
1280 
1281  if (c_history == -1)
1282  {
1283  c_history = l_history - 1;
1284  return ReStartInput (No_MatchHistory);
1285  }
1286 
1287  return TRUE;
1288 }
1289 
1290 /*
1291  * Get record associated with event
1292  */
1293 
1294 char *GetHistoryRecord (int event)
1295 {
1296  int i = l_history - 1;
1297 
1298  while (i >= 0)
1299  {
1300  if (cmd_history[i].number == event)
1301  return cmd_history[i].command;
1302 
1303  --i;
1304  }
1305 
1306  return (char *)NULL;
1307 }
1308 
1309 /*
1310  * Scan back or forward from current history
1311  */
1312 
1314 {
1317 
1318  if (l_history == 0)
1319  {
1321  return;
1322  }
1323 
1324 /* scan for a match */
1325 
1326  while (((c_history += direction) >= 0) && (c_history != l_history) &&
1328  M_length) != 0))
1329  continue;
1330 
1331 /* Anything found ? */
1332 
1333  if ((c_history < 0) || (c_history >= l_history))
1334  {
1335  c_history = l_history - 1;
1337  }
1338 
1339  else
1340  UpdateConsoleInputLine (null);
1341 }
1342 
1343 /* Load history file */
1344 
1345 void LoadHistory (void)
1346 {
1347  FILE *fp;
1348  char *cp;
1349  int i = 0;
1350  bool Append = FALSE;
1351 
1352 /* Initialise history array */
1353 
1354  c_history = -1; /* Current entry */
1355  l_history = 0; /* End of history array */
1356 
1358  {
1360  (cp = BuildFileName ("history.sh")));
1361  ReleaseMemoryCell ((void *)cp);
1362  }
1363 
1366 
1367  if ((fp = OpenHistoryFile (sOpenReadMode)) == (FILE *)NULL)
1368  return;
1369 
1370 /* Read in file */
1371 
1373 
1374  while ((i = fgetc (fp)) != EOF)
1375  {
1376  if (i == 0)
1377  {
1378  *cp = 0;
1380  AddHistory (Append);
1381  Append = FALSE;
1382  }
1383 
1384  else if (i == CHAR_NEW_LINE)
1385  {
1386  *cp = 0;
1388  AddHistory (Append);
1389  Append = TRUE;
1390  }
1391 
1392  else if ((cp - ConsoleLineBuffer) < LINE_MAX - 2)
1393  *(cp++) = (char)i;
1394  }
1395 
1396  CloseFile (fp);
1397 }
1398 
1399 /* Open the history file */
1400 
1402 {
1403  char *name;
1404 
1405  if (!HistoryEnabled)
1406  return (FILE *)NULL;
1407 
1409  return FOpenFile (name, mode);
1410 }
1411 
1412 /* Add entry to history file */
1413 
1414 void AddHistory (bool AppendToLast)
1415 {
1416  char *cp;
1417  struct cmd_history *cmd;
1418  size_t Len;
1419  int HistorySize;
1420 
1421 /* Clean up console buffer */
1422 
1424 
1425 /*
1426  * Ignore if no history or blank line
1427  */
1428 
1429  if ((!HistoryEnabled) || (strlen (ConsoleLineBuffer) == 0))
1430  return;
1431 
1432 /* Has the size changed ? */
1433 
1434  HistorySize = (int)GetVariableAsNumeric (HistorySizeVariable);
1435 
1436  if (HistorySize != CurrentHistorySize)
1437  {
1438 
1439 /* Zero - empty history */
1440 
1441  if (!HistorySize)
1442  ClearHistory ();
1443 
1444 /* Allocate a new buffer */
1445 
1446  else if ((cmd = (struct cmd_history *)GetAllocatedSpace
1447  (sizeof (struct cmd_history) * HistorySize)) ==
1448  (struct cmd_history *)NULL)
1449  /* DO NOTHING IF NO MEMORY */;
1450 
1451 /* If new buffer is bigger, copy old to new and release */
1452 
1453  else if ((HistorySize > CurrentHistorySize) ||
1454  (l_history < HistorySize))
1455  {
1456  if (cmd_history != (struct cmd_history *)NULL)
1457  {
1458  int Clen;
1459 
1460 /* Calculate the length to copy */
1461 
1462  Clen = (HistorySize > CurrentHistorySize)
1464 
1466  sizeof (struct cmd_history) * Clen);
1467 
1468 /* Set up new values */
1469 
1471  }
1472 
1473  CurrentHistorySize = HistorySize;
1474  SetMemoryAreaNumber ((void *)(cmd_history = cmd), 0);
1475  }
1476 
1477 /* Less space is available, copy reduced area and update entry numbers */
1478 
1479  else
1480  {
1481  int i = (CurrentHistorySize - HistorySize);
1482 
1483 /* Free entries at bottom */
1484 
1485  for (Len = 0; (Len < (size_t)i) && (Len < (size_t)l_history); Len++)
1487 
1488 /* Transfer entries at top */
1489 
1490  memcpy (cmd, &cmd_history[i],
1491  sizeof (struct cmd_history) * HistorySize);
1492 
1493 /* Update things */
1494 
1495  if ((c_history -= i) < -1)
1496  c_history = -1;
1497 
1498  if ((l_history -= i) < 0)
1499  l_history = 0;
1500 
1501 /* Set up new values */
1502 
1504  CurrentHistorySize = HistorySize;
1505  SetMemoryAreaNumber ((void *)(cmd_history = cmd), 0);
1506  }
1507  }
1508 
1509 /* If there is no history space - return */
1510 
1511  if (!CurrentHistorySize)
1512  return;
1513 
1514 /* If the array is full, remove the last item */
1515 
1517  {
1519 
1520  --l_history;
1521  memcpy (&cmd_history[0], &cmd_history[1],
1522  sizeof (struct cmd_history) * (CurrentHistorySize - 1));
1523  }
1524 
1525 /* Save the string. Is this a PS2 prompt */
1526 
1527  if ((AppendToLast) && l_history)
1528  {
1529  cmd = &cmd_history[l_history - 1];
1530 
1531 /* Check length */
1532 
1533  if ((Len = strlen (cmd->command) + strlen (ConsoleLineBuffer) + 2)
1534  >= LINE_MAX)
1535  {
1537  return;
1538  }
1539 
1540 /* Append to buffer, reallocate to new length */
1541 
1542  if ((cp = GetAllocatedSpace (Len)) == (char *)NULL)
1543  return;
1544 
1545  sprintf (cp, "%s\n%s", cmd->command, ConsoleLineBuffer);
1546 
1548  cmd->command = cp;
1549  SetMemoryAreaNumber ((void *)cp, 0);
1550  }
1551 
1552 /* Save the command line */
1553 
1554  else
1555  {
1558 
1560  c_history = ++l_history;
1561  }
1562 }
1563 
1564 /*
1565  * Dump history to file
1566  */
1567 
1568 void DumpHistory (void)
1569 {
1570  struct cmd_history *cp = cmd_history;
1571  FILE *fp;
1572  int i;
1573 
1574 /* If history is not enabled or we can't open the file, give up */
1575 
1576  if ((!HistoryEnabled) ||
1577  ((fp = OpenHistoryFile (sOpenWriteMode)) == (FILE *)NULL))
1578  return;
1579 
1580 /* Write history as a null terminated record */
1581 
1582  for (i = 0; i < l_history; ++cp, ++i)
1583  {
1584  fputs (cp->command, fp);
1585  fputc (0, fp);
1586  }
1587 
1588  CloseFile (fp);
1589 }
1590 
1591 /* Clear out history */
1592 
1593 void ClearHistory (void)
1594 {
1595  int i;
1596  struct cmd_history *cp = cmd_history;
1597 
1598 /* Release the entries */
1599 
1600  for (i = 0; i < l_history; ++cp, ++i)
1602 
1604 
1605 /* Reset data information */
1606 
1607  c_history = -1; /* Current entry */
1608  l_history = 0; /* End of history array */
1609  Current_Event = 0;
1610  CurrentHistorySize = 0;
1611  cmd_history = (struct cmd_history *)NULL;
1612 }
1613 
1614 /* Output warning message and prompt */
1615 
1616 static bool F_LOCAL ReStartInput (char *cp)
1617 {
1618  if (cp != (char *)NULL)
1619  {
1620  if (!IS_Console (1) ||
1623 
1625 
1626  if (IS_Console (1))
1627  EraseToEndOfLine ();
1628 
1629  fputchar (CHAR_NEW_LINE);
1630  }
1631 
1633 
1634 /* Re-initialise */
1635 
1637  return FALSE;
1638 }
1639 
1640 /* Copy backwards */
1641 
1642 static void F_LOCAL memrcpy (char *sp1, char *sp, int cnt)
1643 {
1644  while (cnt--)
1645  *(sp1--) = *(sp--);
1646 }
1647 
1648 /* Complete Filename functions */
1649 
1650 static bool F_LOCAL CompleteFileName (char *InsertPosition, bool Searching)
1651 {
1652  int NumberOfMatches = 0;
1653  char *SearchString = null;
1654  char *NameStart = InsertPosition;
1655  char *StartDirInCLB;
1656  size_t MatchStringLen = 0;
1657  char *cp;
1658  int i;
1659  size_t maxi;
1660  bool InsertSpace = TRUE;
1661  char **FileList;
1662 
1663 /* Space or at start of line - use NULL file name */
1664 
1665  if ((NameStart != ConsoleLineBuffer) && isspace (*NameStart) &&
1666  !isspace (*(NameStart - 1)))
1667  {
1668  --NameStart;
1669  InsertSpace = FALSE;
1670  }
1671 
1672  if (!isspace (*NameStart))
1673  {
1674  while (!isspace (*NameStart) && (NameStart != ConsoleLineBuffer))
1675  --NameStart;
1676 
1677  if (isspace (*NameStart))
1678  ++NameStart;
1679 
1680  MatchStringLen = InsertPosition - NameStart;
1681 
1682  if ((SearchString = AllocateMemoryCell (MatchStringLen + 1)) ==
1683  (char *)NULL)
1684  return RingWarningBell ();
1685 
1686  memcpy (SearchString, NameStart, MatchStringLen);
1687  }
1688 
1689 /* Find the directory name */
1690 
1691  if ((cp = FindLastPathCharacter (SearchString)) != (char *)NULL)
1692  StartDirInCLB = NameStart + (int)(cp - SearchString + 1);
1693 
1694 /* No directory flag - Drive specifier? */
1695 
1696  else if ((strlen (SearchString) > (size_t)1) &&
1697  IsDriveCharacter (*(SearchString + 1)))
1698  StartDirInCLB = NameStart + 2;
1699 
1700 /* No drive specifier */
1701 
1702  else
1703  StartDirInCLB = NameStart;
1704 
1705  FileList = BuildCompletionList (SearchString, strlen (SearchString),
1706  &NumberOfMatches, FALSE);
1707 
1708  if (SearchString != null)
1709  ReleaseMemoryCell ((void *)SearchString);
1710 
1711 /* If there are no matches, Just ring the bell */
1712 
1713  if (FileList == (char **)NULL)
1714  return RingWarningBell ();
1715 
1716 /* At this point, we have some data. If we are searching, sort the
1717  * filenames and display them. Remember to release the memory allocated for
1718  * the word block and its entries.
1719  */
1720 
1721  if (Searching)
1722  {
1723 
1724 /* Sort the file names and display them */
1725 
1726  qsort (&FileList[0], NumberOfMatches, sizeof (char *), SortCompare);
1727 
1728 /* Display. */
1729 
1730  fputchar (CHAR_NEW_LINE);
1731  PrintAList (NumberOfMatches, FileList);
1732 
1733 /* Release memory */
1734 
1735  ReleaseAList (FileList);
1736 
1737 /* Redraw current line */
1738 
1741  return TRUE;
1742  }
1743 
1744 /* OK, we are completing. Get the common part of the filename list */
1745 
1746  maxi = GetCommonPartOfFileList (FileList);
1747 
1748 /* If the file name is length matches the search length, there are no unique
1749  * parts to the filenames in the directory. Just ring the bell and return.
1750  */
1751 
1752  if ((maxi == MatchStringLen) && (NumberOfMatches > 1))
1753  {
1754  ReleaseAList (FileList);
1755  return RingWarningBell ();
1756  }
1757 
1758 /* So, at this point, we are completing and have something to append. Check
1759  * that the line is not too long and if there is an end bit, we can save a
1760  * copy of it.
1761  */
1762 
1763 /* Insert after spaces */
1764 
1765  if (InsertSpace && isspace (*InsertPosition) &&
1766  (InsertPosition != ConsoleLineBuffer))
1767  {
1768  ++StartDirInCLB;
1769  ++InsertPosition;
1770  }
1771 
1772  cp = null;
1773 
1774  if (((strlen (InsertPosition) + maxi +
1775  (StartDirInCLB - ConsoleLineBuffer) + 3) >= LINE_MAX) ||
1776  (strlen (InsertPosition) &&
1777  ((cp = StringCopy (InsertPosition)) == null)))
1778  {
1779  ReleaseAList (FileList);
1780  return RingWarningBell ();
1781  }
1782 
1783 /* Append the new end of line bits */
1784 
1785  strcpy (StartDirInCLB, *FileList);
1786  strcpy (&StartDirInCLB[i = strlen (StartDirInCLB)], " ");
1787 
1788 /* Save the current position */
1789 
1791 
1792 /* If we found only 1 and its a directory, append a d sep */
1793 
1794  if ((NumberOfMatches == 1) && IsDirectory (NameStart))
1795  {
1796  StartDirInCLB[i] = CHAR_UNIX_DIRECTORY;
1797  strcpy (c_buffer_pos, cp);
1798  }
1799 
1800 /* If multiple matches, position at filename and not original position */
1801 
1802  else
1803  {
1804  if (isspace (*cp))
1805  --c_buffer_pos;
1806 
1807  strcpy (c_buffer_pos, cp);
1808 
1809  if ((NumberOfMatches > 1) && !isspace (*cp))
1810  --c_buffer_pos;
1811  }
1812 
1813 /* Release the saved buffer and reset end of line pointer */
1814 
1815  if (cp != null)
1816  ReleaseMemoryCell ((void *)cp);
1817 
1818  ReleaseAList (FileList);
1820 
1821 /* Beep if more than one */
1822 
1823  if (NumberOfMatches > 1)
1824  RingWarningBell ();
1825 
1826  return TRUE;
1827 }
1828 
1829 /* Initialise input */
1830 
1831 static void F_LOCAL InitialiseInput (bool im)
1832 {
1833  c_buffer_pos = ConsoleLineBuffer; /* Initialise */
1835  SetCursorShape (InsertMode = im);
1836  M_length = -1;
1837 
1838 /* Reset max line length */
1839 
1840  MaxLength = 0;
1841  OldMaxLength = 0;
1842 
1843 /* Save the cursor position */
1844 
1845  if (IS_Console (1))
1847 }
1848 
1849 /* Configure Keyboard I/O */
1850 
1851 void Configure_Keys (void)
1852 {
1853  char *cp; /* Line pointers */
1854  int i, fval, cval;
1855  int nFields;
1856  LineFields LF;
1857  long value;
1858 
1859 /* Get some memory for the input line and the file name */
1860 
1861  if ((LF.LineLength = strlen (cp = GetVariableAsString (ShellVariableName,
1862  FALSE)) + 5) < 200)
1863  LF.LineLength = 200;
1864 
1865  if ((LF.Line = AllocateMemoryCell (LF.LineLength)) == (char *)NULL)
1866  return;
1867 
1868  strcpy (LF.Line, cp);
1869 
1870 /* Find the .exe in the name */
1871 
1872  if ((cp = FindLastPathCharacter (LF.Line)) != (char *)NULL)
1873  ++cp;
1874 
1875  else
1876  cp = LF.Line;
1877 
1878  if ((cp = strrchr (cp, CHAR_PERIOD)) == (char *)NULL)
1879  cp = &LF.Line[strlen (LF.Line)];
1880 
1881  strcpy (cp, ".ini");
1882 
1883  if ((LF.FP = FOpenFile (CheckDOSFileName (LF.Line),
1884  sOpenReadMode)) == (FILE *)NULL)
1885  {
1886  ReleaseMemoryCell ((void *)LF.Line);
1887  return;
1888  }
1889 
1890 /* Initialise the internal buffer */
1891 
1892  LF.Fields = (Word_B *)NULL;
1893 
1894 /* Scan for the file */
1895 
1896  while ((nFields = ExtractFieldsFromLine (&LF)) != -1)
1897  {
1898  if (nFields < 2)
1899  continue;
1900 
1901 /* Look up the keyword name */
1902 
1903  for (i = 0;
1904  (i < KF_LENGTH) && (stricmp (LF.Fields->w_words[0],
1905  KF_List[i].kf_name) != 0);
1906  ++i)
1907  continue;
1908 
1909 /* Ignore no matches */
1910 
1911  if (i == KF_LENGTH)
1912  continue;
1913 
1914 /* Get the value of the second field - must be numeric */
1915 
1916  cval = 0;
1917 
1918  if (!ConvertNumericValue (LF.Fields->w_words[1], &value, 0))
1919  continue;
1920 
1921  fval = (int)value;
1922 
1923 /* Get the value of the third field, if it exists - must be numeric */
1924 
1925  if (nFields == 3)
1926  {
1927  if (!ConvertNumericValue (LF.Fields->w_words[2], &value, 0))
1928  continue;
1929 
1930  cval = (int)value;
1931  }
1932 
1933 /* OK we have a valid value, save it */
1934 
1935  KF_List[i].akey = (char)fval;
1936  KF_List[i].fkey = (char)cval;
1937  }
1938 
1939  ReleaseMemoryCell ((void *)LF.Line);
1940 }
1941 
1942 /* Check cursor is in column zero */
1943 
1944 #if (OS_TYPE == OS_OS2)
1945 void PositionCursorInColumnZero (void)
1946 {
1947  BYTE abCell[2];
1948  USHORT usRow;
1949  USHORT usColumn;
1950  USHORT cb = sizeof (abCell);
1951 
1952 /* Get screen infor and cursor position */
1953 
1956 
1957  VioGetCurPos (&usRow, &usColumn, 0);
1958  VioReadCellStr (abCell, &cb , usRow, usColumn, 0);
1959 
1960  if ((StartCursorPosition % MaximumColumns) || (abCell[0] != CHAR_SPACE))
1961  fputchar (CHAR_NEW_LINE);
1962 }
1963 #endif
1964 
1965 /* NT Version */
1966 
1967 #if (OS_TYPE == OS_NT)
1968 void PositionCursorInColumnZero (void)
1969 {
1970  char abCell[2];
1971  CONSOLE_SCREEN_BUFFER_INFO CSI;
1972  DWORD ActionCount;
1973 
1974 /* Get screen infor and cursor position */
1975 
1978 
1979  GetConsoleScreenBufferInfo (NT_StdOut, &CSI);
1980  ReadConsoleOutputCharacter (NT_StdOut, abCell, 1, CSI.dwCursorPosition,
1981  &ActionCount);
1982 
1983  if ((StartCursorPosition % MaximumColumns) || (*abCell != CHAR_SPACE))
1984  fputchar (CHAR_NEW_LINE);
1985 }
1986 #endif
1987 
1988 /* DOS Version */
1989 
1990 #if (OS_TYPE == OS_DOS)
1992 {
1993  union REGS r;
1994 
1995 /* Get screen infor and cursor position */
1996 
1999 
2000  r.h.ah = 0x08;
2001  r.h.bh = 0x00;
2002  SystemInterrupt (0x10, &r, &r);
2003 
2004  if ((StartCursorPosition % MaximumColumns) || (r.h.al != CHAR_SPACE))
2005  fputchar (CHAR_NEW_LINE);
2006 }
2007 #endif
2008 
2009 /*
2010  * Get screen parameters
2011  */
2012 
2013 #if (OS_TYPE == OS_OS2)
2014 void GetScreenParameters (void)
2015 {
2016  VIOMODEINFO viomi;
2017 
2018  viomi.cb = sizeof(viomi);
2019 
2020  VioGetMode (&viomi, 0);
2021  MaximumColumns = viomi.col;
2022  MaximumLines = viomi.row;
2023 
2024 /* Set up LINES and COLUMNS variables */
2025 
2028 }
2029 #endif
2030 
2031 /* NT Version */
2032 
2033 #if (OS_TYPE == OS_NT)
2034 void GetScreenParameters (void)
2035 {
2036  CONSOLE_SCREEN_BUFFER_INFO CSI;
2037 
2038  NT_StdOut = GetStdHandle (STD_OUTPUT_HANDLE);
2039  GetConsoleScreenBufferInfo (NT_StdOut, &CSI);
2040 
2041  MaximumColumns = CSI.dwMaximumWindowSize.X;
2042  MaximumLines = CSI.dwMaximumWindowSize.Y;
2043 
2044 /* Set up LINES and COLUMNS variables */
2045 
2048 }
2049 #endif
2050 
2051 /* DOS version */
2052 
2053 #if (OS_TYPE == OS_DOS)
2055 {
2056  union REGS r;
2057 
2058 # if (OS_SIZE == OS_16)
2059  MaximumColumns = *(int *)(0x0040004aL);
2060 # else
2061  MaximumColumns = *(short *)(0x044aL);
2062 # endif
2063 
2064  MaximumLines = 25;
2065 
2066 /* Is this an EGA? This test was found in NANSI.SYS */
2067 
2068  r.h.ah = 0x12;
2069  r.x.REG_BX = 0xff10;
2070  SystemInterrupt (0x10, &r, &r);
2071 
2072 /* Else read the number of rows */
2073 
2074  if (!(r.x.REG_BX & 0xfefc))
2075  {
2076  r.x.REG_AX = 0x1130;
2077  r.h.bh = 0;
2078  SystemInterrupt (0x10, &r, &r);
2079  MaximumLines = r.h.dl + 1;
2080  }
2081 
2082 /* Set up LINES and COLUMNS variables */
2083 
2086 }
2087 #endif
2088 
2089 /* Ring Bell ? */
2090 
2091 bool RingWarningBell (void)
2092 {
2093  if (KF_List[KF_RINGBELL].akey)
2094 #if (OS_TYPE == OS_OS2)
2095  DosBeep (1380, 500);
2096 #elif (OS_TYPE == OS_NT)
2097  Beep (1380, 500);
2098 #else
2099  fputchar (0x07);
2100  fflush (stdout);
2101 #endif
2102 
2103  return FALSE;
2104 }
2105 
2106 /*
2107  * Read keyboard function
2108  */
2109 
2110 #if (OS_TYPE == OS_OS2)
2111 unsigned char ReadKeyBoard (unsigned char *f_key)
2112 {
2113  KBDKEYINFO kbci;
2114 
2115  *f_key = 0;
2116 
2117 /* Wait for input */
2118 
2119  KbdCharIn (&kbci, IO_WAIT, 0);
2120 
2121  DisplayKeyCode (kbci.chChar, kbci.chScan);
2122 
2123  if (kbci.chChar == 0x03)
2124  raise (SIGINT);
2125 
2126 /* Check for non-function character */
2127 
2128  if (kbci.chChar && (kbci.chChar != 0xe0))
2129  return (unsigned char)kbci.chChar;
2130 
2131 /* Return scan code and type (normal or ALT'ed) */
2132 
2133  *f_key = (unsigned char)kbci.chScan;
2134  return (unsigned char)((kbci.fsState & (ALT | LEFTALT | RIGHTALT))
2135  ? KT_ALTFUNCTION
2136  : KT_FUNCTION);
2137 }
2138 #endif
2139 
2140 /* NT Version */
2141 
2142 #if (OS_TYPE == OS_NT)
2143 unsigned char ReadKeyBoard (unsigned char *f_key)
2144 {
2145  INPUT_RECORD Buffer;
2146  DWORD NumberOfEventsRead;
2147  int i;
2148 
2149  *f_key = 0;
2150 
2151 /* Wait for input */
2152 
2153  while (TRUE)
2154  {
2155  if (!ReadConsoleInput (NT_StdIn, &Buffer, 1, &NumberOfEventsRead))
2156  continue;
2157 
2158  if (Buffer.EventType == WINDOW_BUFFER_SIZE_EVENT)
2159  return KT_RESIZE;
2160 
2161 /* Ignore other non-keyboard events */
2162 
2163  if (Buffer.EventType != KEY_EVENT)
2164  continue;
2165 
2166 /* Ignore key release events */
2167 
2168  if (!Buffer.Event.KeyEvent.bKeyDown)
2169  continue;
2170 
2171 /* See if it is an ignore key? */
2172 
2173  for (i = 0; i < IGNORE_CNT; i++)
2174  {
2175  if (Buffer.Event.KeyEvent.wVirtualScanCode == IgnoreScanCode[i])
2176  break;
2177  }
2178 
2179  if (i != IGNORE_CNT)
2180  continue;
2181 
2182 /* Keystroke mapping */
2183 
2184  if (DoNTKeyMap (&Buffer.Event.KeyEvent))
2185  break;
2186 
2187 /* ? wRepeatCount */
2188 
2189  }
2190 
2191  DisplayKeyCode (Buffer.Event.KeyEvent.uChar.AsciiChar,
2192  Buffer.Event.KeyEvent.wVirtualScanCode);
2193 
2194  if (Buffer.Event.KeyEvent.uChar.AsciiChar == 0x03)
2195  raise (SIGINT);
2196 
2197 /* Check for non-function character */
2198 
2199  if (Buffer.Event.KeyEvent.uChar.AsciiChar &&
2200  (Buffer.Event.KeyEvent.uChar.AsciiChar != 0xe0))
2201  return (unsigned char)Buffer.Event.KeyEvent.uChar.AsciiChar;
2202 
2203 /* Return scan code and type (normal or ALT'ed) */
2204 
2205  *f_key = (unsigned char)Buffer.Event.KeyEvent.wVirtualScanCode;
2206  return (unsigned char)((Buffer.Event.KeyEvent.dwControlKeyState &
2207  (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED))
2208  ? KT_ALTFUNCTION
2209  : KT_FUNCTION);
2210 }
2211 
2212 /*
2213  * Handle keyboard mapping
2214  */
2215 
2216 static bool F_LOCAL DoNTKeyMap (KEY_EVENT_RECORD *KeyEvent)
2217 {
2218  int i;
2219 
2220  if (KeyEvent->wVirtualScanCode == 0x0f) /* TAB */
2221  {
2222  if (KeyEvent->dwControlKeyState & (CTRL_PRESSED | ALT_PRESSED))
2223  return FALSE;
2224 
2225  else if (KeyEvent->dwControlKeyState & SHIFT_PRESSED)
2226  KeyEvent->uChar.AsciiChar = 0;
2227 
2228  else
2229  KeyEvent->uChar.AsciiChar = CHAR_TAB;
2230 
2231  return TRUE;
2232  }
2233 
2234  else if ((KeyEvent->wVirtualScanCode == 0x0e) || /* BACKSPACE */
2235  (KeyEvent->wVirtualScanCode == 0x1c)) /* RETURN */
2236  return !C2bool (KeyEvent->dwControlKeyState & ALT_PRESSED);
2237 
2238 /* All other mapped characters are OK */
2239 
2240  else if (KeyEvent->uChar.AsciiChar)
2241  return TRUE;
2242 
2243 /* Handle function keys */
2244 
2245  for (i = 0; i < MAX_NT_FKMAP; i++)
2246  {
2247  if (KeyEvent->wVirtualScanCode != NT_KFMap [i].Normal)
2248  continue;
2249 
2250 /* If Ctrl Alt pressed - ignore key */
2251 
2252  if ((KeyEvent->dwControlKeyState & (CTRL_PRESSED | ALT_PRESSED))
2253  == (CTRL_PRESSED | ALT_PRESSED))
2254  return FALSE;
2255 
2256  else if (KeyEvent->dwControlKeyState & CTRL_PRESSED)
2257  KeyEvent->wVirtualScanCode = NT_KFMap [i].Control;
2258 
2259  else if (KeyEvent->dwControlKeyState & ALT_PRESSED)
2260  KeyEvent->wVirtualScanCode = NT_KFMap [i].Alt;
2261 
2262  else if (KeyEvent->dwControlKeyState & SHIFT_PRESSED)
2263  KeyEvent->wVirtualScanCode = NT_KFMap [i].Shift;
2264 
2265  return TRUE;
2266  }
2267 
2268  return TRUE;
2269 }
2270 #endif
2271 
2272 /* DOS Version */
2273 
2274 #if (OS_TYPE == OS_DOS)
2275 unsigned char ReadKeyBoard (unsigned char *f_key)
2276 {
2277  unsigned char a_key;
2278  union KeyCode {
2279  unsigned short Key;
2280  struct Scan {
2281  unsigned char ascii, scan;
2282  } Scan;
2283  } KeyCode;
2284 
2285 /* If DEQSview is active - we must poll the keyboard */
2286 
2287 # if (OS_SIZE == OS_16)
2288  if (DESQviewActive)
2289  {
2290  if (!((KeyCode.Scan.ascii = Poll_Keyboard ())) ||
2291  (KeyCode.Scan.ascii == 0xe0))
2292  KeyCode.Scan.scan = Poll_Keyboard ();
2293  }
2294 
2295  else
2296 # endif
2297 
2298 /*
2299  * Read Keyboard via interrupt 10 function 1 or 10 depending on whether we
2300  * have an extended keyboard or not!.
2301  */
2302 
2303  {
2304  KeyCode.Key = _bios_keybrd (ReadKeyboardOption);
2305 
2306  if (KeyCode.Scan.ascii == 0xe0)
2307  KeyCode.Scan.ascii = 0;
2308  }
2309 
2310  DisplayKeyCode (KeyCode.Scan.ascii, KeyCode.Scan.scan);
2311 
2312 /* Check for interrupt */
2313 
2314  if (KeyCode.Scan.ascii == 3)
2315  raise (SIGINT);
2316 
2317 /* Set up return values */
2318 
2319  if (KeyCode.Scan.ascii == 0)
2320  {
2321  a_key = KT_FUNCTION;
2322  *f_key = KeyCode.Scan.scan;
2323 
2324 /* If ALT Key set, return 0xff instead of 0 for function key */
2325 
2326  if (_bios_keybrd (_KEYBRD_SHIFTSTATUS) & 0x08)
2327  a_key = KT_ALTFUNCTION;
2328  }
2329 
2330 /* ASCII keycode - return it. */
2331 
2332  else
2333  {
2334  a_key = KeyCode.Scan.ascii;
2335  *f_key = 0;
2336  }
2337 
2338  return a_key;
2339 }
2340 #endif
2341 
2342 #ifdef KEYDEBUG
2343 static void DisplayKeyCode (unsigned int a, unsigned int b)
2344 {
2345  int cp = ReadCursorPosition ();
2346 
2347  SetCursorPosition (23*80 + 59);
2348  printf ("ASCII %.2x SCAN %.2x\n", a, b);
2350 }
2351 #endif
2352 
2353 /*
2354  * Update Initialisation value
2355  */
2356 
2357 bool ChangeInitialisationValue (char *string, int newvalue)
2358 {
2359  int i;
2360 
2361  for (i = KF_END_FKEYS; i < KF_LENGTH; ++i)
2362  {
2363  if (stricmp (string, KF_List[i].kf_name) == 0)
2364  {
2365  KF_List[i].akey = (char)newvalue;
2366  return TRUE;
2367  }
2368  }
2369 
2370  return FALSE;
2371 }
2372 
2373 /*
2374  * Enable keyboard polling function - required if DESQview loaded
2375  */
2376 
2377 #if (OS_TYPE == OS_DOS)
2378 static void F_LOCAL CheckKeyboardPolling (void)
2379 {
2380  static bool Initialised = FALSE;
2381  union REGS r;
2382  int i;
2383 
2384  if (Initialised)
2385  return;
2386 
2387  Initialised = TRUE;
2388 
2389 /* Check to see we are running under DESQview */
2390 
2391 # if (OS_SIZE == OS_16)
2392  r.x.REG_AX = 0x2b01;
2393  r.x.REG_CX = 0x4445;
2394  r.x.REG_DX = 0x5351;
2395  DosInterrupt (&r, &r);
2396 
2397  if (r.h.al != 0xff)
2398  DESQviewActive = TRUE;
2399 # endif
2400 
2401 /* Otherwise check for extended keyboard. Stick 0xffff in the keyboard
2402  * buffer and read it back. If we find it - OK!
2403  */
2404 
2405  ReadKeyboardOption = _KEYBRD_READ; /* Normal keyboard */
2406 
2407  r.h.ah = 0x05;
2408  r.x.REG_CX = 0xffff;
2409  SystemInterrupt (0x16, &r, &r);
2410 
2411  if (r.h.al)
2412  return;
2413 
2414 /* 16 attempts to read extended keyboard interface */
2415 
2416  for (i = 0; i < 16; i++)
2417  {
2418  if ((unsigned)_bios_keybrd (_NKEYBRD_READ) == 0xffff)
2419  {
2420  ReadKeyboardOption = _NKEYBRD_READ; /* Extended keyboard */
2421  return;
2422  }
2423  }
2424 }
2425 #endif
2426 
2427 /*
2428  * Print a single history entry
2429  */
2430 
2432  bool n_flag,
2433  struct cmd_history *cmd)
2434 {
2435  char *cp = cmd->command;
2436 
2437  if (n_flag)
2438  {
2439  fprintf (fp, "%5d: ", cmd->number);
2440 
2441  while (*cp)
2442  {
2443  putc (*cp, fp);
2444 
2445  if (*(cp++) == CHAR_NEW_LINE)
2446  fputs (" ", fp);
2447  }
2448  }
2449 
2450  else
2451  fputs (cp, fp);
2452 
2453  putc (CHAR_NEW_LINE, fp);
2454 }
2455 
2456 /*
2457  * Get the last history event number
2458  */
2459 
2461 {
2462  return (l_history) ? cmd_history[l_history - 1].number + 1 : 1;
2463 }
2464 
2465 /*
2466  * Get the last history event number
2467  */
2468 
2470 {
2471  return (cmd_history[0].number) ? cmd_history[0].number : 1;
2472 }
2473 
2474 /*
2475  * Get the last history event
2476  */
2477 
2478 #if (OS_TYPE != OS_DOS)
2479 char *GetLastHistoryString (void)
2480 {
2481  return l_history ? cmd_history[l_history - 1].command : (char *)NULL;
2482 }
2483 #endif
2484 
2485 /*
2486  * Dump history
2487  */
2488 
2489 void PrintHistory (bool r_flag, bool n_flag, int First, int Last, FILE *fp)
2490 {
2491  int i;
2492 
2493  if (r_flag)
2494  {
2495  for (i = l_history - 1;
2496  (i >= 0) && (cmd_history[i].number >= First); --i)
2497  {
2498  if (cmd_history[i].number <= Last)
2499  PrintOutHistory (fp, n_flag, &cmd_history[i]);
2500  }
2501  }
2502 
2503  else
2504  {
2505  for (i = 0; (i < l_history) && (cmd_history[i].number <= Last); ++i)
2506  {
2507  if (cmd_history[i].number >= First)
2508  PrintOutHistory (fp, n_flag, &cmd_history[i]);
2509  }
2510  }
2511 }
2512 
2513 /*
2514  * Search for an event
2515  */
2516 
2518 {
2519  int Length = strlen (buffer);
2520  int i;
2521 
2522  for (i = l_history - 1;
2523  (i >= 0) && strncmp (buffer, cmd_history[i].command, Length); --i)
2524  continue;
2525 
2526  return (i == -1) ? -1 : cmd_history[i].number;
2527 }
2528 
2529 /*
2530  * Release Command
2531  */
2532 
2534 {
2535  if (cp->command != null)
2536  ReleaseMemoryCell ((void *)cp->command);
2537 }
2538 
2539 /*
2540  * Flush history buffer. If save is set, the contents of the console
2541  * buffer will be saved.
2542  */
2543 
2545 {
2546  if (SaveHistory)
2548 
2549  memset (ConsoleLineBuffer, 0, LINE_MAX + 1);
2550 
2551  AppendHistory = FALSE;
2552  SaveHistory = FALSE;
2553 }
2554 
2555 /*
2556  * Save the current console buffer
2557  */
2558 
2559 static void F_LOCAL SaveCurrentHistory (void)
2560 {
2561  c_history = l_history;
2562 
2563  if (SaveHistory)
2565 
2568 }
2569 
2570 /*
2571  * Insert a Character into the buffer
2572  */
2573 
2574 static bool F_LOCAL InsertACharacter (int NewCharacter)
2575 {
2577  return RingWarningBell (); /* Ring bell - line full */
2578 
2582 
2583  ++EndOfCurrentLine;
2584 
2585 /* Fast end of line processing */
2586 
2587  if ((c_buffer_pos == EndOfCurrentLine - 1) && (NewCharacter != CHAR_TAB))
2588  {
2589  *(c_buffer_pos++) = (char)NewCharacter;
2590  OutputACharacter (NewCharacter);
2591  return FALSE;
2592  }
2593 
2594 /* Not at end of line - redraw */
2595 
2596  *(c_buffer_pos++) = (char)NewCharacter;
2597  return TRUE;
2598 }
2599 
2600 /*
2601  * Delete Last History Item
2602  */
2603 
2605 {
2606  if (l_history)
2608 }
2609 
2610 /*
2611  * Clear the screen
2612  */
2613 
2614 #if (OS_TYPE == OS_OS2)
2615 bool ClearScreen (void)
2616 {
2617  BYTE abCell[2];
2618  USHORT usRow;
2619  USHORT usColumn;
2620  USHORT cb = sizeof (abCell);
2621 
2622  fputchar (CHAR_NEW_LINE);
2623  FlushStreams ();
2624 
2625 /* Read attribute under cursor */
2626 
2627  VioGetCurPos (&usRow, &usColumn, 0);
2628  VioReadCellStr (abCell, &cb , usRow, usColumn, 0);
2629 
2630  abCell[0] = CHAR_SPACE;
2631 
2632  VioScrollUp (0, 0, 0xffff, 0xffff, 0xffff, abCell, 0);
2633  VioSetCurPos (0, 0, 0);
2634 
2637  return TRUE;
2638 }
2639 #endif
2640 
2641 /*
2642  * NT Version
2643  */
2644 
2645 #if (OS_TYPE == OS_NT)
2646 bool ClearScreen (void)
2647 {
2648  WORD Atts[2];
2649  CONSOLE_SCREEN_BUFFER_INFO CSI;
2650  DWORD ActionCount;
2651  CHAR_INFO *Buffer;
2652  COORD dwBufferSize;
2653  COORD dwBufferCoord;
2654  SMALL_RECT WriteRegion;
2656 
2657  FlushStreams ();
2658 
2659 /* Read attribute under cursor */
2660 
2661  GetConsoleScreenBufferInfo (NT_StdOut, &CSI);
2662  ReadConsoleOutputAttribute (NT_StdOut, Atts, 1, CSI.dwCursorPosition,
2663  &ActionCount);
2664 
2665 /*
2666  * Write it. What a pain!!!
2667  *
2668  * Get some memory
2669  */
2670 
2671  Buffer = (CHAR_INFO *)AllocateMemoryCell (Size * sizeof (CHAR_INFO));
2672 
2673 /* Set up attributes */
2674 
2675  for (ActionCount = 0; ActionCount < Size; ActionCount++)
2676  {
2677  Buffer[ActionCount].Attributes = Atts[0];
2678  Buffer[ActionCount].Char.AsciiChar = CHAR_SPACE;
2679  }
2680 
2681 /* Size */
2682 
2683  dwBufferSize.X = MaximumColumns;
2684  dwBufferSize.Y = MaximumLines;
2685 
2686 /* Co-ordinated */
2687 
2688  dwBufferCoord.X = 0;
2689  dwBufferCoord.Y = 0;
2690 
2691 /* Set up output data */
2692 
2693  WriteRegion.Left = 0;
2694  WriteRegion.Top = 0;
2695  WriteRegion.Right = MaximumColumns - 1;
2696  WriteRegion.Bottom = MaximumLines - 1;
2697 
2698  WriteConsoleOutput (NT_StdOut, Buffer, dwBufferSize, dwBufferCoord,
2699  &WriteRegion);
2700 
2702 
2703  SetConsoleCursorPosition (NT_StdOut, dwBufferCoord);
2704 
2707  return TRUE;
2708 }
2709 #endif
2710 
2711 /* DOS Version */
2712 
2713 #if (OS_TYPE == OS_DOS)
2714 bool ClearScreen (void)
2715 {
2716  union REGS r;
2717  unsigned char backg;
2718 
2719  fputchar (CHAR_NEW_LINE);
2720  FlushStreams ();
2721 
2722 /* Get the background attribute of the cursor */
2723 
2724  r.h.ah = 0x08;
2725  r.h.bh = 0;
2726  SystemInterrupt (0x10, &r, &r);
2727  backg = (unsigned char)(r.h.ah & 0x07);
2728 
2729 /* Clear the screen */
2730 
2731  r.x.REG_AX = 0x0600;
2732  r.h.bh = backg;
2733  r.x.REG_CX = 0;
2734  r.h.dh = (unsigned char)MaximumLines;
2735  r.h.dl = (unsigned char)MaximumColumns;
2736  SystemInterrupt (0x10, &r, &r);
2737 
2738 /* Position to top of page */
2739 
2740  r.h.ah = 0x02; /* Set new position */
2741  r.h.bh = 0; /* Page zero */
2742  r.x.REG_DX = 0x0000;
2743  SystemInterrupt (0x10, &r, &r);
2744 
2747  return TRUE;
2748 }
2749 #endif
2750 
2751 /*
2752  * Display a line, handling control characters
2753  */
2754 
2756 {
2757  int off = ReadCursorPosition ();
2758 
2759 /* Print characters */
2760 
2761  while (*line)
2762  {
2763 
2764 /* Process TABS */
2765 
2766  if (*line == CHAR_TAB)
2767  {
2768  do
2769  {
2770  fputchar (CHAR_SPACE);
2771  } while ((++off) % 8);
2772  }
2773 
2774 /* Process Control and printing characters */
2775 
2776  else
2777  off += OutputACharacter (*line);
2778 
2779  ++line;
2780  }
2781 }
2782 
2783 /*
2784  * Get the Root Disk Drive. If not defined, set it to the current drive.
2785  */
2786 
2787 #if (OS_TYPE != OS_UNIX)
2789 {
2790  if (!KF_List[KF_ROOTDRIVE].akey)
2792 
2793  return KF_List[KF_ROOTDRIVE].akey;
2794 }
2795 #endif
2796 
2797 /*
2798  * Get the EOF Key
2799  */
2800 
2801 int GetEOFKey (void)
2802 {
2803 #if (OS_TYPE == OS_UNIX)
2804  struct termios ts;
2805 
2806  return tcgetattr (1, &ts) ? 4 : ts.c_cc[VEOF];
2807 #else
2808  if (!KF_List[KF_EOFKEY].akey)
2809  KF_List[KF_EOFKEY].akey = 0x1a;
2810 
2811  return KF_List[KF_EOFKEY].akey;
2812 #endif
2813 }
2814 
2815 /*
2816  * Output a Character - excluding TABS. Return # chars output.
2817  *
2818  * TABS are not checked for
2819  */
2820 
2821 static int F_LOCAL OutputACharacter (int c)
2822 {
2823  int off = 1;
2824 
2825 /* Check for control and process */
2826 
2827  if (iscntrl (c))
2828  {
2829  fputchar (CHAR_NOT);
2830  c += '@';
2831  off++;
2832  }
2833 
2834 /* Output the character */
2835 
2836  fputchar (c);
2837  return off;
2838 }
2839 
2840 /*
2841  * Strip off trailing EOFs and EOLs from console buffer
2842  */
2843 
2844 char CleanUpBuffer (int length, char *buffer, int eofc)
2845 {
2846  char *cp = &buffer[length - 1];
2847  char ret;
2848 
2849  while (length && ((*cp == (char)eofc) || (*cp == CHAR_NEW_LINE)))
2850  {
2851  length--;
2852  cp--;
2853  }
2854 
2855  ret = *(cp + 1);
2856  *(cp + 1) = 0;
2857  return ret;
2858 }
2859 
2860 /*
2861  * Look up the keystroke to see if it is one of our functions
2862  */
2863 
2864 int LookUpKeyBoardFunction (unsigned char a_key, unsigned char f_key)
2865 {
2866  int i;
2867 
2868  for (i = 0; (i < KF_END_FKEYS); ++i)
2869  {
2870  if (KF_List[i].akey != a_key)
2871  continue;
2872 
2873 /* Function or meta key? */
2874 
2875  if ((a_key != KT_FUNCTION) && (a_key != KT_ALTFUNCTION))
2876  break;
2877 
2878  else if (KF_List[i].fkey == f_key)
2879  break;
2880  }
2881 
2882 /* If this is a function key and is not ours, ignore it */
2883 
2884  if ((i == KF_END_FKEYS) && ((a_key == KT_FUNCTION) ||
2885  (a_key == KT_ALTFUNCTION)))
2886  return 0;
2887 
2888  return (i == KF_END_FKEYS) ? (int)a_key
2889  : -((int)(KF_List[i].fcode) + 1);
2890 }
2891 
2892 /*
2893  * Build a list of filenames for completion
2894  */
2895 
2896 char **BuildCompletionList (char *String, size_t Length, int *Count,
2897  bool Full)
2898 {
2899  char *MatchString = GetAllocatedSpace (Length + 2);
2900  char **FileList;
2901  char *vecp[2];
2902  char *cp;
2903  char **ap;
2904  size_t DiscardLength;
2905 
2906 /* Build the string to expand */
2907 
2908  *Count = 0;
2909  memmove (MatchString, String, Length);
2910 
2911  if (MatchString[Length - 1] != CHAR_MATCH_ALL)
2912  {
2913  MatchString[Length] = CHAR_MATCH_ALL;
2914  MatchString[Length + 1] = 0;
2915  }
2916 
2917  else
2918  MatchString[Length] = 0;
2919 
2920  vecp[0] = MatchString;
2921  vecp[1] = (char *)NULL;
2922 
2923 /* Expand it */
2924 
2925  FileList = ExpandWordList (vecp, EXPAND_SPLITIFS | EXPAND_GLOBBING |
2926  EXPAND_TILDE, (ExeMode *)NULL);
2927 
2928 /* Check to see if it expanded */
2929 
2930  if ((strcmp (FileList[0], MatchString) == 0) &&
2931  (FileList[1] == (char *) NULL))
2932  {
2933  ReleaseMemoryCell (FileList[0]);
2934  ReleaseMemoryCell (FileList);
2935  FileList = (char **)NULL;
2936  }
2937 
2938  ReleaseMemoryCell (MatchString);
2939 
2940  if (FileList != (char **)NULL)
2941  *Count = CountNumberArguments (FileList);
2942 
2943 /* Exit if expansion failed or we don't want directory stripping */
2944 
2945  if ((FileList == (char **)NULL) || Full)
2946  return FileList;
2947 
2948 /* Strip off directory name ..../ or x: */
2949 
2950  if ((cp = FindLastPathCharacter (FileList[0])) != (char *)NULL)
2951  cp++;
2952 
2953  else if (IsDriveCharacter (FileList[0][1]))
2954  cp = &FileList[0][2];
2955 
2956  else
2957  return FileList;
2958 
2959 /* Get the discard length and remove it from the strings */
2960 
2961  DiscardLength = cp - FileList[0];
2962  ap = FileList;
2963 
2964  while ((cp = *(ap++)) != (char *)NULL)
2965  strcpy (cp, cp + DiscardLength);
2966 
2967  return FileList;
2968 }
2969 
2970 /*
2971  * Get the Common part of the name from a list of files
2972  */
2973 
2974 size_t GetCommonPartOfFileList (char **FileList)
2975 {
2976  char **ap = FileList + 1;
2977  char *BaseName = *FileList;
2978  size_t maxi = strlen (*FileList);
2979  size_t i;
2980 
2981 /* Scan the list */
2982 
2983  while (*ap != (char *)NULL)
2984  {
2985  for (i = 0; (BaseName[i] == (*ap)[i]) && (i < maxi); i++)
2986  continue;
2987 
2988  BaseName[maxi = i] = 0;
2989  ap++;
2990  }
2991 
2992  return maxi;
2993 }
2994 
2995 /*
2996  * Return the function key information associated with an internal key
2997  * function
2998  */
2999 
3000 #if defined (FLAGS_EMACS) || defined (FLAGS_GMACS)
3001 unsigned char GetFunctionKeyMap (int key, unsigned char *f_key)
3002 {
3003  *f_key = KF_List[key].fkey;
3004  return KF_List[key].akey;
3005 }
3006 #endif
3007 
3008 /*
3009  * Change Keyboard to RAW/COOKED mode
3010  */
3011 
3012 #if (OS_TYPE == OS_OS2)
3013 static void F_LOCAL ChangeKeyboardMode (bool Cooked)
3014 {
3015  KBDINFO kbstInfo;
3016 
3017 /* Get current mode */
3018 
3019  kbstInfo.cb = sizeof (kbstInfo);
3020  KbdGetStatus (&kbstInfo, 0);
3021 
3022 /* Change it */
3023 
3024  kbstInfo.fsMask &= ~(KEYBOARD_ASCII_MODE | KEYBOARD_ECHO_ON |
3025  KEYBOARD_ECHO_OFF | KEYBOARD_BINARY_MODE);
3026 
3027  kbstInfo.fsMask |= (Cooked) ? (KEYBOARD_ASCII_MODE | KEYBOARD_ECHO_ON)
3028  : (KEYBOARD_ECHO_OFF | KEYBOARD_BINARY_MODE);
3029 
3030  KbdSetStatus (&kbstInfo, 0);
3031 }
3032 #endif
3033 
3034 /* NT Version */
3035 
3036 #if (OS_TYPE == OS_NT)
3037 static void F_LOCAL ChangeKeyboardMode (bool Cooked)
3038 {
3039  DWORD NewMode = ENABLE_WINDOW_INPUT;
3040 
3041 /* Get handlers */
3042 
3043  NT_StdIn = GetStdHandle (STD_INPUT_HANDLE);
3044  NT_StdOut = GetStdHandle (STD_OUTPUT_HANDLE);
3045 
3046 /* Set up cooked mode if required */
3047 
3048  if (Cooked)
3049  NewMode = (ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT |
3050  ENABLE_ECHO_INPUT);
3051 
3052 /* Change modes */
3053 
3054  SetConsoleMode (NT_StdIn, NewMode);
3055  SetConsoleMode (NT_StdOut, ENABLE_PROCESSED_OUTPUT |
3056  ENABLE_WRAP_AT_EOL_OUTPUT);
3057 }
3058 #endif
3059 
3060 /* UNIX Version */
3061 
3062 #if (OS_TYPE == OS_UNIX)
3063 static void F_LOCAL ChangeKeyboardMode (bool Cooked)
3064 {
3065  fputs ("UNIX: ChangeKeyboardMode NI\n", stderr);
3066 }
3067 #endif
3068 
3069 /*
3070  * EMX needs a read keyboard function
3071  */
3072 
3073 #if (OS_TYPE == OS_DOS) && defined (__EMX__)
3074 unsigned int _bios_keybrd (unsigned int function)
3075 {
3076  union REGS r;
3077 
3078  r.h.ah = function;
3079  SystemInterrupt (0x16, &r, &r);
3080  return r.x.REG_AX;
3081 }
3082 #endif
long __cdecl strtol(char const *_String, char **_EndPtr, int _Radix)
cp
Definition: action.c:1035
#define name
#define mode
Definition: aptex-macros.h:510
#define bool
Definition: autosp.c:101
#define KeyCode
static const cmsUInt8Number Shift[512]
Definition: cmshalf.c:463
#define b
Definition: jpegint.h:372
#define ap
@ FALSE
Definition: dd.h:101
@ TRUE
Definition: dd.h:102
#define CHAR_INFO
Definition: dd.h:253
#define Control
Definition: detex.c:1849
#define Normal
Definition: detex.c:1848
#define strrchr
Definition: detex.c:67
#define fflush
Definition: xxstdio.h:24
#define fgets
Definition: xxstdio.h:29
#define fgetc
Definition: xxstdio.h:26
char * strncpy()
int strcmp()
Definition: coll.cpp:143
int printf()
char * strcpy()
i32 Count[10]
Definition: dvibook.c:121
static FcCharSet * scan(FILE *f, char *file, FcCharSetFreezer *freezer)
Definition: fc-lang.c:137
#define sp1
SimBuffer::B Buffer
Definition: gensi.hpp:669
#define c(n)
Definition: gpos-common.c:150
#define a(n)
Definition: gpos-common.c:148
#define memmove(d, s, n)
Definition: gsftopk.c:65
#define memcpy(d, s, n)
Definition: gsftopk.c:64
#define BaseName(x)
Definition: in_pcx.cpp:40
#define putc
Definition: jbib.h:20
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
#define EOF
Definition: afmparse.c:59
#define Len
Definition: deflate.h:82
unsigned char BYTE
Definition: sfnt.h:34
unsigned short USHORT
Definition: sfnt.h:36
#define stricmp
Definition: win32lib.h:93
#define getpid
Definition: win32lib.h:76
static int ret
Definition: convert.c:72
#define fputs
Definition: mendex.h:67
#define fprintf
Definition: mendex.h:64
#define USHORT
Definition: ttf.h:11
#define length(c)
Definition: ctangleboot.c:65
int strncmp()
unsigned short WORD
Definition: common.h:143
#define sprintf
Definition: snprintf.c:44
#define isdigit(c)
Definition: snprintf.c:177
#define qsort
Definition: includes.h:72
#define size_t
Definition: glob.c:257
#define cmd(arg)
Definition: mitsu.h:44
#define LINE_MAX
Definition: mkind.h:326
unsigned int DWORD
Definition: mktexlib.h:49
string fn
Definition: fc-lang.py:335
dictionary off
Definition: fc-lang.py:226
union value value
Definition: obx.h:44
#define fp
static int cnt
Definition: pkout.c:166
int r
Definition: ppmqvga.c:68
#define CSI
Definition: ppmtosixel.c:27
char line[1024]
Definition: process_score.c:29
bstring c int memset(void *s, int c, int length)
#define cb(n)
#define isspace(ch)
Definition: utype.h:87
#define direction(p, c)
Definition: sh12.c:109
WORD IgnoreScanCode[6]
Definition: sh1.c:344
int GetEOFKey(void)
Definition: sh9.c:2801
static int near GetLineFromDevice(void)
Definition: sh9.c:416
void SetCursorPosition(int new)
Definition: sh9.c:924
int GetRootDiskDrive(void)
Definition: sh9.c:2788
unsigned char GetFunctionKeyMap(int key, unsigned char *f_key)
Definition: sh9.c:3001
static bool near ProcessFunctionKey(int)
Definition: sh9.c:553
void ClearHistory(void)
Definition: sh9.c:1593
static bool DESQviewActive
Definition: sh9.c:168
static void near GenerateNewCursorPosition(void)
Definition: sh9.c:1075
static bool near ScanHistory(void)
Definition: sh9.c:1232
#define DisplayKeyCode(a, b)
Definition: sh9.c:153
int ReadCursorPosition(void)
Definition: sh9.c:853
void SetCursorShape(bool mode)
Definition: sh9.c:790
static struct cmd_history * cmd_history
Definition: sh9.c:295
static unsigned int ReadKeyboardOption
Definition: sh9.c:178
int GetFirstHistoryEvent(void)
Definition: sh9.c:2469
static void near PageHistoryRecord(int)
Definition: sh9.c:1313
static void near CheckKeyboardPolling(void)
Definition: sh9.c:2378
static FILE *near OpenHistoryFile(char *)
Definition: sh9.c:1401
static bool near CompleteFileName(char *, bool)
Definition: sh9.c:1650
void DisplayLineWithControl(char *line)
Definition: sh9.c:2755
static int m_line
Definition: sh9.c:186
static bool near ProcessAlphaNumericKey(int)
Definition: sh9.c:519
#define _KEYBRD_SHIFTSTATUS
Definition: sh9.c:107
static int M_length
Definition: sh9.c:189
static bool InsertMode
Definition: sh9.c:183
static bool SaveHistory
Definition: sh9.c:195
static void near GetLineFromConsole(void)
Definition: sh9.c:439
static void near memrcpy(char *, char *, int)
Definition: sh9.c:1642
static void near InitialiseInput(bool)
Definition: sh9.c:1831
static char * History_2long
Definition: sh9.c:199
static char * No_MatchHistory
Definition: sh9.c:197
void LoadHistory(void)
Definition: sh9.c:1345
static char * c_buffer_pos
Definition: sh9.c:184
#define _NKEYBRD_READ
Definition: sh9.c:99
#define _KEYBRD_READ
Definition: sh9.c:105
static int l_history
Definition: sh9.c:188
static void near SaveCurrentHistory(void)
Definition: sh9.c:2559
#define ChangeKeyboardMode(a)
Definition: sh9.c:160
static bool AppendHistory
Definition: sh9.c:194
size_t GetCommonPartOfFileList(char **FileList)
Definition: sh9.c:2974
#define KF_LENGTH
Definition: sh9.c:119
int LookUpKeyBoardFunction(unsigned char a_key, unsigned char f_key)
Definition: sh9.c:2864
void AddHistory(bool AppendToLast)
Definition: sh9.c:1414
void PrintHistory(bool r_flag, bool n_flag, int First, int Last, FILE *fp)
Definition: sh9.c:2489
static struct Key_Fun_List KF_List[]
void FlushHistoryBuffer(void)
Definition: sh9.c:2544
static int MaxLength
Definition: sh9.c:190
static int c_history
Definition: sh9.c:187
static bool near ReStartInput(char *)
Definition: sh9.c:1616
static char * No_posthistory
Definition: sh9.c:198
char CleanUpBuffer(int length, char *buffer, int eofc)
Definition: sh9.c:2844
int GetConsoleInput(void)
Definition: sh9.c:302
static bool near UpdateConsoleInputLine(char *)
Definition: sh9.c:1207
static int OldMaxLength
Definition: sh9.c:191
static bool near InsertACharacter(int)
Definition: sh9.c:2574
static void near ReleaseCommandMemory(struct cmd_history *)
Definition: sh9.c:2533
static int near OutputACharacter(int)
Definition: sh9.c:2821
static void near PrintOutHistory(FILE *, bool, struct cmd_history *)
Definition: sh9.c:2431
bool RingWarningBell(void)
Definition: sh9.c:2091
char * GetHistoryRecord(int event)
Definition: sh9.c:1294
void DumpHistory(void)
Definition: sh9.c:1568
static void near ReDisplayInputLine(void)
Definition: sh9.c:1098
int SearchHistory(char *buffer)
Definition: sh9.c:2517
unsigned char ReadKeyBoard(unsigned char *f_key)
Definition: sh9.c:2275
static char * EndOfCurrentLine
Definition: sh9.c:185
int GetLastHistoryEvent(void)
Definition: sh9.c:2460
static bool near Process_History(int)
Definition: sh9.c:1125
static void near EraseToEndOfLine(void)
Definition: sh9.c:1029
void PositionCursorInColumnZero(void)
Definition: sh9.c:1991
static int CurrentHistorySize
Definition: sh9.c:192
bool ClearScreen(void)
Definition: sh9.c:2714
static char * No_prehistory
Definition: sh9.c:196
char ** BuildCompletionList(char *String, size_t Length, int *Count, bool Full)
Definition: sh9.c:2896
bool ChangeInitialisationValue(char *string, int newvalue)
Definition: sh9.c:2357
void DeleteLastHistory(void)
Definition: sh9.c:2604
void GetScreenParameters(void)
Definition: sh9.c:2054
void Configure_Keys(void)
Definition: sh9.c:1851
char * GetVariableAsString(char *, bool)
Definition: sh1.c:3578
#define KF_INSERT
Definition: sh.h:2166
#define F_LOCAL
Definition: sh.h:121
bool UseConsoleBuffer
Definition: sh6.c:124
#define KF_END
Definition: sh.h:2165
#define CHAR_NEW_LINE
Definition: sh.h:1007
#define KF_WORDRIGHT
Definition: sh.h:2160
#define EXPAND_TILDE
Definition: sh.h:1485
char ShellVariableName[]
Definition: sh6.c:205
#define EXPAND_SPLITIFS
Definition: sh.h:1482
#define KF_SCANBACKWARD
Definition: sh.h:2154
char LIT_COLUMNS[]
Definition: sh6.c:263
#define IS_Console(a)
Definition: sh.h:1182
unsigned char Poll_Keyboard(void)
char ** ExpandWordList(char **, int, ExeMode *)
Definition: sh4.c:178
#define FL_TEST(x)
Definition: sh.h:1705
char LIT_LINES[]
Definition: sh6.c:262
long GetVariableAsNumeric(char *)
Definition: sh1.c:3556
#define CHAR_PERIOD
Definition: sh.h:1042
#define KF_END_FKEYS
Definition: sh.h:2175
void FlushStreams(void)
Definition: sh8.c:1646
char * sOpenWriteMode
Definition: sh6.c:291
#define KF_PREVIOUS
Definition: sh.h:2156
bool ConvertNumericValue(char *, long *, int)
Definition: system.c:1922
#define KF_SCANFOREWARD
Definition: sh.h:2155
#define DosInterrupt(a, b)
Definition: sh.h:587
#define KF_EOFKEY
Definition: sh.h:2186
char PS1[]
Definition: sh6.c:195
#define IsDriveCharacter(a)
Definition: sh.h:1137
void * GetAllocatedSpace(size_t)
Definition: sh1.c:1241
void SetVariableFromString(char *, char *)
Definition: sh1.c:3415
unsigned int GetCurrentDrive(void)
Definition: sh8.c:1060
unsigned int ShellGlobalFlags
Definition: sh6.c:130
#define C2bool(c)
Definition: sh.h:1476
#define KF_FLUSH
Definition: sh.h:2164
int CloseFile(FILE *)
Definition: sh8.c:1626
int CountNumberArguments(char **)
Definition: system.c:1950
#define KF_LEFT
Definition: sh.h:2158
char PS2[]
Definition: sh6.c:196
int MaximumLines
Definition: sh6.c:278
void OutputUserPrompt(char *)
Definition: sh1.c:2325
bool HistoryEnabled
Definition: sh6.c:149
#define KT_ALTFUNCTION
Definition: sh.h:2138
FILE * FOpenFile(char *, char *)
Definition: sh8.c:1587
#define EXPAND_GLOBBING
Definition: sh.h:1483
char * LastUserPrompt
Definition: sh6.c:192
#define KF_NEXT
Definition: sh.h:2157
#define KF_WORDLEFT
Definition: sh.h:2161
char * CheckDOSFileName(char *)
Definition: sh8.c:1298
char ConsoleLineBuffer[]
Definition: sh6.c:382
#define CHAR_TAB
Definition: sh.h:1014
#define KF_QUOTE
Definition: sh.h:2174
char * StringSave(char *)
Definition: sh1.c:1308
char * sOpenReadMode
Definition: sh6.c:290
#define KF_HALFHEIGTH
Definition: sh.h:2182
int MaximumColumns
Definition: sh6.c:277
int SortCompare(const void *, const void *)
Definition: sh4.c:1234
void PrintAList(int, char **)
Definition: sh3.c:4516
#define FLAG_INTERACTIVE
Definition: sh.h:1720
#define CHAR_BACKSPACE
Definition: sh.h:1015
void SetVariableFromNumeric(char *, long)
Definition: sh1.c:3519
char HistoryFileVariable[]
Definition: sh6.c:206
void ReleaseMemoryCell(void *)
Definition: sh1.c:2141
#define FLAGS_EDITORS
Definition: sh.h:1750
#define KF_CLEARSCREEN
Definition: sh.h:2171
#define KF_DIRECTORY
Definition: sh.h:2170
#define KF_CLEAR
Definition: sh.h:2163
#define CHAR_MATCH_ALL
Definition: sh.h:1036
char * StringCopy(char *)
Definition: sh1.c:1325
#define KF_JOBS
Definition: sh.h:2172
#define KF_RIGHT
Definition: sh.h:2159
#define KF_INSERTMODE
Definition: sh.h:2183
#define FindLastPathCharacter(a)
Definition: sh.h:1141
#define KF_COMPLETE
Definition: sh.h:2169
char HistorySizeVariable[]
Definition: sh6.c:207
char * LIT_NewLine
Definition: sh6.c:254
int StartCursorPosition
Definition: sh6.c:134
#define KF_INSERTCURSOR
Definition: sh.h:2184
#define KF_DELETERIGHT
Definition: sh.h:2167
bool ChangeInitLoad
Definition: sh6.c:129
#define KF_START
Definition: sh.h:2162
#define CHAR_NOT
Definition: sh.h:1013
void SetMemoryAreaNumber(void *, int)
Definition: sh1.c:2302
char * BuildFileName(char *)
Definition: sh1.c:3021
int ExtractFieldsFromLine(LineFields *)
Definition: system.c:1140
int EditorInput(void)
Definition: sh13.c:3189
#define SystemInterrupt(a, b, c)
Definition: sh.h:585
#define KT_RESIZE
Definition: sh.h:2139
char * AllocateMemoryCell(size_t)
Definition: sh1.c:2071
#define CHAR_RETURN
Definition: sh.h:1011
int feputc(int)
Definition: sh8.c:3380
#define IS_TTY(a)
Definition: sh.h:1180
#define KF_DELETELEFT
Definition: sh.h:2168
#define KF_TRANSPOSE
Definition: sh.h:2173
#define KF_ROOTDRIVE
Definition: sh.h:2185
#define KT_FUNCTION
Definition: sh.h:2137
int Current_Event
Definition: sh6.c:128
#define CHAR_SPACE
Definition: sh.h:1012
#define KF_RINGBELL
Definition: sh.h:2181
#define CHAR_HISTORY
Definition: sh.h:1027
bool IsDirectory(char *)
Definition: sh8.c:1262
void ReleaseAList(char **)
Definition: sh1.c:2126
char LIT_history[]
Definition: sh6.c:260
int PrintWarningMessage(char *,...)
Definition: sh1.c:1010
#define CHAR_UNIX_DIRECTORY
Definition: sh.h:1006
char * BasicErrorMessage
Definition: sh6.c:242
Definition: sh.h:1945
unsigned char akey
Definition: sh9.c:257
char * kf_name
Definition: sh9.c:256
unsigned char fcode
Definition: sh9.c:259
unsigned char fkey
Definition: sh9.c:258
A string of characters.
Definition: t1part.c:49
Definition: utils.c:300
char * command
Definition: sh9.c:127
int number
Definition: sh9.c:126
Definition: bdf.c:133
Definition: sh.h:1559
type_key Key[]
Definition: t1part.c:271
#define FILE
Definition: t1stdio.h:34
*job_name strlen((char *) job_name) - 4)
#define key
Definition: tex2xindy.c:753
int diff
Definition: tex4ht.c:3815
return() int(((double) *(font_tbl[cur_fnt].wtbl+(int)(*(font_tbl[cur_fnt].char_wi+(int)(ch - font_tbl[cur_fnt].char_f)% 256)))/(double)(1L<< 20)) *(double) font_tbl[cur_fnt].scale)
#define sp
Definition: stack.c:11
Definition: obx.h:51
@ LF
Definition: uprops.h:351
#define return(val)