src/cforth/linenoise.c
static void refreshSingleLine(struct linenoiseState *l) {
    COORD coordinate;
    CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
    HANDLE ofd = GetStdHandle(STD_OUTPUT_HANDLE);
    int right;

    char seq[64];
    size_t plen = strlen(l->prompt);
    char *buf = l->buf;
    size_t len = l->len;
    size_t pos = l->pos;
    
    while((plen+pos) >= l->cols) {
        buf++;
        len--;
        pos--;
    }
    while (plen+len > l->cols) {
        len--;
    }

    (void)GetConsoleScreenBufferInfo(ofd, &csbiInfo);
    right = csbiInfo.dwSize.X;
    coordinate.Y = csbiInfo.dwCursorPosition.Y;

    /* Write the current buffer content */
    coordinate.X = plen;
    WriteConsoleOutputCharacter(ofd, buf, len, coordinate, NULL);

    /* Erase to right */
    coordinate.X = plen + len;
    FillConsoleOutputCharacter(ofd, (TCHAR) ' ', right - plen - len, coordinate, NULL);

    /* Move cursor to original position. */
    coordinate.X = pos + plen;
    SetConsoleCursorPosition(ofd, coordinate);
}
/* Single line low level line refresh.
 *
 * Rewrite the currently edited line accordingly to the buffer content,
 * cursor position, and number of columns of the terminal. */
Single line low level line refresh.
Rewrite the currently edited line accordingly to the buffer content,
cursor position, and number of columns of the terminal.
Single line low level line refresh . Rewrite the currently edited line accordingly to the buffer content cursor position and number of columns of the terminal .
static void refreshSingleLine(struct linenoiseState *l) {
    COORD coordinate;
    CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
    HANDLE ofd = GetStdHandle(STD_OUTPUT_HANDLE);
    int right;
    char seq[64];
    size_t plen = strlen(l->prompt);
    char *buf = l->buf;
    size_t len = l->len;
    size_t pos = l->pos;
    while((plen+pos) >= l->cols) {
        buf++;
        len--;
        pos--;
    }
    while (plen+len > l->cols) {
        len--;
    }
    (void)GetConsoleScreenBufferInfo(ofd, &csbiInfo);
    right = csbiInfo.dwSize.X;
    coordinate.Y = csbiInfo.dwCursorPosition.Y;
    coordinate.X = plen;
    WriteConsoleOutputCharacter(ofd, buf, len, coordinate, NULL);
    coordinate.X = plen + len;
    FillConsoleOutputCharacter(ofd, (TCHAR) ' ', right - plen - len, coordinate, NULL);
    coordinate.X = pos + plen;
    SetConsoleCursorPosition(ofd, coordinate);
}
static void refreshSingleLine ( struct linenoiseState * l ) { COORD coordinate ; CONSOLE_SCREEN_BUFFER_INFO csbiInfo ; HANDLE ofd = GetStdHandle ( STD_OUTPUT_HANDLE ) ; int right ; char seq [ 64 ] ; size_t plen = strlen ( l -> prompt ) ; char * buf = l -> buf ; size_t len = l -> len ; size_t pos = l -> pos ; while ( ( plen + pos ) >= l -> cols ) { buf ++ ; len -- ; pos -- ; } while ( plen + len > l -> cols ) { len -- ; } ( void ) GetConsoleScreenBufferInfo ( ofd , & csbiInfo ) ; right = csbiInfo . dwSize . X ; coordinate . Y = csbiInfo . dwCursorPosition . Y ; coordinate . X = plen ; WriteConsoleOutputCharacter ( ofd , buf , len , coordinate , NULL ) ; coordinate . X = plen + len ; FillConsoleOutputCharacter ( ofd , ( TCHAR ) ' ' , right - plen - len , coordinate , NULL ) ; coordinate . X = pos + plen ; SetConsoleCursorPosition ( ofd , coordinate ) ; }
Single line low level line refresh.
Single line low level line refresh .
/* Write the current buffer content */ /* Erase to right */ /* Move cursor to original position. */