shithub: olednews

Download patch

ref: f944d6f355cce5ebc947a440ce3f811f2db76282
parent: a52e9a3cf743fe00f2c42b661cbf938690c0472c
author: glenda <glenda@narshaddaa>
date: Mon Apr 24 02:39:44 EDT 2023

working two line scrolling!

--- a/textimg.c
+++ b/textimg.c
@@ -54,7 +54,7 @@
 	int ms = 100;
 	long n;
 	//nlines = 2;	// i guess?
-	char *buf;
+	char *buf, *buftop;
 	int lineh;
 
 	s = "/lib/font/bit/vga/vga.0000-007F";
@@ -101,6 +101,10 @@
 		if(buf[i] == '\n' || buf[i] == '\r')
 			buf[i] = ' ';
 
+	buftop = calloc(ncharspline, sizeof (char));
+	memset(buftop, ' ', ncharspline*sizeof (char));
+	buftop[n] = '\0';
+
 	for(;;){
 		Memimage *img;
 
@@ -113,18 +117,12 @@
 		if (!img)
 			sysfatal("cannot allocate memimage: %r");
 		memfillcolor(img, DWhite);
-
-		/*
-		img = allocmemimage(Rect(0, -32, 1, -16), GREY1);
-		if (!img)
-			sysfatal("cannot allocate memimage: %r");
-		memfillcolor(img, DWhite);*/
 		
 		// Top line
-		memimagestring(img, Pt(0, 0), memblack, ZP, f, buf);
+		memimagestring(img, Pt(0, 0), memblack, ZP, f, buftop);
 
 		// Bottom line
-		memimagestring(img, Pt(0, 16), memblack, ZP, f, "hi");
+		memimagestring(img, Pt(0, 16), memblack, ZP, f, buf);
 		writeuncompressed(fd, img);
 	
 		close(fd);
@@ -140,8 +138,16 @@
 		if(c == '\n' || c == '\r')
 			c = ' ';
 
-		for(i = 0; i < n-1; i++)
+		// Shift the top in
+		for(i = 0; i < n-1; i++){
+			buftop[i] = buftop[i+1];
+		}
+		buftop[n-1] = buf[0];
+
+		// Shift the bottom in
+		for(i = 0; i < n-1; i++){
 			buf[i] = buf[i+1];
+		}
 		buf[n-1] = c;
 		freememimage(img);