mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-11 09:14:38 +03:00
term: Do not scroll screen when it shouldn't be
This commit is contained in:
parent
c3f5f0d6fd
commit
25d9fd6614
@ -13,6 +13,8 @@ void text_set_cursor_pos(int x, int y);
|
|||||||
void text_get_cursor_pos(int *x, int *y);
|
void text_get_cursor_pos(int *x, int *y);
|
||||||
void text_set_text_fg(int fg);
|
void text_set_text_fg(int fg);
|
||||||
void text_set_text_bg(int bg);
|
void text_set_text_bg(int bg);
|
||||||
|
bool text_scroll_disable(void);
|
||||||
|
void text_scroll_enable(void);
|
||||||
|
|
||||||
void text_double_buffer(bool state);
|
void text_double_buffer(bool state);
|
||||||
void text_double_buffer_flush(void);
|
void text_double_buffer_flush(void);
|
||||||
|
@ -37,7 +37,22 @@ static void draw_cursor(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool scroll_enabled = true;
|
||||||
|
|
||||||
|
bool text_scroll_disable(void) {
|
||||||
|
bool ret = scroll_enabled;
|
||||||
|
scroll_enabled = false;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void text_scroll_enable(void) {
|
||||||
|
scroll_enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
static void scroll(void) {
|
static void scroll(void) {
|
||||||
|
if (scroll_enabled == false)
|
||||||
|
return;
|
||||||
|
|
||||||
// move the text up by one row
|
// move the text up by one row
|
||||||
for (size_t i = 0; i <= VIDEO_BOTTOM - VD_COLS; i++) {
|
for (size_t i = 0; i <= VIDEO_BOTTOM - VD_COLS; i++) {
|
||||||
current_buffer[i] = current_buffer[i + VD_COLS];
|
current_buffer[i] = current_buffer[i + VD_COLS];
|
||||||
|
@ -74,7 +74,7 @@ void gterm_plot_px(int x, int y, uint32_t hex) {
|
|||||||
gterm_framebuffer[fb_i] = hex;
|
gterm_framebuffer[fb_i] = hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t blend_gradient_from_box(int x, int y, uint32_t bg_px, uint32_t hex) {
|
static uint32_t blend_gradient_from_box(int x, int y, uint32_t bg_px, uint32_t hex) {
|
||||||
int distance, x_distance, y_distance;
|
int distance, x_distance, y_distance;
|
||||||
|
|
||||||
if (x < frame_width)
|
if (x < frame_width)
|
||||||
@ -153,13 +153,13 @@ static uint32_t blend_gradient_from_box(int x, int y, uint32_t bg_px, uint32_t h
|
|||||||
|
|
||||||
void gterm_generate_canvas(void) {
|
void gterm_generate_canvas(void) {
|
||||||
if (background) {
|
if (background) {
|
||||||
// Instead of executing blend_gradient_from_box for every pixel in the fb, just run it for the margin
|
// Instead of executing blend_gradient_from_box for every pixel in the fb, just run it for the margin
|
||||||
uint8_t *img = background->img;
|
uint8_t *img = background->img;
|
||||||
const int img_width = background->img_width, x16_x_delta = (img_width * 16) / gterm_width,
|
const int img_width = background->img_width, x16_x_delta = (img_width * 16) / gterm_width,
|
||||||
img_height = background->img_height, img_pitch = background->pitch, colsize = background->bpp / 8;
|
img_height = background->img_height, img_pitch = background->pitch, colsize = background->bpp / 8;
|
||||||
const int frame_height_end = frame_height + VGA_FONT_HEIGHT * rows, frame_width_end = frame_width + VGA_FONT_WIDTH * cols;
|
const int frame_height_end = frame_height + VGA_FONT_HEIGHT * rows, frame_width_end = frame_width + VGA_FONT_WIDTH * cols;
|
||||||
const int fheight = frame_height - margin_gradient, fheight_end = frame_height_end + margin_gradient,
|
const int fheight = frame_height - margin_gradient, fheight_end = frame_height_end + margin_gradient,
|
||||||
fwidth = frame_width - margin_gradient, fwidth_end = frame_width_end + margin_gradient;
|
fwidth = frame_width - margin_gradient, fwidth_end = frame_width_end + margin_gradient;
|
||||||
|
|
||||||
// Draw the part of the image outside the margin
|
// Draw the part of the image outside the margin
|
||||||
genloop(0, gterm_width, 0, fheight, i);
|
genloop(0, gterm_width, 0, fheight, i);
|
||||||
@ -284,7 +284,22 @@ static inline bool compare_char(struct gterm_char *a, struct gterm_char *b) {
|
|||||||
return !(a->c != b->c || a->bg != b->bg || a->fg != b->fg);
|
return !(a->c != b->c || a->bg != b->bg || a->fg != b->fg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool scroll_enabled = true;
|
||||||
|
|
||||||
|
bool gterm_scroll_disable(void) {
|
||||||
|
bool ret = scroll_enabled;
|
||||||
|
scroll_enabled = false;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gterm_scroll_enable(void) {
|
||||||
|
scroll_enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
static void scroll(void) {
|
static void scroll(void) {
|
||||||
|
if (scroll_enabled == false)
|
||||||
|
return;
|
||||||
|
|
||||||
clear_cursor();
|
clear_cursor();
|
||||||
|
|
||||||
for (int i = cols; i < rows * cols; i++) {
|
for (int i = cols; i < rows * cols; i++) {
|
||||||
@ -316,7 +331,7 @@ void gterm_clear(bool move) {
|
|||||||
empty.fg = 9;
|
empty.fg = 9;
|
||||||
empty.bg = 8;
|
empty.bg = 8;
|
||||||
for (int i = 0; i < rows * cols; i++) grid[i] = empty;
|
for (int i = 0; i < rows * cols; i++) grid[i] = empty;
|
||||||
|
|
||||||
if (move) {
|
if (move) {
|
||||||
cursor_x = 0;
|
cursor_x = 0;
|
||||||
cursor_y = 0;
|
cursor_y = 0;
|
||||||
|
@ -18,6 +18,8 @@ void gterm_set_cursor_pos(int x, int y);
|
|||||||
void gterm_get_cursor_pos(int *x, int *y);
|
void gterm_get_cursor_pos(int *x, int *y);
|
||||||
void gterm_set_text_fg(int fg);
|
void gterm_set_text_fg(int fg);
|
||||||
void gterm_set_text_bg(int bg);
|
void gterm_set_text_bg(int bg);
|
||||||
|
bool gterm_scroll_disable(void);
|
||||||
|
void gterm_scroll_enable(void);
|
||||||
|
|
||||||
void gterm_double_buffer_flush(void);
|
void gterm_double_buffer_flush(void);
|
||||||
void gterm_double_buffer(bool state);
|
void gterm_double_buffer(bool state);
|
||||||
|
@ -27,6 +27,8 @@ void term_vbe(int width, int height) {
|
|||||||
get_cursor_pos = gterm_get_cursor_pos;
|
get_cursor_pos = gterm_get_cursor_pos;
|
||||||
set_text_fg = gterm_set_text_fg;
|
set_text_fg = gterm_set_text_fg;
|
||||||
set_text_bg = gterm_set_text_bg;
|
set_text_bg = gterm_set_text_bg;
|
||||||
|
scroll_disable = gterm_scroll_disable;
|
||||||
|
scroll_enable = gterm_scroll_enable;
|
||||||
|
|
||||||
term_double_buffer = gterm_double_buffer;
|
term_double_buffer = gterm_double_buffer;
|
||||||
term_double_buffer_flush = gterm_double_buffer_flush;
|
term_double_buffer_flush = gterm_double_buffer_flush;
|
||||||
|
@ -13,6 +13,8 @@ extern void (*set_cursor_pos)(int x, int y);
|
|||||||
extern void (*get_cursor_pos)(int *x, int *y);
|
extern void (*get_cursor_pos)(int *x, int *y);
|
||||||
extern void (*set_text_fg)(int fg);
|
extern void (*set_text_fg)(int fg);
|
||||||
extern void (*set_text_bg)(int bg);
|
extern void (*set_text_bg)(int bg);
|
||||||
|
extern bool (*scroll_disable)(void);
|
||||||
|
extern void (*scroll_enable)(void);
|
||||||
|
|
||||||
extern void (*term_double_buffer)(bool status);
|
extern void (*term_double_buffer)(bool status);
|
||||||
extern void (*term_double_buffer_flush)(void);
|
extern void (*term_double_buffer_flush)(void);
|
||||||
|
@ -25,6 +25,8 @@ void (*set_cursor_pos)(int x, int y);
|
|||||||
void (*get_cursor_pos)(int *x, int *y);
|
void (*get_cursor_pos)(int *x, int *y);
|
||||||
void (*set_text_fg)(int fg);
|
void (*set_text_fg)(int fg);
|
||||||
void (*set_text_bg)(int bg);
|
void (*set_text_bg)(int bg);
|
||||||
|
bool (*scroll_disable)(void);
|
||||||
|
void (*scroll_enable)(void);
|
||||||
|
|
||||||
void (*term_double_buffer)(bool status);
|
void (*term_double_buffer)(bool status);
|
||||||
void (*term_double_buffer_flush)(void);
|
void (*term_double_buffer_flush)(void);
|
||||||
@ -45,6 +47,8 @@ void term_textmode(void) {
|
|||||||
get_cursor_pos = text_get_cursor_pos;
|
get_cursor_pos = text_get_cursor_pos;
|
||||||
set_text_fg = text_set_text_fg;
|
set_text_fg = text_set_text_fg;
|
||||||
set_text_bg = text_set_text_bg;
|
set_text_bg = text_set_text_bg;
|
||||||
|
scroll_disable = text_scroll_disable;
|
||||||
|
scroll_enable = text_scroll_enable;
|
||||||
|
|
||||||
term_double_buffer = text_double_buffer;
|
term_double_buffer = text_double_buffer;
|
||||||
term_double_buffer_flush = text_double_buffer_flush;
|
term_double_buffer_flush = text_double_buffer_flush;
|
||||||
@ -215,8 +219,11 @@ static void control_sequence_parse(uint8_t c) {
|
|||||||
int x, y;
|
int x, y;
|
||||||
get_cursor_pos(&x, &y);
|
get_cursor_pos(&x, &y);
|
||||||
set_cursor_pos(0, y);
|
set_cursor_pos(0, y);
|
||||||
|
bool r = scroll_disable();
|
||||||
for (int i = 0; i < term_cols; i++)
|
for (int i = 0; i < term_cols; i++)
|
||||||
raw_putchar(' ');
|
raw_putchar(' ');
|
||||||
|
if (r)
|
||||||
|
scroll_enable();
|
||||||
set_cursor_pos(x, y);
|
set_cursor_pos(x, y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -606,7 +606,7 @@ refresh:
|
|||||||
term_double_buffer_flush();
|
term_double_buffer_flush();
|
||||||
if ((c = pit_sleep_and_quit_on_keypress(1))) {
|
if ((c = pit_sleep_and_quit_on_keypress(1))) {
|
||||||
skip_timeout = true;
|
skip_timeout = true;
|
||||||
print("\e[2K\r\e[2A");
|
print("\e[2K\r");
|
||||||
term_double_buffer_flush();
|
term_double_buffer_flush();
|
||||||
goto timeout_aborted;
|
goto timeout_aborted;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user