<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="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">(<a href="Buf.Cursor.html#TYPEcsr">csr</a> -> <a href="Rope.html#TYPErune">Rope.rune</a> -> bool) -> <a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> 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>
+<pre><span id="VALmove_to"><span class="keyword">val</span> move_to</span> : <code class="type"><a href="Buf.html#TYPEdest">Buf.dest</a> -> <a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> int</code></pre>
<pre><span id="VALnextc"><span class="keyword">val</span> nextc</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> int</code></pre>
<pre><span id="VALprevc"><span class="keyword">val</span> prevc</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> int</code></pre>
<pre><span id="VALnextln"><span class="keyword">val</span> nextln</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> int</code></pre>
<pre><span id="VALprevln"><span class="keyword">val</span> prevln</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> int</code></pre>
-<pre><span id="VALis_eol"><span class="keyword">val</span> is_eol</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> bool</code></pre>
-<pre><span id="VALto_bol"><span class="keyword">val</span> to_bol</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> int</code></pre></body></html>
\ No newline at end of file
+<pre><span id="VALbol"><span class="keyword">val</span> bol</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> int</code></pre>
+<pre><span id="VALeol"><span class="keyword">val</span> eol</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> int</code></pre>
+<pre><span id="VALis_at"><span class="keyword">val</span> is_at</span> : <code class="type"><a href="Buf.html#TYPEdest">Buf.dest</a> -> <a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> bool</code></pre>
+<pre><span id="VALis_bol"><span class="keyword">val</span> is_bol</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> bool</code></pre>
+<pre><span id="VALis_eol"><span class="keyword">val</span> is_eol</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> <a href="Buf.Cursor.html#TYPEcsr">csr</a> -> bool</code></pre></body></html>
\ No newline at end of file
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> = <code class="type"><a href="Buf.html#TYPEbuf">buf</a></code> </pre>
+<pre><code><span id="TYPEdest"><span class="keyword">type</span> <code class="type"></code>dest</span> = </code></pre><table class="typetable">
+<tr>
+<td align="left" valign="top" >
+<code><span class="keyword">|</span></code></td>
+<td align="left" valign="top" >
+<code><span id="TYPEELTdest.StartOfLine"><span class="constructor">StartOfLine</span></span></code></td>
+
+</tr>
+<tr>
+<td align="left" valign="top" >
+<code><span class="keyword">|</span></code></td>
+<td align="left" valign="top" >
+<code><span id="TYPEELTdest.EndOfLine"><span class="constructor">EndOfLine</span></span></code></td>
+
+</tr>
+<tr>
+<td align="left" valign="top" >
+<code><span class="keyword">|</span></code></td>
+<td align="left" valign="top" >
+<code><span id="TYPEELTdest.NextChar"><span class="constructor">NextChar</span></span></code></td>
+
+</tr>
+<tr>
+<td align="left" valign="top" >
+<code><span class="keyword">|</span></code></td>
+<td align="left" valign="top" >
+<code><span id="TYPEELTdest.PrevChar"><span class="constructor">PrevChar</span></span></code></td>
+
+</tr>
+<tr>
+<td align="left" valign="top" >
+<code><span class="keyword">|</span></code></td>
+<td align="left" valign="top" >
+<code><span id="TYPEELTdest.NextLine"><span class="constructor">NextLine</span></span></code></td>
+
+</tr>
+<tr>
+<td align="left" valign="top" >
+<code><span class="keyword">|</span></code></td>
+<td align="left" valign="top" >
+<code><span id="TYPEELTdest.PrevLine"><span class="constructor">PrevLine</span></span></code></td>
+
+</tr></table>
+
+
+
<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="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="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 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
+<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>
+<pre><span id="VALmove_to"><span class="keyword">val</span> move_to</span> : <code class="type"><a href="Buf.html#TYPEdest">dest</a> -> <a href="Buf.html#TYPEbuf">buf</a> -> int -> int</code></pre>
+<pre><span id="VALnextc"><span class="keyword">val</span> nextc</span> : <code class="type"><a href="Buf.html#TYPEbuf">buf</a> -> int -> int</code></pre>
+<pre><span id="VALprevc"><span class="keyword">val</span> prevc</span> : <code class="type"><a href="Buf.html#TYPEbuf">buf</a> -> int -> int</code></pre>
+<pre><span id="VALnextln"><span class="keyword">val</span> nextln</span> : <code class="type"><a href="Buf.html#TYPEbuf">buf</a> -> int -> int</code></pre>
+<pre><span id="VALprevln"><span class="keyword">val</span> prevln</span> : <code class="type"><a href="Buf.html#TYPEbuf">buf</a> -> int -> int</code></pre>
+<pre><span id="VALbol"><span class="keyword">val</span> bol</span> : <code class="type"><a href="Buf.html#TYPEbuf">buf</a> -> int -> int</code></pre>
+<pre><span id="VALeol"><span class="keyword">val</span> eol</span> : <code class="type"><a href="Buf.html#TYPEbuf">buf</a> -> int -> int</code></pre>
+<pre><span id="VALeol"><span class="keyword">val</span> eol</span> : <code class="type"><a href="Buf.html#TYPEbuf">buf</a> -> int -> int</code></pre>
+<pre><span id="VALis_at"><span class="keyword">val</span> is_at</span> : <code class="type"><a href="Buf.html#TYPEdest">dest</a> -> <a href="Buf.html#TYPEbuf">buf</a> -> int -> bool</code></pre>
+<pre><span id="VALis_bol"><span class="keyword">val</span> is_bol</span> : <code class="type"><a href="Buf.html#TYPEbuf">buf</a> -> int -> bool</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></body></html>
\ No newline at end of file
<pre><span id="VALfind_line"><span class="keyword">val</span> find_line</span> : <code class="type">'a array -> 'a -> int -> int</code></pre>
<pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type"><a href="Buf.html#TYPEt">Buf.t</a> -> int -> int -> <a href="Scrollmap.html#TYPEt">t</a></code></pre>
<pre><span id="VALfirst"><span class="keyword">val</span> first</span> : <code class="type"><a href="Scrollmap.html#TYPEt">t</a> -> int</code></pre>
-<pre><span id="VALbopl"><span class="keyword">val</span> bopl</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> int -> int</code></pre>
-<pre><span id="VALbonl"><span class="keyword">val</span> bonl</span> : <code class="type"><a href="Buf.html#TYPEbuf">Buf.buf</a> -> int -> int</code></pre>
<pre><span id="VALscroll_up"><span class="keyword">val</span> scroll_up</span> : <code class="type"><a href="Scrollmap.html#TYPEt">t</a> -> <a href="Buf.html#TYPEt">Buf.t</a> -> <a href="Scrollmap.html#TYPEt">t</a></code></pre>
<pre><span id="VALscroll_dn"><span class="keyword">val</span> scroll_dn</span> : <code class="type"><a href="Scrollmap.html#TYPEt">t</a> -> <a href="Buf.html#TYPEt">Buf.t</a> -> <a href="Scrollmap.html#TYPEt">t</a></code></pre>
<pre><span id="VALresize"><span class="keyword">val</span> resize</span> : <code class="type"><a href="Scrollmap.html#TYPEt">t</a> -> <a href="Buf.html#TYPEt">Buf.t</a> -> int -> <a href="Scrollmap.html#TYPEt">t</a></code></pre></body></html>
\ No newline at end of file
<tr><td align="left"><br>C</td></tr>
<tr><td><a href="Buf.Cursor.html#TYPEcsr">csr</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
<td></td></tr>
+<tr><td align="left"><br>D</td></tr>
+<tr><td><a href="Buf.html#TYPEdest">dest</a> [<a href="Buf.html">Buf</a>]</td>
+<td></td></tr>
<tr><td align="left"><br>F</td></tr>
<tr><td><a href="X11.html#TYPEfont">font</a> [<a href="X11.html">X11</a>]</td>
<td></td></tr>
<h1>Index of values</h1>
<table>
<tr><td align="left"><br>B</td></tr>
-<tr><td><a href="Scrollmap.html#VALbonl">bonl</a> [<a href="Scrollmap.html">Scrollmap</a>]</td>
+<tr><td><a href="Buf.Cursor.html#VALbol">bol</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
+<td></td></tr>
+<tr><td><a href="Buf.html#VALbol">bol</a> [<a href="Buf.html">Buf</a>]</td>
<td></td></tr>
<tr><td><a href="Cfg.Color.Syntax.html#VALboolean">boolean</a> [<a href="Cfg.Color.Syntax.html">Cfg.Color.Syntax</a>]</td>
<td></td></tr>
<tr><td><a href="Cfg.html#VALboolvar">boolvar</a> [<a href="Cfg.html">Cfg</a>]</td>
<td></td></tr>
-<tr><td><a href="Scrollmap.html#VALbopl">bopl</a> [<a href="Scrollmap.html">Scrollmap</a>]</td>
-<td></td></tr>
<tr><td><a href="Cfg.Color.html#VALborders">borders</a> [<a href="Cfg.Color.html">Cfg.Color</a>]</td>
<td></td></tr>
<tr><td><a href="Draw.html#VALbuffer">buffer</a> [<a href="Draw.html">Draw</a>]</td>
<td></td></tr>
<tr><td><a href="Rope.html#VALempty">empty</a> [<a href="Rope.html">Rope</a>]</td>
<td></td></tr>
+<tr><td><a href="Buf.Cursor.html#VALeol">eol</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
+<td></td></tr>
+<tr><td><a href="Buf.html#VALeol">eol</a> [<a href="Buf.html">Buf</a>]</td>
+<td></td></tr>
<tr><td><a href="X11.html#VALevent_loop">event_loop</a> [<a href="X11.html">X11</a>]</td>
<td></td></tr>
<tr><td><a href="Cfg.html#VALevent_timeout">event_timeout</a> [<a href="Cfg.html">Cfg</a>]</td>
<td></td></tr>
<tr><td><a href="Cfg.html#VALintvar">intvar</a> [<a href="Cfg.html">Cfg</a>]</td>
<td></td></tr>
+<tr><td><a href="Buf.Cursor.html#VALis_at">is_at</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
+<td></td></tr>
+<tr><td><a href="Buf.html#VALis_at">is_at</a> [<a href="Buf.html">Buf</a>]</td>
+<td></td></tr>
+<tr><td><a href="Buf.Cursor.html#VALis_bol">is_bol</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
+<td></td></tr>
+<tr><td><a href="Buf.html#VALis_bol">is_bol</a> [<a href="Buf.html">Buf</a>]</td>
+<td></td></tr>
<tr><td><a href="Rope.html#VALis_bol">is_bol</a> [<a href="Rope.html">Rope</a>]</td>
<td></td></tr>
<tr><td><a href="Buf.Cursor.html#VALis_eol">is_eol</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
<td></td></tr>
+<tr><td><a href="Buf.html#VALis_eol">is_eol</a> [<a href="Buf.html">Buf</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.Cursor.html#VALiter">iter</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
<td></td></tr>
<tr><td><a href="Rope.html#VALmove_till">move_till</a> [<a href="Rope.html">Rope</a>]</td>
<td></td></tr>
+<tr><td><a href="Buf.Cursor.html#VALmove_to">move_to</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
+<td></td></tr>
+<tr><td><a href="Buf.html#VALmove_to">move_to</a> [<a href="Buf.html">Buf</a>]</td>
+<td></td></tr>
<tr><td align="left"><br>N</td></tr>
<tr><td><a href="Draw.Cursor.html#VALnext_glyph">next_glyph</a> [<a href="Draw.Cursor.html">Draw.Cursor</a>]</td>
<td></td></tr>
<td></td></tr>
<tr><td><a href="Buf.Cursor.html#VALnextc">nextc</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
<td></td></tr>
+<tr><td><a href="Buf.html#VALnextc">nextc</a> [<a href="Buf.html">Buf</a>]</td>
+<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="Buf.Cursor.html#VALnextln">nextln</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
<td></td></tr>
+<tr><td><a href="Buf.html#VALnextln">nextln</a> [<a href="Buf.html">Buf</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="Buf.Cursor.html#VALprevc">prevc</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
<td></td></tr>
+<tr><td><a href="Buf.html#VALprevc">prevc</a> [<a href="Buf.html">Buf</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="Buf.Cursor.html#VALprevln">prevln</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
<td></td></tr>
+<tr><td><a href="Buf.html#VALprevln">prevln</a> [<a href="Buf.html">Buf</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="Cfg.Color.html#VALtags_sel">tags_sel</a> [<a href="Cfg.Color.html">Cfg.Color</a>]</td>
<td></td></tr>
-<tr><td><a href="Buf.Cursor.html#VALto_bol">to_bol</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
-<td></td></tr>
<tr><td><a href="Rope.html#VALto_bol">to_bol</a> [<a href="Rope.html">Rope</a>]</td>
<td></td></tr>
<tr><td><a href="Rope.html#VALto_eol">to_eol</a> [<a href="Rope.html">Rope</a>]</td>
(<span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> <span class="constructor">Rope</span>.rune <span class="keywordsign">-></span> bool) <span class="keywordsign">-></span><br>
<span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> unit<br>
<span class="keyword">val</span> getc : <span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> <span class="constructor">Rope</span>.rune<br>
+ <span class="keyword">val</span> move_to : <span class="constructor">Buf</span>.dest <span class="keywordsign">-></span> <span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> int<br>
<span class="keyword">val</span> nextc : <span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> int<br>
<span class="keyword">val</span> prevc : <span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> int<br>
<span class="keyword">val</span> nextln : <span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> int<br>
<span class="keyword">val</span> prevln : <span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> int<br>
+ <span class="keyword">val</span> bol : <span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> int<br>
+ <span class="keyword">val</span> eol : <span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> int<br>
+ <span class="keyword">val</span> is_at : <span class="constructor">Buf</span>.dest <span class="keywordsign">-></span> <span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> bool<br>
+ <span class="keyword">val</span> is_bol : <span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> bool<br>
<span class="keyword">val</span> is_eol : <span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> bool<br>
- <span class="keyword">val</span> to_bol : <span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr <span class="keywordsign">-></span> int<br>
<span class="keyword">end</span></code></body></html>
\ No newline at end of file
type t = buf
+type dest =
+ | StartOfLine | EndOfLine
+ | NextChar | PrevChar
+ | NextLine | PrevLine
+
let empty =
{ path = ""; rope = Rope.empty }
let getc buf csr =
Rope.getc buf.rope csr.stop
- let nextc buf csr =
- csr.stop <- (Rope.nextc buf.rope csr.stop); csr.stop
-
- let prevc buf csr =
- csr.stop <- (Rope.prevc buf.rope csr.stop); csr.stop
-
- let nextln buf csr =
- csr.stop <- (Rope.nextln buf.rope csr.stop); csr.stop
-
- let prevln buf csr =
- csr.stop <- (Rope.prevln buf.rope csr.stop); csr.stop
-
- let is_eol buf csr =
- Rope.is_eol buf.rope csr.stop
+ let move_to dest buf csr =
+ csr.stop <- (match dest with
+ | StartOfLine -> Rope.to_bol buf.rope csr.stop
+ | EndOfLine -> Rope.to_eol buf.rope csr.stop
+ | NextChar -> Rope.nextc buf.rope csr.stop
+ | PrevChar -> Rope.prevc buf.rope csr.stop
+ | NextLine -> Rope.nextln buf.rope csr.stop
+ | PrevLine -> Rope.prevln buf.rope csr.stop
+ );
+ csr.stop
- let to_bol buf csr =
- csr.stop <- (Rope.to_bol buf.rope csr.stop); csr.stop
+ let nextc = move_to NextChar
+ let prevc = move_to PrevChar
+ let nextln = move_to NextLine
+ let prevln = move_to PrevLine
+ let bol = move_to StartOfLine
+ let eol = move_to EndOfLine
+
+ let is_at dest buf csr =
+ match dest with
+ | StartOfLine -> Rope.is_bol buf.rope csr.stop
+ | EndOfLine -> Rope.is_eol buf.rope csr.stop
+ | _ -> false
+
+ let is_bol = is_at StartOfLine
+ let is_eol = is_at EndOfLine
end
+let move_to dest buf i =
+ Cursor.move_to dest buf (Cursor.make buf i)
+let nextc = move_to NextChar
+let prevc = move_to PrevChar
+let nextln = move_to NextLine
+let prevln = move_to PrevLine
+let bol = move_to StartOfLine
+let eol = move_to EndOfLine
+let eol = move_to EndOfLine
+
+let is_at dest buf i =
+ Cursor.is_at dest buf (Cursor.make buf i)
+let is_bol = is_at StartOfLine
+let is_eol = is_at EndOfLine
type buf
type t = buf
-val empty : t
-val load : string -> t
-val iter : (int -> bool) -> t -> int -> unit
-val iteri : (int -> int -> bool) -> t -> int -> unit
+type dest =
+ | StartOfLine | EndOfLine
+ | NextChar | PrevChar
+ | NextLine | PrevLine
module Cursor : sig
type t
+
val make : buf -> int -> t
val clone : t -> t
val iter : (t -> int -> bool) -> buf -> t -> unit
val offset : t -> int
val goto : buf -> t -> int -> unit
+
val getc : buf -> t -> int
(*
val putc : buf -> t -> int -> unit
val gets : buf -> t -> string
val puts : buf -> t -> string -> unit
*)
+
+ val move_to : dest -> buf -> t -> int
val nextc : buf -> t -> int
val prevc : buf -> t -> int
val nextln : buf -> t -> int
val prevln : buf -> t -> int
-(*
+ val bol : buf -> t -> int
+ val eol : buf -> t -> int
+
+ val is_at : dest -> buf -> t -> bool
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
+
+val empty : t
+val load : string -> t
+val iter : (int -> bool) -> t -> int -> unit
+val iteri : (int -> int -> bool) -> t -> int -> unit
+
+val move_to : dest -> t -> int -> int
+val nextc : t -> int -> int
+val prevc : t -> int -> int
+val nextln : t -> int -> int
+val prevln : t -> int -> int
+val bol : t -> int -> int
+val eol : t -> int -> int
+
+val is_at : dest -> t -> int -> bool
+val is_bol : t -> int -> bool
+val is_eol : t -> int -> bool
let make buf width off =
let csr = Draw.Cursor.make (width, 0) 0 0 in
- (*let bol = Buf.goto StartOfLine buf off in*)
- let bol = Buf.Cursor.to_bol buf (Buf.Cursor.make buf off) in
+ let bol = Buf.bol buf off in
let lines = ref [bol] in
let process_glyph i c =
let not_eol = (c != 0x0A) in
let first map =
map.lines.(map.index)
-let bopl buf off =
- Buf.Cursor.prevln buf (Buf.Cursor.make buf off)
-
-let bonl buf off =
- Buf.Cursor.nextln buf (Buf.Cursor.make buf off)
-
let scroll_up map buf =
let next = map.index - 1 in
if (next >= 0) then
{ map with index = next }
else
- make buf map.width (bopl buf map.lines.(0))
+ let off = map.lines.(0) in
+ make buf map.width (Buf.prevln buf off)
let scroll_dn map buf =
let next = map.index + 1 in
if (next < (Array.length map.lines)) then
{ map with index = next }
else
- make buf map.width (bonl buf map.lines.((Array.length map.lines) - 1))
+ let off = map.lines.((Array.length map.lines) - 1) in
+ make buf map.width (Buf.nextln buf off)
let resize map buf width =
if map.width == width then map