From: Michael D. Lowis Date: Fri, 10 Nov 2017 03:38:42 +0000 (-0500) Subject: Updated scrollbar to adjust thumb position based on first visible position in the... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=483587716fd5b5894669e2d3410528242e253de3;p=archive%2Ftide-ocaml.git Updated scrollbar to adjust thumb position based on first visible position in the buffer --- diff --git a/docs/Draw.html b/docs/Draw.html index 867004a..534867c 100644 --- a/docs/Draw.html +++ b/docs/Draw.html @@ -45,5 +45,5 @@
val buffer : Cursor.t -> Buf.t -> int -> int
val status : Cursor.t -> string -> unit
val tags : Cursor.t -> 'a -> unit
-
val scroll : Cursor.t -> float -> unit
+
val scroll : Cursor.t -> float * float -> unit
val edit : Cursor.t -> Buf.t -> int -> int
\ No newline at end of file diff --git a/lib/draw.ml b/lib/draw.ml index 3e803cd..b636ada 100644 --- a/lib/draw.ml +++ b/lib/draw.ml @@ -121,10 +121,13 @@ let tags csr buf = string "Quit Save Undo Redo Cut Copy Paste | Find " csr; hrule csr.width csr -let scroll csr pct = - let thumbsz = int_of_float ((float_of_int csr.height) *. pct) in +let scroll csr params = + let start, pct = params and height = float_of_int (csr.height - csr.y) in + let thumbsz = (height *. pct) and thumboff = (height *. start) in + let mcsr = Cursor.clone csr in rule_bkg 14 csr.height csr; - dark_bkg 14 (max thumbsz 5) csr; + mcsr.y <- mcsr.y + (int_of_float thumboff); + dark_bkg 14 (int_of_float (max thumbsz 5.0)) mcsr; csr.x <- csr.x + 14; vrule csr.height csr diff --git a/lib/draw.mli b/lib/draw.mli index c71bf5f..558ab19 100644 --- a/lib/draw.mli +++ b/lib/draw.mli @@ -26,5 +26,5 @@ val vrule : int -> Cursor.t -> unit val status : Cursor.t -> string -> unit val tags : Cursor.t -> Buf.t -> unit -val scroll : Cursor.t -> float -> unit +val scroll : Cursor.t -> (float * float) -> unit val edit : Cursor.t -> Buf.t -> int -> int