shithub: vdir

Download patch

ref: d57a09f05c237d004770493258c206bbe9916681
parent: ff8478aa12d49a2bb177a84fb038a102b79d1830
author: phil9 <telephil9@gmail.com>
date: Thu May 9 12:46:03 EDT 2024

use main colors in confirm dialog

	confirm() takes the colors as parameter so that they are shared
	between the main window and the dialog. This will help /dev/theme
	users.

--- a/confirm.c
+++ b/confirm.c
@@ -8,12 +8,12 @@
 enum { Padding = 12, };
 
 int
-confirm(const char *message, Mousectl *mctl, Keyboardctl *kctl)
+confirm(const char *message, Mousectl *mctl, Keyboardctl *kctl, Image *bg, Image *fg, Image *hi)
 {
 	Alt alts[3];
 	Rectangle r, sc;
 	Point o, p;
-	Image *b, *save, *bg, *fg, *hi;
+	Image *b, *save;
 	int done, rc, h, w;
 	Mouse m;
 	Rune k;
@@ -29,9 +29,6 @@
 	alts[2].v  = nil;
 	while(nbrecv(kctl->c, nil)==1)
 		;
-	bg = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0xffffffff);
-	fg = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x000000ff);
-	hi = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DGreygreen);
 	done = 0;
 	rc = 0;
 	save = nil;
@@ -91,7 +88,5 @@
 			
 	}
 	replclipr(b, 0, sc);
-	freeimage(bg);
-	freeimage(fg);
 	return rc;
 }
--- a/vdir.c
+++ b/vdir.c
@@ -10,7 +10,7 @@
 #include "theme.h"
 
 extern void alert(const char *message, const char *err, Mousectl *mctl, Keyboardctl *kctl);
-extern int confirm(const char *message, Mousectl *mctl, Keyboardctl *kctl);
+extern int confirm(const char *message, Mousectl *mctl, Keyboardctl *kctl, Image *bg, Image *fg, Image *hi);
 void redraw(void);
 
 enum
@@ -71,6 +71,7 @@
 Image *selfg;
 Image *scrollbg;
 Image *scrollfg;
+Image *high;
 int sizew;
 int lineh;
 int nlines;
@@ -267,7 +268,7 @@
 		snprint(buf, sizeof buf, "Delete directory '%s' and its subdirectories ?", d.name);
 	else
 		snprint(buf, sizeof buf, "Delete file '%s' ?", d.name);
-	if(!confirm(buf, mctl, kctl))
+	if(!confirm(buf, mctl, kctl, viewbg, viewfg, high))
 		return;
 	p = smprint("%s/%s", path, d.name);
 	qp = quotestrdup(p);
@@ -336,6 +337,7 @@
 		selfg  = display->black;
 		scrollbg = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x999999FF);
 		scrollfg = display->white;
+		high = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DGreygreen);
 	}else{
 		toolbg = theme->back;
 		toolfg = theme->text;
@@ -345,6 +347,7 @@
 		selfg  = theme->text;
 		scrollbg = theme->border;
 		scrollfg = theme->back;
+		high = theme->high;
 	}
 }