mirror of
https://github.com/limine-bootloader/limine
synced 2025-03-02 07:51:37 +03:00
term: Bound check when setting cursor position
This commit is contained in:
parent
6e1afcd3cb
commit
0e2b9c5776
@ -176,6 +176,16 @@ void text_get_cursor_pos(int *x, int *y) {
|
||||
|
||||
void text_set_cursor_pos(int x, int y) {
|
||||
clear_cursor();
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
} else if (x >= VD_COLS / 2) {
|
||||
x = VD_COLS / 2 - 1;
|
||||
}
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
} else if (y >= VD_ROWS) {
|
||||
y = VD_ROWS - 1;
|
||||
}
|
||||
cursor_offset = y * VD_COLS + x * 2;
|
||||
draw_cursor();
|
||||
}
|
||||
|
@ -356,6 +356,16 @@ bool gterm_disable_cursor(void) {
|
||||
|
||||
void gterm_set_cursor_pos(int x, int y) {
|
||||
clear_cursor();
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
} else if (x >= cols) {
|
||||
x = cols - 1;
|
||||
}
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
} else if (y >= rows) {
|
||||
y = rows - 1;
|
||||
}
|
||||
cursor_x = x;
|
||||
cursor_y = y;
|
||||
draw_cursor();
|
||||
|
Loading…
x
Reference in New Issue
Block a user