shithub: patch

Download patch

ref: 23dc7aaa3f6a42dc1b8f4a44f6ffefbe025e2979
parent: be8b66b5f49e5ea3891d531e4b7c4479ce18e46c
author: qwx <qwx@sciops.net>
date: Fri Mar 11 06:06:41 EST 2022

vdir-tweaks: goddamn it

--- a/vdir-tweaks
+++ b/vdir-tweaks
@@ -48,31 +48,48 @@
  		alert("Error", "File does not exist anymore", nil, mctl, kctl);
  		loaddirs();
  		redraw();
-@@ -591,6 +594,15 @@
+@@ -587,39 +590,10 @@
+ 	else if(m.buttons == 0)
+ 		scrolling = 0;
+ 
+-	if(m.buttons&1){
++	if(m.buttons&1 && oldbuttons == 0){
  		if(scrolling){
  			dy = 1+nlines*((double)(m.xy.y - scrollr.min.y)/Dy(scrollr));
  			scrollup(dy);
-+		}else if(ptinrect(m.xy, viewr)){
-+			n = indexat(m.xy);
-+			if(n==-1)
-+				return;
-+			d = dirs[offset+n];
-+			if(d.qid.type & QTDIR){
-+				cd(d.name);
-+				redraw();
-+			}
- 		}
- 	}else if(m.buttons&2){
- 		if(ptinrect(m.xy, viewr)){
-@@ -598,6 +610,7 @@
- 			if(n==-1)
- 				return;
- 			d = dirs[offset+n];
-+			menu2.lasthit = 0;
- 			switch(menuhit(2, mctl, &menu2, nil)){
- 			case Mdelete:
- 				rm(d.name);
-@@ -633,7 +646,7 @@
+-		}
+-	}else if(m.buttons&2){
+-		if(ptinrect(m.xy, viewr)){
+-			n = indexat(m.xy);
+-			if(n==-1)
+-				return;
+-			d = dirs[offset+n];
+-			switch(menuhit(2, mctl, &menu2, nil)){
+-			case Mdelete:
+-				rm(d.name);
+-				redraw();
+-				break;
+-			case Mrename:
+-				if(enter("Rename to", buf, sizeof buf, mctl, kctl, nil)>0){
+-					mv(d.name, buf);
+-					redraw();
+-				}
+-				break;
+-			}
+-		}else if(scrolling){
+-			if(nlines<ndirs){
+-				offset = scrollclamp((m.xy.y - scrollr.min.y) * ndirs/Dy(scrollr));
+-				redraw();
+-			}
+-		}
+-	}if((m.buttons&4) && oldbuttons == 0){
+-		if(scrolling){
+-			dy = 1+nlines*((double)(m.xy.y - scrollr.min.y)/Dy(scrollr));
+-			scrolldown(dy);
+ 		}else if(ptinrect(m.xy, homer)){
+ 			cd(nil);
+ 			redraw();
+@@ -633,7 +607,7 @@
  				redraw();
  			}
  		}else if(ptinrect(m.xy, pathr)){
@@ -81,17 +98,49 @@
  		}else if(ptinrect(m.xy, newdirr)){
  			m.xy = cept("Create directory");
  			if(enter("Create directory", buf, sizeof buf, mctl, kctl, nil)>0){
-@@ -651,13 +664,8 @@
- 			if(n==-1)
- 				return;
- 			d = dirs[offset+n];
--			if(d.qid.type & QTDIR){
--				cd(d.name);
--				redraw();
+@@ -654,10 +628,44 @@
+ 			if(d.qid.type & QTDIR){
+ 				cd(d.name);
+ 				redraw();
 -			}else{
 -				if(plumbfile(path, d.name))
 -					flash(n);
--			}
+ 			}
++		}
++	}else if(m.buttons&2 && oldbuttons == 0){
++		if(ptinrect(m.xy, viewr)){
++			n = indexat(m.xy);
++			if(n==-1)
++				return;
++			d = dirs[offset+n];
++			menu2.lasthit = 0;
++			switch(menuhit(2, mctl, &menu2, nil)){
++			case Mdelete:
++				rm(d.name);
++				redraw();
++				break;
++			case Mrename:
++				if(enter("Rename to", buf, sizeof buf, mctl, kctl, nil)>0){
++					mv(d.name, buf);
++					redraw();
++				}
++				break;
++			}
++		}else if(scrolling){
++			if(nlines<ndirs){
++				offset = scrollclamp((m.xy.y - scrollr.min.y) * ndirs/Dy(scrollr));
++				redraw();
++			}
++		}
++	}if((m.buttons&4) && oldbuttons == 0){
++		if(scrolling){
++			dy = 1+nlines*((double)(m.xy.y - scrollr.min.y)/Dy(scrollr));
++			scrolldown(dy);
++		}else if(ptinrect(m.xy, viewr)){
++			n = indexat(m.xy);
++			if(n==-1)
++				return;
++			d = dirs[offset+n];
 +			if(plumbfile(path, d.name, d.qid.type & QTDIR))
 +				flash(n);
  		}