readline: make ctrl-u to work like linux console
PATCH v3 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 | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
lib/readline.c +24 -2
@@ -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) { +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 :
Signature · 9 lines
2.7.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Am 16.10.19 um 09:25 schrieb [email protected]:
Quoted 28 lines
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.
Signed-off-by DU HUANPENG <[email protected]>--- lib/readline.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)lib/readline.c +2
-1@@ -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 ();
lib/readline.c int readline(const char *prompt, char *buf, int len) · line 298
Quoted 9 lines
lib/readline.c +2
-1@@ -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?
Quoted 14 lines
lib/readline.c +13
-0+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 ;
lib/readline.c int readline(const char *prompt, char *buf, int len) · line 321
Quoted 10 lines
lib/readline.c +7
-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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox