summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Rameau <quinq@fifth.space>2024-02-25 01:31:31 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2024-02-25 11:56:43 +0100
commit7473a8d1a57e5f9aba41b953f4e498c35e1c9dc5 (patch)
tree58b0baa2424b1e26c7661048ba2e429b52876067
parentcsi: check for private marker in 'S' case (diff)
downloadst-7473a8d1a57e5f9aba41b953f4e498c35e1c9dc5.tar.gz
st-7473a8d1a57e5f9aba41b953f4e498c35e1c9dc5.zip
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 034954d..77c3e8a 100644
--- a/st.c
+++ b/st.c
@@ -86,8 +86,8 @@ enum escape_state {
86 86
87typedef struct { 87typedef struct {
88 Glyph attr; /* current char attributes */ 88 Glyph attr; /* current char attributes */
89 int x; 89 int x; /* terminal column */
90 int y; 90 int y; /* terminal row */
91 char state; 91 char state;
92} TCursor; 92} TCursor;
93 93
@@ -2175,12 +2175,16 @@ tstrsequence(uchar c)
2175void 2175void
2176tcontrolcode(uchar ascii) 2176tcontrolcode(uchar ascii)
2177{ 2177{
2178 size_t i;
2179
2178 switch (ascii) { 2180 switch (ascii) {
2179 case '\t': /* HT */ 2181 case '\t': /* HT */
2180 tputtab(1); 2182 tputtab(1);
2181 return; 2183 return;
2182 case '\b': /* BS */ 2184 case '\b': /* BS */
2183 tmoveto(term.c.x-1, term.c.y); 2185 for (i = 1; term.c.x && term.line[term.c.y][term.c.x - i].u == 0; ++i)
2186 ;
2187 tmoveto(term.c.x - i, term.c.y);
2184 return; 2188 return;
2185 case '\r': /* CR */ 2189 case '\r': /* CR */
2186 tmoveto(0, term.c.y); 2190 tmoveto(0, term.c.y);