]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
Enable commandline editing with history buffer parmanently, and remove macro CONFIG_C...
authorLeo C <erbl259-lmu@yahoo.de>
Fri, 22 Apr 2016 07:59:08 +0000 (09:59 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Fri, 22 Apr 2016 07:59:08 +0000 (09:59 +0200)
avr/cli_readline.c
include/cli_readline.h
include/config.h

index 6aef92e301084cd38fc3a5d88947969b7c182822..5545015c27436cd17370702882bca0007f99646b 100644 (file)
@@ -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)
index b7dc938003afbf6430e6897b7b1a955c9effd6ff..44715687400c4877272f32bab529816b6c74f64a 100644 (file)
@@ -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).
index 7fc1b5ef38eaf7d16c68c742bdf0014269fe74ce..1501989ea94ba7661ac5dd8dffab8b414a116a41 100644 (file)
@@ -61,7 +61,6 @@
 
 #define CONFIG_SYS_FBOOTSIG "Peda"
 
-#define CONFIG_CMDLINE_EDITING 1
 /* TODO: */
 //#define CONFIG_AUTO_COMPLETE 1