Skip to content

Commit

Permalink
TTY: Fix cursor leaving traces screen
Browse files Browse the repository at this point in the history
Puhdistaja!
  • Loading branch information
NDRAEY committed Aug 2, 2024
1 parent 33a7972 commit 34c7d4c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions kernel/src/io/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,22 @@ uint32_t tty_color_table[128] = {
};

bool tty_cursor_status = false; // Not shown
bool tty_cursor_enable = true;

void tty_draw_cursor() {
if(tty_cursor_status && tty_cursor_enable) {
draw_filled_rectangle(tty_current_column * 8, tty_current_row * 16 + 12, 8, 4, 0x404040);
} else {
draw_filled_rectangle(tty_current_column * 8, tty_current_row * 16 + 12, 8, 4, 0);
}
}

void tty_cursor_task() {
while(1) {
tty_cursor_status = !tty_cursor_status;
if(tty_cursor_status) {
draw_filled_rectangle(tty_current_column * 8, tty_current_row * 16 + 12, 8, 4, 0x404040);
} else {
draw_filled_rectangle(tty_current_column * 8, tty_current_row * 16 + 12, 8, 4, 0);
if(tty_cursor_enable) {
tty_cursor_status = !tty_cursor_status;
}
tty_draw_cursor();

punch();
sleep_ms(500);
Expand Down Expand Up @@ -149,8 +156,11 @@ void _tty_putc(int c) {
}

void tty_putc(int c) {
_tty_putc(c);
tty_cursor_enable = false;
tty_draw_cursor();
_tty_putc(c);
tty_render();
tty_cursor_enable = true;
}

void tty_render() {
Expand Down Expand Up @@ -223,8 +233,13 @@ void _tty_puts(const char *str) {
}

void tty_puts(const char *str) {
tty_cursor_enable = false;
tty_draw_cursor();

_tty_puts(str);
tty_render();

tty_cursor_enable = true;
}

void _tty_vprintf(const char* format, va_list args) {
Expand Down
Binary file added ramdisk/zig
Binary file not shown.

0 comments on commit 34c7d4c

Please sign in to comment.