]> git.mdlowis.com Git - archive/tide-ocaml.git/commitdiff
minor refactoring
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 26 Jan 2018 02:12:57 +0000 (21:12 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 26 Jan 2018 02:12:57 +0000 (21:12 -0500)
deps.mk
edit.ml
lib/rope.mli
lib/view.ml
lib/view.mli [new file with mode: 0644]

diff --git a/deps.mk b/deps.mk
index ebb53f0238c311cb9fa91943d7daaf21bd8bb128..96700839022705f17b5b40bbb2c92bc57ea99d22 100644 (file)
--- a/deps.mk
+++ b/deps.mk
@@ -19,8 +19,9 @@ lib/rope.cmi :
 lib/scrollmap.cmo : lib/draw.cmi lib/buf.cmi lib/scrollmap.cmi lib/scrollmap.ml
 lib/scrollmap.cmx lib/scrollmap.o : lib/draw.cmi lib/draw.cmx lib/buf.cmi lib/buf.cmx lib/scrollmap.cmi lib/scrollmap.ml
 lib/scrollmap.cmi : lib/buf.cmi
-lib/view.cmo lib/view.cmi : lib/scrollmap.cmi lib/draw.cmi lib/colormap.cmi lib/buf.cmi lib/view.ml
-lib/view.cmx lib/view.o lib/view.cmi : lib/scrollmap.cmi lib/scrollmap.cmx lib/draw.cmi lib/draw.cmx lib/colormap.cmi lib/colormap.cmx lib/buf.cmi lib/buf.cmx lib/view.ml
+lib/view.cmo : lib/scrollmap.cmi lib/draw.cmi lib/colormap.cmi lib/buf.cmi lib/view.cmi lib/view.ml
+lib/view.cmx lib/view.o : lib/scrollmap.cmi lib/scrollmap.cmx lib/draw.cmi lib/draw.cmx lib/colormap.cmi lib/colormap.cmx lib/buf.cmi lib/buf.cmx lib/view.cmi lib/view.ml
+lib/view.cmi : lib/draw.cmi lib/buf.cmi
 lib/x11.cmo lib/x11.cmi : lib/x11.ml
 lib/x11.cmx lib/x11.o lib/x11.cmi : lib/x11.ml
 tests/buf_tests.cmo tests/buf_tests.cmi : tests/buf_tests.ml
diff --git a/edit.ml b/edit.ml
index a7cfdd6fb3b235f3d8b82198812d5d68ef001e20..c174ac70e00d7073566ada089b4cd03dc0bdbc20 100644 (file)
--- a/edit.ml
+++ b/edit.ml
@@ -18,7 +18,7 @@ let scroll_dn () =
 let onselect mods x y nclicks =
   Printf.printf "select (%d,%d) %d" x y nclicks;
   print_endline "";
-  edit_view := View.select !edit_view (View.get_at !edit_view x y)
+  edit_view := View.select_at !edit_view x y
 
 let onexec mods x y nclicks =
   Printf.printf "exec (%d,%d) %d" x y nclicks;
@@ -48,7 +48,7 @@ let onmousebtn mods btn x y pressed nclicks =
 let onmousemove mods x y =
   Printf.printf "select (%d,%d)" x y;
   print_endline "";
-  edit_view := View.select ~extend:true !edit_view (View.get_at !edit_view x y)
+  edit_view := View.select_at ~extend:true !edit_view x y
 
 let onupdate width height =
   let csr = Draw.Cursor.make (width, height) 0 0 in
index ed40cb59a2d25b226c8bf98d6aa0273989c44924..ca1460a0725f00e39ec27700b5ec8cd8d2df5a0e 100644 (file)
@@ -42,4 +42,3 @@ val is_eol : rope -> int -> bool
 
 val to_bol : rope -> int -> int
 val to_eol : rope -> int -> int
-
index e2026beeedd2e529a0b296f48d24d9ad06d6d56c..8f0fde9db5692f3035fba010854807bfc7eb553c 100644 (file)
@@ -45,9 +45,6 @@ let get_at view x y =
   in
   get_col_offset view.buf off (w - sx) (x - sx)
 
-let select view start stop =
-  { view with buf = Buf.select view.buf start stop }
-
 let select ?extend:(ext=false) view pos =
   let start,stop = Buf.csrrange view.buf in
   if ext then
@@ -55,6 +52,8 @@ let select ?extend:(ext=false) view pos =
   else
     { view with buf = Buf.select view.buf pos pos }
 
+let select_at ?extend:(ext=false) view x y =
+  select ~extend:ext view (get_at view x y)
 
 let path view =
   Buf.path view.buf
diff --git a/lib/view.mli b/lib/view.mli
new file mode 100644 (file)
index 0000000..a5048ca
--- /dev/null
@@ -0,0 +1,15 @@
+type t
+
+val from_buffer : Buf.t -> int -> int -> t
+val empty : int -> int -> t
+val make : int -> int -> string -> t
+
+val path : t -> string
+val draw : t -> Draw.Cursor.t -> t
+
+val scroll_up : t -> t
+val scroll_dn : t -> t
+val scroll_params : t -> (float * float)
+
+val select : ?extend:bool -> t -> int -> t
+val select_at : ?extend:bool -> t -> int -> int -> t