term: Tidy up gterm wrapper code
This commit is contained in:
parent
4d855fc17e
commit
8849d08eeb
@ -193,6 +193,14 @@ static bool last_serial = false;
|
|||||||
static char *last_config = NULL;
|
static char *last_config = NULL;
|
||||||
|
|
||||||
bool gterm_init(char *config, size_t width, size_t height) {
|
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 (current_video_mode >= 0
|
||||||
#if defined (BIOS)
|
#if defined (BIOS)
|
||||||
&& current_video_mode != 0x03
|
&& current_video_mode != 0x03
|
||||||
@ -422,5 +430,16 @@ no_load_font:;
|
|||||||
font_scale_x, font_scale_y,
|
font_scale_x, font_scale_y,
|
||||||
margin);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -259,33 +259,6 @@ void term_fallback(void) {
|
|||||||
extern void reset_term(void);
|
extern void reset_term(void);
|
||||||
extern void set_cursor_pos_helper(size_t x, size_t y);
|
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)
|
#if defined (BIOS)
|
||||||
void term_textmode(void) {
|
void term_textmode(void) {
|
||||||
term_notready();
|
term_notready();
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
_NOT_READY,
|
_NOT_READY,
|
||||||
VBE,
|
GTERM,
|
||||||
TEXTMODE,
|
TEXTMODE,
|
||||||
FALLBACK
|
FALLBACK
|
||||||
};
|
};
|
||||||
@ -37,7 +37,6 @@ inline void set_cursor_pos_helper(size_t x, size_t y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void term_fallback(void);
|
void term_fallback(void);
|
||||||
void term_vbe(char *config, size_t width, size_t height);
|
|
||||||
void term_textmode(void);
|
void term_textmode(void);
|
||||||
|
|
||||||
void _term_write(uint64_t buf, uint64_t count);
|
void _term_write(uint64_t buf, uint64_t count);
|
||||||
|
@ -563,7 +563,7 @@ static void menu_init_term(void) {
|
|||||||
if (menu_resolution != NULL)
|
if (menu_resolution != NULL)
|
||||||
parse_resolution(&req_width, &req_height, &req_bpp, menu_resolution);
|
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 {
|
} else {
|
||||||
#if defined (BIOS)
|
#if defined (BIOS)
|
||||||
term_textmode();
|
term_textmode();
|
||||||
@ -845,7 +845,7 @@ timeout_aborted:
|
|||||||
goto refresh;
|
goto refresh;
|
||||||
}
|
}
|
||||||
if (term_backend == FALLBACK) {
|
if (term_backend == FALLBACK) {
|
||||||
term_vbe(NULL, 0, 0);
|
gterm_init(NULL, 0, 0);
|
||||||
#if defined (BIOS)
|
#if defined (BIOS)
|
||||||
if (term_backend == FALLBACK) {
|
if (term_backend == FALLBACK) {
|
||||||
term_textmode();
|
term_textmode();
|
||||||
|
@ -684,9 +684,9 @@ FEAT_START
|
|||||||
|
|
||||||
char *term_conf_override_s = config_get_value(config, 0, "TERM_CONFIG_OVERRIDE");
|
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) {
|
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 {
|
} else {
|
||||||
term_vbe(NULL, req_width, req_height);
|
gterm_init(NULL, req_width, req_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_video_mode < 0) {
|
if (current_video_mode < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user