From: Leo C Date: Fri, 22 Apr 2016 07:59:08 +0000 (+0200) Subject: Enable commandline editing with history buffer parmanently, and remove macro CONFIG_C... X-Git-Tag: hexrel-6.6~2 X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/commitdiff_plain/c647afca0ab5d67de1c18b52b4e50262fcb73425 Enable commandline editing with history buffer parmanently, and remove macro CONFIG_CMDLINE_EDITING and the non-history-buffer code. --- diff --git a/avr/cli_readline.c b/avr/cli_readline.c index 6aef92e..5545015 100644 --- a/avr/cli_readline.c +++ b/avr/cli_readline.c @@ -191,44 +191,6 @@ int vt_parse (void) char console_buffer[CONFIG_SYS_CBSIZE + 1]; /* console I/O buffer */ -#ifndef CONFIG_CMDLINE_EDITING -static const FLASH char erase_seq[] = "\b \b"; /* erase sequence */ -static const FLASH char tab_seq[] = " "; /* used to expand TABs */ - -static char *delete_char (char *buffer, char *p, int *colp, int *np, int plen) -{ - char *s; - - if (*np == 0) - return p; - - if (*(--p) == '\t') { /* will retype the whole line */ - while (*colp > plen) { - my_puts_P(erase_seq); - (*colp)--; - } - for (s = buffer; s < p; ++s) { - if (*s == '\t') { - my_puts_P(tab_seq + ((*colp) & 07)); - *colp += 8 - ((*colp) & 07); - } else { - ++(*colp); - putchar(*s); - } - } - } else { - my_puts_P(erase_seq); - (*colp)--; - } - (*np)--; - - return p; -} -#endif /* CONFIG_CMDLINE_EDITING */ - - -#ifdef CONFIG_CMDLINE_EDITING - /* * cmdline-editing related codes from vivi. * Author: Janghoon Lyu @@ -557,14 +519,11 @@ static int cread_line(const FLASH char *const prompt, char *buf, uint_fast8_t *l return 0; } -#endif /* CONFIG_CMDLINE_EDITING */ - /****************************************************************************/ static int cli_readline_into_buffer(const FLASH char *const prompt, char *buffer) { char *p = buffer; -#ifdef CONFIG_CMDLINE_EDITING uint_fast8_t len = CONFIG_SYS_CBSIZE; int rc; @@ -573,95 +532,6 @@ static int cli_readline_into_buffer(const FLASH char *const prompt, char *buffer rc = cread_line(prompt, p, &len); return rc < 0 ? rc : (int) len; - -#else /* CONFIG_CMDLINE_EDITING */ - char *p_buf = p; - int n = 0; /* buffer index */ - int plen = 0; /* prompt length */ - int col; /* output column cnt */ - char c; - - /* print prompt */ - if (prompt) { - plen = strlen_P(prompt); - my_puts_P(prompt); - } - col = plen; - - for (;;) { - - c = my_getchar(1); - - /* - * Special character handling - */ - switch (c) { - case '\r': /* Enter */ - case '\n': - *p = '\0'; - my_puts_P(PSTR("\r\n")); - return p - p_buf; - - case '\0': /* nul */ - continue; - - case 0x03: /* ^C - break */ - p_buf[0] = '\0'; /* discard input */ - return -1; - - case 0x15: /* ^U - erase line */ - while (col > plen) { - my_puts_P(erase_seq); - --col; - } - p = p_buf; - n = 0; - continue; - - case 0x17: /* ^W - erase word */ - p = delete_char(p_buf, p, &col, &n, plen); - while ((n > 0) && (*p != ' ')) - p = delete_char(p_buf, p, &col, &n, plen); - continue; - - case 0x08: /* ^H - backspace */ - case 0x7F: /* DEL - backspace */ - p = delete_char(p_buf, p, &col, &n, plen); - continue; - - default: - /* - * Must be a normal character then - */ - if (n < CONFIG_SYS_CBSIZE-2) { - if (c == '\t') { /* expand TABs */ -#ifdef CONFIG_AUTO_COMPLETE - /* - * if auto completion triggered just - * continue - */ - *p = '\0'; - if (cmd_auto_complete(prompt, - console_buffer, - &n, &col)) { - p = p_buf + n; /* reset */ - continue; - } -#endif - my_puts_P(tab_seq + (col & 07)); - col += 8 - (col & 07); - } else { - ++col; - putchar(c); - } - *p++ = c; - ++n; - } else { /* Buffer full */ - putchar('\a'); - } - } - } -#endif /* CONFIG_CMDLINE_EDITING */ } int cli_readline(const FLASH char *const prompt) diff --git a/include/cli_readline.h b/include/cli_readline.h index b7dc938..4471568 100644 --- a/include/cli_readline.h +++ b/include/cli_readline.h @@ -29,10 +29,9 @@ int cli_readline(const FLASH char *const prompt); * maximum line length is CONFIG_SYS_CBSIZE including a \0 terminator, which * will always be added. * - * The command is echoed as it is typed. Command editing is supported if - * CONFIG_CMDLINE_EDITING is defined. Tab auto-complete is supported if - * CONFIG_AUTO_COMPLETE is defined. If CONFIG_BOOT_RETRY_TIME is defined, - * then a timeout will be applied. + * The command is echoed as it is typed. Command editing is supported. + * Tab auto-complete is supported if CONFIG_AUTO_COMPLETE is defined. + * If CONFIG_BOOT_RETRY_TIME is defined, then a timeout will be applied. * * If CONFIG_BOOT_RETRY_TIME is defined and retry_time >= 0, * time out when time goes past endtime (timebase time in ticks). diff --git a/include/config.h b/include/config.h index 7fc1b5e..1501989 100644 --- a/include/config.h +++ b/include/config.h @@ -61,7 +61,6 @@ #define CONFIG_SYS_FBOOTSIG "Peda" -#define CONFIG_CMDLINE_EDITING 1 /* TODO: */ //#define CONFIG_AUTO_COMPLETE 1