]> git.mdlowis.com Git - archive/tide-ocaml.git/commitdiff
Added skeleton logic for building the scrollmap
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 25 Oct 2017 20:13:49 +0000 (16:13 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 25 Oct 2017 20:13:49 +0000 (16:13 -0400)
edit.ml
lib/buf.ml
lib/buf.mli
lib/scrollmap.ml
lib/scrollmap.mli

diff --git a/edit.ml b/edit.ml
index 3f6ee0fce81e15e8b920b2f0eb9803bb2d2db66d..b51ed485b68ed4f0c0feab8bba748719d6c983b3 100644 (file)
--- a/edit.ml
+++ b/edit.ml
@@ -18,7 +18,8 @@ let onupdate width height =
   Draw.status csr "UNSI> *scratch*";
   Draw.tags csr !tags_buf;
   Draw.scroll csr;
-  Draw.edit csr !edit_buf
+  Draw.edit csr !edit_buf;
+  let _ = Scrollmap.make !edit_buf width height 0 in ()
 
 let onshutdown () = ()
 
index ee81c8f16c4e9ea1876a37f0b6034090b0599e0d..10ca9978de886ea20033c21475c0b22515bea745 100644 (file)
@@ -19,6 +19,9 @@ let start buf =
 let iter_from fn buf i =
   Rope.iter_from fn buf.rope i
 
+let iteri_from fn buf i =
+  Rope.iteri_from fn buf.rope i
+
 (* Unit Tests *****************************************************************)
 
 let run_unit_tests () =
index 5705ee6b9a454934b96606451ce6535486548229..37720f12b359835d1b81ac95802524464d53c966 100644 (file)
@@ -4,3 +4,4 @@ val load : string -> t
 val rope : t -> Rope.t
 val start : t -> int
 val iter_from : (int -> bool) -> t -> int -> unit
+val iteri_from : (int -> int -> bool) -> t -> int -> unit
index 7c8c7ede508ba2683e70d5cf21ab424771ddd59a..d1a0e2be50f2e277bb656b38cab553548e354c43 100644 (file)
@@ -3,10 +3,22 @@ type t = {
   map : int array
 }
 
-let make buf =
-  let bol = (Rope.to_bol (Buf.rope buf) (Buf.start buf)) in
+let make buf width height off =
+  let bol = (Rope.to_bol (Buf.rope buf) off) in
+  let lines = ref [bol] in
+  let csr = Draw.Cursor.make (width, 0) 0 0 in
+  let process_glyph i c =
+    let open Draw.Cursor in
+    next_glyph csr c false;
+    (*if csr.startx == csr.x then
+      lines := i :: !lines;*)
+    ((Rope.is_eol (Buf.rope buf) i) == false)
+  in
+  Buf.iteri_from process_glyph buf off;
+  List.iter (fun n -> Printf.printf "%d " n) !lines;
+  print_endline "";
   { index = 0; map = [||] }
 
-(* Unit Tests** ***************************************************************)
+(* Unit Tests *****************************************************************)
 
 let run_unit_tests () = ()
index 52ab68552ce59fe4312955fafbc32e20c758195d..2e8723e2926502750926bfd10bcf2aba706f185a 100644 (file)
@@ -1,3 +1,3 @@
 type t
-val make : Buf.t -> t
+val make : Buf.t -> int -> int -> int -> t
 val run_unit_tests : unit -> unit