(* Mouse Actions
******************************************************************************)
let onselect mods x y nclicks =
- let pos = (View.get_at !edit_view x y) in
- edit_view := View.select !edit_view pos pos
+ Printf.printf "select (%d,%d) %d" x y nclicks;
+ print_endline "";
+ edit_view := View.select !edit_view (View.get_at !edit_view x y)
let onexec mods x y nclicks =
Printf.printf "exec (%d,%d) %d" x y nclicks;
| _ -> ()
let onmousemove mods x y =
- Printf.printf "click (%d,%d)" x y;
- print_endline ""
+ Printf.printf "select (%d,%d)" x y;
+ print_endline "";
+ edit_view := View.select ~extend:true !edit_view (View.get_at !edit_view x y)
let onupdate width height =
let csr = Draw.Cursor.make (width, height) 0 0 in
csr
let initial =
- { start = 0; stop = 1 }
+ { start = 0; stop = 0 }
let make buf idx =
- { start = 0; stop = (Rope.limit_index buf.rope idx) }
+ let idx = (Rope.limit_index buf.rope idx) in
+ { start = idx; stop = idx }
+
+ let select buf start stop =
+ { start = (Rope.limit_index buf.rope start);
+ stop = (Rope.limit_index buf.rope stop) }
let move_to dest buf csr =
csr.stop <- (match dest with
let csrpos buf =
Cursor.stop buf.cursor
+let csrrange buf =
+ (buf.cursor.start, buf.cursor.stop)
+
let selected buf pos =
Cursor.selected buf.cursor pos
})
let select buf start stop =
- { buf with cursor = Cursor.make buf start }
+ Printf.printf "Buf.select %d %d\n" start stop;
+ print_endline "";
+ { buf with cursor = Cursor.select buf start stop }
(*
let clone csr =
val iteri : (int -> int -> bool) -> t -> int -> unit
val iter : (int -> bool) -> t -> int -> unit
val csrpos : t -> int
+val csrrange : t -> (int * int)
+
val selected : t -> int -> bool
val make_lexer : t -> Colormap.lexer
val select : t -> int -> int -> t
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
+ { view with buf = Buf.select view.buf start pos }
+ else
+ { view with buf = Buf.select view.buf pos pos }
+
+
let path view =
Buf.path view.buf