]> git.mdlowis.com Git - archive/tide-ocaml.git/commitdiff
added logic to determine if a drawn character is selected and tweaked cursor pos api
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 20 Dec 2017 03:16:02 +0000 (22:16 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 20 Dec 2017 03:16:02 +0000 (22:16 -0500)
lib/buf.ml
lib/buf.mli
lib/draw.ml

index a3e48f1ffc7853628f409e56a88ce10840e44b84..08eda4c71114daceba90b7eee0461d20e1726361 100644 (file)
@@ -52,7 +52,7 @@ module Cursor = struct
       csr
 
   let initial =
-    { start = 0; stop = 0 }
+    { start = 0; stop = 1 }
 
   let make buf idx =
     { start = 0; stop = (Rope.limit_index buf.rope idx) }
@@ -82,7 +82,6 @@ let nextln = move_to NextLine
 let prevln = move_to PrevLine
 let bol = move_to StartOfLine
 
-
 let pick_syntax path =
   let name = Filename.basename path in
   let ext = Filename.extension path in
@@ -117,8 +116,11 @@ let iteri fn buf i =
 let iter fn buf i =
   iteri (fun i c -> (fn c)) buf i
 
-let cursor buf =
-  buf.cursor
+let csrpos buf =
+  Cursor.stop buf.cursor
+
+let selected buf pos =
+  Cursor.selected buf.cursor pos
 
 let make_lexer buf =
   let pos = ref 0 in
@@ -176,5 +178,3 @@ let is_at dest buf i =
 let is_bol = is_at StartOfLine
 let is_eol = is_at EndOfLine
 *)
-
-
index ced60f441d5102787d45db645ea340d8c8bf411d..db12bf0a7c9a34a7fbbcd18a893cb5c6ab1b971f 100644 (file)
@@ -19,8 +19,10 @@ val path : t -> string
 val length : t -> int
 val iteri : (int -> int -> bool) -> t -> int -> unit
 val iter : (int -> bool) -> t -> int -> unit
-val cursor : t -> Cursor.t
+val csrpos : t -> int
+val selected : t -> int -> bool
 val make_lexer : t -> Colormap.lexer
+
 val nextln : t -> int -> int
 val prevln : t -> int -> int
 val bol : t -> int -> int
index f5d6ea3e802e0a20876bd90ed27f623025585994..107e591724299706f253f2856e2533de02b5ddf4 100644 (file)
@@ -104,7 +104,7 @@ let buffer csr buf clr off =
   let num = ref 0 and csr = (restart csr 2 0) in
   let draw_rune c =
     let pos = off + !num in
-    if pos == (Buf.Cursor.stop (Buf.cursor buf)) then
+    if pos == (Buf.csrpos buf) then
       draw_cursor csr;
     draw_glyph csr c (Colormap.find pos clr);
     num := !num + 1;