
On Tue, 2007-11-27 at 19:36 +0100, Stefan Roese wrote:
Hi Jocke,
On Tuesday 27 November 2007, Joakim Tjernlund wrote:
Trying to move my boot to latest u-boot and I can't make command completion work. Does it work in current u-boot and what config options do you use?
IIRC, then you have to choose to enable either command completion (CONFIG_AUTO_COMPLETE) or command history (CONFIG_CMDLINE_EDITING). Command history is my choice here.
Ahh, I can only use one. In my old boot I can use both because I applied a patch from Pantelis that I thought was in uboot already. Can you have a look at Pantelis patch an apply if appropriate?
Here is the patch: From: Pantelis Antoniou pantelis@embeddedalley.com To: u-boot-users@lists.sourceforge.net Cc: Frank Robbins frank.robbins@analogue-micro.com, Dan Malek dan@embeddedalley.com, Wolfgang Denk wd@denx.de, Peter Tympanick ptymps@ultsol.com Subject: [U-Boot-Users] [PATCH 1/8] Make autocomplete work with HUSH parser too. Date: Sun, 03 Dec 2006 00:15:50 +0200 (Sat, 23:15 CET)
Auto complete did not work when the HUSH parser was selected. Fix this obvious problem.
--- Signed-off-by: Pantelis Antoniou pantelis@embeddedalley.com ---
README | 4 ---- common/main.c | 25 +++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/README b/README index ecfd1f8..e28f935 100644 --- a/README +++ b/README @@ -1511,10 +1511,6 @@ The following options need to be configured:
Enable auto completion of commands using TAB.
- Note that this feature has NOT been implemented yet - for the "hush" shell. - - CFG_HUSH_PARSER
Define this variable to enable the "hush" shell (from diff --git a/common/main.c b/common/main.c index cc4b50f..a8ae07c 100644 --- a/common/main.c +++ b/common/main.c @@ -718,10 +718,11 @@ static void cread_add_str(char *str, int strsize, int insert, unsigned long *num } }
-static int cread_line(char *buf, unsigned int *len) +static int cread_line(const char *const prompt, char *buf, unsigned int *len) { unsigned long num = 0; unsigned long eol_num = 0; + int num2, col; unsigned long rlen; unsigned long wlen; char ichar; @@ -840,6 +841,7 @@ static int cread_line(char *buf, unsigned int *len) insert = !insert; break; case CTL_CH('x'): + case CTL_CH('u'): /* like that too */ BEGINNING_OF_LINE(); ERASE_TO_EOL(); break; @@ -889,6 +891,25 @@ static int cread_line(char *buf, unsigned int *len) REFRESH_TO_EOL(); continue; } +#ifdef CONFIG_AUTO_COMPLETE + case '\t': + + /* do not autocomplete when in the middle */ + if (num < eol_num) { + getcmd_cbeep(); + break; + } + + buf[num] = '\0'; + col = strlen(prompt) + eol_num; + num2 = num; + if (cmd_auto_complete(prompt, buf, &num2, &col)) { + col = num2 - num; + num += col; + eol_num += col; + } + break; +#endif default: cread_add_char(ichar, insert, &num, &eol_num, buf, *len); break; @@ -931,7 +952,7 @@ int readline (const char *const prompt)
puts (prompt);
- rc = cread_line(p, &len); + rc = cread_line(prompt, p, &len); return rc < 0 ? rc : len; #else char *p = console_buffer;