ref: cf29ee19bf527ca8bf82da1985ef96566a3343c6
parent: d02d4158efd4d0d5dc4b78d17a2bfe21cefbef3e
author: phil9 <[email protected]>
date: Sat Aug 14 12:47:51 EDT 2021
plumb current directory path (thanks unobe) the current directory path is sent to the plumber when right-clicking the path bar or hitting space. This can be used to open a new rc window in the current directory for instance.
--- a/README.md
+++ b/README.md
@@ -11,6 +11,7 @@
- New dir : present an entry to create a new directory
- New file: present an entry to create a new empty file
+Right-clicking on the path, plumbs the path name
Right-clicking on folders, opens them.
Right-clicking on files send them to the plumber.
@@ -18,6 +19,7 @@
- Page up / Page down to scroll
- Home to go to $home
- Up arrow to go to parent directory
+- Space to plumb current directory path
- q / Del to quit
Usage:
--- a/vdir.c
+++ b/vdir.c
@@ -30,6 +30,7 @@
Rectangle viewr;
Rectangle scrollr;
Rectangle scrposr;
+Rectangle pathr;
Image *folder;
Image *file;
Image *ihome;
@@ -189,7 +190,7 @@
f = smprint("%s/%s", path, name);
plumbsendtext(plumbfd, "vdir", nil, nil, f);
free(f);
-}
+}
void
initcolors(void)
@@ -289,6 +290,7 @@
upr = drawbutton(&p, iup);
p.x += Toolpadding;
p.y = toolr.min.y + (Toolpadding+16+Toolpadding-font->height)/2;
+ pathr = Rect(p.x, p.y, p.x + stringwidth(font, path), p.y + font->height);
string(screen, p, toolfg, ZP, font, path);
p.x = screen->r.max.x - 2*(Toolpadding+16+Toolpadding);
p.y = screen->r.min.y + Toolpadding;
@@ -375,6 +377,9 @@
up();
redraw();
break;
+ case 0x20:
+ plumbsendtext(plumbfd, "vdir", nil, nil, path);
+ break;
}
}
@@ -429,6 +434,8 @@
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(eenter("Create directory", buf, sizeof buf, &m)>0){