diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2008-03-01 21:08:14 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2008-03-01 21:08:14 +0100 |
commit | df31bb46be18edbaca1adbef3dcb16d2033942b9 (patch) | |
tree | 98ca794cf8d8753c47135c9b3189a49fd5cb7ea2 /lib | |
parent | a1a747af7f7bd816af73d808e1c750f536873c3d (diff) | |
download | barebox-df31bb46be18edbaca1adbef3dcb16d2033942b9.tar.gz barebox-df31bb46be18edbaca1adbef3dcb16d2033942b9.tar.xz |
implement TAB completion
Diffstat (limited to 'lib')
-rw-r--r-- | lib/readline.c | 23 | ||||
-rw-r--r-- | lib/readline_simple.c | 10 |
2 files changed, 24 insertions, 9 deletions
diff --git a/lib/readline.c b/lib/readline.c index 2cf90eca8d..1bdfe61b9d 100644 --- a/lib/readline.c +++ b/lib/readline.c @@ -2,6 +2,7 @@ #include <readkey.h> #include <init.h> #include <xfuncs.h> +#include <complete.h> /* * cmdline-editing related codes from vivi. @@ -179,7 +180,13 @@ int readline(const char *prompt, char *buf, int len) char ichar; int insert = 1; int rc = 0; +#ifdef CONFIG_AUTO_COMPLETE + char tmp; + int reprint, i; + char *completestr; + complete_reset(); +#endif puts (prompt); while (1) { @@ -192,6 +199,22 @@ int readline(const char *prompt, char *buf, int len) } switch (ichar) { + case '\t': +#ifdef CONFIG_AUTO_COMPLETE + tmp = buf[num]; + buf[num] = 0; + reprint = complete(buf, &completestr); + if (reprint) + printf("%s%s", prompt, buf); + + i = 0; + while (completestr[i]) + cread_add_char(completestr[i++], insert, &num, &eol_num, buf, len); + + buf[num] = tmp; +#endif + break; + case KEY_HOME: BEGINNING_OF_LINE(); break; diff --git a/lib/readline_simple.c b/lib/readline_simple.c index b1ac64a545..9dd21545e2 100644 --- a/lib/readline_simple.c +++ b/lib/readline_simple.c @@ -118,14 +118,6 @@ int readline (const char *prompt, char *line, int len) */ if (n < CONFIG_CBSIZE-2) { if (c == '\t') { /* expand TABs */ -#ifdef CONFIG_AUTO_COMPLETE - /* if auto completion triggered just continue */ - *p = '\0'; - if (cmd_auto_complete(prompt, line, &n, &col)) { - p = line + n; /* reset */ - continue; - } -#endif puts (tab_seq+(col&07)); col += 8 - (col&07); } else { @@ -155,4 +147,4 @@ int readline (const char *prompt, char *line, int len) * Enable the "Simple parser" in "General Settings", "Select your shell" to * get back the old console feeling. * - */
\ No newline at end of file + */ |