shithub: olednews

Download patch

ref: a52e9a3cf743fe00f2c42b661cbf938690c0472c
parent: 8592776712b7d54043d044bda06380a58fb515cd
author: glenda <glenda@narshaddaa>
date: Mon Apr 24 02:32:39 EDT 2023

two line scrolling wtih separate strings

--- a/textimg.c
+++ b/textimg.c
@@ -45,7 +45,17 @@
 	Point p;
 	char *path;
 	int fd;
-	Biobufhdr *in;
+	Biobufhdr *in;	
+	int ncharspline;//, nlines;
+	int h = 32;
+	int w = 126;
+	int y = 0;
+	int i;
+	int ms = 100;
+	long n;
+	//nlines = 2;	// i guess?
+	char *buf;
+	int lineh;
 
 	s = "/lib/font/bit/vga/vga.0000-007F";
 	f = nil;
@@ -79,18 +89,10 @@
 	if (p.x == 0)
 		sysfatal("no length");
 
-	int ncharspline;//, nlines;
-	int h = 32;
-	int w = 126;
-	int y = 0;
-	int i;
-	int ms = 100;
-	long n;
+	lineh = f->height;
+
 	ncharspline = w / p.x;
-	//nlines = 2;	// i guess?
-	char *buf;
 	buf = calloc(ncharspline, sizeof (char));
-	fprint(2, "ncharspline: %d\n", ncharspline);
 	n = Bread(in, buf, ncharspline-1);
 	if(n <= 0)
 		sysfatal("no bread in the bread box");
@@ -101,7 +103,6 @@
 
 	for(;;){
 		Memimage *img;
-		//fprint(2, "buf str: %s\n", buf);
 
 		fd = open(path, OWRITE);
 		if(fd < 0){
@@ -108,19 +109,27 @@
 			sysfatal("could not open kbdoled file → %r");
 		}
 		
-		//img = allocmemimage(Rect(0, 0, p.x, f->height), RGB24);
-		img = allocmemimage(Rect(0, 0, p.x*ncharspline, f->height), GREY1);
+		img = allocmemimage(Rect(0, 0, p.x*ncharspline, f->height+lineh), GREY1);
 		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);
+
+		// Bottom line
+		memimagestring(img, Pt(0, 16), memblack, ZP, f, "hi");
 		writeuncompressed(fd, img);
 	
 		close(fd);
-		//free(buf);
 		if(y == 0)
-			y = h/2;
+			y = 16;
 		else
 			y = 0;
 
@@ -134,7 +143,7 @@
 		for(i = 0; i < n-1; i++)
 			buf[i] = buf[i+1];
 		buf[n-1] = c;
-		//freememimage(img);
+		freememimage(img);
 
 		sleep(ms);
 	}