dvdhrm / kmscon

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

Cursor position report should be 1-based #123

Open xiaq opened 8 years ago

xiaq commented 8 years ago

The following prints ^[[1;1R on xterm, the linux console, libvte-based terminals:

clear
echo '\033[6n'
read | cat -v

But it prints ^[[0;0R on kmscon.

xiaq commented 8 years ago

This patch to libtsm should fix this issue:

diff --git a/src/tsm/tsm-vte.c b/src/tsm/tsm-vte.c
index ec8a936..d2d4776 100644
--- a/src/tsm/tsm-vte.c
+++ b/src/tsm/tsm-vte.c
@@ -1513,7 +1513,8 @@ static void csi_dsr(struct tsm_vte *vte)
    } else if (vte->csi_argv[0] == 6) {
        x = tsm_screen_get_cursor_x(vte->con);
        y = tsm_screen_get_cursor_y(vte->con);
-       len = snprintf(buf, sizeof(buf), "\e[%u;%uR", x, y);
+       /* CSI DSR uses 1-based coordinates */
+       len = snprintf(buf, sizeof(buf), "\e[%u;%uR", x+1, y+1);
        if (len >= sizeof(buf))
            vte_write(vte, "\e[0;0R", 6);
        else