--- /dev/null
+(* Copyright (C) 2004, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://helm.cs.unibo.it/
+ *)
+
+class html_logger ?width ?height ?packing ?show () =
+ let scrolled_window = GBin.scrolled_window ?packing ?show () in
+ let vadj = scrolled_window#vadjustment in
+ let tv =
+ GText.view ~editable:false ~cursor_visible:false
+ ?width ?height ~packing:(scrolled_window#add) ()
+ in
+ let colors = Hashtbl.create 13 in
+ let get_color color =
+ try
+ Hashtbl.find colors color
+ with Not_found ->
+ let tag =
+ tv#buffer#create_tag
+ [`FOREGROUND_SET true ;
+ `FOREGROUND_GDK
+ (Gdk.Color.alloc (Gdk.Color.get_system_colormap ()) (`NAME color))]
+ in
+ Hashtbl.add colors color tag;
+ tag
+ in
+ let log ?(append_NL = true) msg =
+ let rec aux color indent =
+ let indent_str = String.make indent ' ' in
+ function
+ | `T s -> tv#buffer#insert ~tags:[ get_color color ] s
+ | `L tags ->
+ List.iter
+ (fun tag -> aux color indent tag; tv#buffer#insert indent_str)
+ tags
+ | `BR -> tv#buffer#insert ("\n" ^ indent_str)
+ | `DIV (local_indent, new_color, tag) ->
+ tv#buffer#insert ("\n" ^ indent_str);
+ aux
+ (match new_color with None -> color | Some new_color -> new_color)
+ (indent + local_indent) tag
+ in
+ (match msg with
+ | `Error tag -> aux "red" 0 tag
+ | `Msg tag -> aux "black" 0 tag);
+ if append_NL then tv#buffer#insert "\n"
+ in
+ object (self)
+ initializer HelmLogger.register_log_callback log
+ end
+
--- /dev/null
+(* Copyright (C) 2004, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://helm.cs.unibo.it/
+ *)
+
+class html_logger:
+ ?width:int -> ?height:int -> ?packing:(GObj.widget -> unit) -> ?show:bool ->
+ unit ->
+ object
+ end
+
+
PACKAGE = cic_proof_checking
-REQUIRES = helm-cic
+REQUIRES = helm-cic helm-logger helm-getter
PREDICATES =
REDUCTION_IMPLEMENTATION = cicReductionMachine.ml
INTERFACE_FILES = \
- cicLogger.mli cicEnvironment.mli cicPp.mli cicSubstitution.mli \
+ cicLogger.mli \
+ cicEnvironment.mli cicPp.mli cicSubstitution.mli \
cicMiniReduction.mli cicReductionNaif.mli cicReduction.mli \
cicTypeChecker.mli
IMPLEMENTATION_FILES = $(INTERFACE_FILES:%.mli=%.ml)
Cache.find_or_add_unchecked uri
~get_object_to_add:
(function () ->
- let filename = Getter.getxml uri in
+ let filename = Http_getter.getxml' uri in
let bodyfilename =
match UriManager.bodyuri_of_uri uri with
None -> None
| Some bodyuri ->
try
- ignore (Getter.resolve bodyuri) ;
+ ignore (Http_getter.resolve' bodyuri) ;
(* The body exists ==> it is not an axiom *)
- Some (Getter.getxml bodyuri)
+ Some (Http_getter.getxml' bodyuri)
with
- Getter.Unresolved ->
+ Http_getter_types.Unresolvable_URI _ ->
(* The body does not exist ==> we consider it an axiom *)
None
in
| `Type_checking_completed of UriManager.uri
| `Trusting of UriManager.uri
]
-;;
-let log_to_html ~print_and_flush =
+let log =
let module U = UriManager in
- let indent = ref 0 in
- let mkindent () =
- String.make !indent ' '
- in
function
| `Start_type_checking uri ->
- print_and_flush (
- mkindent () ^
- "<div style=\"margin-left: " ^
- string_of_float (float_of_int !indent *. 0.5) ^ "cm\">" ^
- "Type-Checking of " ^ (U.string_of_uri uri) ^ " started</div>\n"
- ) ;
- incr indent
+ HelmLogger.log (`Msg (`DIV (1, None, `T
+ ("Type-Checking of " ^ (U.string_of_uri uri) ^ " started"))))
| `Type_checking_completed uri ->
- decr indent ;
- print_and_flush (
- mkindent () ^
- "<div style=\"color: green ; margin-left: " ^
- string_of_float (float_of_int !indent *. 0.5) ^ "cm\">" ^
- "Type-Checking of " ^ (U.string_of_uri uri) ^ " completed.</div>\n"
- )
+ HelmLogger.log (`Msg (`DIV (1, Some "green", `T
+ ("Type-Checking of " ^ (U.string_of_uri uri) ^ " completed"))))
| `Trusting uri ->
- print_and_flush (
- mkindent () ^
- "<div style=\"color: blue ; margin-left: " ^
- string_of_float (float_of_int !indent *. 0.5) ^ "cm\">" ^
- (U.string_of_uri uri) ^ " is trusted.</div>\n"
- )
-;;
+ HelmLogger.log (`Msg (`DIV (1, Some "blue", `T
+ ((U.string_of_uri uri) ^ " is trusted."))))
-let log_callback = ref (function (_:msg) -> ())
-let log msg = !log_callback msg;;
| `Type_checking_completed of UriManager.uri
| `Trusting of UriManager.uri
]
-;;
-(* A callback that can be used to log to html *)
-val log_to_html : print_and_flush:(string -> unit) -> msg -> unit
+val log: msg -> unit
-(* The log function used. The default does nothing. *)
-val log_callback : (msg -> unit) ref
-
-(* Log something via log_callback *)
-val log : msg -> unit