]> matita.cs.unibo.it Git - helm.git/commitdiff
new logger
authorStefano Zacchiroli <zack@upsilon.cc>
Wed, 11 Feb 2004 12:04:16 +0000 (12:04 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Wed, 11 Feb 2004 12:04:16 +0000 (12:04 +0000)
helm/gTopLevel/helmGtkLogger.ml [new file with mode: 0644]
helm/gTopLevel/helmGtkLogger.mli [new file with mode: 0644]
helm/ocaml/cic_proof_checking/Makefile
helm/ocaml/cic_proof_checking/cicEnvironment.ml
helm/ocaml/cic_proof_checking/cicLogger.ml
helm/ocaml/cic_proof_checking/cicLogger.mli

diff --git a/helm/gTopLevel/helmGtkLogger.ml b/helm/gTopLevel/helmGtkLogger.ml
new file mode 100644 (file)
index 0000000..cfb2c48
--- /dev/null
@@ -0,0 +1,71 @@
+(* 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
+
diff --git a/helm/gTopLevel/helmGtkLogger.mli b/helm/gTopLevel/helmGtkLogger.mli
new file mode 100644 (file)
index 0000000..06206dd
--- /dev/null
@@ -0,0 +1,31 @@
+(* 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
+
index 96ac166b53257376f169d621e776ddef235da4f0..61d7d5002c7e52f9bcb559f44a7ccc9fbe6796bd 100644 (file)
@@ -1,11 +1,13 @@
+
 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)
index 22138dde8d1eee672f46385db7bc68f9428c29d7..45c0dba5a8b404fbe2201e8e9a0ff24b638340c4 100644 (file)
@@ -303,17 +303,17 @@ let find_or_add_unchecked_to_cache uri =
  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
index 9fc983fc7fec8e9588dd68efc7b28f48491a30f8..6867b8b928314bbbc73226610f30d4a5714a7185 100644 (file)
@@ -28,39 +28,17 @@ type msg =
  | `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;;
index 781abdef6e9a7b6275e14935df9336ddb3cf0a31..848b30573cce84d618929e1f1db4ddb81a670df8 100644 (file)
@@ -28,13 +28,6 @@ type 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