shithub: vdiff

Download patch

ref: 5463484216a9be9d57acdecf1e02d16843fc2f65
parent: be786d9d7e9f80b7b02e468fac819434545f0dd5
author: phil9 <telephil9@gmail.com>
date: Sat Aug 7 03:36:20 EDT 2021

use mousescrollsize()

	mouse scroll speed is now based on the mousescrollsize() helper function.
	This allows for defining an env variable named mousescrollsize to change
	the speed instead of having an hard coded default.
	Thanks nicolagi for the pointer.

--- a/vdiff.c
+++ b/vdiff.c
@@ -41,6 +41,7 @@
 Rectangle textr;
 Image *cols[Ncols];
 Image *scrollbg;
+int scrollsize;
 int lineh;
 int nlines;
 int offset;
@@ -133,6 +134,7 @@
 	lineh = Vpadding+font->height+Vpadding;
 	nlines = Dy(textr)/lineh;
 	offset = 0;
+	scrollsize = mousescrollsize(nlines);
 	redraw();
 }
 
@@ -309,9 +311,9 @@
 				if(n>=0 && lines[n+offset]->f != nil)
 					plumb(lines[n+offset]->f, lines[n+offset]->l);
 			}else if(ev.mouse.buttons&8)
-				scroll(-10);
+				scroll(-scrollsize);
 			else if(ev.mouse.buttons&16)
-				scroll(10);
+				scroll(scrollsize);
 			break;
 		case Ekeyboard:
 			switch(ev.kbdc){