From 9a6389661ea123f2cc8cabd35c095cdcc99d9e26 Mon Sep 17 00:00:00 2001 From: nick black Date: Tue, 10 Aug 2021 17:16:34 -0400 Subject: [PATCH 1/3] kmscon cursor report uses 0-indexing, account in ncdirect_cursor_yx() #2044 --- src/lib/direct.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/direct.c b/src/lib/direct.c index abe002a9f..4b4ad8a4c 100644 --- a/src/lib/direct.c +++ b/src/lib/direct.c @@ -447,10 +447,13 @@ int ncdirect_cursor_yx(ncdirect* n, int* y, int* x){ int tmp = *y; *y = *x; *x = tmp; + }else{ + // we use 0-based coordinates, but known terminals use 1-based + // coordinates. the only known exception is kmscon, which is + // incidentally the only one which inverts its response. + --*y; + --*x; } - // we use 0-based coordinates, but known terminals use 1-based coordinates - --*y; - --*x; } if(tcsetattr(n->tcache.ttyfd, TCSANOW, &oldtermios)){ fprintf(stderr, "Couldn't restore terminal mode on %d (%s)\n", From a23e91e258b38f0aa633b9f5250dad4dc801cacb Mon Sep 17 00:00:00 2001 From: nick black Date: Tue, 10 Aug 2021 20:21:10 -0400 Subject: [PATCH 2/3] ncdirect_dump_plane: pass true y to sprite_draw() #2043 --- src/lib/direct.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/lib/direct.c b/src/lib/direct.c index 4b4ad8a4c..4905ea616 100644 --- a/src/lib/direct.c +++ b/src/lib/direct.c @@ -504,12 +504,13 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np, int xoff){ int dimy, dimx; ncplane_dim_yx(np, &dimy, &dimx); if(np->sprite){ - if(xoff){ - // doing an x-move without specifying the y coordinate requires asking - // the terminal where the cursor currently is. - if(ncdirect_cursor_move_yx(n, -1, xoff)){ - return -1; - } + int y; + const char* u7 = get_escape(&n->tcache, ESCAPE_U7); + if(cursor_yx_get(n->tcache.ttyfd, u7, &y, NULL)){ + return -1; + } + if(ncdirect_cursor_move_yx(n, y, xoff)){ + return -1; } // flush our FILE*, as we're about to use UNIX I/O (since we can't rely on // stdio to transfer large amounts at once). @@ -520,7 +521,7 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np, int xoff){ if(fbuf_init(&f)){ return -1; } - if(sprite_draw(&n->tcache, NULL, np->sprite, &f, 0, xoff) < 0){ + if(sprite_draw(&n->tcache, NULL, np->sprite, &f, y, xoff) < 0){ return -1; } if(sprite_commit(&n->tcache, &f, np->sprite, true)){ From 21952acd296a90534b1eb9a7e7259787172365bd Mon Sep 17 00:00:00 2001 From: nick black Date: Tue, 10 Aug 2021 20:21:29 -0400 Subject: [PATCH 3/3] fbcon_draw: properly guard against lower boundary #2032 --- TERMINALS.md | 2 +- src/lib/linux.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TERMINALS.md b/TERMINALS.md index d71374f7b..71eda4594 100644 --- a/TERMINALS.md +++ b/TERMINALS.md @@ -75,7 +75,7 @@ relies on the font. Patches to correct/complete this table are very welcome! | [Guake](https://github.com/Guake/guake) | | ? |? | | | | [ITerm2](https://github.com/gnachman/iTerm2) | ✅ | ✅ |✅ |`TERM=xterm-256color` || | [Kitty](https://github.com/kovidgoyal/kitty) | ✅ | ✅ |✅ |`TERM=xterm-kitty` | See below. | -| [kmscon](https://github.com/dvdhrm/kmscon) | | ❌ | ❌ |`TERM=xterm-256color` | No RGB color AFAICT, nor any distinct terminfo entry. No actual `ccc` implementation. | +| [kmscon](https://github.com/dvdhrm/kmscon) | | ❌ | ❌ |`TERM=xterm-256color` | No RGB color AFAICT, nor any distinct terminfo entry. No actual `ccc` implementation. Sets `COLORTERM=kmscon`.| | [Konsole](https://invent.kde.org/utilities/konsole) | ❌ | ❌ |? |`TERM=konsole-direct` | | | Linux console | ❌ | ✅ |see [below](#the-linux-console) |`TERM=linux` `COLORTERM=24bit` | 8 (512 glyph fonts) or 16 (256 glyph fonts) colors max, but RGB values are downsampled to a 256-index palette. See below. | | [mlterm](https://github.com/arakiken/mlterm) | ✅ | ❌ |? |`TERM=mlterm-256color` | Do not set `COLORTERM`. `mlterm-direct` gives strange results. | diff --git a/src/lib/linux.c b/src/lib/linux.c index 8abae66c9..c6f1a44a2 100644 --- a/src/lib/linux.c +++ b/src/lib/linux.c @@ -173,7 +173,7 @@ int fbcon_draw(const tinfo* ti, const struct ncpile *p, sprixel* s, fbuf* f, int (void)p; (void)f; // we don't write to the stream int wrote = 0; - for(unsigned l = 0 ; l < (unsigned)s->pixy && l < ti->pixy ; ++l){ + for(unsigned l = 0 ; l < (unsigned)s->pixy && l + y * ti->cellpixy < ti->pixy ; ++l){ // FIXME pixel size isn't necessarily 4B, line isn't necessarily psize*pixx size_t offset = ((l + y * ti->cellpixy) * ti->pixx + x * ti->cellpixx) * 4; uint8_t* tl = ti->linux_fbuffer + offset;