mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: sendpatch@qq.com
To: barebox@lists.infradead.org
Cc: DU HUANPENG <u74147@gmail.com>
Subject: [PATCH v4] readline: make ctrl-u to work like linux console
Date: Wed, 16 Oct 2019 23:56:44 +0800	[thread overview]
Message-ID: <1571241404-25229-1-git-send-email-sendpatch@qq.com> (raw)

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

             reply	other threads:[~2019-10-16 15:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16 15:56 sendpatch [this message]
2019-10-18 12:00 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1571241404-25229-1-git-send-email-sendpatch@qq.com \
    --to=sendpatch@qq.com \
    --cc=barebox@lists.infradead.org \
    --cc=u74147@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox