mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-04 22:22:24 +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];
|
||||||
|
@ -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++) {
|
||||||
|
@ -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