1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:07:35 +00:00

sh: Support erasing a whole word with WERASE (^W).

This commit is contained in:
Andreas Kling 2019-04-25 23:05:10 +02:00
parent 71770e000b
commit 89e9aafbb5

View file

@ -7,6 +7,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <ctype.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/utsname.h>
@ -573,6 +574,21 @@ int main(int argc, char** argv)
fflush(stdout);
continue;
}
if (ch == g->termios.c_cc[VWERASE]) {
bool has_seen_nonspace = false;
while (linedx > 0) {
if (isspace(linebuf[linedx - 1])) {
if (has_seen_nonspace)
break;
} else {
has_seen_nonspace = true;
}
putchar(0x8);
--linedx;
}
fflush(stdout);
continue;
}
if (ch == g->termios.c_cc[VKILL]) {
if (linedx == 0)
continue;