mothra: enable mousewheel scrolling in history list

In the history list, scrolling was only possible using the scrollbar
	but not the mousewheel like in the text panel.
This commit is contained in:
phil9 2022-04-06 15:29:41 +00:00 committed by xfnw
parent 826d64c11c
commit cc9d153723

View file

@ -140,11 +140,11 @@ int adjkb(void){
return 0; return 0;
} }
void scrolltext(int dy, int whence) void scrollpanel(Panel *p, int dy, int whence)
{ {
Scroll s; Scroll s;
s = plgetscroll(text); s = plgetscroll(p);
switch(whence){ switch(whence){
case 0: case 0:
s.pos.y = dy; s.pos.y = dy;
@ -160,7 +160,7 @@ void scrolltext(int dy, int whence)
s.pos.y = s.size.y; s.pos.y = s.size.y;
if(s.pos.y < 0) if(s.pos.y < 0)
s.pos.y = 0; s.pos.y = 0;
plsetscroll(text, s); plsetscroll(p, s);
} }
void sidescroll(int dx, int whence) void sidescroll(int dx, int whence)
@ -404,22 +404,22 @@ Plkey:
plkeyboard(e.kbdc); plkeyboard(e.kbdc);
break; break;
case Khome: case Khome:
scrolltext(0, 0); scrollpanel(text, 0, 0);
break; break;
case Kup: case Kup:
scrolltext(-text->size.y/4, 1); scrollpanel(text, -text->size.y/4, 1);
break; break;
case Kpgup: case Kpgup:
scrolltext(-text->size.y/2, 1); scrollpanel(text, -text->size.y/2, 1);
break; break;
case Kdown: case Kdown:
scrolltext(text->size.y/4, 1); scrollpanel(text, text->size.y/4, 1);
break; break;
case Kpgdown: case Kpgdown:
scrolltext(text->size.y/2, 1); scrollpanel(text, text->size.y/2, 1);
break; break;
case Kend: case Kend:
scrolltext(-text->size.y, 2); scrollpanel(text, -text->size.y, 2);
break; break;
case Kack: case Kack:
search(); search();
@ -438,11 +438,18 @@ Plkey:
break; break;
case Emouse: case Emouse:
mouse=e.mouse; mouse=e.mouse;
if(mouse.buttons & (8|16) && ptinrect(mouse.xy, list->r) && defdisplay){
if(mouse.buttons & 8)
scrollpanel(list, list->r.min.y - mouse.xy.y, 1);
else
scrollpanel(list, mouse.xy.y - list->r.min.y, 1);
break;
}
if(mouse.buttons & (8|16) && ptinrect(mouse.xy, text->r)){ if(mouse.buttons & (8|16) && ptinrect(mouse.xy, text->r)){
if(mouse.buttons & 8) if(mouse.buttons & 8)
scrolltext(text->r.min.y - mouse.xy.y, 1); scrollpanel(text, text->r.min.y - mouse.xy.y, 1);
else else
scrolltext(mouse.xy.y - text->r.min.y, 1); scrollpanel(text, mouse.xy.y - text->r.min.y, 1);
break; break;
} }
plmouse(root, &mouse); plmouse(root, &mouse);