4 static char erase_seq
[] = "\b \b"; /* erase sequence */
5 static char tab_seq
[] = " "; /* used to expand TABs */
7 static char * delete_char (char *buffer
, char *p
, int *colp
, int *np
, int plen
)
15 if (*(--p
) == '\t') { /* will retype the whole line */
16 while (*colp
> plen
) {
20 for (s
=buffer
; s
<p
; ++s
) {
22 puts (tab_seq
+((*colp
) & 07));
23 *colp
+= 8 - ((*colp
) & 07);
38 * Prompt for input and read a line.
39 * If CONFIG_BOOT_RETRY_TIME is defined and retry_time >= 0,
40 * time out when time goes past endtime (timebase time in ticks).
41 * Return: number of read characters
45 int readline (const char *prompt
, char *line
, int len
)
48 int n
= 0; /* buffer index */
49 int plen
= 0; /* prompt length */
50 int col
; /* output column cnt */
55 plen
= strlen (prompt
);
61 #ifdef CONFIG_BOOT_RETRY_TIME
62 while (!tstc()) { /* while no incoming data */
63 if (retry_time
>= 0 && get_ticks() > endtime
)
64 return (-2); /* timed out */
67 WATCHDOG_RESET(); /* Trigger watchdog, if needed */
69 #ifdef CONFIG_SHOW_ACTIVITY
71 extern void show_activity(int arg
);
78 * Special character handling
81 case '\r': /* Enter */
90 case 0x03: /* ^C - break */
91 line
[0] = '\0'; /* discard input */
94 case 0x15: /* ^U - erase line */
103 case 0x17: /* ^W - erase word */
104 p
=delete_char(line
, p
, &col
, &n
, plen
);
105 while ((n
> 0) && (*p
!= ' ')) {
106 p
=delete_char(line
, p
, &col
, &n
, plen
);
110 case 0x08: /* ^H - backspace */
111 case 0x7F: /* DEL - backspace */
112 p
=delete_char(line
, p
, &col
, &n
, plen
);
117 * Must be a normal character then
119 if (n
< CONFIG_CBSIZE
-2) {
120 if (c
== '\t') { /* expand TABs */
121 puts (tab_seq
+(col
&07));
124 ++col
; /* echo input */
129 } else { /* Buffer full */
138 * @brief Primitiv Line Parser
141 /** @page readline_parser Primitive Line Parser
143 * There is still a primtive line parser as a alternative to the hush shell
144 * environment available. This is for persons who like the old fashion way of
145 * edititing and command entering.
147 * Enable the "Simple parser" in "General Settings", "Select your shell" to
148 * get back the old console feeling.