diff options
author | DU HUANPENG <u74147@gmail.com> | 2019-10-16 23:56:44 +0800 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-10-18 13:59:04 +0200 |
commit | d4eb2645610625b3b6f5179a319935d3fc7c6829 (patch) | |
tree | f2855189886aa3319f49ff57a74d411254919780 /lib | |
parent | 4c8af438c80e9959a3d6f33889af6686b24bfd2b (diff) | |
download | barebox-d4eb2645610625b3b6f5179a319935d3fc7c6829.tar.gz barebox-d4eb2645610625b3b6f5179a319935d3fc7c6829.tar.xz |
readline: make ctrl-u to work like linux console
currtly, the ctrl-u discards the whole line, in most linux
boxes, ctrl-u just erase characters before cursor to the
begginning of the line. this patch make ctrl-u to do this.
Signed-off-by: DU HUANPENG <u74147@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/readline.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/readline.c b/lib/readline.c index d026af1104..3d16c1838c 100644 --- a/lib/readline.c +++ b/lib/readline.c @@ -290,9 +290,17 @@ int readline(const char *prompt, char *buf, int len) insert = !insert; break; case BB_KEY_ERASE_LINE: + BEGINNING_OF_LINE(); + ERASE_TO_EOL(); + break; case CTL_CH('u'): + wlen = eol_num - num; + memmove(buf, buf+num, wlen); BEGINNING_OF_LINE(); ERASE_TO_EOL(); + eol_num = wlen; + REFRESH_TO_EOL(); + BEGINNING_OF_LINE(); break; case DEL: case BB_KEY_DEL7: |