ref: 069affc42b1315d01c31ec1a19486216dfa0e5dc
parent: 7dd978d5bfd01aaa6f899714422275adeeb894ec
author: phil9 <[email protected]>
date: Fri Dec 30 04:10:39 EST 2022
add support for viewing files using right mouse click in panel
--- a/a.h
+++ b/a.h
@@ -112,6 +112,7 @@
void dirviewemouse(Dirview*, Mouse);
Dirpanel* dirviewcurrentpanel(Dirview*);
Dirpanel* dirviewotherpanel(Dirview*);
+void cmdview(void);
Dirmodel* mkdirmodel(char*);
Dir dirmodelgetdir(Dirmodel*, int);
--- a/dirpanel.c
+++ b/dirpanel.c
@@ -182,11 +182,19 @@
int n;
pt = subpt(m.xy, screen->r.min);
- if((m.buttons&1) && ptinrect(pt, p->filesr)){
+ if(!ptinrect(pt, p->filesr))
+ return;
+ if(m.buttons == 1){
n = (pt.y - p->filesr.min.y) / (font->height+2);
if(n != p->cursor && n < p->nlines){
p->cursor = n;
dirpanelredrawnotify(p);
+ }
+ }else if(m.buttons == 4){
+ n = (pt.y - p->filesr.min.y) / (font->height+2);
+ if(n < p->nlines){
+ p->cursor = n;
+ cmdview(); /* ugly hack */
}
}
}
--- a/dirview.c
+++ b/dirview.c
@@ -49,7 +49,7 @@
void
dirviewemouse(Dirview *v, Mouse m)
{
- if(m.buttons != 1)
+ if(!m.buttons)
return;
if((ptinrect(m.xy, v->leftp->r) && !v->leftp->focused)
|| (ptinrect(m.xy, v->rightp->r) && !v->rightp->focused))