200 lines · 6.0 KB · Text
RawDownload
diff -r e87d9104e8fc data.c--- a/data.c	Mon Feb 19 08:15:49 2018 +0000+++ b/data.c	Sun Dec 09 16:21:22 2018 -0600@@ -7,6 +7,7 @@ #include <keyboard.h> #include <frame.h> #include <fcall.h>+#include <theme.h> #include "dat.h" #include "fns.h" @@ -189,22 +190,23 @@ { 	int fd; 	Image *bimg = nil;+	themeinit("rio"); -	background = allocimage(display, Rect(0,0,1,1), RGB24, 1, bgtrans);+	background = allocimage(display, Rect(0,0,1,1), RGB24, 1, themeget("background", bgtrans));  	/* greys are multiples of 0x11111100+0xFF, 14* being palest */-	cols[BACK] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, winbgcolor^reverse);-	cols[BORD] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, scrollbarcolor^reverse);-	cols[TEXT] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, textcolor^reverse);-	cols[HTEXT] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x000000FF);+	cols[BACK] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("termback", winbgcolor^reverse));+	cols[BORD] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("termbord", scrollbarcolor^reverse));+	cols[TEXT] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("termtext", textcolor^reverse));+	cols[HTEXT] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("termhtext", 0x000000FF)); 	if(!reverse) {-		cols[HIGH] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xCCCCCCFF);-		titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, borderactivecolor);-		lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, borderbgcolor);+		cols[HIGH] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("termhigh", 0xCCCCCCFF));+		titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("title", borderactivecolor));+		lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("lighttitle", borderbgcolor)); 	} else {-		cols[HIGH] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPurpleblue);-		titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, borderactivecolor);-		lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, borderbgcolor);+		cols[HIGH] = allocimage(display, Rect(0,0,1,1), CMAP8, 1,themeget("termhigh", DPurpleblue));+		titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("title", borderactivecolor));+		lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("lighttitle", borderbgcolor)); 	} 	if(bf != nil){ 		fd = open(bf, OREAD);@@ -218,14 +220,16 @@ 		background = allocimage(display, Rect(0, 0, Dx(bimg->r), Dy(bimg->r)), RGB24, 1, 0xFFFFFFFF); 		draw(background, background->r, bimg, 0, bimg->r.min); 	}-	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);-	paletextcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x666666FF^reverse);-	sizecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DRed);+	dholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("hold", DMedblue));+	lightholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("lighthold", DGreyblue));+	paleholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("palehold", DPalegreyblue));+	paletextcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("paletext", 0x666666FF^reverse));+	sizecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, themeget("size", DRed));  	if(reverse == 0) 		holdcol = dholdcol; 	else 		holdcol = paleholdcol;++	themeend(); }diff -r e87d9104e8fc mkfile--- a/mkfile	Mon Feb 19 08:15:49 2018 +0000+++ b/mkfile	Sun Dec 09 16:21:22 2018 -0600@@ -24,7 +24,8 @@ </sys/src/cmd/mkone  $O.out:	/$objtype/lib/libdraw.a /$objtype/lib/libframe.a \-	/$objtype/lib/libthread.a /$objtype/lib/libplumb.a /$objtype/lib/libc.a+	/$objtype/lib/libthread.a /$objtype/lib/libplumb.a \+	/$objtype/lib/libtheme.a /$objtype/lib/libc.a syms:V: 	$CC -a $CFLAGS rio.c	> syms 	$CC -aa $CFLAGS *.c 	>>symsdiff -r e87d9104e8fc rio.c--- a/rio.c	Mon Feb 19 08:15:49 2018 +0000+++ b/rio.c	Sun Dec 09 16:21:22 2018 -0600@@ -29,7 +29,7 @@ Image*	sweep(void); Image*	bandsize(Window*); Image*	drag(Window*);-void		resized(void);+void		resized(int new); Channel	*exitchan;	/* chan(int) */ Channel	*winclosechan; /* chan(Window*); */ Channel	*kbdchan;	/* chan(char*); */@@ -602,7 +602,7 @@ 	for(;;) 	    switch(alt(alts)){ 		case MReshape:-			resized();+			resized(1); 			break; 		case MMouse: 			if(wkeyboard!=nil && (mouse->buttons & (1<<5))){@@ -708,16 +708,17 @@ }  void-resized(void)+resized(int new) { 	Image *im; 	int i, j; 	Rectangle r; 	Point o, n; 	Window *w;--	if(getwindow(display, Refnone) < 0)-		error("failed to re-attach window");+	+	if(new)+		if(getwindow(display, Refnone) < 0)+			error("failed to re-attach window"); 	freescrtemps(); 	view = screen; 	freescreen(wscreen);diff -r e87d9104e8fc wctl.c--- a/wctl.c	Mon Feb 19 08:15:49 2018 +0000+++ b/wctl.c	Sun Dec 09 16:21:22 2018 -0600@@ -30,6 +30,7 @@ 	Hide, 	Unhide, 	Delete,+	Background, };  static char *cmds[] = {@@ -45,6 +46,7 @@ 	[Hide]	= "hide", 	[Unhide]	= "unhide", 	[Delete]	= "delete",+	[Background]	= "background", 	nil }; @@ -301,7 +303,7 @@  	while(isspace(*s)) 		s++;-	if(cmd!=New && *s!='\0'){+	if((cmd!=New && cmd!=Background) && *s!='\0'){ 		strcpy(err, "extraneous text in wctl message"); 		return -1; 	}@@ -440,6 +442,20 @@ 	return -1; } +static void+wctlbackground(char *file)+{+	char *n;+	+	if((n = strchr(file, '\n')) != nil)+		*n = '\0';++	freeimage(background);+	iconinit(file);+	extern void resized(int);+	resized(0);+}+ int writewctl(Xfid *x, char *err) {@@ -473,6 +489,13 @@ 		if(pid > 0) 			wsetpid(w, pid, 0); 		return 1;+	case Background:+		if(*arg == '\0'){+			strcpy(err, "invalid argument");+			return -1;+		}+		wctlbackground(arg);+		return 1; 	}  	incref(w);@@ -502,6 +525,12 @@ 		switch(cmd){ 		case New: 			wctlnew(rect, arg, pid, hideit, scrollit, dir, err);+			break;+		case Background:+			if(*arg == '\0')+				break;+			wctlbackground(arg);+			break; 		} 		free(buf); 	}