From: Oleksij Rempel <linux@rempel-privat.de>
To: sendpatch@qq.com, barebox@lists.infradead.org
Cc: DU HUANPENG <u74147@gmail.com>
Subject: Re: [PATCH v3] readline: make ctrl-u to work like linux console
Date: Wed, 16 Oct 2019 09:39:01 +0200 [thread overview]
Message-ID: <e8cdac6a-dc25-57c2-f6e1-c2238ba2e6eb@rempel-privat.de> (raw)
In-Reply-To: <1571210705-18315-1-git-send-email-sendpatch@qq.com>
Am 16.10.19 um 09:25 schrieb sendpatch@qq.com:
> 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 | 26 ++++++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/lib/readline.c b/lib/readline.c
> index d026af1..3d5fafd 100644
> --- a/lib/readline.c
> +++ b/lib/readline.c
> @@ -188,9 +188,10 @@ int readline(const char *prompt, char *buf, int len)
> unsigned wlen;
> int ichar;
> int insert = 1;
> + int i;
> #ifdef CONFIG_AUTO_COMPLETE
> char tmp;
> - int reprint, i;
> + int reprint;
> char *completestr;
>
> complete_reset();
> @@ -290,10 +291,31 @@ int readline(const char *prompt, char *buf, int len)
> insert = !insert;
> break;
> case BB_KEY_ERASE_LINE:
> - case CTL_CH('u'):
> BEGINNING_OF_LINE();
> ERASE_TO_EOL();
> break;
> + case CTL_CH('u'):
> + if (num <= eol_num) {
i doubt num can be ever bigger then eol_num. or do i missing some thing?
> + for (i = num; i < eol_num; i++)
> + buf[i-num] = buf[i];
> + buf[i] = '\0';
> +
> + for (i = 0; i < num; i++)
> + getcmd_putch(CTL_BACKSPACE);
> + for (i = 0; i < eol_num; i++)
> + getcmd_putch(' ');
> + for (i = 0; i < eol_num; i++)
> + getcmd_putch(CTL_BACKSPACE);
> +
> + eol_num -= num;
> + num = 0;
> +
> + for (i = 0 ; i < eol_num; i++)
> + getcmd_putch(buf[i]);
> + for (i = 0; i < eol_num; i++)
> + getcmd_putch(CTL_BACKSPACE);
> + }
> + break;
> case DEL:
> case BB_KEY_DEL7:
> case 8:
>
--
Regards,
Oleksij
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2019-10-16 7:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 7:25 sendpatch
2019-10-16 7:39 ` Oleksij Rempel [this message]
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=e8cdac6a-dc25-57c2-f6e1-c2238ba2e6eb@rempel-privat.de \
--to=linux@rempel-privat.de \
--cc=barebox@lists.infradead.org \
--cc=sendpatch@qq.com \
--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