aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libdraw/mkfile1
-rw-r--r--src/libdraw/scroll.c29
2 files changed, 30 insertions, 0 deletions
diff --git a/src/libdraw/mkfile b/src/libdraw/mkfile
index e734fd5f..fbbe68e4 100644
--- a/src/libdraw/mkfile
+++ b/src/libdraw/mkfile
@@ -42,6 +42,7 @@ OFILES=\
rectclip.$O\
replclipr.$O\
rgb.$O\
+ scroll.$O\
string.$O\
stringbg.$O\
stringsubfont.$O\
diff --git a/src/libdraw/scroll.c b/src/libdraw/scroll.c
new file mode 100644
index 00000000..ea0aa25c
--- /dev/null
+++ b/src/libdraw/scroll.c
@@ -0,0 +1,29 @@
+#include <u.h>
+#include <libc.h>
+#include <draw.h>
+
+int
+mousescrollsize(int maxlines)
+{
+ static int lines, pcnt;
+ char *mss;
+
+ if(lines == 0 && pcnt == 0){
+ mss = getenv("mousescrollsize");
+ if(mss){
+ if(strchr(mss, '%') != nil)
+ pcnt = atof(mss);
+ else
+ lines = atoi(mss);
+ free(mss);
+ }
+ if(lines == 0 && pcnt == 0)
+ lines = 1;
+ if(pcnt>=100)
+ pcnt = 100;
+ }
+
+ if(lines)
+ return lines;
+ return pcnt * maxlines/100.0;
+}