]> git.mdlowis.com Git - archive/tide-ocaml.git/commitdiff
fixed up scroll parameters
authorMichael D. Lowis <mike@mdlowis.com>
Sat, 11 Nov 2017 02:04:42 +0000 (21:04 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Sat, 11 Nov 2017 02:04:42 +0000 (21:04 -0500)
edit.ml

diff --git a/edit.ml b/edit.ml
index b53ba942506c3058164c66d3e65cdb88177ab2cc..f690825fda8159470198db602631bdbef3c3e646 100644 (file)
--- a/edit.ml
+++ b/edit.ml
@@ -30,9 +30,11 @@ module View = struct
   let scroll_dn view =
     { view with map = Scrollmap.scroll_dn view.map view.buf }
 
-  let visible view =
-    (float_of_int view.num) /. (float_of_int (Buf.length view.buf))
-
+  let scroll_params view =
+    let length = float_of_int (Buf.length view.buf)
+    and first = float_of_int (Scrollmap.first view.map)
+    and nvisible = float_of_int view.num in
+    ((first /. length), (nvisible /. length))
 end
 
 let tags_buf = ref Buf.empty
@@ -63,7 +65,7 @@ let onupdate width height =
   let scrollcsr = (Draw.Cursor.clone csr) in
   Draw.Cursor.move_x csr 15;
   edit_view := View.draw !edit_view csr;
-  Draw.scroll scrollcsr (View.visible !edit_view)
+  Draw.scroll scrollcsr (View.scroll_params !edit_view)
 
 let onshutdown () = ()