From: Michael D. Lowis Date: Mon, 19 Feb 2018 02:45:41 +0000 (-0500) Subject: rework event handlers in preparation for region focus handling X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=bb6472fe1be06cf4e1fc3ca027f7596b567147f8;p=archive%2Ftide-ocaml.git rework event handlers in preparation for region focus handling --- diff --git a/edit.ml b/edit.ml index d7e0e84..4854514 100644 --- a/edit.ml +++ b/edit.ml @@ -3,36 +3,53 @@ open X11 let edit_view = ref (View.empty 640 480) let tags_view = ref (View.empty 640 480) -let scroll_up () = +(* Mouse Actions + ******************************************************************************) +let scroll_up view = for i = 1 to 4 do - edit_view := View.scroll_up !edit_view + view := View.scroll_up !view done -let scroll_dn () = +let scroll_dn view = for i = 1 to 4 do - edit_view := View.scroll_dn !edit_view + view := View.scroll_dn !view done +let select_at view x y = + view := View.select_at !view x y + +let select_ctx_at view x y = () + (*view := View.select_ctx_at !view x y*) + +let select_line_at view x y = () + (*view := View.select_line_at !view x y*) + +let exec_at view x y = + view := View.exec_at !view x y + +let fetch_at view x y = + view := View.fetch_at !view x y + (* Mouse Actions ******************************************************************************) let onselect mods x y nclicks = Printf.printf "select (%d,%d) %d" x y nclicks; print_endline ""; match nclicks with - | 1 -> edit_view := View.select_at !edit_view x y - | 2 -> () (* edit_view := View.select_ctx_at !edit_view x y *) - | 3 -> () (* edit_view := View.select_line_at !edit_view x y *) + | 1 -> select_at edit_view x y + | 2 -> select_ctx_at edit_view x y + | 3 -> select_line_at edit_view x y | _ -> () let onexec mods x y nclicks = Printf.printf "exec (%d,%d) %d" x y nclicks; print_endline ""; - edit_view := View.exec_at !edit_view x y + exec_at edit_view x y let onfetch mods x y nclicks = Printf.printf "fetch (%d,%d) %d" x y nclicks; print_endline ""; - edit_view := View.fetch_at !edit_view x y + fetch_at edit_view x y (* Event functions ******************************************************************************) @@ -47,8 +64,8 @@ let onmousebtn mods btn x y pressed nclicks = | 1 -> onselect mods x y nclicks | 2 -> onexec mods x y nclicks | 3 -> onfetch mods x y nclicks - | 4 -> scroll_up () - | 5 -> scroll_dn () + | 4 -> scroll_up edit_view + | 5 -> scroll_dn edit_view | _ -> () let onmousemove mods x y =