(* Mouse Actions
******************************************************************************)
let onselect mods x y nclicks =
- let sx,sy = !edit_view.pos and w,h = !edit_view.dim in
- Printf.printf "select (%d,%d) %d" x y nclicks;
- print_endline ""
+ let pos = (View.get_at !edit_view x y) in
+ edit_view := View.select !edit_view pos pos
let onexec mods x y nclicks =
Printf.printf "exec (%d,%d) %d" x y nclicks;
!count)
})
+let select buf start stop =
+ { buf with cursor = Cursor.make buf start }
+
(*
let clone csr =
{ start = csr.start; stop = csr.stop }
val csrpos : t -> int
val selected : t -> int -> bool
val make_lexer : t -> Colormap.lexer
+val select : t -> int -> int -> t
val nextln : t -> int -> int
val prevln : t -> int -> int
let make width height path =
from_buffer (Buf.load path) width height
+let get_at view x y =
+ let sx,sy = view.pos and w,h = view.dim in
+ try List.nth view.lines ((h - (y + 2)) / Draw.font.height)
+ with Failure _ -> Buf.length view.buf
+
+let select view start stop =
+ { view with buf = Buf.select view.buf start stop }
+
let path view =
Buf.path view.buf