Added backspace support for the interactive shell, updated it behavior slightly.
This commit is contained in:
@@ -86,6 +86,8 @@ void putch(unsigned char c)
|
|||||||
if(c == 0x08)
|
if(c == 0x08)
|
||||||
{
|
{
|
||||||
if(csr_x != 0) csr_x--;
|
if(csr_x != 0) csr_x--;
|
||||||
|
where = textmemptr + (csr_y * 80 + csr_x);
|
||||||
|
*where = ' ' | att; /* Character AND attributes: color */
|
||||||
}
|
}
|
||||||
/* Handles a tab by incrementing the cursor's x, but only
|
/* Handles a tab by incrementing the cursor's x, but only
|
||||||
* to a point that will make it divisible by 8 */
|
* to a point that will make it divisible by 8 */
|
||||||
|
|||||||
+22
-2
@@ -15,16 +15,34 @@ void run_shell()
|
|||||||
void key_pressed(unsigned char* character)
|
void key_pressed(unsigned char* character)
|
||||||
{
|
{
|
||||||
int len = strlen(commandbuffer);
|
int len = strlen(commandbuffer);
|
||||||
|
//Check to see if the backspace has been pressed.
|
||||||
|
if(character != '\b')
|
||||||
|
{
|
||||||
|
//If it has not then simply add the character
|
||||||
|
//to the commandbuffer, and don't forget the null byte.
|
||||||
commandbuffer[len] = character;
|
commandbuffer[len] = character;
|
||||||
commandbuffer[len + 1] = '\0';
|
commandbuffer[len + 1] = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Otherwise clear the last character from the command
|
||||||
|
//buffer.
|
||||||
|
commandbuffer[len - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
putch(character);
|
putch(character);
|
||||||
}
|
}
|
||||||
|
|
||||||
void execmd()
|
void execmd()
|
||||||
{
|
{
|
||||||
|
if(strlen(commandbuffer) == 0)
|
||||||
|
{
|
||||||
|
puts("\n#>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(strcmp(commandbuffer, "version"))
|
if(strcmp(commandbuffer, "version"))
|
||||||
{
|
{
|
||||||
puts("\nInteractive Shell Version 0.0.0.1\n");
|
puts("\nInteractive Shell Version 0.0.1.2\n");
|
||||||
}
|
}
|
||||||
else if(strcmp(commandbuffer,"cls"))
|
else if(strcmp(commandbuffer,"cls"))
|
||||||
{
|
{
|
||||||
@@ -32,7 +50,9 @@ void execmd()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
puts("\nUnknown command\n");
|
puts("\nUnknown command: ");
|
||||||
|
puts(commandbuffer);
|
||||||
|
puts(".\n");
|
||||||
}
|
}
|
||||||
puts("#>");
|
puts("#>");
|
||||||
commandbuffer[0] = '\0';
|
commandbuffer[0] = '\0';
|
||||||
|
|||||||
Reference in New Issue
Block a user