9 type node |
9 type node |
10 val content_node: string -> Pretty.T list -> node |
10 val content_node: string -> Pretty.T list -> node |
11 val session_node: {name: string, unfold: bool, directory: string, path: string} -> node |
11 val session_node: {name: string, unfold: bool, directory: string, path: string} -> node |
12 type entry = (string * node) * string list |
12 type entry = (string * node) * string list |
13 val display_graph: entry list -> unit |
13 val display_graph: entry list -> unit |
|
14 val display_graph_old: entry list -> unit |
14 end; |
15 end; |
15 |
16 |
16 structure Graph_Display: GRAPH_DISPLAY = |
17 structure Graph_Display: GRAPH_DISPLAY = |
17 struct |
18 struct |
18 |
19 |
28 Node {name = name, content = [], unfold = unfold, directory = directory, path = path}; |
29 Node {name = name, content = [], unfold = unfold, directory = directory, path = path}; |
29 |
30 |
30 type entry = (string * node) * string list; |
31 type entry = (string * node) * string list; |
31 |
32 |
32 |
33 |
33 (* encode graph *) |
34 (* display graph *) |
|
35 |
|
36 local |
34 |
37 |
35 fun encode_node (Node {name, content, ...}) = |
38 fun encode_node (Node {name, content, ...}) = |
36 (name, content) |> |
39 (name, content) |> |
37 let open XML.Encode |
40 let open XML.Encode |
38 in pair string (YXML.parse_body o Pretty.symbolic_string_of o Pretty.chunks) end; |
41 in pair string (YXML.parse_body o Pretty.symbolic_string_of o Pretty.chunks) end; |
39 |
42 |
40 val encode_graph = |
43 val encode_graph = |
41 let open XML.Encode in list (pair (pair string encode_node) (list string)) end; |
44 let open XML.Encode in list (pair (pair string encode_node) (list string)) end; |
42 |
45 |
|
46 in |
|
47 |
|
48 fun display_graph entries = |
|
49 let |
|
50 val ((bg1, bg2), en) = |
|
51 YXML.output_markup_elem |
|
52 (Active.make_markup Markup.graphviewN {implicit = false, properties = []}); |
|
53 in writeln ("See " ^ bg1 ^ YXML.string_of_body (encode_graph entries) ^ bg2 ^ "graph" ^ en) end; |
|
54 |
|
55 end; |
|
56 |
43 |
57 |
44 (* support for old browser *) |
58 (* support for old browser *) |
|
59 |
|
60 local |
45 |
61 |
46 structure Graph = |
62 structure Graph = |
47 Graph(type key = string * string val ord = prod_ord string_ord string_ord); |
63 Graph(type key = string * string val ord = prod_ord string_ord string_ord); |
48 |
64 |
49 fun build_graph entries = |
65 fun build_graph entries = |
69 #> map (fn ((key, Node {name, unfold, content = _, directory, path}), parents) => |
85 #> map (fn ((key, Node {name, unfold, content = _, directory, path}), parents) => |
70 "\"" ^ name ^ "\" \"" ^ key ^ "\" \"" ^ directory ^ (if unfold then "\" + \"" else "\" \"") ^ |
86 "\"" ^ name ^ "\" \"" ^ key ^ "\" \"" ^ directory ^ (if unfold then "\" + \"" else "\" \"") ^ |
71 path ^ "\" > " ^ space_implode " " (map quote parents) ^ " ;") |
87 path ^ "\" > " ^ space_implode " " (map quote parents) ^ " ;") |
72 #> cat_lines; |
88 #> cat_lines; |
73 |
89 |
|
90 in |
74 |
91 |
75 (* display graph *) |
92 fun display_graph_old entries = |
76 |
|
77 fun display_graph entries = |
|
78 let |
93 let |
79 val ((bg1, bg2), en) = |
94 val ((bg1, bg2), en) = |
80 YXML.output_markup_elem |
95 YXML.output_markup_elem |
81 (Active.make_markup Markup.graphviewN {implicit = false, properties = []}); |
|
82 val _ = |
|
83 writeln ("See " ^ bg1 ^ YXML.string_of_body (encode_graph entries) ^ bg2 ^ "graph" ^ en); |
|
84 |
|
85 (*old browser*) |
|
86 val ((bg1, bg2), en) = |
|
87 YXML.output_markup_elem |
|
88 (Active.make_markup Markup.browserN {implicit = false, properties = []}); |
96 (Active.make_markup Markup.browserN {implicit = false, properties = []}); |
89 val _ = |
97 in writeln ("See " ^ bg1 ^ encode_browser entries ^ bg2 ^ "graph" ^ en) end; |
90 writeln ("See " ^ bg1 ^ encode_browser entries ^ bg2 ^ "old graph" ^ en); |
|
91 in () end; |
|
92 |
98 |
93 end; |
99 end; |
|
100 |
|
101 end; |