Fix some issues detected when trying to run apt

This commit is contained in:
mintsuki 2022-12-15 00:10:06 +01:00
parent 5798447df2
commit bd351cda31
2 changed files with 19 additions and 6 deletions

View File

@ -724,10 +724,13 @@ static void fbterm_raw_putchar(struct term_context *_ctx, uint8_t 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;

14
term.c
View File

@ -569,8 +569,12 @@ static void control_sequence_parse(struct term_context *ctx, uint8_t 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)
@ -699,6 +703,12 @@ static void control_sequence_parse(struct term_context *ctx, uint8_t c) {
}
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) {