Fast and reasonably complete (framebuffer) terminal emulator (Zig fork)

Fix some issues detected when trying to run apt

mintsuki bd351cda 5798447d

Changed files
+19 -6
backends
+7 -4
backends/framebuffer.c
···
if (ctx->cursor_x >= _ctx->cols && (ctx->cursor_y < _ctx->scroll_bottom_margin - 1 || _ctx->scroll_enabled)) {
ctx->cursor_x = 0;
ctx->cursor_y++;
-
}
-
if (ctx->cursor_y >= _ctx->scroll_bottom_margin) {
-
ctx->cursor_y = _ctx->scroll_bottom_margin - 1;
-
fbterm_scroll(_ctx);
+
if (ctx->cursor_y == _ctx->scroll_bottom_margin) {
+
ctx->cursor_y--;
+
fbterm_scroll(_ctx);
+
}
+
if (ctx->cursor_y >= _ctx->cols) {
+
ctx->cursor_y = _ctx->cols - 1;
+
}
}
struct fbterm_char ch;
+12 -2
term.c
···
break;
case 'H':
case 'f':
-
ctx->esc_values[0] -= 1;
-
ctx->esc_values[1] -= 1;
+
if (ctx->esc_values[0] != 0) {
+
ctx->esc_values[0]--;
+
}
+
if (ctx->esc_values[1] != 0) {
+
ctx->esc_values[1]--;
+
}
if (ctx->esc_values[1] >= ctx->cols)
ctx->esc_values[1] = ctx->cols - 1;
if (ctx->esc_values[0] >= ctx->rows)
···
}
break;
case 'r':
+
if (ctx->esc_values[0] == 0) {
+
ctx->esc_values[0] = 1;
+
}
+
if (ctx->esc_values[1] == 0) {
+
ctx->esc_values[1] = 1;
+
}
ctx->scroll_top_margin = 0;
ctx->scroll_bottom_margin = ctx->rows;
if (ctx->esc_values_i > 0) {