let onevent evnt =
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
- | MouseMove e -> onmousemove e.mods e.x e.y
- | Paste e -> () (*print_endline "paste"*)
- | Command e -> () (*print_endline "command"*)
- | PipeClosed e -> () (*print_endline "pipeclosed"*)
- | PipeWriteReady e -> () (*print_endline "pipewriteready"*)
- | PipeReadReady e -> () (*print_endline "pipereadready"*)
- | Update e -> onupdate e.width e.height
- | Shutdown -> onshutdown ()
+ | 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
+ | MouseMove e -> onmousemove e.mods e.x e.y
+ | Paste e -> () (*print_endline "paste"*)
+ | Command e -> () (*print_endline "command"*)
+ | PipeClosed e -> () (*print_endline "pipeclosed"*)
+ | PipeWriteReady e -> () (*print_endline "pipewriteready"*)
+ | PipeReadReady e -> () (*print_endline "pipereadready"*)
+ | Update e -> onupdate e.width e.height
+ | Shutdown -> onshutdown ()
with e -> begin
print_endline (Printexc.to_string e);
Printexc.print_backtrace stdout
let rec getc rope i =
check_index rope i;
match rope with
- | Leaf (s,off,_) ->
+ | Leaf (s,off,_) -> (Char.code s.[off + i])
+(*
let c = (Char.code s.[off + i]) in
let len = (length rope) in
let next = (i + 1) in
0x0A
else
c
+*)
| Node (l,r,h,len) ->
let left_len = (length l) in
if i < left_len then
let rec move_till step testfn rope pos =
let adjust_pos = if step < 0 then prevc else nextc in
- if (testfn rope pos) || pos == 0 || pos == (last rope) then pos
+ if (testfn rope pos) then pos
else (move_till step testfn rope (adjust_pos rope pos))
let to_bol rope pos =
let rope = Node((Leaf("a", 0, 1)), (Leaf("b", 0, 1)), 0, 2) in
assert( (getc rope (1)) == Char.code 'b' );
);
- test "getc : return \\n for \\r\\n" (fun () ->
+(* test "getc : return \\n for \\r\\n" (fun () ->
let rope = from_string "\r\n" in
assert( (getc rope (0)) == Char.code '\n' );
);
+*)
test "getc : return \\r for \\r at end of string" (fun () ->
let rope = from_string "\r" in
assert( (getc rope (0)) == Char.code '\r' );
let rope = Leaf("abc", 0, 3) in
assert( is_eol rope 2 );
);
- test "is_eol : should return true if pos is last char of line with \n ending" (fun () ->
+ test "is_eol : should return true if pos is last char of line with \\n ending" (fun () ->
let rope = Leaf("abc\n", 0, 4) in
assert( is_eol rope 3 );
);
- test "is_eol : should return true if pos is last char of line with \r\n ending" (fun () ->
+(* test "is_eol : should return true if pos is last char of line with \\r\\n ending" (fun () ->
let rope = Leaf("abc\r\n", 0, 5) in
assert( is_eol rope 3 );
- );
+ );*)
test "is_eol : should return false if pos is not last char of line" (fun () ->
let rope = Leaf("abcd\n", 0, 5) in
assert( (is_eol rope 2) == false );