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:
parent
71770e000b
commit
89e9aafbb5
1 changed files with 16 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue