term: Compatibility with new terminal code

This commit is contained in:
mintsuki 2022-12-30 07:58:46 +01:00
parent 1aba6b3aeb
commit 2ee939725e
5 changed files with 14 additions and 33 deletions

View File

@ -81,20 +81,6 @@ static void text_clear(struct term_context *_ctx, bool move) {
}
}
static void text_enable_cursor(struct term_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx;
ctx->cursor_status = true;
}
static bool text_disable_cursor(struct term_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx;
bool ret = ctx->cursor_status;
ctx->cursor_status = false;
return ret;
}
static void text_full_refresh(struct term_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx;
@ -103,7 +89,7 @@ static void text_full_refresh(struct term_context *_ctx) {
ctx->back_buffer[i] = ctx->front_buffer[i];
}
if (ctx->cursor_status) {
if (_ctx->cursor_enabled) {
draw_cursor(ctx);
ctx->old_cursor_offset = ctx->cursor_offset;
}
@ -112,11 +98,11 @@ static void text_full_refresh(struct term_context *_ctx) {
static void text_double_buffer_flush(struct term_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx;
if (ctx->cursor_status) {
if (_ctx->cursor_enabled) {
draw_cursor(ctx);
}
if (ctx->cursor_offset != ctx->old_cursor_offset || ctx->cursor_status == false) {
if (ctx->cursor_offset != ctx->old_cursor_offset || _ctx->cursor_enabled == false) {
ctx->video_mem[ctx->old_cursor_offset + 1] = ctx->back_buffer[ctx->old_cursor_offset + 1];
}
@ -125,7 +111,7 @@ static void text_double_buffer_flush(struct term_context *_ctx) {
continue;
}
if (ctx->cursor_status && i == ctx->cursor_offset + 1) {
if (_ctx->cursor_enabled && i == ctx->cursor_offset + 1) {
continue;
}
@ -133,7 +119,7 @@ static void text_double_buffer_flush(struct term_context *_ctx) {
ctx->video_mem[i] = ctx->back_buffer[i];
}
if (ctx->cursor_status) {
if (_ctx->cursor_enabled) {
ctx->old_cursor_offset = ctx->cursor_offset;
}
}
@ -299,7 +285,6 @@ void vga_textmode_init(bool managed) {
}
ctx->cursor_offset = 0;
ctx->cursor_status = true;
ctx->text_palette = 0x07;
ctx->video_mem = (volatile uint8_t *)0xb8000;
@ -309,7 +294,7 @@ void vga_textmode_init(bool managed) {
// VGA cursor code taken from: https://wiki.osdev.org/Text_Mode_Cursor
if (!managed) {
text_disable_cursor(term);
term->cursor_enabled = false;
outb(0x3d4, 0x0a);
outb(0x3d5, (inb(0x3d5) & 0xc0) | 14);
@ -340,8 +325,6 @@ void vga_textmode_init(bool managed) {
term->raw_putchar = text_putchar;
term->clear = text_clear;
term->enable_cursor = text_enable_cursor;
term->disable_cursor = text_disable_cursor;
term->set_cursor_pos = text_set_cursor_pos;
term->get_cursor_pos = text_get_cursor_pos;
term->set_text_fg = text_set_text_fg;

View File

@ -352,12 +352,12 @@ again:
static void reprint_string(int x, int y, const char *s) {
size_t orig_x, orig_y;
FOR_TERM(TERM->disable_cursor(TERM));
FOR_TERM(TERM->cursor_enabled = false);
terms[0]->get_cursor_pos(terms[0], &orig_x, &orig_y);
set_cursor_pos_helper(x, y);
print("%s", s);
set_cursor_pos_helper(orig_x, orig_y);
FOR_TERM(TERM->enable_cursor(TERM));
FOR_TERM(TERM->cursor_enabled = true);
}
static void cursor_back(void) {

View File

@ -178,8 +178,6 @@ void term_fallback(void) {
fallback_clear(NULL, true);
term->enable_cursor = (void *)dummy_handle;
term->disable_cursor = (void *)dummy_handle;
term->set_text_fg = (void *)dummy_handle;
term->set_text_bg = (void *)dummy_handle;
term->set_text_fg_bright = (void *)dummy_handle;

View File

@ -42,7 +42,7 @@ inline void reset_term(void) {
print("\e[2J\e[H");
term_context_reinit(term);
term->in_bootloader = true;
term->enable_cursor(term);
term->cursor_enabled = true;
term->double_buffer_flush(term);
}
}

View File

@ -170,7 +170,7 @@ static bool editor_no_term_reset = false;
char *config_entry_editor(const char *title, const char *orig_entry) {
FOR_TERM(TERM->autoflush = false);
FOR_TERM(TERM->enable_cursor(TERM));
FOR_TERM(TERM->cursor_enabled = true);
print("\e[2J\e[H");
@ -214,7 +214,7 @@ refresh:
invalid_syntax = false;
print("\e[2J\e[H");
FOR_TERM(TERM->disable_cursor(TERM));
FOR_TERM(TERM->cursor_enabled = false);
{
size_t x, y;
print("\n");
@ -423,7 +423,7 @@ refresh:
// Hack to redraw the cursor
set_cursor_pos_helper(cursor_x, cursor_y);
FOR_TERM(TERM->enable_cursor(TERM));
FOR_TERM(TERM->cursor_enabled = true);
FOR_TERM(TERM->double_buffer_flush(TERM));
@ -730,7 +730,7 @@ refresh:
FOR_TERM(TERM->autoflush = false);
FOR_TERM(TERM->disable_cursor(TERM));
FOR_TERM(TERM->cursor_enabled = false);
print("\e[2J\e[H");
{
@ -747,7 +747,7 @@ refresh:
quiet = false;
menu_init_term();
FOR_TERM(TERM->autoflush = false);
FOR_TERM(TERM->disable_cursor(TERM));
FOR_TERM(TERM->cursor_enabled = false);
}
print("Config file %s.\n\n", config_ready ? "contains no valid entries" : "not found");
print("For information on the format of Limine config entries, consult CONFIG.md in\n");