shithub: riscv

Download patch

ref: ac2e6cf02063ca9f9769b669ef53ce5c1a764f4e
parent: d831a028dc82c4b20c4748b764bbfda3d9addc04
author: cinap_lenrek <cinap_lenrek@centraldogma>
date: Wed May 11 09:38:28 EDT 2011

rio: continue on zero length /dev/cons read, put reverse pale colors back in

--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -1232,7 +1232,7 @@
 			Rune r;
 
 			e = buf + sizeof(buf);
-			if((n = read(fd, p, e-p)) <= 0)
+			if((n = read(fd, p, e-p)) < 0)
 				break;
 			e = p + n;
 			while(p < e && fullrune(p, e - p)){
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -23,6 +23,7 @@
 
 static	int		topped;
 static	int		id;
+static	int		reverse;
 
 static	Image	*cols[NCOL];
 static	Image	*grey;
@@ -30,6 +31,7 @@
 static	Cursor	*lastcursor;
 static	Image	*titlecol;
 static	Image	*lighttitlecol;
+static	Image	*dholdcol;
 static	Image	*holdcol;
 static	Image	*lightholdcol;
 static	Image	*paleholdcol;
@@ -41,19 +43,36 @@
 	Rectangle r;
 
 	if(cols[0] == nil){
+		/* there are no pastel paints in the dungeons and dragons world
+		 * - rob pike
+		 */
+		reverse = 0;
+		if(getenv("reverse") != nil)
+			reverse = ~0xFF;
+
 		/* greys are multiples of 0x11111100+0xFF, 14* being palest */
-		grey = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xEEEEEEFF);
-		darkgrey = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x666666FF);
-		cols[BACK] = display->white;
-		cols[HIGH] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xCCCCCCFF);
+		grey = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xEEEEEEFF^reverse);
+		darkgrey = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x666666FF^reverse);
+		cols[BACK] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xFFFFFFFF^reverse);
+		cols[HIGH] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xCCCCCCFF^reverse);
 		cols[BORD] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x999999FF);
-		cols[TEXT] = display->black;
-		cols[HTEXT] = display->black;
-		titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DGreygreen);
-		lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPalegreygreen);
-		holdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DMedblue);
+		cols[TEXT] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x000000FF^reverse);
+		cols[HTEXT] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x000000FF^reverse);
+		if(reverse == 0) {
+			titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DGreygreen);
+			lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPalegreygreen);
+		} else {
+			titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPurpleblue);
+			lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x666666FF^reverse);
+		}
+		dholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DMedblue);
 		lightholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DGreyblue);
 		paleholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPalegreyblue);
+
+		if(reverse == 0)
+			holdcol = dholdcol;
+		else
+			holdcol = paleholdcol;
 	}
 	w = emalloc(sizeof(Window));
 	w->screenr = i->r;
@@ -740,7 +759,7 @@
 			w->cols[TEXT] = w->cols[HTEXT] = lightholdcol;
 	else
 		if(w == input)
-			w->cols[TEXT] = w->cols[HTEXT] = display->black;
+			w->cols[TEXT] = w->cols[HTEXT] = cols[TEXT];
 		else
 			w->cols[TEXT] = w->cols[HTEXT] = darkgrey;
 }
@@ -1341,7 +1360,6 @@
 		if(hidden[i] == w){
 			--nhidden;
 			memmove(hidden+i, hidden+i+1, (nhidden-i)*sizeof(hidden[0]));
-			hidden[nhidden] = nil;
 			break;
 		}
 	for(i=0; i<nwindow; i++)