vtgl

terminal emulator implemented in OpenGL
git clone anongit@rnpnr.xyz:vtgl.git
Log | Files | Refs | Feed | LICENSE

Commit: 137351243382fefabc0f9fa9124e0d24fd54ec6e
Parent: 8dfed6621fa3f75adc05275031b3f3c40d7fcab3
Author: Randy Palamar
Date:   Sun, 11 Aug 2024 11:22:10 -0600

fix state setting when splitting lines and make sure utf-8 doesn't get split

Diffstat:
Mterminal.c | 17+++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/terminal.c b/terminal.c @@ -223,7 +223,6 @@ dump_csi(CSI *csi) fputs(" } }\n", stderr); } - /* ED/DECSED: Erase in Display */ static void erase_in_display(Term *t, CSI *csi) @@ -633,6 +632,7 @@ check_if_csi_moves_cursor(Term *t, s8 *raw) case 'H': result = EMC_CURSOR_MOVED; break; case 'h': set_mode(t, &csi, 1); break; case 'l': set_mode(t, &csi, 0); break; + case 'm': set_colours(t, &csi); break; default: break; } @@ -711,6 +711,7 @@ split_raw_input_to_lines(Term *t, s8 raw) lb->buf[lb->widx].has_unicode |= _mm_movemask_epi8(hasutf8); raw = consume(raw, data - raw.data); + u32 last_c = 0; if (raw.len) { if (peek(raw, 0) == 0x1B) { s8 old = raw; @@ -726,11 +727,11 @@ split_raw_input_to_lines(Term *t, s8 raw) default: break; } } else { - u32 c = get_ascii(&raw); - if (c == '\n') { + last_c = get_ascii(&raw); + if (last_c == '\n') { parsed_lines++; feed_line(lb, raw.data, t->cursor.state); - } else if (c & 0x80) { + } else if (last_c & 0x80) { lb->buf[lb->widx].has_unicode = 1; } } @@ -739,7 +740,7 @@ split_raw_input_to_lines(Term *t, s8 raw) lb->buf[lb->widx].end = raw.data; //if (tv->lines.buf[tv->lines.widx].end < tv->lines.buf[tv->lines.widx].start) // tv->lines.buf[tv->lines.widx].end += tv->log.cap; - if (line_length(lb->buf + lb->widx) > SPLIT_LONG) { + if (line_length(lb->buf + lb->widx) > SPLIT_LONG && !(last_c & 0x80)) { parsed_lines++; feed_line(lb, raw.data, t->cursor.state); } @@ -823,8 +824,12 @@ get_line_idx(LineBuf *lb, size off) static void blit_lines(Term *t, Arena a, size line_count) { + /* TODO: this can't be correct; it could cause an unintentional screen scroll. + * need some way of determining if we are replaying a line and if so restore the + * cursor to position the line originally started at */ /* NOTE: assume altscreen programs are managing the cursor correctly on their own */ - t->cursor.col = t->mode & TM_ALTSCREEN ? t->cursor.col : 0; + //t->cursor.col = t->mode & TM_ALTSCREEN ? t->cursor.col : 0; + t->cursor.col = 0; for (size i = 0; i <= line_count; i++) { size line_idx = get_line_idx(&t->log_lines, -line_count + i);