./unittests
clean:
- $(RM) deps.mk $(BINS) *.cm* *.o *.a *.so lib/*.cm* lib/*.o
+ $(RM) deps.mk $(BINS) *.cm* *.o *.a *.so lib/*.cm* lib/*.o tests/*.cm* tests/*.o
# Executable targets
edit: tide.$(LIBEXT) edit.$(OBJEXT)
let tabglyph = 0x30
let tabwidth = 4
+let glyph_width g =
+ let open X11 in g.xoff
+
module Cursor = struct
type t = {
height : int;
((csr.y + font_height) < csr.height)
let draw_tab csr =
- let tabsz = ((X11.get_glyph font tabglyph).xoff * tabwidth) in
+ let xoff = (glyph_width (X11.get_glyph font tabglyph)) in
+ let tabsz = (xoff * tabwidth) in
csr.x <- (csr.startx + ((csr.x - csr.startx + tabsz) / tabsz * tabsz))
let place_glyph csr glyph =
- let xoff = (let open X11 in glyph.xoff) in
+ let xoff = (glyph_width glyph) in
if (csr.x + xoff) > csr.width then (next_line csr);
let _ = X11.draw_glyph Cfg.Color.palette.(5) glyph (csr.x, csr.y) in
csr.x <- csr.x + xoff
let next_glyph csr c =
let glyph = (X11.get_glyph font c) in
+ let xoff = (glyph_width glyph) in
match c with
| 0x0A -> next_line csr; true
| 0x0D -> false
| 0x09 -> draw_tab csr; false
- | _ -> let nl = (if (csr.x + glyph.xoff) > csr.width then
+ | _ -> let nl = (if (csr.x + xoff) > csr.width then
(next_line csr; true) else false) in
- csr.x <- csr.x + glyph.xoff; nl
+ csr.x <- csr.x + xoff; nl
end
open Cursor
(* getc() tests *)
test "getc : raise Out_of_bounds on negative index" (fun () ->
let rope = Leaf("a", 0, 1) in
- try getc rope (-1); assert false
+ try let _ = getc rope (-1) in assert false
with Out_of_bounds _ -> assert true
);
test "getc : raise Out_of_bounds on out of bounds index" (fun () ->
let rope = Leaf("a", 0, 1) in
- try getc rope (2); assert false
+ try let _ = getc rope (2) in assert false
with Out_of_bounds _ -> assert true
);
test "getc : return index 0 of leaf" (fun () ->