shithub: vdir

Download patch

ref: a928b0dd3afdc98a8ad1212ed37653ebdde2f33e
parent: c7312d75a4ecb460c498ebd0540c3c92d4f20fb0
author: telephil9 <telephil9@gmail.com>
date: Sat Apr 4 13:36:18 EDT 2020

Center entries in the window

Entries are displayed where the mouse event happened (ie mouse.xy).
For us events happen in the toolbar at the top of the window
which was not convenient. This commit centers the entries in the window.

--- a/vdir.c
+++ b/vdir.c
@@ -378,6 +378,17 @@
 	}
 }
 
+Point
+cept(const char *text)
+{
+	Point p;
+
+	p = screen->r.min;
+	p.x += (Dx(screen->r)-stringwidth(font, text)-4)/2;
+	p.y += (Dy(screen->r)-font->height-4)/2;
+	return p;
+}
+
 void
 evtmouse(Mouse m)
 {
@@ -393,16 +404,19 @@
 			up();
 			redraw();
 		}else if(ptinrect(m.xy, cdr)){
+			m.xy = cept("Go to directory");
 			if(eenter("Go to directory", buf, sizeof buf, &m)>0){
 				cd(buf);
 				redraw();
 			}
 		}else if(ptinrect(m.xy, newdirr)){
+			m.xy = cept("Create directory");
 			if(eenter("Create directory", buf, sizeof buf, &m)>0){
 				mkdir(buf);
 				redraw();
 			}
 		}else if(ptinrect(m.xy, newfiler)){
+			m.xy = cept("Create file");
 			if(eenter("Create file", buf, sizeof buf, &m)>0){
 				touch(buf);
 				redraw();