mirror of
https://github.com/troglobit/finit.git
synced 2026-10-15 10:29:35 +00:00
getty.c: Handle Ctrl-U properly, erase line to beginning
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
907595d9ed
commit
2fe257b7af
1 file changed
+9
@@ -40,6 +40,7 @@
|
||||
#define _PATH_LOGIN "/bin/login"
|
||||
#endif
|
||||
|
||||
#define CTL(x) ((x) ^ 0100)
|
||||
#define print(s) (void)write(STDOUT_FILENO, s, strlen(s))
|
||||
|
||||
|
||||
@@ -203,6 +204,14 @@ static void do_getty(char *tty, char *name, size_t len)
|
||||
|
||||
np = name;
|
||||
while ((ch = readch(tty)) != '\n') {
|
||||
if (ch == CTL('U')) {
|
||||
while (np > name) {
|
||||
(void)write(1, "\b \b", 3);
|
||||
np--;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (np < name + len)
|
||||
*np++ = ch;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user