ocamldoc -d docs -html -I lib $(LIBSRCS)
# Dependency generation
-deps deps.mk: $(wildcard *.ml* lib/*.ml* tests/*.ml*)
+deps: deps.mk
+deps.mk: $(wildcard *.ml* lib/*.ml* tests/*.ml*)
ocamldep -I . -I lib/ -I tests/ -all -one-line $^ > deps.mk
-include deps.mk
edit_view := View.scroll_dn !edit_view
done
+(* Mouse Actions
+ ******************************************************************************)
+let onselect mods x y nclicks =
+ let sx,sy = !edit_view.pos and w,h = !edit_view.dim in
+ Printf.printf "lines: %d\n" ((h - sy) / Draw.font.height);
+ Printf.printf "select (%d,%d) %d" x y nclicks;
+ print_endline ""
+
+let onexec mods x y nclicks =
+ Printf.printf "exec (%d,%d) %d" x y nclicks;
+ print_endline ""
+
+let onfetch mods x y nclicks =
+ Printf.printf "fetch (%d,%d) %d" x y nclicks;
+ print_endline ""
+
(* Event functions
******************************************************************************)
-let onfocus focused = ()
+let onfocus focused =
+ Printf.printf "focused %b" focused;
+ print_endline ""
let onkeypress mods rune = ()
-let onmousebtn mods btn x y pressed =
+let onmousebtn mods btn x y pressed nclicks =
if pressed then match btn with
- | 1 -> ()
- | 2 -> ()
- | 3 -> ()
+ | 1 -> onselect mods x y nclicks
+ | 2 -> onexec mods x y nclicks
+ | 3 -> onfetch mods x y nclicks
| 4 -> scroll_up ()
| 5 -> scroll_dn ()
| _ -> ()
-let onmousemove mods x y = ()
+let onmousemove mods x y =
+ Printf.printf "click (%d,%d)" x y;
+ print_endline ""
let onupdate width height =
let csr = Draw.Cursor.make (width, height) 0 0 in
try match evnt with
| Focus state -> onfocus state
| KeyPress e -> onkeypress e.mods e.rune
- | MouseClick e -> onmousebtn e.mods e.btn e.x e.y true
- | MouseRelease e -> onmousebtn e.mods e.btn e.x e.y false
+ | MouseClick e -> onmousebtn e.mods e.btn e.x e.y true e.nclicks
+ | MouseRelease e -> onmousebtn e.mods e.btn e.x e.y false 1
| MouseMove e -> onmousemove e.mods e.x e.y
| Paste e -> () (*print_endline "paste"*)
| Command e -> () (*print_endline "command"*)
(* tags region default contents *)
let edit_tags = strvar "tide.ui.tags.edit"
"Quit Save Undo Redo Cut Copy Paste | Find "
-let cmd_tags = strvar "tide.ui.font"
+let cmd_tags = strvar "tide.ui.tags.cmd"
"Quit Undo Redo Cut Copy Paste | Send Find "
(* font settings *)
-let font = strvar "tide.ui.tags.edit" "Verdana:size=11"
-let line_spacing = intvar "tide.ui.line_spacing" 1
+let font = strvar "tide.ui.font" "Verdana:size=11"
+(*let line_spacing = intvar "tide.ui.line_spacing" 1*)
(* user interface related options *)
+(*
let winwidth = intvar "tide.ui.width" 640
let winheight = intvar "tide.ui.height" 480
let line_nums = boolvar "tide.ui.line_numbers" true
let syntax_enabled = boolvar "tide.ui.syntax_enabled" true
let ruler_column = intvar "tide.ui.rulercolumn" 80
let event_timeout = intvar "tide.ui.timeout" 50
+*)
(* input related options *)
+(*
let copy_indent = boolvar "tide.input.copy_indent" true
let trim_on_save = boolvar "tide.input.trim_on_save" true
let expand_tabs = boolvar "tide.input.expand_tabs" true
let scroll_lines = intvar "tide.input.scroll_lines" 4
let dbl_click_time = intvar "tide.input.click_time" 500
let max_scan_dist = intvar "tide.input.max_scan_dist" 0
+*)
module Color = struct
(* color palette *)
|]
(* UI color index definitions *)
+(*
let scroll_nor = clrvar "tide.colors.scroll.normal" (3, 0)
let gutter_nor = clrvar "tide.colors.gutter.normal" (1, 4)
let gutter_sel = clrvar "tide.colors.gutter.selected" (2, 7)
let edit_csr = intvar "tide.colors.edit.cursor" 7
let edit_rul = intvar "tide.colors.edit.ruler" 1
let borders = clrvar "tide.colors.borders" (3, 3)
+*)
(* syntax color definitions *)
module Syntax = struct
let constant = intvar "tide.colors.syntax.constant" 14
let keyword = intvar "tide.colors.syntax.keyword" 15
let typedef = intvar "tide.colors.syntax.typedef" 8
-
+ let preproc = intvar "tide.colors.syntax.preproc" 9
+(*
let number = intvar "tide.colors.syntax.number" 14
let boolean = intvar "tide.colors.syntax.boolean" 14
let float = intvar "tide.colors.syntax.float" 14
let string = intvar "tide.colors.syntax.string" 14
let char = intvar "tide.colors.syntax.character" 14
- let preproc = intvar "tide.colors.syntax.preproc" 9
let statement = intvar "tide.colors.syntax.statement" 10
let procedure = intvar "tide.colors.syntax.function" 11
let variable = intvar "tide.colors.syntax.variable" 12
let special = intvar "tide.colors.syntax.special" 13
let operator = intvar "tide.colors.syntax.operator" 12
+*)
end
end
startx = csr.startx; starty = csr.starty;
x = csr.x; y = csr.y }
+ let pos csr =
+ (csr.x, csr.y)
+
+ let dim csr =
+ (csr.width, csr.height)
+
let move_x csr n =
csr.x <- csr.x + n
type t
val make : (int * int) -> int -> int -> t
val clone : t -> t
+ val pos : t -> (int * int)
+ val dim : t -> (int * int)
val move_x : t -> int -> unit
val max_width : t -> int
(*
num : int;
buf : Buf.t;
map : Scrollmap.t;
- clr : Colormap.t
+ clr : Colormap.t;
+ pos : int * int;
+ dim : int * int
}
let from_buffer buf width height =
{ num = 0; buf = buf;
map = Scrollmap.make buf width 0;
- clr = Colormap.make (Buf.make_lexer buf) }
+ clr = Colormap.make (Buf.make_lexer buf);
+ pos = (0,0);
+ dim = (width, height) }
let empty width height =
from_buffer (Buf.empty) width height
let draw view csr =
let view = (resize view (Draw.Cursor.max_width csr)) in
- let num = Draw.buffer csr view.buf view.clr (Scrollmap.first view.map) in
- { view with num = num }
+ let newcsr = (Draw.Cursor.clone csr) in
+ let num = Draw.buffer newcsr view.buf view.clr (Scrollmap.first view.map) in
+ { view with
+ num = num;
+ pos = Draw.Cursor.pos csr;
+ dim = Draw.Cursor.dim csr }
let scroll_up view =
{ view with map = Scrollmap.scroll_up view.map view.buf }
type xevent =
| Focus of bool
| KeyPress of { mods: int; rune: int }
- | MouseClick of { mods: int; btn: int; x: int; y: int }
+ | MouseClick of { mods: int; btn: int; x: int; y: int; nclicks: int }
| MouseRelease of { mods: int; btn: int; x: int; y: int }
| MouseMove of { mods: int; x: int; y: int }
| Paste of { text: string }
}
static value ev_focus(XEvent* e) {
- bool focused = (e->type = FocusIn);
- if (X.xic)
- (focused ? XSetICFocus : XUnsetICFocus)(X.xic);
- return mkvariant(TFocus, 1, Val_true);
+ bool focused = (e->type == FocusIn);
+ value focusval = (focused ? Val_true : Val_false);
+ if (X.xic) (focused ? XSetICFocus : XUnsetICFocus)(X.xic);
+ return mkvariant(TFocus, 1, focusval);
}
static value ev_keypress(XEvent* e) {
return mkvariant(TKeyPress, 2, e->xkey.state, Val_int(special_keys(key)));
}
+static int times_clicked(int btn, Time curr) {
+ static struct { Time time; int nclicks; } hist[5] = {0,0};
+ if (btn >= 5) return 1;
+ Time diff = curr - hist[btn].time;
+ hist[btn].time = curr;
+ if (diff < 250) return ++(hist[btn].nclicks);
+ else return (hist[btn].nclicks = 1);
+}
+
static value ev_mouse(XEvent* e) {
+ Time time = e->xbutton.time;
int mods = e->xbutton.state, btn = e->xbutton.button,
x = e->xbutton.x, y = e->xbutton.y;
if (e->type == MotionNotify)
return mkvariant(TMouseMove, 3, Val_int(mods), Val_int(x), Val_int(y));
else if (e->type == ButtonPress)
- return mkvariant(TMouseClick, 4, Val_int(mods), Val_int(btn), Val_int(x), Val_int(y));
+ return mkvariant(TMouseClick, 5, Val_int(mods), Val_int(btn), Val_int(x), Val_int(y), Val_int(times_clicked(btn, time)));
else
return mkvariant(TMouseRelease, 4, Val_int(mods), Val_int(btn), Val_int(x), Val_int(y));
}