mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v4] readline: make ctrl-u to work like linux console
@ 2019-10-16 15:56 sendpatch
  2019-10-18 12:00 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: sendpatch @ 2019-10-16 15:56 UTC (permalink / raw)
  To: barebox; +Cc: DU HUANPENG

From: DU HUANPENG <u74147@gmail.com>

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>
---
 lib/readline.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/readline.c b/lib/readline.c
index d026af1..3d16c18 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:
-- 
2.7.4




_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-18 12:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16 15:56 [PATCH v4] readline: make ctrl-u to work like linux console sendpatch
2019-10-18 12:00 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox