forked from espressif/esp-idf
fix(console): fix linenoise flushing in dumb mode
This commit is contained in:
@@ -1092,6 +1092,7 @@ static int linenoiseRaw(char *buf, size_t buflen, const char *prompt) {
|
|||||||
static int linenoiseDumb(char* buf, size_t buflen, const char* prompt) {
|
static int linenoiseDumb(char* buf, size_t buflen, const char* prompt) {
|
||||||
/* dumb terminal, fall back to fgets */
|
/* dumb terminal, fall back to fgets */
|
||||||
fputs(prompt, stdout);
|
fputs(prompt, stdout);
|
||||||
|
flushWrite();
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
while (count < buflen) {
|
while (count < buflen) {
|
||||||
int c = fgetc(stdin);
|
int c = fgetc(stdin);
|
||||||
@@ -1105,11 +1106,13 @@ static int linenoiseDumb(char* buf, size_t buflen, const char* prompt) {
|
|||||||
count --;
|
count --;
|
||||||
}
|
}
|
||||||
fputs("\x08 ", stdout); /* Windows CMD: erase symbol under cursor */
|
fputs("\x08 ", stdout); /* Windows CMD: erase symbol under cursor */
|
||||||
|
flushWrite();
|
||||||
} else {
|
} else {
|
||||||
buf[count] = c;
|
buf[count] = c;
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
fputc(c, stdout); /* echo */
|
fputc(c, stdout); /* echo */
|
||||||
|
flushWrite();
|
||||||
}
|
}
|
||||||
fputc('\n', stdout);
|
fputc('\n', stdout);
|
||||||
flushWrite();
|
flushWrite();
|
||||||
|
Reference in New Issue
Block a user