4 (* HTML simulator (first in its kind) *)
12 type html_msg = [ `Error of html_tag | `Msg of html_tag ]
14 class html_logger ~width ~height ~packing ~show () =
15 let scrolled_window = GBin.scrolled_window ~packing ~show () in
16 let vadj = scrolled_window#vadjustment in
18 GText.view ~editable:false ~cursor_visible:false
19 ~width ~height ~packing:(scrolled_window#add) ()
23 [`FOREGROUND_SET true ;
25 (Gdk.Color.alloc (Gdk.Color.get_system_colormap ()) (`NAME "green"))]
29 [`FOREGROUND_SET true ;
31 (Gdk.Color.alloc (Gdk.Color.get_system_colormap ()) (`NAME "red"))]
35 method log ?(append_NL = true)
36 (m : [`Msg of html_tag | `Error of html_tag])
38 let process_msg tags =
41 `T s -> tv#buffer#insert ~tags s
42 | `L l -> List.iter aux l
43 | `BR -> tv#buffer#insert ~tags "\n"
48 | `Msg m -> process_msg [green] m
49 | `Error m -> process_msg [red] m);
52 vadj#set_value (vadj#upper)
54 val mutable cic_indent_level = 0
56 method log_cic_msg ?(append_NL = true) (cic_msg: CicLogger.msg) =
57 let get_indent () = String.make cic_indent_level ' ' in
58 let incr () = cic_indent_level <- cic_indent_level + 1 in
59 let decr () = cic_indent_level <- cic_indent_level - 1 in
63 | `Start_type_checking uri ->
65 sprintf "Type checking of %s started" (UriManager.string_of_uri uri)
66 | `Type_checking_completed uri ->
68 sprintf "Type checking of %s completed"
69 (UriManager.string_of_uri uri)
71 sprintf "%s is trusted" (UriManager.string_of_uri uri))
73 self#log ~append_NL (`Msg (`T msg))