From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] command compleation in latest u-boot?
Date: Mon, 17 Dec 2007 23:19:54 -0500 [thread overview]
Message-ID: <200712172319.55508.vapier@gentoo.org> (raw)
In-Reply-To: <200711281041.36019.sr@denx.de>
On Wednesday 28 November 2007, Stefan Roese wrote:
> On Wednesday 28 November 2007, Joakim Tjernlund wrote:
> > > 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?
>
> Yes, would be good if both is possible. Could you do me a favor and redo
> this patch against the current source code. Also it seems that this will
> trigger some compile warning for unused variables "num2, col" when
> CONFIG_AUTO_COMPLETE is not defined. Please check and resend a fixed
> version and I'll make sure that it gets applied when the next merge window
> opens.
the patch posted still applies cleanly (ignoring offsets and the crappy word
wrapping). for sake of completeness, ive attached patch against current
mainline git after giving it a spin against a recent version.
-mike
diff --git a/common/main.c b/common/main.c
index 379695c..4253eac 100644
--- a/common/main.c
+++ b/common/main.c
@@ -696,7 +696,7 @@ 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;
@@ -818,6 +818,7 @@ static int cread_line(char *buf, unsigned int *len)
insert = !insert;
break;
case CTL_CH('x'):
+ case CTL_CH('u'):
BEGINNING_OF_LINE();
ERASE_TO_EOL();
break;
@@ -867,6 +868,27 @@ static int cread_line(char *buf, unsigned int *len)
REFRESH_TO_EOL();
continue;
}
+#ifdef CONFIG_AUTO_COMPLETE
+ case '\t': {
+ int num2, col;
+
+ /* 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;
@@ -909,7 +931,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;
next prev parent reply other threads:[~2007-12-18 4:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-27 18:29 [U-Boot-Users] command compleation in latest u-boot? Joakim Tjernlund
2007-11-27 18:36 ` Stefan Roese
2007-11-27 19:08 ` Joakim Tjernlund
2007-11-28 9:01 ` Joakim Tjernlund
2007-11-28 9:41 ` Stefan Roese
2007-12-18 4:19 ` Mike Frysinger [this message]
2007-12-22 15:02 ` Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200712172319.55508.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox