]> git.mdlowis.com Git - archive/tide-ocaml.git/commitdiff
reworked index manipulation for next and previous lines into rope.ml. Still need...
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 7 Nov 2017 02:00:19 +0000 (21:00 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 7 Nov 2017 02:00:19 +0000 (21:00 -0500)
docs/Rope.html
docs/index_values.html
lib/rope.ml
lib/rope.mli
lib/scrollmap.ml

index 6110fe7348fb7391571449268598ae3037eea611..8b12eb3bc25833dd5a91cbc1e7581ef33efd42d4 100644 (file)
@@ -80,4 +80,6 @@
 <pre><span id="VALis_eol"><span class="keyword">val</span> is_eol</span> : <code class="type"><a href="Rope.html#TYPEt">t</a> -> int -> bool</code></pre>
 <pre><span id="VALmove_till"><span class="keyword">val</span> move_till</span> : <code class="type">int -> (<a href="Rope.html#TYPEt">t</a> -> int -> bool) -> <a href="Rope.html#TYPEt">t</a> -> int -> int</code></pre>
 <pre><span id="VALto_bol"><span class="keyword">val</span> to_bol</span> : <code class="type"><a href="Rope.html#TYPEt">t</a> -> int -> int</code></pre>
-<pre><span id="VALto_eol"><span class="keyword">val</span> to_eol</span> : <code class="type"><a href="Rope.html#TYPEt">t</a> -> int -> int</code></pre></body></html>
\ No newline at end of file
+<pre><span id="VALto_eol"><span class="keyword">val</span> to_eol</span> : <code class="type"><a href="Rope.html#TYPEt">t</a> -> int -> int</code></pre>
+<pre><span id="VALnextln"><span class="keyword">val</span> nextln</span> : <code class="type"><a href="Rope.html#TYPEt">t</a> -> int -> int</code></pre>
+<pre><span id="VALprevln"><span class="keyword">val</span> prevln</span> : <code class="type"><a href="Rope.html#TYPEt">t</a> -> int -> int</code></pre></body></html>
\ No newline at end of file
index 157b6bbf61377aa4e53c4f2a878be114927bdb12..c5f39108255fecd01a4d6b02dfa23de122f69d76 100644 (file)
 <td></td></tr>
 <tr><td><a href="Rope.html#VALnextc">nextc</a> [<a href="Rope.html">Rope</a>]</td>
 <td></td></tr>
+<tr><td><a href="Rope.html#VALnextln">nextln</a> [<a href="Rope.html">Rope</a>]</td>
+<td></td></tr>
 <tr><td><a href="Cfg.Color.Syntax.html#VALnormal">normal</a> [<a href="Cfg.Color.Syntax.html">Cfg.Color.Syntax</a>]</td>
 <td></td></tr>
 <tr><td><a href="Cfg.Color.Syntax.html#VALnumber">number</a> [<a href="Cfg.Color.Syntax.html">Cfg.Color.Syntax</a>]</td>
 <td></td></tr>
 <tr><td><a href="Rope.html#VALprevc">prevc</a> [<a href="Rope.html">Rope</a>]</td>
 <td></td></tr>
+<tr><td><a href="Rope.html#VALprevln">prevln</a> [<a href="Rope.html">Rope</a>]</td>
+<td></td></tr>
 <tr><td><a href="Cfg.Color.Syntax.html#VALprocedure">procedure</a> [<a href="Cfg.Color.Syntax.html">Cfg.Color.Syntax</a>]</td>
 <td></td></tr>
 <tr><td><a href="X11.html#VALprop_get">prop_get</a> [<a href="X11.html">X11</a>]</td>
index 5c078dbd16fe0c6181388f2db3d9dbab29137134..fdde27f96d38b64f632c77ee2601780a9ea3396e 100644 (file)
@@ -46,14 +46,6 @@ let join left right =
     let nh = 1 + lh + rh in
     Node (left, right, nh, llen + rlen)
 
-(*
-    let n = Node (left, right, nh, llen + rlen) in
-    match (lh - rh) with
-    | 0  -> n
-    | 1  -> n
-    | -1 -> n
-*)
-
 let rec split rope i =
   if i < 0 || i > (length rope) then
     raise (Out_of_bounds "Rope.split");
@@ -172,3 +164,11 @@ let to_bol rope pos =
 
 let to_eol rope pos =
   move_till (+1) is_eol rope pos
+
+(******************************************************************************)
+
+let nextln rope pos =
+  nextc rope (to_eol rope pos)
+
+let prevln rope pos =
+  prevc rope (to_bol rope pos)
index 227323b819d799ca59e1d75d7db582c64e9b80dd..69a55918ebddc0e0d4b0080ee9ce64195cdfeca3 100644 (file)
@@ -30,6 +30,8 @@ val puts : rope -> string -> int -> rope
 
 val nextc : rope -> int -> int
 val prevc : rope -> int -> int
+val nextln : rope -> int -> int
+val prevln : rope -> int -> int
 
 val is_bol : rope -> int -> bool
 val is_eol : rope -> int -> bool
index 8a8fefe891f5cb1a26d814034a953eac1eb1cc63..7f8682d077876838ca56437664a37d293002ea7b 100644 (file)
@@ -15,10 +15,10 @@ let make buf width off =
   let bol = (Rope.to_bol (Buf.rope buf) off) in
   let lines = ref [bol] in
   let process_glyph i c =
-    let is_eol = (Rope.is_eol (Buf.rope buf) i) in
-    if (Draw.Cursor.next_glyph csr c) && is_eol == false then
+    let not_eol = ((Rope.is_eol (Buf.rope buf) i) == false) in
+    if (Draw.Cursor.next_glyph csr c) && not_eol then
       lines := i :: !lines;
-    (is_eol == false)
+    not_eol
   in
   Buf.iteri_from process_glyph buf off;
   let lines = (Array.of_list (List.rev !lines)) in
@@ -28,13 +28,9 @@ let make buf width off =
 let first map =
   map.lines.(map.index)
 
-let bopl buf off =
-  let rope = (Buf.rope buf) in
-  Rope.prevc rope (Rope.to_bol rope off)
+let bopl buf off = (Rope.prevln (Buf.rope buf) off)
 
-let bonl buf off =
-  let rope = (Buf.rope buf) in
-  Rope.nextc rope (Rope.to_eol rope off)
+let bonl buf off = (Rope.nextln (Buf.rope buf) off)
 
 let scroll_up map buf =
   let next = map.index - 1 in