* [RFC 0/3] readline: add ctrl-w handling (cut-the-last-word)
@ 2012-10-26 5:58 Antony Pavlov
2012-10-26 5:58 ` [RFC 1/3] readline: move backspace key handling to the DO_BACKSPACE macro Antony Pavlov
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Antony Pavlov @ 2012-10-26 5:58 UTC (permalink / raw)
To: barebox
The popular 'bash' command interpreter has the ctrl-w keystroke for
cutting the last word in the command line. This keystroke is
very handy for me and I really miss it in barebox.
This patch series adds ctrl-w support to barebox's readline
and in addition fixes a typo.
[RFC 1/3] readline: move backspace key handling to the DO_BACKSPACE
[RFC 2/3] readline: add ctrl-w handling (cut-the-last-word)
[RFC 3/3] readline: fix the 'new blank line at EOF' typo
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC 1/3] readline: move backspace key handling to the DO_BACKSPACE macro
2012-10-26 5:58 [RFC 0/3] readline: add ctrl-w handling (cut-the-last-word) Antony Pavlov
@ 2012-10-26 5:58 ` Antony Pavlov
2012-10-26 5:58 ` [RFC 2/3] readline: add ctrl-w handling (cut-the-last-word) Antony Pavlov
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Antony Pavlov @ 2012-10-26 5:58 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
lib/readline.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/lib/readline.c b/lib/readline.c
index 5717a17..086b7f1 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -137,6 +137,18 @@ static char* hist_next(void)
} \
}
+#define DO_BACKSPACE() \
+ wlen = eol_num - num; \
+ num--; \
+ memmove(buf + num, buf + num + 1, wlen); \
+ getcmd_putch(CTL_BACKSPACE); \
+ putnstr(buf + num, wlen); \
+ getcmd_putch(' '); \
+ do { \
+ getcmd_putch(CTL_BACKSPACE); \
+ } while (wlen--); \
+ eol_num--;
+
static void cread_add_char(char ichar, int insert, unsigned long *num,
unsigned long *eol_num, char *buf, unsigned long len)
{
@@ -273,16 +285,7 @@ int readline(const char *prompt, char *buf, int len)
case KEY_DEL7:
case 8:
if (num) {
- wlen = eol_num - num;
- num--;
- memmove(buf + num, buf + num + 1, wlen);
- getcmd_putch(CTL_BACKSPACE);
- putnstr(buf + num, wlen);
- getcmd_putch(' ');
- do {
- getcmd_putch(CTL_BACKSPACE);
- } while (wlen--);
- eol_num--;
+ DO_BACKSPACE();
}
break;
case KEY_DEL:
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC 2/3] readline: add ctrl-w handling (cut-the-last-word)
2012-10-26 5:58 [RFC 0/3] readline: add ctrl-w handling (cut-the-last-word) Antony Pavlov
2012-10-26 5:58 ` [RFC 1/3] readline: move backspace key handling to the DO_BACKSPACE macro Antony Pavlov
@ 2012-10-26 5:58 ` Antony Pavlov
2012-10-26 5:58 ` [RFC 3/3] readline: fix the 'new blank line at EOF' typo Antony Pavlov
2012-10-27 12:24 ` [RFC 0/3] readline: add ctrl-w handling (cut-the-last-word) Sascha Hauer
3 siblings, 0 replies; 7+ messages in thread
From: Antony Pavlov @ 2012-10-26 5:58 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
lib/readline.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/readline.c b/lib/readline.c
index 086b7f1..37566c3 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -328,6 +328,16 @@ int readline(const char *prompt, char *buf, int len)
REFRESH_TO_EOL();
continue;
}
+ case CTL_CH('w'):
+ while ((num >= 1) && (buf[num - 1] == ' ')) {
+ DO_BACKSPACE();
+ }
+
+ while ((num >= 1) && (buf[num - 1] != ' ')) {
+ DO_BACKSPACE();
+ }
+
+ break;
default:
if (isascii(ichar) && isprint(ichar))
cread_add_char(ichar, insert, &num, &eol_num, buf, len);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC 3/3] readline: fix the 'new blank line at EOF' typo
2012-10-26 5:58 [RFC 0/3] readline: add ctrl-w handling (cut-the-last-word) Antony Pavlov
2012-10-26 5:58 ` [RFC 1/3] readline: move backspace key handling to the DO_BACKSPACE macro Antony Pavlov
2012-10-26 5:58 ` [RFC 2/3] readline: add ctrl-w handling (cut-the-last-word) Antony Pavlov
@ 2012-10-26 5:58 ` Antony Pavlov
2012-10-27 12:24 ` [RFC 0/3] readline: add ctrl-w handling (cut-the-last-word) Sascha Hauer
3 siblings, 0 replies; 7+ messages in thread
From: Antony Pavlov @ 2012-10-26 5:58 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
lib/readline.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/readline.c b/lib/readline.c
index 37566c3..3fb620e 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -353,4 +353,3 @@ int readline(const char *prompt, char *buf, int len)
return rc < 0 ? rc : len;
}
-
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC 0/3] readline: add ctrl-w handling (cut-the-last-word)
2012-10-26 5:58 [RFC 0/3] readline: add ctrl-w handling (cut-the-last-word) Antony Pavlov
` (2 preceding siblings ...)
2012-10-26 5:58 ` [RFC 3/3] readline: fix the 'new blank line at EOF' typo Antony Pavlov
@ 2012-10-27 12:24 ` Sascha Hauer
2012-10-28 15:11 ` Antony Pavlov
3 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2012-10-27 12:24 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
Hi Antony,
On Fri, Oct 26, 2012 at 09:58:52AM +0400, Antony Pavlov wrote:
> The popular 'bash' command interpreter has the ctrl-w keystroke for
> cutting the last word in the command line. This keystroke is
> very handy for me and I really miss it in barebox.
>
> This patch series adds ctrl-w support to barebox's readline
> and in addition fixes a typo.
>
> [RFC 1/3] readline: move backspace key handling to the DO_BACKSPACE
> [RFC 2/3] readline: add ctrl-w handling (cut-the-last-word)
> [RFC 3/3] readline: fix the 'new blank line at EOF' typo
Looks good.
Sascha
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC 0/3] readline: add ctrl-w handling (cut-the-last-word)
2012-10-27 12:24 ` [RFC 0/3] readline: add ctrl-w handling (cut-the-last-word) Sascha Hauer
@ 2012-10-28 15:11 ` Antony Pavlov
2012-10-29 9:02 ` Sascha Hauer
0 siblings, 1 reply; 7+ messages in thread
From: Antony Pavlov @ 2012-10-28 15:11 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On 27 October 2012 16:24, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> Hi Antony,
>
> On Fri, Oct 26, 2012 at 09:58:52AM +0400, Antony Pavlov wrote:
>> The popular 'bash' command interpreter has the ctrl-w keystroke for
>> cutting the last word in the command line. This keystroke is
>> very handy for me and I really miss it in barebox.
>>
>> This patch series adds ctrl-w support to barebox's readline
>> and in addition fixes a typo.
>>
>> [RFC 1/3] readline: move backspace key handling to the DO_BACKSPACE
>> [RFC 2/3] readline: add ctrl-w handling (cut-the-last-word)
>> [RFC 3/3] readline: fix the 'new blank line at EOF' typo
>
> Looks good.
So apply the patches, please.
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC 0/3] readline: add ctrl-w handling (cut-the-last-word)
2012-10-28 15:11 ` Antony Pavlov
@ 2012-10-29 9:02 ` Sascha Hauer
0 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2012-10-29 9:02 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Sun, Oct 28, 2012 at 07:11:37PM +0400, Antony Pavlov wrote:
> On 27 October 2012 16:24, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> > Hi Antony,
> >
> > On Fri, Oct 26, 2012 at 09:58:52AM +0400, Antony Pavlov wrote:
> >> The popular 'bash' command interpreter has the ctrl-w keystroke for
> >> cutting the last word in the command line. This keystroke is
> >> very handy for me and I really miss it in barebox.
> >>
> >> This patch series adds ctrl-w support to barebox's readline
> >> and in addition fixes a typo.
> >>
> >> [RFC 1/3] readline: move backspace key handling to the DO_BACKSPACE
> >> [RFC 2/3] readline: add ctrl-w handling (cut-the-last-word)
> >> [RFC 3/3] readline: fix the 'new blank line at EOF' typo
> >
> > Looks good.
>
> So apply the patches, please.
Just did that.
Sascha
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-10-29 9:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-26 5:58 [RFC 0/3] readline: add ctrl-w handling (cut-the-last-word) Antony Pavlov
2012-10-26 5:58 ` [RFC 1/3] readline: move backspace key handling to the DO_BACKSPACE macro Antony Pavlov
2012-10-26 5:58 ` [RFC 2/3] readline: add ctrl-w handling (cut-the-last-word) Antony Pavlov
2012-10-26 5:58 ` [RFC 3/3] readline: fix the 'new blank line at EOF' typo Antony Pavlov
2012-10-27 12:24 ` [RFC 0/3] readline: add ctrl-w handling (cut-the-last-word) Sascha Hauer
2012-10-28 15:11 ` Antony Pavlov
2012-10-29 9:02 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox