From: Michael D. Lowis Date: Tue, 7 Nov 2017 15:41:01 +0000 (-0500) Subject: Removed rope accessor from buf.ml and switched scrollmap completely over to cursor... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=ac9f1fcea847f38c4601d5c9dd32905e3203f5f2;p=archive%2Ftide-ocaml.git Removed rope accessor from buf.ml and switched scrollmap completely over to cursor usage --- diff --git a/docs/Buf.Cursor.html b/docs/Buf.Cursor.html index e9499e0..0ee7c57 100644 --- a/docs/Buf.Cursor.html +++ b/docs/Buf.Cursor.html @@ -54,4 +54,6 @@
val nextc : Buf.buf -> csr -> int
val prevc : Buf.buf -> csr -> int
val nextln : Buf.buf -> csr -> int
-
val prevln : Buf.buf -> csr -> int
\ No newline at end of file +
val prevln : Buf.buf -> csr -> int
+
val is_eol : Buf.buf -> csr -> bool
+
val to_bol : Buf.buf -> csr -> int
\ No newline at end of file diff --git a/docs/Buf.html b/docs/Buf.html index 9a579ca..15b942c 100644 --- a/docs/Buf.html +++ b/docs/Buf.html @@ -53,7 +53,7 @@
val empty : buf
val load : string -> buf
-
val rope : buf -> Rope.t
val iter_from : (Rope.rune -> bool) -> buf -> int -> unit
val iteri_from : (int -> Rope.rune -> bool) -> buf -> int -> unit
+
val is_eol : buf -> int -> bool
module Cursor: sig .. end
\ No newline at end of file diff --git a/docs/index_values.html b/docs/index_values.html index 481f44d..8c16029 100644 --- a/docs/index_values.html +++ b/docs/index_values.html @@ -157,6 +157,10 @@ is_bol [Rope] +is_eol [Buf.Cursor] + +is_eol [Buf] + is_eol [Rope] iter_from [Buf] @@ -263,8 +267,6 @@ restart [Draw.Cursor] -rope [Buf] - rule_bkg [Draw] ruler_column [Cfg] @@ -315,6 +317,8 @@ tags_sel [Cfg.Color] +to_bol [Buf.Cursor] + to_bol [Rope] to_eol [Rope] diff --git a/docs/type_Buf.Cursor.html b/docs/type_Buf.Cursor.html index bf0d467..fe50066 100644 --- a/docs/type_Buf.Cursor.html +++ b/docs/type_Buf.Cursor.html @@ -27,4 +27,6 @@   val prevc : Buf.buf -> Buf.Cursor.csr -> int
  val nextln : Buf.buf -> Buf.Cursor.csr -> int
  val prevln : Buf.buf -> Buf.Cursor.csr -> int
+  val is_eol : Buf.buf -> Buf.Cursor.csr -> bool
+  val to_bol : Buf.buf -> Buf.Cursor.csr -> int
end \ No newline at end of file diff --git a/lib/buf.ml b/lib/buf.ml index 2dd9911..cdefefb 100644 --- a/lib/buf.ml +++ b/lib/buf.ml @@ -11,15 +11,15 @@ let empty = let load path = { path = path; rope = Rope.from_string (Misc.load_file path) } -let rope buf = (* DELETEME *) - buf.rope - 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 +let is_eol buf off = + Rope.is_eol buf.rope off + module Cursor = struct type csr = { mutable start : int; @@ -51,5 +51,11 @@ module Cursor = struct 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 to_bol buf csr = + csr.stop <- (Rope.to_bol buf.rope csr.stop); csr.stop end diff --git a/lib/buf.mli b/lib/buf.mli index b565d38..12b49c2 100644 --- a/lib/buf.mli +++ b/lib/buf.mli @@ -2,13 +2,15 @@ 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 +val is_eol : buf -> int -> bool + module Cursor : sig type t val make : buf -> int -> t + val offset : buf -> t -> int val goto : buf -> t -> int -> unit val getc : buf -> t -> int (* @@ -20,4 +22,7 @@ module Cursor : sig val prevc : buf -> t -> int val nextln : buf -> t -> int val prevln : buf -> t -> int + + val is_eol : buf -> t -> bool + val to_bol : buf -> t -> int end diff --git a/lib/scrollmap.ml b/lib/scrollmap.ml index 52ec4ef..01914d6 100644 --- a/lib/scrollmap.ml +++ b/lib/scrollmap.ml @@ -11,12 +11,12 @@ let rec find_line lines off idx = idx let make buf width off = - let csr = Draw.Cursor.make (width, 0) 0 0 in - let bol = (Rope.to_bol (Buf.rope buf) off) in - let lines = ref [bol] in + let bcsr = Buf.Cursor.make buf off in + let dcsr = Draw.Cursor.make (width, 0) 0 0 in + let lines = ref [Buf.Cursor.to_bol buf bcsr] in let process_glyph i c = - let not_eol = ((Rope.is_eol (Buf.rope buf) i) == false) in - if (Draw.Cursor.next_glyph csr c) && not_eol then + let not_eol = ((Buf.is_eol buf i) == false) in + if (Draw.Cursor.next_glyph dcsr c) && not_eol then lines := i :: !lines; not_eol in