]> matita.cs.unibo.it Git - helm.git/blob - helm/www/lambdadelta/bin/xhtbl/matrix.ml
62f6b194e73d35e54b64e19ce6769cd16b23f920
[helm.git] / helm / www / lambdadelta / bin / xhtbl / matrix.ml
1 module A = Array
2 module N = Filename
3
4 module T = Table
5
6 type cell = {
7    ck: T.text list; (* contents *)
8    cc: T.css;       (* css classes *)
9    cu: T.uri;       (* uri *)
10    cx: T.ext;       (* extension *)   
11    cb: T.border;    (* border *)
12 }
13
14 type matrix = {
15    r: int;              (* rows *)
16    c: int;              (* columns *)
17    m: cell array array; (* matrix *)
18 }
19
20 let empty = {
21    ck = []; cc = []; cu = ""; cx = ""; cb = T.border false;
22 }
23
24 let make ts = {
25    r = ts.T.rf; c = ts.T.cf;
26    m = A.make_matrix ts.T.rf ts.T.cf empty;
27 }
28
29 let set_key m y x kl = 
30    m.m.(y).(x) <- {m.m.(y).(x) with ck = kl}
31
32 let set_attrs m y x c u e = 
33    m.m.(y).(x) <- {m.m.(y).(x) with
34       cc = c @ m.m.(y).(x).cc;
35       cu = u ^ m.m.(y).(x).cu;
36       cx = m.m.(y).(x).cx ^ e;
37    }
38
39 let set_west m y x b =
40    let c = m.m.(y).(x) in
41    let cb = {c.cb with T.w = c.cb.T.w || b.T.w} in 
42    m.m.(y).(x) <- {c with cb = cb}
43
44 let set_north m y x b =
45    let c = m.m.(y).(x) in
46    let cb = {c.cb with T.n = c.cb.T.n || b.T.n} in 
47    m.m.(y).(x) <- {c with cb = cb}
48
49 let set_east m y x b =
50    if x < pred m.c then set_west m y (succ x) {b with T.w = b.T.e} else
51    let c = m.m.(y).(x) in
52    let cb = {c.cb with T.e = c.cb.T.e || b.T.e} in 
53    m.m.(y).(x) <- {c with cb = cb}
54
55 let set_south m y x b =
56    if y < pred m.r then set_north m (succ y) x {b with T.n = b.T.s} else
57    let c = m.m.(y).(x) in
58    let cb = {c.cb with T.s = c.cb.T.s || b.T.s} in 
59    m.m.(y).(x) <- {c with cb = cb}