<pre><span class="keyword">module</span> Cursor: <code class="code">sig</code> <a href="Buf.Cursor.html">..</a> <code class="code">end</code></pre><hr width="100%">
-<pre><code><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> = {</code></pre><table class="typetable">
+<pre><code><span id="TYPEcsr"><span class="keyword">type</span> <code class="type"></code>csr</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
-<code><span id="TYPEELTt.start">start</span> : <code class="type">int</code>;</code></td>
+<code><span class="keyword">mutable </span><span id="TYPEELTcsr.start">start</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
-<code><span id="TYPEELTt.stop">stop</span> : <code class="type">int</code>;</code></td>
-
-</tr>
-<tr>
-<td align="left" valign="top" >
-<code> </code></td>
-<td align="left" valign="top" >
-<code><span id="TYPEELTt.column">column</span> : <code class="type">int</code>;</code></td>
+<code><span class="keyword">mutable </span><span id="TYPEELTcsr.stop">stop</span> : <code class="type">int</code>;</code></td>
</tr></table>
}
-<pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type">int -> int -> <a href="Buf.Cursor.html#TYPEt">t</a></code></pre>
-<pre><span id="VALclone"><span class="keyword">val</span> clone</span> : <code class="type"><a href="Buf.Cursor.html#TYPEt">t</a> -> <a href="Buf.Cursor.html#TYPEt">t</a></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.Cursor.html#TYPEcsr">csr</a></code> </pre>
+
+
+<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="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="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> -> unit</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> -> unit</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> -> unit</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> -> unit</code></pre></body></html>
\ No newline at end of file
<pre><span class="keyword">module</span> Buf: <code class="code">sig</code> <a href="Buf.html">..</a> <code class="code">end</code></pre><hr width="100%">
-<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><code><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> = {</code></pre><table class="typetable">
+<pre><code><span id="TYPEbuf"><span class="keyword">type</span> <code class="type"></code>buf</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
-<code><span id="TYPEELTt.path">path</span> : <code class="type">string</code>;</code></td>
+<code><span id="TYPEELTbuf.path">path</span> : <code class="type">string</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
-<code><span id="TYPEELTt.rope">rope</span> : <code class="type"><a href="Rope.html#TYPEt">Rope.t</a></code>;</code></td>
+<code><span id="TYPEELTbuf.rope">rope</span> : <code class="type"><a href="Rope.html#TYPEt">Rope.t</a></code>;</code></td>
</tr></table>
}
-<pre><span id="VALempty"><span class="keyword">val</span> empty</span> : <code class="type"><a href="Buf.html#TYPEt">t</a></code></pre>
-<pre><span id="VALload"><span class="keyword">val</span> load</span> : <code class="type">string -> <a href="Buf.html#TYPEt">t</a></code></pre>
-<pre><span id="VALrope"><span class="keyword">val</span> rope</span> : <code class="type"><a href="Buf.html#TYPEt">t</a> -> <a href="Rope.html#TYPEt">Rope.t</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#TYPEt">t</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#TYPEt">t</a> -> int -> unit</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><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="VALrope"><span class="keyword">val</span> rope</span> : <code class="type"><a href="Buf.html#TYPEbuf">buf</a> -> <a href="Rope.html#TYPEt">Rope.t</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 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
</div>
<h1>Index of types</h1>
<table>
+<tr><td align="left"><br>B</td></tr>
+<tr><td><a href="Buf.html#TYPEbuf">buf</a> [<a href="Buf.html">Buf</a>]</td>
+<td></td></tr>
+<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>F</td></tr>
<tr><td><a href="X11.html#TYPEfont">font</a> [<a href="X11.html">X11</a>]</td>
<td></td></tr>
<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="Draw.html#VALglyph_width">glyph_width</a> [<a href="Draw.html">Draw</a>]</td>
<td></td></tr>
+<tr><td><a href="Buf.Cursor.html#VALgoto">goto</a> [<a href="Buf.Cursor.html">Buf.Cursor</a>]</td>
+<td></td></tr>
<tr><td><a href="Cfg.Color.html#VALgutter_nor">gutter_nor</a> [<a href="Cfg.Color.html">Cfg.Color</a>]</td>
<td></td></tr>
<tr><td><a href="Cfg.Color.html#VALgutter_sel">gutter_sel</a> [<a href="Cfg.Color.html">Cfg.Color</a>]</td>
<td></td></tr>
<tr><td><a href="Draw.Cursor.html#VALnext_line">next_line</a> [<a href="Draw.Cursor.html">Draw.Cursor</a>]</td>
<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="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="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#VALpreproc">preproc</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="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="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>
</head>
<body>
<code class="code"><span class="keyword">sig</span><br>
- <span class="keyword">type</span> t = { start : int; stop : int; column : int; }<br>
- <span class="keyword">val</span> make : int <span class="keywordsign">-></span> int <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.t<br>
- <span class="keyword">val</span> clone : <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.t <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.t<br>
+ <span class="keyword">type</span> csr = { <span class="keyword">mutable</span> start : int; <span class="keyword">mutable</span> stop : int; }<br>
+ <span class="keyword">type</span> t = <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr<br>
+ <span class="keyword">val</span> make : <span class="constructor">Buf</span>.buf <span class="keywordsign">-></span> int <span class="keywordsign">-></span> <span class="constructor">Buf</span>.<span class="constructor">Cursor</span>.csr<br>
+ <span class="keyword">val</span> goto : <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 <span class="keywordsign">-></span> unit<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> unit<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> unit<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> unit<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> unit<br>
<span class="keyword">end</span></code></body></html>
\ No newline at end of file
-module Cursor = struct
- type t = {
- start : int;
- stop : int;
- column : int;
- }
-
- let make start stop =
- { start = start; stop = stop; column = 0 }
-
- let clone csr =
- { start = csr.start; stop = csr.stop; column = csr.column }
-end
-
-type t = {
+type buf = {
path : string;
rope : Rope.t
}
+type t = buf
let empty =
{ path = ""; rope = Rope.empty }
let iteri_from fn buf i =
Rope.iteri_from fn buf.rope i
+
+module Cursor = struct
+ type csr = {
+ mutable start : int;
+ mutable stop : int
+ }
+
+ type t = csr
+
+ let make buf idx =
+ { start = 0; stop = (Rope.limit_index buf.rope idx) }
+
+ let goto buf csr idx =
+ csr.stop <- (Rope.limit_index buf.rope idx)
+
+ let getc buf csr =
+ Rope.getc buf.rope csr.stop
+
+ let nextc buf csr =
+ csr.stop <- (Rope.nextc buf.rope csr.stop)
+
+ let prevc buf csr =
+ csr.stop <- (Rope.prevc buf.rope csr.stop)
+
+ let nextln buf csr =
+ csr.stop <- (Rope.nextln buf.rope csr.stop)
+
+ let prevln buf csr =
+ csr.stop <- (Rope.prevln buf.rope csr.stop)
+end
+
-(*
-module Cursor : sig
- type t
- val to_offset : t -> int
- val next_rune : t -> t
- val prev_rune : t -> t
- val next_line : t -> t
- val prev_line : t -> t
-end
-*)
-
-type t
+type buf
+type t = buf
val empty : t
val load : string -> t
val rope : t -> Rope.t
val iter_from : (int -> bool) -> t -> int -> unit
val iteri_from : (int -> int -> bool) -> t -> int -> unit
+
+module Cursor : sig
+ type t
+ val make : buf -> int -> t
+ val goto : buf -> t -> int -> unit
+ val getc : buf -> t -> int
+ val nextc : buf -> t -> unit
+ val prevc : buf -> t -> unit
+ val nextln : buf -> t -> unit
+ val prevln : buf -> t -> unit
+end