Update of /cvsroot/blob/blob/src
In directory usw-pr-cvs1:/tmp/cvs-serv31277
Modified Files:
command.c
Log Message:
- added calls for command line history
Index: command.c
===================================================================
RCS file: /cvsroot/blob/blob/src/command.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- command.c 2001/10/03 16:09:09 1.9
+++ command.c 2001/10/05 12:07:27 1.10
@@ -36,6 +36,7 @@
#endif
#include "command.h"
+#include "command_hist.h"
#include "errno.h"
#include "init.h"
#include "serial.h"
@@ -48,7 +49,6 @@
extern u32 __commandlist_end;
-
/* the first command */
commandlist_t *commands;
@@ -193,11 +193,13 @@
int i;
int numRead;
int maxRead = len - 1;
-
+
TimerClearOverflow();
startTime = TimerGetTime();
+ cmdhist_reset();
+
for(numRead = 0, i = 0; numRead < maxRead;) {
/* try to get a byte from the serial port */
while(!SerialInputByte(&c)) {
@@ -208,6 +210,7 @@
(timeout * TICKS_PER_SECOND)) {
/* timeout */
command[i++] = '\0';
+ cmdhist_push( command );
return(numRead);
}
}
@@ -217,6 +220,7 @@
/* print newline */
SerialOutputByte('\n');
+ cmdhist_push( command );
return(numRead);
} else if(c == '\b') { /* FIXME: is this backspace? */
if(i > 0) {
@@ -225,6 +229,36 @@
/* cursor one position back. */
SerialOutputString("\b \b");
}
+ } else if ( c == CMDHIST_KEY_UP ) {
+ char *cmd = NULL;
+ /* get cmd from history */
+ if ( cmdhist_next( &cmd ) != 0 )
+ continue;
+
+ /* clear line */
+ while ( numRead-- ) {
+ SerialOutputString("\b \b");
+ }
+
+ /* display it */
+ SerialOutputString(cmd);
+ i = numRead = strlen( cmd );
+ strcpy( command, cmd );
+ } else if ( c == CMDHIST_KEY_DN ) {
+ char *cmd = NULL;
+ /* get cmd from history */
+ if ( cmdhist_prev( &cmd ) != 0 )
+ continue;
+
+ /* clear line */
+ while ( numRead-- ) {
+ SerialOutputString("\b \b");
+ }
+
+ /* display it */
+ SerialOutputString(cmd);
+ i = numRead = strlen( cmd );
+ strcpy( command, cmd );
} else {
command[i++] = c;
numRead++;
@@ -234,5 +268,7 @@
}
}
+ cmdhist_push( command );
return(numRead);
}
+
|