From d1b5af8aa838e30440ce80ad859ab999912b1c63 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Tue, 7 Nov 2017 08:42:35 -0500 Subject: [PATCH] Switched scrollmap over to using the cursor --- docs/Buf.Cursor.html | 9 +++++---- docs/Scrollmap.html | 4 ++-- docs/X11.html | 8 ++------ docs/index.html | 4 +--- docs/index_modules.html | 4 +--- docs/index_values.html | 6 +++--- docs/type_Buf.Cursor.html | 9 +++++---- lib/buf.ml | 11 +++++++---- lib/buf.mli | 8 ++++---- lib/scrollmap.ml | 6 ++++-- 10 files changed, 34 insertions(+), 35 deletions(-) diff --git a/docs/Buf.Cursor.html b/docs/Buf.Cursor.html index eba0995..e9499e0 100644 --- a/docs/Buf.Cursor.html +++ b/docs/Buf.Cursor.html @@ -48,9 +48,10 @@
val make : Buf.buf -> int -> csr
+
val offset : 'a -> csr -> int
val goto : Buf.buf -> csr -> int -> unit
val getc : Buf.buf -> csr -> Rope.rune
-
val nextc : Buf.buf -> csr -> unit
-
val prevc : Buf.buf -> csr -> unit
-
val nextln : Buf.buf -> csr -> unit
-
val prevln : Buf.buf -> csr -> unit
\ No newline at end of file +
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 diff --git a/docs/Scrollmap.html b/docs/Scrollmap.html index 0af79ac..ce83037 100644 --- a/docs/Scrollmap.html +++ b/docs/Scrollmap.html @@ -56,8 +56,8 @@
val find_line : 'a array -> 'a -> int -> int
val make : Buf.t -> int -> int -> t
val first : t -> int
-
val bopl : Buf.t -> int -> int
-
val bonl : Buf.t -> int -> int
+
val bopl : Buf.buf -> int -> int
+
val bonl : Buf.buf -> int -> int
val scroll_up : t -> Buf.t -> t
val scroll_dn : t -> Buf.t -> t
val resize : t -> Buf.t -> int -> t
\ No newline at end of file diff --git a/docs/X11.html b/docs/X11.html index 130a69d..41d086d 100644 --- a/docs/X11.html +++ b/docs/X11.html @@ -27,9 +27,7 @@

Module X11

-
module X11: sig .. end
-
-
+
module X11: sig .. end

type xatom 
@@ -473,9 +471,7 @@
val font_load : string -> font
val font_glyph : font -> int -> glyph
val draw_glyph : int -> glyph -> int * int -> int
-
val glyph_cache : (int, glyph) Hashtbl.t
-
- +
val glyph_cache : (int, glyph) Hashtbl.t
val cache_update : int -> glyph -> glyph
val get_glyph : font -> int -> glyph
val draw_rune : font -> int -> int -> int * int -> int
diff --git a/docs/index.html b/docs/index.html index 316de90..995df80 100644 --- a/docs/index.html +++ b/docs/index.html @@ -28,9 +28,7 @@

- + diff --git a/docs/index_modules.html b/docs/index_modules.html index 1cb5199..f7ab3ae 100644 --- a/docs/index_modules.html +++ b/docs/index_modules.html @@ -54,9 +54,7 @@ - +
Misc
X11
-
-
X11
Cfg
Rope
Buf

X
X11
-
-
\ No newline at end of file diff --git a/docs/index_values.html b/docs/index_values.html index 527dc7e..481f44d 100644 --- a/docs/index_values.html +++ b/docs/index_values.html @@ -134,9 +134,7 @@ gets [Rope] glyph_cache [X11] -
-
- + glyph_width [Draw] goto [Buf.Cursor] @@ -229,6 +227,8 @@ number [Cfg.Color.Syntax]
O +offset [Buf.Cursor] + operator [Cfg.Color.Syntax]
P diff --git a/docs/type_Buf.Cursor.html b/docs/type_Buf.Cursor.html index 0c8a7e4..bf0d467 100644 --- a/docs/type_Buf.Cursor.html +++ b/docs/type_Buf.Cursor.html @@ -20,10 +20,11 @@   type csr = { mutable start : int; mutable stop : int; }
  type t = Buf.Cursor.csr
  val make : Buf.buf -> int -> Buf.Cursor.csr
+  val offset : '-> Buf.Cursor.csr -> int
  val goto : Buf.buf -> Buf.Cursor.csr -> int -> unit
  val getc : Buf.buf -> Buf.Cursor.csr -> Rope.rune
-  val nextc : Buf.buf -> Buf.Cursor.csr -> unit
-  val prevc : Buf.buf -> Buf.Cursor.csr -> unit
-  val nextln : Buf.buf -> Buf.Cursor.csr -> unit
-  val prevln : Buf.buf -> Buf.Cursor.csr -> unit
+  val nextc : Buf.buf -> Buf.Cursor.csr -> int
+  val prevc : Buf.buf -> Buf.Cursor.csr -> int
+  val nextln : Buf.buf -> Buf.Cursor.csr -> int
+  val prevln : Buf.buf -> Buf.Cursor.csr -> int
end \ No newline at end of file diff --git a/lib/buf.ml b/lib/buf.ml index fc71ccd..2dd9911 100644 --- a/lib/buf.ml +++ b/lib/buf.ml @@ -31,6 +31,9 @@ module Cursor = struct let make buf idx = { start = 0; stop = (Rope.limit_index buf.rope idx) } + let offset buf csr = + csr.stop + let goto buf csr idx = csr.stop <- (Rope.limit_index buf.rope idx) @@ -38,15 +41,15 @@ module Cursor = struct Rope.getc buf.rope csr.stop let nextc buf csr = - csr.stop <- (Rope.nextc buf.rope csr.stop) + csr.stop <- (Rope.nextc buf.rope csr.stop); csr.stop let prevc buf csr = - csr.stop <- (Rope.prevc buf.rope csr.stop) + csr.stop <- (Rope.prevc buf.rope csr.stop); csr.stop let nextln buf csr = - csr.stop <- (Rope.nextln buf.rope csr.stop) + csr.stop <- (Rope.nextln buf.rope csr.stop); csr.stop let prevln buf csr = - csr.stop <- (Rope.prevln buf.rope csr.stop) + csr.stop <- (Rope.prevln buf.rope csr.stop); csr.stop end diff --git a/lib/buf.mli b/lib/buf.mli index 0aa7f06..b565d38 100644 --- a/lib/buf.mli +++ b/lib/buf.mli @@ -16,8 +16,8 @@ module Cursor : sig val gets : buf -> t -> string val puts : buf -> t -> string -> unit *) - val nextc : buf -> t -> unit - val prevc : buf -> t -> unit - val nextln : buf -> t -> unit - val prevln : buf -> t -> unit + val nextc : buf -> t -> int + val prevc : buf -> t -> int + val nextln : buf -> t -> int + val prevln : buf -> t -> int end diff --git a/lib/scrollmap.ml b/lib/scrollmap.ml index 7f8682d..52ec4ef 100644 --- a/lib/scrollmap.ml +++ b/lib/scrollmap.ml @@ -28,9 +28,11 @@ let make buf width off = let first map = map.lines.(map.index) -let bopl buf off = (Rope.prevln (Buf.rope buf) off) +let bopl buf off = + Buf.Cursor.prevln buf (Buf.Cursor.make buf off) -let bonl buf off = (Rope.nextln (Buf.rope 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 -- 2.52.0