mirror of https://github.com/mintsuki/flanterm
Fix bug introduced in 9225cfb1
that resulted in hangs
This commit is contained in:
parent
6ee3fe00c6
commit
a82ef0a111
|
@ -571,8 +571,8 @@ static void fbterm_set_cursor_pos(struct term_context *_ctx, size_t x, size_t y)
|
|||
static void fbterm_get_cursor_pos(struct term_context *_ctx, size_t *x, size_t *y) {
|
||||
struct fbterm_context *ctx = (void *)_ctx;
|
||||
|
||||
*x = ctx->cursor_x;
|
||||
*y = ctx->cursor_y;
|
||||
*x = ctx->cursor_x >= _ctx->cols ? _ctx->cols - 1 : ctx->cursor_x;
|
||||
*y = ctx->cursor_y >= _ctx->rows ? _ctx->rows - 1 : ctx->cursor_y;
|
||||
}
|
||||
|
||||
static void fbterm_move_character(struct term_context *_ctx, size_t new_x, size_t new_y, size_t old_x, size_t old_y) {
|
||||
|
@ -647,12 +647,12 @@ static void fbterm_set_text_bg_default(struct term_context *_ctx) {
|
|||
static void draw_cursor(struct term_context *_ctx) {
|
||||
struct fbterm_context *ctx = (void *)_ctx;
|
||||
|
||||
size_t i = ctx->cursor_x + ctx->cursor_y * _ctx->cols;
|
||||
|
||||
if (i >= _ctx->cols * _ctx->rows) {
|
||||
if (ctx->cursor_x >= _ctx->cols || ctx->cursor_y >= _ctx->rows) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t i = ctx->cursor_x + ctx->cursor_y * _ctx->cols;
|
||||
|
||||
struct fbterm_char c;
|
||||
struct fbterm_queue_item *q = ctx->map[i];
|
||||
if (q != NULL) {
|
||||
|
@ -694,7 +694,9 @@ static void fbterm_double_buffer_flush(struct term_context *_ctx) {
|
|||
}
|
||||
|
||||
if ((ctx->old_cursor_x != ctx->cursor_x || ctx->old_cursor_y != ctx->cursor_y) || ctx->cursor_status == false) {
|
||||
plot_char(_ctx, &ctx->grid[ctx->old_cursor_x + ctx->old_cursor_y * _ctx->cols], ctx->old_cursor_x, ctx->old_cursor_y);
|
||||
if (ctx->old_cursor_x < _ctx->cols && ctx->old_cursor_y < _ctx->rows) {
|
||||
plot_char(_ctx, &ctx->grid[ctx->old_cursor_x + ctx->old_cursor_y * _ctx->cols], ctx->old_cursor_x, ctx->old_cursor_y);
|
||||
}
|
||||
}
|
||||
|
||||
ctx->old_cursor_x = ctx->cursor_x;
|
||||
|
@ -706,12 +708,12 @@ static void fbterm_double_buffer_flush(struct term_context *_ctx) {
|
|||
static void fbterm_raw_putchar(struct term_context *_ctx, uint8_t c) {
|
||||
struct fbterm_context *ctx = (void *)_ctx;
|
||||
|
||||
if (ctx->cursor_x == _ctx->cols && (ctx->cursor_y < _ctx->scroll_bottom_margin - 1 || _ctx->scroll_enabled)) {
|
||||
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--;
|
||||
if (ctx->cursor_y >= _ctx->scroll_bottom_margin) {
|
||||
ctx->cursor_y = _ctx->scroll_bottom_margin - 1;
|
||||
fbterm_scroll(_ctx);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue