[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    PATCH: ENABLE_FEATURE_EDITING_HELP: Provide help on lineedit keycodes.
From:       Flemming Madsen <busybox () themadsens ! dk>
Date:       2011-09-26 19:18:42
Message-ID: CACWu54Wkdk6Hbssa+Qr_3GNAZy99QZxGWpP_r=PqbJT3wGwZSg () mail ! gmail ! com
[Download RAW message or body]

ENABLE_FEATURE_EDITING_HELP: Provide help on lineedit keycodes.
Add the following to 'help' output:

Signed-off-by: Flemming Madsen <busybox@themadsens.dk>

---

Line editing:
-------------------
	C-A, <Home>	Move to start of line
	C-E, <End>	Move to end of line
	C-B, <Left>	Move back one char
	C-F, <Right>	Move forward one char
	C-D		Delete one char or exit
	<Del>		Delete one char to the right
	C-H		Delete one char to the left
	C-W		Delete one Word to the left
	C-U		Clear line before cursor
	C-K		Kill / Clear rest of line
	C-L		Clear screen
	C-R		Inremental reverse history search
	C-X		Redraw line
	C-P, <Up>	Get previous command line
	C-N, <Down>	Get next command line
	<Tab>		Tab completion
	M-Tab, S-Tab	Tab menu forward. <Tab> goes back again
	M-b, C-Left	Move word backward
	M-f, C-Right	Move word forward
	M-w, M-BkSpace	Delete word backward
	M-d, M-Delete	Delete word forward
	M-P, M-Up	Get previous line, matching prefix
	M-N, M-Down	Get next line, matching prefix
	M-., M-_	Insert last word of previous line


Mostly because bash has a man page and the 'bind -p' command, whereas
Busybox users has to peruse the raw source code to get at the same
information. Also I find it darn convenient.  Of course one could argue
that vi-binding users are left out in the cold ...

["06-lineedit-keys-builtin-help.patch" (text/x-patch)]

ENABLE_FEATURE_EDITING_HELP: Provide help on lineedit keycodes.
Add the following to 'help' output:

Signed-off-by: Flemming Madsen <busybox@themadsens.dk>

---

Line editing:
-------------------
	C-A, <Home>	Move to start of line
	C-E, <End>	Move to end of line
	C-B, <Left>	Move back one char
	C-F, <Right>	Move forward one char
	C-D		Delete one char or exit
	<Del>		Delete one char to the right
	C-H		Delete one char to the left
	C-W		Delete one Word to the left
	C-U		Clear line before cursor
	C-K		Kill / Clear rest of line
	C-L		Clear screen
	C-R		Inremental reverse history search
	C-X		Redraw line
	C-P, <Up>	Get previous command line
	C-N, <Down>	Get next command line
	<Tab>		Tab completion
	M-Tab, S-Tab	Tab menu forward. <Tab> goes back again
	M-b, C-Left	Move word backward
	M-f, C-Right	Move word forward
	M-w, M-BkSpace	Delete word backward
	M-d, M-Delete	Delete word forward
	M-P, M-Up	Get previous line, matching prefix
	M-N, M-Down	Get next line, matching prefix
	M-., M-_	Insert last word of previous line


Mostly because bash has a man page and the 'bind -p' command, whereas
Busybox users has to peruse the raw source code to get at the same
information. Also I find it darn convenient.  Of course one could argue
that vi-binding users are left out in the cold ...

Index: busybox/busybox-1.19.2/include/libbb.h
===================================================================
--- busybox.orig/busybox-1.19.2/include/libbb.h	2011-09-26 09:47:01.000000000 +0200
+++ busybox/busybox-1.19.2/include/libbb.h	2011-09-26 09:47:02.000000000 +0200
@@ -1457,6 +1457,9 @@
  * >0 length of input string, including terminating '\n'
  */
 int read_line_input(line_input_t *st, const char *prompt, char *command, int \
maxsize, int timeout) FAST_FUNC; +#if ENABLE_FEATURE_EDITING_HELP
+void line_input_help(void) FAST_FUNC;
+#endif
 #else
 #define MAX_HISTORY 0
 int read_line_input(const char* prompt, char* command, int maxsize) FAST_FUNC;
Index: busybox/busybox-1.19.2/libbb/lineedit.c
===================================================================
--- busybox.orig/busybox-1.19.2/libbb/lineedit.c	2011-09-26 09:47:01.000000000 +0200
+++ busybox/busybox-1.19.2/libbb/lineedit.c	2011-09-26 09:47:02.000000000 +0200
@@ -2920,6 +2920,57 @@
 	return len; /* can't return command_len, DEINIT_S() destroys it */
 }
 
+void FAST_FUNC line_input_help(void)
+{
+#if ENABLE_FEATURE_EDITING_HELP
+	printf("Line editing:\n-------------------\n%s\n",
+			"\t" "C-A, <Home>"	  "\t" "Move to start of line\n"
+			"\t" "C-E, <End>"	  "\t" "Move to end of line\n"
+			"\t" "C-B, <Left>"	  "\t" "Move back one char\n"
+			"\t" "C-F, <Right>"   "\t" "Move forward one char\n"
+#if !ENABLE_FEATURE_EDITING_EXT
+			"\t" "C-Left"		  "\t" "Move word backward\n"
+			"\t" "C-Right"		  "\t" "Move word forward\n"
+#endif
+			"\t" "C-D"			"\t\t" "Delete one char or exit\n"
+			"\t" "<Del>"		"\t\t" "Delete one char to the right\n"
+			"\t" "C-H"			"\t\t" "Delete one char to the left\n"
+			"\t" "C-W"			"\t\t" "Delete one Word to the left\n"
+			"\t" "C-U"			"\t\t" "Clear line before cursor\n"
+			"\t" "C-K"			"\t\t" "Kill / Clear rest of line\n"
+			"\t" "C-L"			"\t\t" "Clear screen\n"
+#if ENABLE_FEATURE_REVERSE_SEARCH && MAX_HISTORY > 0
+			"\t" "C-R"			"\t\t" "Inremental reverse history search\n"
+			"\t" "C-X"			"\t\t" "Redraw line\n"
+#else
+			"\t" "C-R C-X"		  "\t" "Redraw line\n"
+#endif
+#if MAX_HISTORY > 0
+			"\t" "C-P, <Up>"	  "\t" "Get previous command line\n"
+			"\t" "C-N, <Down>"	  "\t" "Get next command line\n"
+#endif
+#if ENABLE_FEATURE_TAB_COMPLETION
+			"\t" "<Tab>"		"\t\t" "Tab completion\n"
+#endif
+#if ENABLE_FEATURE_EDITING_EXT
+#if ENABLE_FEATURE_TAB_COMPLETION
+			"\t" "M-Tab, S-Tab"   "\t" "Tab menu forward. <Tab> goes back again\n"
+#endif
+			"\t" "M-b, C-Left"	  "\t" "Move word backward\n"
+			"\t" "M-f, C-Right"   "\t" "Move word forward\n"
+			"\t" "M-w, M-BkSpace" "\t" "Delete word backward\n"
+			"\t" "M-d, M-Delete"  "\t" "Delete word forward\n"
+#if MAX_HISTORY > 0
+			"\t" "M-P, M-Up"	  "\t" "Get previous line, matching prefix\n"
+			"\t" "M-N, M-Down"	  "\t" "Get next line, matching prefix\n"
+			"\t" "M-., M-_"		  "\t" "Insert last word of previous line\n"
+#endif
+#endif
+
+			);
+#endif
+}
+
 #else  /* !FEATURE_EDITING */
 
 #undef read_line_input
Index: busybox/busybox-1.19.2/shell/ash.c
===================================================================
--- busybox.orig/busybox-1.19.2/shell/ash.c	2011-09-26 09:47:01.000000000 +0200
+++ busybox/busybox-1.19.2/shell/ash.c	2011-09-26 09:47:02.000000000 +0200
@@ -3926,7 +3926,7 @@
 		}
 		st &= 0x7f;
 //TODO: use bbox's get_signame? strsignal adds ~600 bytes to text+rodata
-		col = fmtstr(s, 32, strsignal(st));
+		col = fmtstr(s, 32, "%s", strsignal(st));
 		if (WCOREDUMP(status)) {
 			col += fmtstr(s + col, 16, " (core dumped)");
 		}
@@ -8765,8 +8765,11 @@
 		if (!did_banner) {
 			/* note: ash and hush share this string */
 			out1fmt("\n\n%s %s\n"
-				"Enter 'help' for a list of built-in commands."
-				"\n\n",
+				"Enter 'help' for a list of built-in commands"
+#if ENABLE_FEATURE_EDITING_HELP
+				" and command line editing keys"
+#endif
+				".\n\n",
 				bb_banner,
 				"built-in shell (ash)"
 			);
@@ -12624,6 +12627,10 @@
 	}
 #endif
 	out1fmt("\n\n");
+
+#if ENABLE_FEATURE_EDITING_HELP
+	line_input_help();
+#endif
 	return EXIT_SUCCESS;
 }
 #endif /* FEATURE_SH_EXTRA_QUIET */
Index: busybox/busybox-1.19.2/shell/hush.c
===================================================================
--- busybox.orig/busybox-1.19.2/shell/hush.c	2011-09-26 09:47:01.000000000 +0200
+++ busybox/busybox-1.19.2/shell/hush.c	2011-09-26 09:47:02.000000000 +0200
@@ -8163,8 +8163,11 @@
 	if (!ENABLE_FEATURE_SH_EXTRA_QUIET && G_interactive_fd) {
 		/* note: ash and hush share this string */
 		printf("\n\n%s %s\n"
-			IF_HUSH_HELP("Enter 'help' for a list of built-in commands.\n")
-			"\n",
+			IF_HUSH_HELP("Enter 'help' for a list of built-in commands")
+#if ENABLE_FEATURE_EDITING_HELP
+			" and command line editing keys"
+#endif
+			".\n\n",
 			bb_banner,
 			"hush - the humble shell"
 		);
@@ -8649,6 +8652,9 @@
 			printf("%-10s%s\n", x->b_cmd, x->b_descr);
 	}
 	bb_putchar('\n');
+#if ENABLE_FEATURE_EDITING_HELP
+	line_input_help();
+#endif
 	return EXIT_SUCCESS;
 }
 #endif
Index: busybox/busybox-1.19.2/libbb/Config.src
===================================================================
--- busybox.orig/busybox-1.19.2/libbb/Config.src	2011-09-26 09:47:01.000000000 +0200
+++ busybox/busybox-1.19.2/libbb/Config.src	2011-09-26 09:47:02.000000000 +0200
@@ -70,6 +70,14 @@
 	  You may want to decrease this parameter if your target machine
 	  benefits from smaller stack usage.
 
+config FEATURE_EDITING_HELP
+	bool "Help on line editing (in ash help command)"
+	default n
+	depends on FEATURE_EDITING
+	help
+	  Add a routine for outputting line edit help, and use it in
+	  the ash help builtin command
+
 config FEATURE_EDITING_VI
 	bool "vi-style line editing commands"
 	default n



_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic