shithub: vdiff

Download patch

ref: ad909adf2b1c4d98b3e04698e9802a87ea9685d3
parent: bd118be0e1b3df0cbd9cb3137db32852aec1ffde
author: phil9 <telephil9@gmail.com>
date: Sun Dec 5 05:55:54 EST 2021

add dark mode option (-b)

	Add option to use a dark color scheme based on GitHub dark scheme.

--- a/vdiff.c
+++ b/vdiff.c
@@ -174,14 +174,23 @@
 }
 
 void
-initcols(void)
+initcols(int black)
 {
-	initcol(&scrlcol,     DWhite, 0x999999FF);
-	initcol(&cols[Lfile], DBlack, 0xEFEFEFFF);
-	initcol(&cols[Lsep],  DBlack, 0xEAFFFFFF);
-	initcol(&cols[Ladd],  DBlack, 0xE6FFEDFF);
-	initcol(&cols[Ldel],  DBlack, 0xFFEEF0FF);
-	initcol(&cols[Lnone], DBlack, DWhite);
+	if(black){
+		initcol(&scrlcol,     0x22272EFF, 0xADBAC7FF);
+		initcol(&cols[Lfile], 0xADBAC7FF, 0x2D333BFF);
+		initcol(&cols[Lsep],  0xADBAC7FF, 0x263549FF);
+		initcol(&cols[Ladd],  0xADBAC7FF, 0x273732FF);
+		initcol(&cols[Ldel],  0xADBAC7FF, 0x3F2D32FF);
+		initcol(&cols[Lnone], 0xADBAC7FF, 0x22272EFF);
+	}else{
+		initcol(&scrlcol,     DWhite, 0x999999FF);
+		initcol(&cols[Lfile], DBlack, 0xEFEFEFFF);
+		initcol(&cols[Lsep],  DBlack, 0xEAFFFFFF);
+		initcol(&cols[Ladd],  DBlack, 0xE6FFEDFF);
+		initcol(&cols[Ldel],  DBlack, 0xFFEEF0FF);
+		initcol(&cols[Lnone], DBlack, DWhite);
+	}
 }
 
 int
@@ -308,11 +317,28 @@
 }
 
 void
-main(void)
+usage(void)
 {
+	fprint(2, "%s [-b]\n", argv0);
+	exits("usage");
+}
+
+void
+main(int argc, char *argv[])
+{
 	Event ev;
-	int e, n;
+	int e, n, b;
 
+	b = 0;
+	ARGBEGIN{
+	case 'b':
+		b = 1;
+		break;
+	default:
+		usage();
+		break;
+	}ARGEND;
+
 	parse(0);
 	if(lcount==0){
 		fprint(2, "no diff\n");
@@ -320,7 +346,7 @@
 	}
 	if(initdraw(nil, nil, "vdiff")<0)
 		sysfatal("initdraw: %r");
-	initcols();
+	initcols(b);
 	einit(Emouse|Ekeyboard);
 	eresized(0);
 	for(;;){