ref: 641589f25d1a5d86caa8c006fd659a145a561b72
parent: f0d685d902830be93d1246c09cb6a2d3063dad86
author: phil9 <telephil9@gmail.com>
date: Mon Aug 2 05:26:18 EDT 2021
add scrolling via mouse 1 and 3 on scrollbar (thanks nicolagi) implement standard scrollbar behaviour with mouse 1 scrolling up and mouse 3 scrolling down. Scrolling "speed" is dependent on the mouse click location
--- a/vdiff.c
+++ b/vdiff.c
@@ -274,6 +274,25 @@
e = event(&ev);
switch(e){
case Emouse:
+ if(ev.mouse.buttons&4 && ptinrect(ev.mouse.xy, scrollr)){
+ n = (ev.mouse.xy.y - scrollr.min.y) / lineh;
+ if(n<lcount-offset){
+ scroll(n);
+ } else {
+ scroll(lcount-offset);
+ }
+ break;
+ }
+ if(ev.mouse.buttons&1 && ptinrect(ev.mouse.xy, scrollr)){
+ n = (ev.mouse.xy.y - scrollr.min.y) / lineh;
+ if(-n<lcount-offset){
+ scroll(-n);
+ } else {
+ scroll(-lcount+offset);
+ }
+ break;
+ }
+
if(ev.mouse.buttons&4){
n = indexat(ev.mouse.xy);
if(n>=0 && lines[n+offset]->f != nil)