Skip to contentSkip to conversation

lib: readline support ctrl-l to clear screen

PATCH Applied Du Huanpeng 3 participants 3 messages Nov 15, 2015 – Nov 17, 2015 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: readline support ctrl-l to clear screen

maybe it is easier to press ctrl-l to clear the screen than type 'clear' command.

---
 lib/readline.c | 9 +++++++++
 1 file changed, 9 insertions(+)
lib/readline.c +9 -0
index 14dd311..170effb 100644
@@ -262,6 +262,15 @@ int readline(const char *prompt, char *buf, int len)
 				eol_num--;
 			}
 			break;
+		case CTL_CH('l'):
+			printf(ANSI_CLEAR_SCREEN);
+			buf[eol_num] = 0;
+			printf("%s%s", prompt, buf);
+			wlen = eol_num - num;
+			while (wlen--) {
+				getcmd_putch(CTL_BACKSPACE);
+			}
+			break;
 		case BB_KEY_ERASE_TO_EOL:
 			ERASE_TO_EOL();
 			break;
Signature · 7 lines
1.9.1


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

On Sun, 15 Nov 2015 09:01:19 +0800
Du Huanpeng <[email protected]> wrote:

You have submited at lease two patches with '[PATCH] lib: readline support ctrl-l to clear screen' subject. The patches differ from each other. This causes causes a great deal of confusion.

Please add a version tag when resending patches, see this for details:
http://wiki.qemu.org/Contribute/SubmitAPatch#When_resending_patches_add_a_version_tag

Quoted 36 lines

maybe it is easier to press ctrl-l to clear the screen than type 'clear' command.

---
 lib/readline.c | 9 +++++++++
 1 file changed, 9 insertions(+)
lib/readline.c +9 -0
index 14dd311..170effb 100644
@@ -262,6 +262,15 @@ int readline(const char *prompt, char *buf, int len)
 				eol_num--;
 			}
 			break;
+		case CTL_CH('l'):
+			printf(ANSI_CLEAR_SCREEN);
+			buf[eol_num] = 0;
+			printf("%s%s", prompt, buf);
+			wlen = eol_num - num;
+			while (wlen--) {
+				getcmd_putch(CTL_BACKSPACE);
+			}
+			break;
 		case BB_KEY_ERASE_TO_EOL:
 			ERASE_TO_EOL();
 			break;
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 8 lines
-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#2 lore raw
In reply to Du Huanpeng
Quoted 7 lines · Du Huanpeng

maybe it is easier to press ctrl-l to clear the screen than type 'clear' command.

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

Applied, thanks. Antony is right, please explain the changes to the last version next time.

Sascha

Quoted 30 lines
lib/readline.c +9 -0
index 14dd311..170effb 100644
@@ -262,6 +262,15 @@ int readline(const char *prompt, char *buf, int len)
 				eol_num--;
 			}
 			break;
+		case CTL_CH('l'):
+			printf(ANSI_CLEAR_SCREEN);
+			buf[eol_num] = 0;
+			printf("%s%s", prompt, buf);
+			wlen = eol_num - num;
+			while (wlen--) {
+				getcmd_putch(CTL_BACKSPACE);
+			}
+			break;
 		case BB_KEY_ERASE_TO_EOL:
 			ERASE_TO_EOL();
 			break;
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
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