public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Pantelis Antoniou <pantelis@embeddedalley.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH 1/8] Make autocomplete work with HUSH parser too.
Date: Sun, 03 Dec 2006 00:15:50 +0200	[thread overview]
Message-ID: <20061202221550.652.71435.stgit@pantathon.hol.gr> (raw)

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;

             reply	other threads:[~2006-12-02 22:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-02 22:15 Pantelis Antoniou [this message]
2006-12-02 22:15 ` [U-Boot-Users] [PATCH 2/8] Support LATTICE FPGA parts using JTAG programming. Interface to FPGA API Pantelis Antoniou
2006-12-02 22:16 ` [U-Boot-Users] [PATCH 3/8] Support LATTICE FPGA parts using JTAG programming. JTAG core Pantelis Antoniou
2006-12-02 22:16 ` [U-Boot-Users] [PATCH 4/8] Support LATTICE FPGA parts using JTAG programming. Support functions Pantelis Antoniou
2006-12-02 22:16 ` [U-Boot-Users] [PATCH 5/8] Adds support for RedBoot Pantelis Antoniou
2006-12-02 22:16 ` [U-Boot-Users] [PATCH 6/8] Support Analogue Micro's ASP8347DB board. CONFIG file Pantelis Antoniou
2006-12-02 22:16 ` [U-Boot-Users] [PATCH 7/8] Support Analogue Micro's ASP8347DB board. Implementation Pantelis Antoniou
2006-12-02 22:16 ` [U-Boot-Users] [PATCH 8/8] Pantelis Antoniou MAINTAINER update Pantelis Antoniou

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=20061202221550.652.71435.stgit@pantathon.hol.gr \
    --to=pantelis@embeddedalley.com \
    --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