dvdhrm / kmscon

Linux KMS/DRM based virtual Console Emulator
http://www.freedesktop.org/wiki/Software/kmscon
Other
436 stars 81 forks source link

Does kmscon has any bug in `Esc[nE` and `Esc[nF`? #142

Open viruscamp opened 2 years ago

viruscamp commented 2 years ago

When I am using pacman , I found:
Error output in kmscon:

[]$ sudo pacman -Sy
:: Synchronizing package databases…
 core
 extra
 core is up to date extra is up to date[]$

Correct output in getty, xterm, qterminal, konsole, etc

[]$ sudo pacman -Sy
:: Synchronizing package databases...
 core is up to date
 extra is up to date
[]$ 

I wrote a sample code to simulate it, and got the same outputs:

#include <stdio.h>
#include <unistd.h>

// from pacman-6.0.1/src/pacman/util.c: 1835
/* Moves console cursor `lines` up */
void console_cursor_move_up(unsigned int lines)
{
    printf("\x1B[%dF", lines);
}

/* Moves console cursor `lines` down */
void console_cursor_move_down(unsigned int lines)
{
    printf("\x1B[%dE", lines);
}

/* Erases line from the current cursor position till the end of the line */
void console_erase_line(void)
{
    printf("\x1B[K");
}

int main()
{
    printf(":: Synchronizing package databases...\n");
    printf(" %s\n", "core");
    printf(" %s\n", "extra");
    sleep(1);

    console_cursor_move_up(2);
    printf(" %s is up to date", "core");
    console_erase_line();

    console_cursor_move_down(1);
    printf(" %s is up to date", "extra");
    console_erase_line();

    printf("\n");

    return 0;
}