summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Rameau <quinq@fifth.space>2024-02-25 01:31:31 +0100
committerRafael Marçalo <raroma09@gmail.com>2024-02-25 22:22:34 +0000
commite9a1c1fe3ea43c44c24347acdec1f9952dfcea02 (patch)
treed1b841c7a176c285a96bdb48332ab66471626020
parent0d1d6a361a6b5a5fa4a875e1c358baf346a996f9 (diff)
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.
-rw-r--r--st.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/st.c b/st.c
index 386e001..dd82d37 100644
--- a/st.c
+++ b/st.c
@@ -90,8 +90,8 @@ enum escape_state {
typedef struct {
Glyph attr; /* current char attributes */
- int x;
- int y;
+ int x; /* terminal column */
+ int y; /* terminal row */
char state;
} TCursor;
@@ -2263,12 +2263,16 @@ tstrsequence(uchar c)
void
tcontrolcode(uchar ascii)
{
+ size_t i;
+
switch (ascii) {
case '\t': /* HT */
tputtab(1);
return;
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;
case '\r': /* CR */
tmoveto(0, term.c.y);