| author | wenzelm | 
| Wed, 29 Jun 2005 15:13:38 +0200 | |
| changeset 16608 | 4f8d7b83c7e2 | 
| parent 16451 | c9f1fc144132 | 
| child 16715 | ecca9fd2754f | 
| permissions | -rw-r--r-- | 
| 6346 | 1 | (* Title: Pure/Isar/session.ML | 
| 2 | ID: $Id$ | |
| 3 | Author: Markus Wenzel, TU Muenchen | |
| 4 | ||
| 5 | Session management -- maintain state of logic images. | |
| 6 | *) | |
| 7 | ||
| 8 | signature SESSION = | |
| 9 | sig | |
| 11509 | 10 | val name: unit -> string | 
| 6346 | 11 | val welcome: unit -> string | 
| 15269 
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
 webertj parents: 
14981diff
changeset | 12 | val use_dir: string -> bool -> string list -> bool -> bool -> string -> bool -> string | 
| 15433 
a2cbdf16832e
Added flag for hiding proofs in documents to use_dir.
 berghofe parents: 
15269diff
changeset | 13 | -> string -> string -> string -> int -> bool -> bool -> unit | 
| 6346 | 14 | val finish: unit -> unit | 
| 15 | end; | |
| 16 | ||
| 17 | structure Session: SESSION = | |
| 18 | struct | |
| 19 | ||
| 20 | ||
| 21 | (* session state *) | |
| 22 | ||
| 16451 | 23 | val session = ref ([Context.PureN]: string list); | 
| 6346 | 24 | val session_path = ref ([]: string list); | 
| 25 | val session_finished = ref false; | |
| 15979 | 26 | val remote_path = ref (NONE: Url.T option); | 
| 9414 | 27 | |
| 28 | ||
| 29 | (* access path *) | |
| 6346 | 30 | |
| 31 | fun path () = ! session_path; | |
| 32 | ||
| 16451 | 33 | fun str_of [] = Context.PureN | 
| 6346 | 34 | | str_of elems = space_implode "/" elems; | 
| 35 | ||
| 11509 | 36 | fun name () = "Isabelle/" ^ str_of (path ()); | 
| 37 | fun welcome () = "Welcome to " ^ name () ^ " (" ^ version ^ ")";
 | |
| 6346 | 38 | |
| 39 | ||
| 9414 | 40 | (* add_path *) | 
| 41 | ||
| 42 | fun add_path reset s = | |
| 43 | let val sess = ! session @ [s] in | |
| 44 | (case Library.duplicates sess of | |
| 45 | [] => (session := sess; session_path := ((if reset then [] else ! session_path) @ [s])) | |
| 46 |     | dups => error ("Duplicate session identifiers " ^ commas_quote dups ^ " in " ^ str_of sess))
 | |
| 47 | end; | |
| 48 | ||
| 49 | ||
| 6346 | 50 | (* init *) | 
| 51 | ||
| 52 | fun init reset parent name = | |
| 53 | if not (parent mem_string (! session)) orelse not (! session_finished) then | |
| 54 |     error ("Unfinished parent session " ^ quote parent ^ " for " ^ quote name)
 | |
| 55 | else (add_path reset name; session_finished := false); | |
| 56 | ||
| 57 | ||
| 58 | (* finish *) | |
| 59 | ||
| 60 | fun finish () = | |
| 6663 | 61 | (ThyInfo.finish (); | 
| 6346 | 62 | Present.finish (); | 
| 63 | session_finished := true); | |
| 64 | ||
| 65 | ||
| 66 | (* use_dir *) | |
| 67 | ||
| 7236 
e077484d50d8
Better handling of path for remote theory browsing information.
 berghofe parents: 
7227diff
changeset | 68 | fun get_rpath rpath_str = | 
| 
e077484d50d8
Better handling of path for remote theory browsing information.
 berghofe parents: 
7227diff
changeset | 69 | (if rpath_str = "" then () else | 
| 15979 | 70 | if is_some (! remote_path) then | 
| 7227 
a8e86b8e6fd1
Path for remote theory browsing information is now stored in referece variable rpath.
 berghofe parents: 
6663diff
changeset | 71 | error "Path for remote theory browsing information may only be set once" | 
| 
a8e86b8e6fd1
Path for remote theory browsing information is now stored in referece variable rpath.
 berghofe parents: 
6663diff
changeset | 72 | else | 
| 15979 | 73 | remote_path := SOME (Url.unpack rpath_str); | 
| 74 | (! remote_path, rpath_str <> "")); | |
| 7236 
e077484d50d8
Better handling of path for remote theory browsing information.
 berghofe parents: 
7227diff
changeset | 75 | |
| 15979 | 76 | fun use_dir root build modes reset info doc doc_graph parent name dump rpath_str level verbose hide = | 
| 11543 
d61b913431c5
renamed `keep_derivs' to `proofs', and made an integer;
 wenzelm parents: 
11527diff
changeset | 77 | Library.setmp print_mode (modes @ ! print_mode) | 
| 15433 
a2cbdf16832e
Added flag for hiding proofs in documents to use_dir.
 berghofe parents: 
15269diff
changeset | 78 | (Library.setmp Proofterm.proofs level (Library.setmp IsarOutput.hide_commands hide (fn () => | 
| 11543 
d61b913431c5
renamed `keep_derivs' to `proofs', and made an integer;
 wenzelm parents: 
11527diff
changeset | 79 | (init reset parent name; | 
| 11910 | 80 | Present.init build info doc doc_graph (path ()) name | 
| 15531 | 81 | (if dump = "" then NONE else SOME (Path.unpack dump)) (get_rpath rpath_str) verbose; | 
| 15979 | 82 | File.use (Path.basic root); | 
| 15433 
a2cbdf16832e
Added flag for hiding proofs in documents to use_dir.
 berghofe parents: 
15269diff
changeset | 83 | finish ())))) () | 
| 10571 | 84 | handle exn => (writeln (Toplevel.exn_message exn); exit 1); | 
| 6346 | 85 | |
| 86 | ||
| 87 | end; |