fs_cli: use buffered printers

This commit is contained in:
Travis Cross 2011-09-23 17:14:28 +00:00
parent 481e71970f
commit 991b83d23c
1 changed files with 13 additions and 6 deletions

View File

@ -106,8 +106,9 @@ static void clear_cli(void) {
const LineInfo *lf = el_line(el); const LineInfo *lf = el_line(el);
int len=(lf->lastchar - lf->buffer); int len=(lf->lastchar - lf->buffer);
for (; len>0; len--) { for (; len>0; len--) {
write(STDOUT_FILENO, "\b", 1); putchar('\b');
} }
fflush(stdout);
} }
/* If a fnkey is configured then process the command */ /* If a fnkey is configured then process the command */
@ -576,19 +577,25 @@ static void clear_line(void)
{ {
const LineInfo *lf = el_line(el); const LineInfo *lf = el_line(el);
int len=(strlen(prompt_str) + (lf->lastchar - lf->buffer)); int len=(strlen(prompt_str) + (lf->lastchar - lf->buffer));
write(STDOUT_FILENO, "\r", 1); putchar('\r');
for (; len>0; len--) { for (; len>0; len--) {
write(STDOUT_FILENO, " ", 1); putchar(' ');
} }
write(STDOUT_FILENO, "\r", 1); putchar('\r');
fflush(stdout);
return; return;
} }
static void redisplay(void) static void redisplay(void)
{ {
const LineInfo *lf = el_line(el); const LineInfo *lf = el_line(el);
write(STDOUT_FILENO, prompt_str, strlen(prompt_str)); const char *c = lf->buffer;
write(STDOUT_FILENO, lf->buffer, (lf->lastchar - lf->buffer)); printf("%s",prompt_str);
while (*c && c != lf->lastchar) {
putchar(*c);
c++;
}
fflush(stdout);
return; return;
} }