ref: 56dc18887a7df44e90ceea06adb55475cb508593
dir: /vdir-tweaks/
diff 663d1a8c4432f3cef70466c04699fb6ebaafbc22 uncommitted --- a/vdir.c +++ b/vdir.c @@ -273,7 +273,7 @@ } int -plumbfile(char *path, char *name) +plumbfile(char *path, char *name, int isdir) { char *f; int e; @@ -280,9 +280,12 @@ f = smprint("%s/%s", path, name); e = access(f, 0)==0; - if(e) - plumbsendtext(plumbfd, "vdir", nil, path, name); - else{ + if(e){ + if(isdir) + plumbsendtext(plumbfd, "vdir", nil, nil, f); + else + plumbsendtext(plumbfd, "vdir", nil, path, name); + }else{ alert("Error", "File does not exist anymore", nil, mctl, kctl); loaddirs(); redraw(); @@ -588,40 +591,10 @@ else if(m.buttons == 0) scrolling = 0; - if(m.buttons&1){ - 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: - snprint(buf, sizeof buf, "%s", d.name); - 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); + 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, homer)){ cd(nil); redraw(); @@ -634,8 +607,6 @@ 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){ @@ -656,10 +627,47 @@ 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: + snprint(buf, sizeof buf, "%s", d.name); + 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, pathr)){ + 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(plumbfile(path, d.name, d.qid.type & QTDIR)) + flash(n); } }else if(m.buttons&8) scrollup(Slowscroll);