Fix cursor move with wide glyphs

st would always move back 1 column,
even with wide glyhps (using more than a single column).

The glyph rune is set on its first column,
and the other ones are to 0,
so loop until we detect the start of the previous glyph.
This commit is contained in:
Quentin Rameau 2024-02-25 01:31:31 +01:00 committed by Hiltjo Posthuma
parent a3f7420310
commit 7473a8d1a5
1 changed files with 7 additions and 3 deletions

10
st.c
View File

@ -86,8 +86,8 @@ enum escape_state {
typedef struct { typedef struct {
Glyph attr; /* current char attributes */ Glyph attr; /* current char attributes */
int x; int x; /* terminal column */
int y; int y; /* terminal row */
char state; char state;
} TCursor; } TCursor;
@ -2175,12 +2175,16 @@ tstrsequence(uchar c)
void void
tcontrolcode(uchar ascii) tcontrolcode(uchar ascii)
{ {
size_t i;
switch (ascii) { switch (ascii) {
case '\t': /* HT */ case '\t': /* HT */
tputtab(1); tputtab(1);
return; return;
case '\b': /* BS */ case '\b': /* BS */
tmoveto(term.c.x-1, term.c.y); for (i = 1; term.c.x && term.line[term.c.y][term.c.x - i].u == 0; ++i)
;
tmoveto(term.c.x - i, term.c.y);
return; return;
case '\r': /* CR */ case '\r': /* CR */
tmoveto(0, term.c.y); tmoveto(0, term.c.y);