mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
sh: Support erasing a whole word with WERASE (^W).
This commit is contained in:
parent
71770e000b
commit
89e9aafbb5
1 changed files with 16 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
@ -573,6 +574,21 @@ int main(int argc, char** argv)
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
continue;
|
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 (ch == g->termios.c_cc[VKILL]) {
|
||||||
if (linedx == 0)
|
if (linedx == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue