shithub: patch

Download patch

ref: ef347c230867fbe853a7419c39a9f3bda4702008
parent: 23dc7aaa3f6a42dc1b8f4a44f6ffefbe025e2979
author: qwx <qwx@sciops.net>
date: Fri Mar 11 12:55:45 EST 2022

vdir: nope!

--- a/vdir-tweaks
+++ b/vdir-tweaks
@@ -48,7 +48,7 @@
  		alert("Error", "File does not exist anymore", nil, mctl, kctl);
  		loaddirs();
  		redraw();
-@@ -587,39 +590,10 @@
+@@ -587,17 +590,51 @@
  	else if(m.buttons == 0)
  		scrolling = 0;
  
@@ -57,90 +57,94 @@
  		if(scrolling){
  			dy = 1+nlines*((double)(m.xy.y - scrollr.min.y)/Dy(scrollr));
  			scrollup(dy);
--		}
--	}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)){
--			plumbsendtext(plumbfd, "vdir", nil, nil, path);
-+			plumbsendtext(plumbfd, "vdirw", nil, nil, path);
- 		}else if(ptinrect(m.xy, newdirr)){
- 			m.xy = cept("Create directory");
- 			if(enter("Create directory", buf, sizeof buf, mctl, kctl, nil)>0){
-@@ -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);
++		}else if(ptinrect(m.xy, homer)){
++			cd(nil);
++			redraw();
++		}else if(ptinrect(m.xy, upr)){
++			up();
++			redraw();
++		}else if(ptinrect(m.xy, cdr)){
++			m.xy = cept("Go to directory");
++			if(enter("Go to directory", buf, sizeof buf, mctl, kctl, nil)>0){
++				cd(buf);
 +				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));
++		}else if(ptinrect(m.xy, newdirr)){
++			m.xy = cept("Create directory");
++			if(enter("Create directory", buf, sizeof buf, mctl, kctl, nil)>0){
++				mkdir(buf);
 +				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, newfiler)){
++			m.xy = cept("Create file");
++			if(enter("Create file", buf, sizeof buf, mctl, kctl, nil)>0){
++				touch(buf);
++				redraw();
++			}
 +		}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){
++	}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);
+@@ -620,44 +657,15 @@
+ 		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();
+-		}else if(ptinrect(m.xy, upr)){
+-			up();
+-			redraw();
+-		}else if(ptinrect(m.xy, cdr)){
+-			m.xy = cept("Go to directory");
+-			if(enter("Go to directory", buf, sizeof buf, mctl, kctl, nil)>0){
+-				cd(buf);
+-				redraw();
+-			}
+ 		}else if(ptinrect(m.xy, pathr)){
+-			plumbsendtext(plumbfd, "vdir", nil, nil, path);
+-		}else if(ptinrect(m.xy, newdirr)){
+-			m.xy = cept("Create directory");
+-			if(enter("Create directory", buf, sizeof buf, mctl, kctl, nil)>0){
+-				mkdir(buf);
+-				redraw();
+-			}
+-		}else if(ptinrect(m.xy, newfiler)){
+-			m.xy = cept("Create file");
+-			if(enter("Create file", buf, sizeof buf, mctl, kctl, nil)>0){
+-				touch(buf);
+-				redraw();
+-			}
++			plumbsendtext(plumbfd, "vdirw", nil, nil, path);
+ 		}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(plumbfile(path, d.name))
+-					flash(n);
+-			}
 +			if(plumbfile(path, d.name, d.qid.type & QTDIR))
 +				flash(n);
  		}