ref: 4ae0c34b7ed27db5062153219e7e4b49b9013d75
parent: ebc87ef165d107747d2f7267e8ed12e55f782bff
author: henesy <[email protected]>
date: Fri Mar 11 03:34:07 EST 2022
screen tweaks
--- a/screen.c
+++ b/screen.c
@@ -11,7 +11,7 @@
Image *brush; // For drawing the text
Rune *s = L"☺☹σπß"; // for testing
int bwidth = 4; // border width of window
-Rune **sbuf; // screen buffer
+Rune **sbuf, **ebuf; // screen buffer, empty buffer
usize sheight = 25, swidth = 80; // screen height, width
Lock slock; // screen buffer lock
@@ -21,7 +21,7 @@
// Render the active buffer on a timer
void
-renderbuf(void)
+renderbuf(Rune **buf)
{
int i;
lock(&slock);
@@ -28,10 +28,10 @@
Point out, p;
Point at = screen->r.min;
for(i = 0; i < sheight; i++){
- p = runestringsize(ourfont, sbuf[i]);
+ p = runestringsize(ourfont, buf[i]);
out = runestring(
screen, at, display->black, ZP,
- ourfont, sbuf[i]
+ ourfont, buf[i]
);
at.y += p.y;
}
@@ -62,7 +62,6 @@
void
initbuf(void)
{
- Point out;
int y, x;
ourfont = openfont(display, "/lib/font/bit/vga/unicode.font");
@@ -70,17 +69,16 @@
lock(&slock);
sbuf = calloc(sheight, sizeof (Rune*));
+ ebuf = calloc(sheight, sizeof (Rune*));
for(y = 0; y < sheight; y++){
sbuf[y] = calloc(swidth+1, sizeof (Rune));
- for(x = 0; x < swidth; x++)
+ ebuf[y] = calloc(swidth+1, sizeof (Rune));
+ for(x = 0; x < swidth; x++){
sbuf[y][x] = L'☺';
+ ebuf[y][x] = L' ';
+ }
}
unlock(&slock);
-
- out = runestring(
- screen, screen->r.min, display->black, ZP,
- ourfont, s
- );
}
@@ -107,6 +105,7 @@
initbuf();
+ renderbuf(ebuf);
// Set the screen size (after initbuf)
//echo resize -dx 100 -dy 100 > /dev/wctl
@@ -138,8 +137,11 @@
(ev.mouse.buttons & 4) &&
(emenuhit(3, &ev.mouse, &menu) == 0)) threadexitsall(nil);
else
- if(e == timer)
- renderbuf();
+ if(e == timer){
+ // Might not want this
+ renderbuf(ebuf);
+ renderbuf(sbuf);
+ }
}
}