]> git.mdlowis.com Git - archive/tide-ocaml.git/commitdiff
totally broke scrolling but im not sure how...
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 8 Nov 2017 01:30:22 +0000 (20:30 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 8 Nov 2017 01:30:22 +0000 (20:30 -0500)
12 files changed:
docs/Buf.Cursor.html
docs/Buf.html
docs/Rope.html
docs/index_exceptions.html
docs/index_values.html
docs/type_Buf.Cursor.html
lib/buf.ml
lib/buf.mli
lib/draw.ml
lib/rope.ml
lib/rope.mli
lib/scrollmap.ml

index 0ee7c573d5fece5e3873ee189d983fe8e764af12..8e5a261dbbdf8d8384444d8f675931c84ffe7a49 100644 (file)
@@ -48,6 +48,8 @@
 
 
 <pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> int -> <a href="Buf.Cursor.html#TYPEcsr">csr</a></code></pre>
+<pre><span id="VALclone"><span class="keyword">val</span> clone</span> : <code class="type"><a href="Buf.Cursor.html#TYPEcsr">csr</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a></code></pre>
+<pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">'a -> 'b -> 'c -> unit</code></pre>
 <pre><span id="VALoffset"><span class="keyword">val</span> offset</span> : <code class="type">'a -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> int</code></pre>
 <pre><span id="VALgoto"><span class="keyword">val</span> goto</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> int -> unit</code></pre>
 <pre><span id="VALgetc"><span class="keyword">val</span> getc</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> <a href="Rope.html#TYPErune">Rope.rune</a></code></pre>
index 15b942c55b046bd923e42c246af8d5df8f72e614..81f30d3b6162e1eed214299a3fd2ce7f1b249a10 100644 (file)
@@ -53,7 +53,7 @@
 
 <pre><span id="VALempty"><span class="keyword">val</span> empty</span> : <code class="type"><a href="Buf.html#TYPEbuf">buf</a></code></pre>
 <pre><span id="VALload"><span class="keyword">val</span> load</span> : <code class="type">string -> <a href="Buf.html#TYPEbuf">buf</a></code></pre>
-<pre><span id="VALiter_from"><span class="keyword">val</span> iter_from</span> : <code class="type">(<a href="Rope.html#TYPErune">Rope.rune</a> -> bool) -> <a href="Buf.html#TYPEbuf">buf</a> -> int -> unit</code></pre>
-<pre><span id="VALiteri_from"><span class="keyword">val</span> iteri_from</span> : <code class="type">(int -> <a href="Rope.html#TYPErune">Rope.rune</a> -> bool) -> <a href="Buf.html#TYPEbuf">buf</a> -> int -> unit</code></pre>
+<pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">(<a href="Rope.html#TYPErune">Rope.rune</a> -> bool) -> <a href="Buf.html#TYPEbuf">buf</a> -> int -> unit</code></pre>
+<pre><span id="VALiteri"><span class="keyword">val</span> iteri</span> : <code class="type">(int -> <a href="Rope.html#TYPErune">Rope.rune</a> -> bool) -> <a href="Buf.html#TYPEbuf">buf</a> -> int -> unit</code></pre>
 <pre><span id="VALis_eol"><span class="keyword">val</span> is_eol</span> : <code class="type"><a href="Buf.html#TYPEbuf">buf</a> -> int -> bool</code></pre>
 <pre><span class="keyword">module</span> <a href="Buf.Cursor.html">Cursor</a>: <code class="code">sig</code> <a href="Buf.Cursor.html">..</a> <code class="code">end</code></pre></body></html>
\ No newline at end of file
index 8b12eb3bc25833dd5a91cbc1e7581ef33efd42d4..ba5d84c4150ce9c2fbb95002cf17732c365df42d 100644 (file)
 <pre><span id="VALgetb"><span class="keyword">val</span> getb</span> : <code class="type"><a href="Rope.html#TYPEt">t</a> -> int -> char</code></pre>
 <pre><span id="VALgetc"><span class="keyword">val</span> getc</span> : <code class="type"><a href="Rope.html#TYPEt">t</a> -> int -> int</code></pre>
 <pre><span id="VALputc"><span class="keyword">val</span> putc</span> : <code class="type">'a -> 'b -> 'c -> 'a</code></pre>
-<pre><span id="VALiter_from"><span class="keyword">val</span> iter_from</span> : <code class="type">(int -> bool) -> <a href="Rope.html#TYPEt">t</a> -> int -> unit</code></pre>
-<pre><span id="VALiteri_from"><span class="keyword">val</span> iteri_from</span> : <code class="type">(int -> int -> bool) -> <a href="Rope.html#TYPEt">t</a> -> int -> unit</code></pre>
+<pre><span id="EXCEPTIONBreak_loop"><span class="keyword">exception</span> Break_loop</span></pre>
+
+<pre><span id="VALiteri_leaf"><span class="keyword">val</span> iteri_leaf</span> : <code class="type">(int -> int -> bool) -> int -> string -> int -> int -> unit</code></pre>
+<pre><span id="VALiteri"><span class="keyword">val</span> iteri</span> : <code class="type">(int -> int -> bool) -> <a href="Rope.html#TYPEt">t</a> -> int -> unit</code></pre>
 <pre><span id="VALgets"><span class="keyword">val</span> gets</span> : <code class="type"><a href="Rope.html#TYPEt">t</a> -> int -> int -> string</code></pre>
 <pre><span id="VALputs"><span class="keyword">val</span> puts</span> : <code class="type"><a href="Rope.html#TYPEt">t</a> -> string -> int -> <a href="Rope.html#TYPEt">t</a></code></pre>
 <pre><span id="VALnextc"><span class="keyword">val</span> nextc</span> : <code class="type"><a href="Rope.html#TYPEt">t</a> -> int -> int</code></pre>
index 79682f4a53d07631fc3ea77c93ef96e68f196d19..d9c6c7e827cb879944d8c8d30d0894f63e07e4c7 100644 (file)
@@ -24,6 +24,8 @@
 <tr><td align="left"><br>B</td></tr>
 <tr><td><a href="Rope.html#EXCEPTIONBad_rotation">Bad_rotation</a> [<a href="Rope.html">Rope</a>]</td>
 <td></td></tr>
+<tr><td><a href="Rope.html#EXCEPTIONBreak_loop">Break_loop</a> [<a href="Rope.html">Rope</a>]</td>
+<td></td></tr>
 <tr><td align="left"><br>O</td></tr>
 <tr><td><a href="Rope.html#EXCEPTIONOut_of_bounds">Out_of_bounds</a> [<a href="Rope.html">Rope</a>]</td>
 <td></td></tr>
index 8c16029f2a3dd544b29ce250a5ebaba489923112..f4153976e7310206b83b888a128db49320ae84b5 100644 (file)
@@ -41,6 +41,8 @@
 <td></td></tr>
 <tr><td><a href="Rope.html#VALcheck_index">check_index</a> [<a href="Rope.html">Rope</a>]</td>
 <td></td></tr>
+<tr><td><a href="Buf.Cursor.html#VALclone">clone</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
+<td></td></tr>
 <tr><td><a href="Cfg.html#VALclrvar">clrvar</a> [<a href="Cfg.html">Cfg</a>]</td>
 <td></td></tr>
 <tr><td><a href="Cfg.html#VALcmd_tags">cmd_tags</a> [<a href="Cfg.html">Cfg</a>]</td>
 <td></td></tr>
 <tr><td><a href="Rope.html#VALis_eol">is_eol</a> [<a href="Rope.html">Rope</a>]</td>
 <td></td></tr>
-<tr><td><a href="Buf.html#VALiter_from">iter_from</a> [<a href="Buf.html">Buf</a>]</td>
+<tr><td><a href="Buf.Cursor.html#VALiter">iter</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
+<td></td></tr>
+<tr><td><a href="Buf.html#VALiter">iter</a> [<a href="Buf.html">Buf</a>]</td>
 <td></td></tr>
-<tr><td><a href="Rope.html#VALiter_from">iter_from</a> [<a href="Rope.html">Rope</a>]</td>
+<tr><td><a href="Buf.html#VALiteri">iteri</a> [<a href="Buf.html">Buf</a>]</td>
 <td></td></tr>
-<tr><td><a href="Buf.html#VALiteri_from">iteri_from</a> [<a href="Buf.html">Buf</a>]</td>
+<tr><td><a href="Rope.html#VALiteri">iteri</a> [<a href="Rope.html">Rope</a>]</td>
 <td></td></tr>
-<tr><td><a href="Rope.html#VALiteri_from">iteri_from</a> [<a href="Rope.html">Rope</a>]</td>
+<tr><td><a href="Rope.html#VALiteri_leaf">iteri_leaf</a> [<a href="Rope.html">Rope</a>]</td>
 <td></td></tr>
 <tr><td align="left"><br>J</td></tr>
 <tr><td><a href="Rope.html#VALjoin">join</a> [<a href="Rope.html">Rope</a>]</td>
index fe5006651636ad89810b161b343a0babb4223044..6f5502566cb1448e9e8ba29f5e19b955d6887785 100644 (file)
@@ -20,6 +20,8 @@
 &nbsp;&nbsp;<span class="keyword">type</span>&nbsp;csr&nbsp;=&nbsp;{&nbsp;<span class="keyword">mutable</span>&nbsp;start&nbsp;:&nbsp;int;&nbsp;<span class="keyword">mutable</span>&nbsp;stop&nbsp;:&nbsp;int;&nbsp;}<br>
 &nbsp;&nbsp;<span class="keyword">type</span>&nbsp;t&nbsp;=&nbsp;<span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr<br>
 &nbsp;&nbsp;<span class="keyword">val</span>&nbsp;make&nbsp;:&nbsp;<span class="constructor">Buf</span>.buf&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;int&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr<br>
+&nbsp;&nbsp;<span class="keyword">val</span>&nbsp;clone&nbsp;:&nbsp;<span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr<br>
+&nbsp;&nbsp;<span class="keyword">val</span>&nbsp;iter&nbsp;:&nbsp;<span class="keywordsign">'</span>a&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keywordsign">'</span>b&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keywordsign">'</span>c&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;unit<br>
 &nbsp;&nbsp;<span class="keyword">val</span>&nbsp;offset&nbsp;:&nbsp;<span class="keywordsign">'</span>a&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;int<br>
 &nbsp;&nbsp;<span class="keyword">val</span>&nbsp;goto&nbsp;:&nbsp;<span class="constructor">Buf</span>.buf&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;int&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;unit<br>
 &nbsp;&nbsp;<span class="keyword">val</span>&nbsp;getc&nbsp;:&nbsp;<span class="constructor">Buf</span>.buf&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="constructor">Rope</span>.rune<br>
index cdefefba89ebeb67838f40f795e4db9ee1182372..f8a37f31e3c81f82348c664d2ed9b85e82a662f4 100644 (file)
@@ -11,11 +11,11 @@ let empty =
 let load path =
   { path = path; rope = Rope.from_string (Misc.load_file path) }
 
-let iter_from fn buf i =
-  Rope.iter_from fn buf.rope i
+let iter fn buf i =
+  Rope.iteri (fun i c -> (fn c)) buf.rope i
 
-let iteri_from fn buf i =
-  Rope.iteri_from fn buf.rope i
+let iteri fn buf i =
+  Rope.iteri fn buf.rope i
 
 let is_eol buf off =
   Rope.is_eol buf.rope off
@@ -31,6 +31,11 @@ module Cursor = struct
   let make buf idx =
     { start = 0; stop = (Rope.limit_index buf.rope idx) }
 
+  let clone csr =
+    { start = csr.start; stop = csr.stop }
+
+  let iter fn buf csr = ()
+
   let offset buf csr =
     csr.stop
 
index 12b49c26637b2313a41839b4c780df632bd66e47..a5aa8bcbf4368b413bf4caffa73e35bf0811cf51 100644 (file)
@@ -2,14 +2,16 @@ type buf
 type t = buf
 val empty : t
 val load : string -> t
-val iter_from : (int -> bool) -> t -> int -> unit
-val iteri_from : (int -> int -> bool) -> t -> int -> unit
+val iter : (int -> bool) -> t -> int -> unit
+val iteri : (int -> int -> bool) -> t -> int -> unit
 
 val is_eol : buf -> int -> bool
 
 module Cursor : sig
   type t
   val make : buf -> int -> t
+  val clone : t -> t
+  val iter : (t -> bool) -> buf -> t -> unit
   val offset : buf -> t -> int
   val goto : buf -> t -> int -> unit
   val getc : buf -> t -> int
@@ -23,6 +25,11 @@ module Cursor : sig
   val nextln : buf -> t -> int
   val prevln : buf -> t -> int
 
+(*
+  val is_bol : buf -> t -> bool
+  val to_eol : buf -> t -> int
+*)
+
   val is_eol : buf -> t -> bool
   val to_bol : buf -> t -> int
 end
index e7961366ec6dc3368e3b11ef67902fc08c39d79e..8cafd265ba80dc5fa17d4d8ef57edf93f5205cf8 100644 (file)
@@ -97,7 +97,7 @@ let buffer csr buf off =
     draw_glyph csr c;
     has_next_line csr
   in
-  Buf.iter_from draw_rune buf off
+  Buf.iter draw_rune buf off
 
 let status csr str =
   dark_bkg csr.width (4 + font_height) csr;
index fdde27f96d38b64f632c77ee2601780a9ea3396e..bb5ff3866a711de7f435d36c676147b17df4be4e 100644 (file)
@@ -102,6 +102,25 @@ let putc rope i c = rope
 
 (******************************************************************************)
 
+exception Break_loop
+
+let iteri_leaf fn pos str off len =
+  let offset = pos - off in
+  for i = off to off + len - 1 do (* break loop when fn returns false *)
+    if (fn (i + offset) (Char.code str.[i])) == false then
+      raise Break_loop
+  done
+
+let rec iteri fn rope pos =
+  match rope with
+  | Leaf (str, off, len) ->
+      (try iteri_leaf fn pos str off len
+      with Break_loop -> ())
+  | Node (l,r,_,_) ->
+      iteri fn l pos;
+      iteri fn r (pos + (length l))
+
+(*
 let rec iter_from fn rope pos =
   if pos < (length rope) && (fn (getc rope pos)) then
     iter_from fn rope (pos + 1)
@@ -109,12 +128,13 @@ let rec iter_from fn rope pos =
 let rec iteri_from fn rope pos =
   if pos < (length rope) && (fn pos (getc rope pos)) then
     iteri_from fn rope (pos + 1)
+*)
 
 (******************************************************************************)
 
 let gets rope i j =
   let buf = Bytes.create (j - i) in
-  iteri_from
+  iteri
     (fun n c ->
       Bytes.set buf (n - i) (getb rope i);
       (n <= j))
index 69a55918ebddc0e0d4b0080ee9ce64195cdfeca3..57be4b4a454b2a809106ea053dd52535686a8a8c 100644 (file)
@@ -19,8 +19,7 @@ val join : rope -> rope -> rope
 val split : rope -> int -> (rope * rope)
 val del : rope -> int -> int -> rope
 
-val iter_from : (rune -> bool) -> rope -> int -> unit
-val iteri_from : (int -> rune -> bool) -> rope -> int -> unit
+val iteri : (int -> rune -> bool) -> rope -> int -> unit
 
 val getb : rope -> int -> char
 val getc : rope -> int -> rune
index 01914d66ef73b7704f822abedcaeb99796bc1ab8..7db51d0c6e40e43e712296398e2b0cb6973a8dde 100644 (file)
@@ -20,12 +20,16 @@ let make buf width off =
       lines := i :: !lines;
     not_eol
   in
-  Buf.iteri_from process_glyph buf off;
+  Buf.iteri process_glyph buf off;
   let lines = (Array.of_list (List.rev !lines)) in
+  print_string "map: ";
+  Array.iter (fun x -> Printf.printf "%d " x) lines;
+  print_endline "";
   let index = (find_line lines off ((Array.length lines) - 1)) in
   { width = width; lines = lines; index = index }
 
 let first map =
+  Printf.printf "first: %d\n" map.lines.(map.index);
   map.lines.(map.index)
 
 let bopl buf off =