term: Compatibility with new terminal code

This commit is contained in:
mintsuki 2022-12-30 08:24:51 +01:00
parent 78075319d4
commit 258388c890
5 changed files with 14 additions and 37 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;
}
}
@ -295,7 +281,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;
@ -305,7 +290,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);
@ -336,8 +321,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;
term->disable_cursor(term);
term->cursor_enabled = false;
term->get_cursor_pos(term, &orig_x, &orig_y);
set_cursor_pos_helper(x, y);
print("%s", s);
set_cursor_pos_helper(orig_x, orig_y);
term->enable_cursor(term);
term->cursor_enabled = true;
}
static void cursor_back(void) {

View File

@ -41,10 +41,6 @@ static void notready_size_t(struct term_context *ctx, size_t n) {
(void)ctx;
(void)n;
}
static bool notready_disable(struct term_context *ctx) {
(void)ctx;
return false;
}
static void notready_move_character(struct term_context *ctx, size_t a, size_t b, size_t c, size_t d) {
(void)ctx;
(void)a; (void)b; (void)c; (void)d;
@ -68,8 +64,6 @@ static void term_notready(void) {
term->raw_putchar = notready_raw_putchar;
term->clear = notready_clear;
term->enable_cursor = notready_void;
term->disable_cursor = notready_disable;
term->set_cursor_pos = notready_set_cursor_pos;
term->get_cursor_pos = notready_get_cursor_pos;
term->set_text_fg = notready_size_t;

View File

@ -25,7 +25,7 @@ extern struct term_context *term;
inline void reset_term(void) {
term->autoflush = true;
term->enable_cursor(term);
term->cursor_enabled = true;;
print("\e[2J\e[H");
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) {
term->autoflush = false;
term->enable_cursor(term);
term->cursor_enabled = true;
print("\e[2J\e[H");
@ -214,7 +214,7 @@ refresh:
invalid_syntax = false;
print("\e[2J\e[H");
term->disable_cursor(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);
term->enable_cursor(term);
term->cursor_enabled = true;
term->double_buffer_flush(term);
@ -730,7 +730,7 @@ refresh:
term->autoflush = false;
term->disable_cursor(term);
term->cursor_enabled = false;
print("\e[2J\e[H");
{
@ -747,7 +747,7 @@ refresh:
quiet = false;
menu_init_term();
term->autoflush = false;
term->disable_cursor(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");