mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +00:00
sh: Support basic backspacing on the command line.
It's weird that I didn't do this sooner. I don't know how many tims I've had to retype a misspelled command. :^)
This commit is contained in:
parent
dfdca9d2a7
commit
6cc1a9d90a
1 changed files with 12 additions and 3 deletions
|
@ -413,10 +413,19 @@ int main(int, char**)
|
|||
}
|
||||
}
|
||||
for (ssize_t i = 0; i < nread; ++i) {
|
||||
putchar(keybuf[i]);
|
||||
char ch = keybuf[i];
|
||||
if (ch == 8) {
|
||||
if (linedx == 0)
|
||||
continue;
|
||||
linebuf[--linedx] = '\0';
|
||||
putchar(ch);
|
||||
fflush(stdout);
|
||||
continue;
|
||||
}
|
||||
putchar(ch);
|
||||
fflush(stdout);
|
||||
if (keybuf[i] != '\n') {
|
||||
linebuf[linedx++] = keybuf[i];
|
||||
if (ch != '\n') {
|
||||
linebuf[linedx++] = ch;
|
||||
linebuf[linedx] = '\0';
|
||||
} else {
|
||||
runcmd(linebuf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue