File: matitaTypes.ml

package info (click to toggle)
matita 0.5.8-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 31,144 kB
  • ctags: 10,276
  • sloc: ml: 91,469; xml: 8,768; makefile: 2,021; ansic: 605; sh: 462; php: 381; awk: 121; perl: 36; sql: 11; sed: 4
file content (111 lines) | stat: -rw-r--r-- 3,836 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
(* Copyright (C) 2004-2005, 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/
 *)

(* $Id: matitaTypes.ml 10354 2009-09-29 16:53:28Z tassi $ *)

open Printf
open GrafiteTypes

  (** user hit the cancel button *)
exception Cancel

type abouts =
  [ `Blank
  | `Current_proof
  | `Us
  | `Coercions
  | `CoercionsFull
  | `TeX
  | `Grammar
  | `Hints
  ]
  
type mathViewer_entry =
  [ `About of abouts  (* current proof *)
  | `Check of string  (* term *)
  | `Cic of Cic.term * Cic.metasenv
  | `NCic of NCic.term * NCic.context * NCic.metasenv * NCic.substitution
  | `Dir of string  (* "directory" in cic uris namespace *)
  | `HBugs of [ `Tutors ] (* list of available HBugs tutors *)
  | `Metadata of [ `Deps of [`Fwd | `Back] * UriManager.uri ]
  | `Uri of UriManager.uri (* cic object uri *)
  | `NRef of NReference.reference (* cic object uri *)
  | `Whelp of string * UriManager.uri list (* query and results *)
  | `Univs of UriManager.uri
  ]

let string_of_entry = function
  | `About `Blank -> "about:blank"
  | `About `Current_proof -> "about:proof"
  | `About `Us -> "about:us"
  | `About `Coercions -> "about:coercions?tred=true"
  | `About `CoercionsFull -> "about:coercions"
  | `About `TeX -> "about:tex"
  | `About `Grammar -> "about:grammar"
  | `About `Hints -> "about:hints"
  | `Check _ -> "check:"
  | `Cic (_, _) -> "term:"
  | `NCic (_, _, _, _) -> "nterm:"
  | `Dir uri -> uri
  | `HBugs `Tutors -> "hbugs:/tutors/"
  | `Metadata meta ->
      "metadata:/" ^
      (match meta with
      | `Deps (dir, uri) ->
          "deps/" ^
          let suri =
            let suri = UriManager.string_of_uri uri in
            let len = String.length suri in
            String.sub suri 4 (len - 4) in (* strip "cic:" prefix *)
          (match dir with | `Fwd -> "forward" | `Back -> "backward") ^ suri)
  | `Uri uri -> UriManager.string_of_uri uri
  | `NRef nref -> NReference.string_of_reference nref
  | `Whelp (query, _) -> query
  | `Univs uri -> "univs:" ^ UriManager.string_of_uri uri

let entry_of_string = function
  | "about:blank" -> `About `Blank
  | "about:proof" -> `About `Current_proof
  | "about:us"    -> `About `Us
  | "about:hints"    -> `About `Hints
  | "about:coercions?tred=true"    -> `About `Coercions
  | "about:coercions"    -> `About `CoercionsFull
  | "about:tex"    -> `About `TeX
  | "about:grammar"    -> `About `Grammar
  | _ ->  (* only about entries supported ATM *)
      raise (Invalid_argument "entry_of_string")

class type mathViewer =
  object
    (** @param reuse if set reused last opened cic browser otherwise 
     *  opens a new one. default is false
     *)
    method show_entry: ?reuse:bool -> mathViewer_entry -> unit
    method show_uri_list:
      ?reuse:bool -> entry:mathViewer_entry -> UriManager.uri list -> unit
    method screenshot: 
      GrafiteTypes.status -> NCic.metasenv -> NCic.metasenv ->
        NCic.substitution -> string -> unit
  end