[PATCH v4] readline: make ctrl-u to work like linux console

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: DU HUANPENG <u74147@xxxxxxxxx>

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@xxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux