#include static char erase_seq[] = "\b \b"; /* erase sequence */ static 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) { puts (erase_seq); (*colp)--; } for (s=buffer; s plen) { puts (erase_seq); --col; } p = line; n = 0; continue; case 0x17: /* ^W - erase word */ p=delete_char(line, p, &col, &n, plen); while ((n > 0) && (*p != ' ')) { p=delete_char(line, p, &col, &n, plen); } continue; case 0x08: /* ^H - backspace */ case 0x7F: /* DEL - backspace */ p=delete_char(line, p, &col, &n, plen); continue; default: /* * Must be a normal character then */ if (n < len-2) { if (c == '\t') { /* expand TABs */ puts (tab_seq+(col&07)); col += 8 - (col&07); } else { ++col; /* echo input */ putchar (c); } *p++ = c; ++n; } else { /* Buffer full */ putchar ('\a'); } } } } /** * @file * @brief Primitiv Line Parser */ /** @page readline_parser Primitive Line Parser * * There is still a primtive line parser as a alternative to the hush shell * environment available. This is for persons who like the old fashion way of * edititing and command entering. * * Enable the "Simple parser" in "General Settings", "Select your shell" to * get back the old console feeling. * */