summaryrefslogtreecommitdiff
path: root/avr
diff options
context:
space:
mode:
authorLeo C2016-04-22 09:59:08 +0200
committerLeo C2016-04-22 09:59:08 +0200
commitc647afca0ab5d67de1c18b52b4e50262fcb73425 (patch)
tree3586437e4ee5bd76660062c9580486f057892d3e /avr
parentf32690e8a658acc4b935289d4719be1b004deb3b (diff)
downloadz180-stamp-c647afca0ab5d67de1c18b52b4e50262fcb73425.zip
Enable commandline editing with history buffer parmanently, and remove macro CONFIG_CMDLINE_EDITING and the non-history-buffer code.
Diffstat (limited to 'avr')
-rw-r--r--avr/cli_readline.c130
1 files changed, 0 insertions, 130 deletions
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 <nandy@mizi.com>
@@ -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)