Skip to contentSkip to conversation

readline: make ctrl-u to work like linux console

PATCH Applied [email protected] 2 participants 2 messages Oct 16, 2019 – Oct 18, 2019 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 readline: make ctrl-u to work like linux console

From: DU HUANPENG <[email protected]>

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.

---
 lib/readline.c | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/readline.c +8 -0
index d026af1..3d16c18 100644
@@ -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:
Signature · 9 lines
2.7.4




_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 10 lines · On Wed, Oct 16, 2019 at 11:56:44PM +0800, [email protected] wrote:

From: DU HUANPENG <[email protected]>

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.

---
 lib/readline.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox