]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
Enable command line editing and history (CONFIG_CMDLINE_EDITING)
authorLeo C <erbl259-lmu@yahoo.de>
Wed, 26 Nov 2014 15:51:41 +0000 (16:51 +0100)
committerLeo C <erbl259-lmu@yahoo.de>
Wed, 26 Nov 2014 15:51:41 +0000 (16:51 +0100)
avr/cli_readline.c
include/config.h

index 1dbc73b1e027c3687c2086135a21aba853972d05..1a0aaf2f22736c91c865fa2eb7b354339d8f0f12 100644 (file)
@@ -64,20 +64,26 @@ static char *delete_char (char *buffer, char *p, int *colp, int *np, int plen)
  * Author: Janghoon Lyu <nandy@mizi.com>
  */
 
-#define putnstr(str, n)        printf_P(PSTR("%.*s"), (int)n, str)
+static void putnstr(char *str, int n)
+{
+       /* printf_P(PSTR("%.*s"), (int)n, str) */
+       while (n--)
+               putchar(*str++);
+}
 
-#define CTL_CH(c)              ((c) - 'a' + 1)
+
+#define CTL_CH(c)                      ((c) - 'a' + 1)
 #define CTL_BACKSPACE          ('\b')
-#define DEL                    ((char)255)
-#define DEL7                   ((char)127)
+#define DEL                                    ((char)255)
+#define DEL7                           ((char)127)
 #define CREAD_HIST_CHAR                ('!')
 
 #define getcmd_putch(ch)       putchar(ch)
 #define getcmd_getch()         my_getchar(1)
 #define getcmd_cbeep()         getcmd_putch('\a')
 
-#define HIST_MAX               5
-#define HIST_SIZE              CONFIG_SYS_CBSIZE
+#define HIST_MAX                       5
+#define HIST_SIZE                      CONFIG_SYS_CBSIZE
 
 static int hist_max;
 static int hist_add_idx;
@@ -181,28 +187,29 @@ static void cread_print_hist_list(void)
 }
 #endif /* CONFIG_CMDLINE_EDITING */
 
-#define BEGINNING_OF_LINE() {                  \
-       while (num) {                           \
-               getcmd_putch(CTL_BACKSPACE);    \
-               num--;                          \
-       }                                       \
+#define BEGINNING_OF_LINE() {                                                  \
+       while (num) {                                                              \
+               getcmd_putch(CTL_BACKSPACE);                                           \
+               num--;                                                                 \
+       }                                                                          \
 }
 
-#define ERASE_TO_EOL() {                               \
-       if (num < eol_num) {                            \
-               printf_P(PSTR("%*S"), (int)(eol_num - num), PSTR("")); \
-               do {                                    \
-                       getcmd_putch(CTL_BACKSPACE);    \
-               } while (--eol_num > num);              \
-       }                                               \
+#define ERASE_TO_EOL() {                                                       \
+       if (num < eol_num) {                                                       \
+               /* printf_P(PSTR("%*S"), (int)(eol_num - num), PSTR("")); */           \
+               print_blanks(eol_num - num);                                           \
+               do {                                                                   \
+                       getcmd_putch(CTL_BACKSPACE);                                       \
+               } while (--eol_num > num);                                             \
+       }                                                                          \
 }
 
-#define REFRESH_TO_EOL() {                     \
-       if (num < eol_num) {                    \
-               wlen = eol_num - num;           \
-               putnstr(buf + num, wlen);       \
-               num = eol_num;                  \
-       }                                       \
+#define REFRESH_TO_EOL() {                                                     \
+       if (num < eol_num) {                                                       \
+               wlen = eol_num - num;                                                  \
+               putnstr(buf + num, wlen);                                              \
+               num = eol_num;                                                         \
+       }                                                                          \
 }
 
 static void cread_add_char(char ichar, int insert, unsigned long *num,
@@ -591,4 +598,3 @@ int cli_readline(const FLASH char *const prompt)
 
        return cli_readline_into_buffer(prompt, console_buffer);
 }
-
index 82dbf81c4cbaaa256c454e990c611a3c9e3666a2..d192559325d08f4b019a29170f823cc98acbdf93 100644 (file)
@@ -1,4 +1,4 @@
-#ifndef CONFIG_H               
+#ifndef CONFIG_H
 #define CONFIG_H
 
 /* Environment variables */
 #define CONFIG_ESC_CHAR                ('^'-0x40)
 
 
+#define CONFIG_CMDLINE_EDITING 1
 /* TODO: */
-//#define CONFIG_CMDLINE_EDITING       1
 //#define CONFIG_AUTO_COMPLETE 1
 
 #define CONFIG_SYS_LONGHELP    1
 
 #endif /* CONFIG_H */
-