summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-05-06 14:20:05 -0400
committerFreya Murphy <freya@freyacat.org>2025-05-06 14:20:05 -0400
commit6cfcabf38e6f4982bfb116ac9cedf2333e29d275 (patch)
tree4dabecd0490b2a04d0820487426574f53c56d26a
parentincrease identity map (diff)
downloadcomus-6cfcabf38e6f4982bfb116ac9cedf2333e29d275.tar.gz
comus-6cfcabf38e6f4982bfb116ac9cedf2333e29d275.tar.bz2
comus-6cfcabf38e6f4982bfb116ac9cedf2333e29d275.zip
smooth scrolling for term
-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();
}