term: Tidy up gterm wrapper code

This commit is contained in:
mintsuki 2022-10-04 01:37:19 +02:00
parent ad8151a6a6
commit d442805bc0
5 changed files with 24 additions and 33 deletions

View File

@ -193,6 +193,14 @@ static bool last_serial = false;
static char *last_config = NULL;
bool gterm_init(char *config, size_t width, size_t height) {
if (term_backend != GTERM) {
term->deinit(term, pmm_free);
}
if (quiet || allocations_disallowed) {
return false;
}
if (current_video_mode >= 0
#if defined (BIOS)
&& current_video_mode != 0x03
@ -422,5 +430,16 @@ no_load_font:;
font_scale_x, font_scale_y,
margin);
if (serial) {
term->cols = term->cols > 80 ? 80 : term->cols;
term->rows = term->rows > 24 ? 24 : term->rows;
}
term_context_reinit(term);
term_backend = GTERM;
term->in_bootloader = true;
return true;
}

View File

@ -259,33 +259,6 @@ void term_fallback(void) {
extern void reset_term(void);
extern void set_cursor_pos_helper(size_t x, size_t y);
void term_vbe(char *config, size_t width, size_t height) {
if (term_backend != VBE) {
term->deinit(term, pmm_free);
}
if (quiet || allocations_disallowed) {
return;
}
if (!gterm_init(config, width, height)) {
#if defined (BIOS)
// Failed to set VBE properly, default to text mode
term_textmode();
#endif
return;
}
if (serial) {
term->cols = term->cols > 80 ? 80 : term->cols;
term->rows = term->rows > 24 ? 24 : term->rows;
}
term_backend = VBE;
term->in_bootloader = true;
}
#if defined (BIOS)
void term_textmode(void) {
term_notready();

View File

@ -10,7 +10,7 @@
enum {
_NOT_READY,
VBE,
GTERM,
TEXTMODE,
FALLBACK
};
@ -37,7 +37,6 @@ inline void set_cursor_pos_helper(size_t x, size_t y) {
}
void term_fallback(void);
void term_vbe(char *config, size_t width, size_t height);
void term_textmode(void);
void _term_write(uint64_t buf, uint64_t count);

View File

@ -563,7 +563,7 @@ static void menu_init_term(void) {
if (menu_resolution != NULL)
parse_resolution(&req_width, &req_height, &req_bpp, menu_resolution);
term_vbe(NULL, req_width, req_height);
gterm_init(NULL, req_width, req_height);
} else {
#if defined (BIOS)
term_textmode();
@ -842,7 +842,7 @@ timeout_aborted:
goto refresh;
}
if (term_backend == FALLBACK) {
term_vbe(NULL, 0, 0);
gterm_init(NULL, 0, 0);
#if defined (BIOS)
if (term_backend == FALLBACK) {
term_textmode();

View File

@ -684,9 +684,9 @@ FEAT_START
char *term_conf_override_s = config_get_value(config, 0, "TERM_CONFIG_OVERRIDE");
if (term_conf_override_s != NULL && strcmp(term_conf_override_s, "yes") == 0) {
term_vbe(config, req_width, req_height);
gterm_init(config, req_width, req_height);
} else {
term_vbe(NULL, req_width, req_height);
gterm_init(NULL, req_width, req_height);
}
if (current_video_mode < 0) {