draw_rect { x = pos.x; y = pos.y; w = width; h = height; c = color }
(* curried helpers *)
-let draw_dark_bkg = draw_bkg Cfg.Color.palette.(0)
+let draw_dark_bkg = draw_bkg Cfg.Color.palette.(0)
let draw_light_bkg = draw_bkg Cfg.Color.palette.(1)
-let draw_gray_bkg = draw_bkg Cfg.Color.palette.(3)
+let draw_gray_bkg = draw_bkg Cfg.Color.palette.(3)
let draw_text text pos =
draw_string font Cfg.Color.palette.(5) text (pos.x + 2, pos.y + 2);
| 0x0D -> ()
| 0x09 ->
let tabsz = ((X11.get_glyph font tabglyph).xoff * tabwidth) in
- let ntabs = (width - pos.x) / tabsz in
x := pos.x + (((!x - pos.x) + tabsz) / tabsz * tabsz)
| _ -> begin
if (!x + glyph.xoff) > width then (newline ());
end);
((!y + font.height) < height)
in
- Buf.iter_from draw_char !edit_buf !edit_buf.start;
+ Buf.iter_from draw_char !edit_buf (Buf.start !edit_buf);
pos
let draw_edit pos width height =
() (*print_endline "onfocus"*)
let onkeypress mods rune =
- print_endline "scroll up"
+ ()
let onmousebtn mods btn x y pressed =
- print_endline "scroll down";
- edit_buf := { !edit_buf with start = !edit_buf.start + 1}
+ ()
let onmousemove mods x y =
() (*print_endline "onmousemove"*)
-type cursor = { start : int; stop : int }
-
type t = {
start : int;
path : string;
rope : Rope.t
}
-let font = X11.font_load "Verdana:size=11:antialias=true:autohint=true"
-
let empty =
{ start = 0; path = ""; rope = Rope.empty }
let rope buf =
buf.rope
+let start buf =
+ buf.start
+
let iter_from fn buf i =
Rope.iter_from fn buf.rope i
-
-
-(*
-
-let make_cursor buf start stop =
- { start = (Rope.limit_index buf.rope start);
- stop = (Rope.limit_index buf.rope stop) }
-
-let move_rune count csr buf ext =
- let newstop = csr.stop + count in
- let newstart = if ext then csr.start else newstop in
- make_cursor buf newstart newstop
-
-let move_word count csr buf ext =
- ()
-
-let move_line count csr buf ext =
- ()
-
-*)
(* Unit Tests *****************************************************************)
let run_unit_tests () =
map : int array
}
-let make buf off =
- let bol = (Rope.to_bol (Buf.rope buf) off) in
+let make buf =
+ let bol = (Rope.to_bol (Buf.rope buf) (Buf.start buf)) in
{ index = 0; map = [||] }
+
+(* Unit Tests** ***************************************************************)
+
+let run_unit_tests () = ()