summaryrefslogtreecommitdiff
path: root/kernel/term.c
diff options
context:
space:
mode:
authorGalen Sagarin <gps5307@rit.edu>2025-05-06 15:05:22 -0400
committerGalen Sagarin <gps5307@rit.edu>2025-05-06 15:05:22 -0400
commite4324f180c31ebf06206be6dff5f3863d6ec2675 (patch)
tree73f197fe28c8cc9efdb113b9702790d0085caaff /kernel/term.c
parenttar.c documentation (diff)
parentstart docs (diff)
downloadcomus-e4324f180c31ebf06206be6dff5f3863d6ec2675.tar.gz
comus-e4324f180c31ebf06206be6dff5f3863d6ec2675.tar.bz2
comus-e4324f180c31ebf06206be6dff5f3863d6ec2675.zip
Merge branch 'main' of https://github.com/kenshineto/kern
Should have fixed
Diffstat (limited to 'kernel/term.c')
-rw-r--r--kernel/term.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/kernel/term.c b/kernel/term.c
index 917f645..88fa072 100644
--- a/kernel/term.c
+++ b/kernel/term.c
@@ -7,8 +7,10 @@
// terminal data
static char buffer[TERM_MAX_WIDTH * TERM_MAX_HEIGHT];
static uint16_t buffer_line = UINT16_MAX;
-static uint16_t width = 80; // baseline vga text mode until resized
-static uint16_t height = 25;
+static uint16_t last_width = 80,
+ width = 80; // baseline vga text mode until resized
+static uint16_t last_height = 25, height = 25;
+static uint16_t scrolling = 0;
static uint16_t x = 0;
static uint16_t y = 0;
@@ -140,10 +142,26 @@ void term_redraw(void)
for (uint16_t j = 0; j < height; j++) {
for (uint16_t i = 0; i < width; i++) {
- char c = buffer[BUFIDX(i, j)];
+ char c;
+
+ c = buffer[BUFIDX(i, j)];
+
+ // if screen hasnet changed size
+ // dont redraw what we dont need to redraw
+ if (last_width == height && last_width == width) {
+ char prev;
+ prev = buffer[BUFIDX(i, (j - scrolling))];
+ if (c == prev)
+ continue;
+ }
+
gpu_draw_char(c, i, j);
}
}
+
+ last_width = width;
+ last_height = height;
+ scrolling = 0;
}
void term_scroll(uint16_t lines)
@@ -151,6 +169,8 @@ void term_scroll(uint16_t lines)
if (!lines)
return;
buffer_line += lines;
+ term_clear_line(y);
+ scrolling = lines;
term_redraw();
}