| author | wenzelm | 
| Fri, 03 Mar 2017 10:51:24 +0100 | |
| changeset 65091 | f7aaf4ce55a9 | 
| parent 64186 | 49816908ae42 | 
| child 65236 | 4fa82bbb394e | 
| permissions | -rw-r--r-- | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
1  | 
/* Title: Pure/System/options.scala  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
2  | 
Author: Makarius  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
3  | 
|
| 51945 | 4  | 
System options with external string representation.  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
5  | 
*/  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
6  | 
|
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
7  | 
package isabelle  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
8  | 
|
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
9  | 
|
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
10  | 
object Options  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
11  | 
{
 | 
| 48421 | 12  | 
type Spec = (String, Option[String])  | 
13  | 
||
14  | 
val empty: Options = new Options()  | 
|
15  | 
||
16  | 
||
17  | 
/* representation */  | 
|
18  | 
||
19  | 
sealed abstract class Type  | 
|
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
20  | 
  {
 | 
| 56599 | 21  | 
def print: String = Word.lowercase(toString)  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
22  | 
}  | 
| 49246 | 23  | 
case object Bool extends Type  | 
24  | 
case object Int extends Type  | 
|
25  | 
case object Real extends Type  | 
|
26  | 
case object String extends Type  | 
|
27  | 
case object Unknown extends Type  | 
|
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
28  | 
|
| 56465 | 29  | 
case class Opt(  | 
30  | 
public: Boolean,  | 
|
31  | 
pos: Position.T,  | 
|
32  | 
name: String,  | 
|
33  | 
typ: Type,  | 
|
34  | 
value: String,  | 
|
35  | 
default_value: String,  | 
|
36  | 
description: String,  | 
|
37  | 
section: String)  | 
|
| 48860 | 38  | 
  {
 | 
| 49289 | 39  | 
private def print(default: Boolean): String =  | 
40  | 
    {
 | 
|
41  | 
val x = if (default) default_value else value  | 
|
| 49247 | 42  | 
"option " + name + " : " + typ.print + " = " +  | 
| 49289 | 43  | 
(if (typ == Options.String) quote(x) else x) +  | 
44  | 
(if (description == "") "" else "\n -- " + quote(description))  | 
|
45  | 
}  | 
|
46  | 
||
47  | 
def print: String = print(false)  | 
|
48  | 
def print_default: String = print(true)  | 
|
| 49247 | 49  | 
|
| 56559 | 50  | 
def title(strip: String = ""): String =  | 
| 49270 | 51  | 
    {
 | 
| 56600 | 52  | 
      val words = Word.explode('_', name)
 | 
| 49270 | 53  | 
val words1 =  | 
54  | 
        words match {
 | 
|
55  | 
case word :: rest if word == strip => rest  | 
|
56  | 
case _ => words  | 
|
57  | 
}  | 
|
| 
56609
 
5ac67041ccf8
capitalize more carefully, e.g. relevant for option "ML_exception_trace";
 
wenzelm 
parents: 
56600 
diff
changeset
 | 
58  | 
Word.implode(words1.map(Word.perhaps_capitalize(_)))  | 
| 49270 | 59  | 
}  | 
60  | 
||
| 48860 | 61  | 
def unknown: Boolean = typ == Unknown  | 
62  | 
}  | 
|
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
63  | 
|
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
64  | 
|
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
65  | 
/* parsing */  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
66  | 
|
| 49270 | 67  | 
private val SECTION = "section"  | 
| 
52065
 
78f2475aa126
explicit notion of public options, which are shown in the editor options dialog;
 
wenzelm 
parents: 
51945 
diff
changeset
 | 
68  | 
private val PUBLIC = "public"  | 
| 
48795
 
bece259ee055
clarified format of etc/options: only declarations, not re-definitions;
 
wenzelm 
parents: 
48718 
diff
changeset
 | 
69  | 
private val OPTION = "option"  | 
| 48807 | 70  | 
  private val OPTIONS = Path.explode("etc/options")
 | 
| 50793 | 71  | 
  private val PREFS_DIR = Path.explode("$ISABELLE_HOME_USER/etc")
 | 
72  | 
  private val PREFS = PREFS_DIR + Path.basic("preferences")
 | 
|
| 
48713
 
de26cf3191a3
more token markers, based on actual outer syntax;
 
wenzelm 
parents: 
48693 
diff
changeset
 | 
73  | 
|
| 49270 | 74  | 
lazy val options_syntax =  | 
| 61579 | 75  | 
Outer_Syntax.init() + ":" + "=" + "--" + Symbol.comment + Symbol.comment_decoded +  | 
| 63441 | 76  | 
(SECTION, Keyword.DOCUMENT_HEADING) +  | 
77  | 
(PUBLIC, Keyword.BEFORE_COMMAND) +  | 
|
78  | 
(OPTION, Keyword.THY_DECL)  | 
|
| 49270 | 79  | 
|
| 48807 | 80  | 
lazy val prefs_syntax = Outer_Syntax.init() + "="  | 
| 
48713
 
de26cf3191a3
more token markers, based on actual outer syntax;
 
wenzelm 
parents: 
48693 
diff
changeset
 | 
81  | 
|
| 62968 | 82  | 
trait Parser extends Parse.Parser  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
83  | 
  {
 | 
| 62968 | 84  | 
    val option_name = atom("option name", _.is_name)
 | 
85  | 
    val option_type = atom("option type", _.is_name)
 | 
|
| 48807 | 86  | 
val option_value =  | 
87  | 
      opt(token("-", tok => tok.is_sym_ident && tok.content == "-")) ~ atom("nat", _.is_nat) ^^
 | 
|
88  | 
        { case s ~ n => if (s.isDefined) "-" + n else n } |
 | 
|
89  | 
      atom("option value", tok => tok.is_name || tok.is_float)
 | 
|
| 62968 | 90  | 
}  | 
| 48807 | 91  | 
|
| 62968 | 92  | 
object Parser extends Parse.Parser with Parser  | 
93  | 
  {
 | 
|
| 61579 | 94  | 
def comment_marker: Parser[String] =  | 
95  | 
      $$$("--") | $$$(Symbol.comment) | $$$(Symbol.comment_decoded)
 | 
|
96  | 
||
| 48807 | 97  | 
val option_entry: Parser[Options => Options] =  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
98  | 
    {
 | 
| 49270 | 99  | 
command(SECTION) ~! text ^^  | 
| 49295 | 100  | 
        { case _ ~ a => (options: Options) => options.set_section(a) } |
 | 
| 
60133
 
a90982bbe8b4
clarified keywords for quasi-command spans and Sidekick structure;
 
wenzelm 
parents: 
59811 
diff
changeset
 | 
101  | 
      opt($$$(PUBLIC)) ~ command(OPTION) ~! (position(option_name) ~ $$$(":") ~ option_type ~
 | 
| 61579 | 102  | 
      $$$("=") ~ option_value ~ (comment_marker ~! text ^^ { case _ ~ x => x } | success(""))) ^^
 | 
| 59811 | 103  | 
        { case a ~ _ ~ ((b, pos) ~ _ ~ c ~ _ ~ d ~ e) =>
 | 
| 56465 | 104  | 
(options: Options) => options.declare(a.isDefined, pos, b, c, d, e) }  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
105  | 
}  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
106  | 
|
| 48807 | 107  | 
val prefs_entry: Parser[Options => Options] =  | 
108  | 
    {
 | 
|
| 58908 | 109  | 
      option_name ~ ($$$("=") ~! option_value) ^^
 | 
| 48860 | 110  | 
      { case a ~ (_ ~ b) => (options: Options) => options.add_permissive(a, b) }
 | 
| 48807 | 111  | 
}  | 
112  | 
||
113  | 
def parse_file(syntax: Outer_Syntax, parser: Parser[Options => Options],  | 
|
114  | 
options: Options, file: Path): Options =  | 
|
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
115  | 
    {
 | 
| 59083 | 116  | 
val toks = Token.explode(syntax.keywords, File.read(file))  | 
| 48807 | 117  | 
val ops =  | 
| 59705 | 118  | 
        parse_all(rep(parser), Token.reader(toks, Token.Pos.file(file.implode))) match {
 | 
| 48807 | 119  | 
case Success(result, _) => result  | 
120  | 
case bad => error(bad.toString)  | 
|
121  | 
}  | 
|
| 49270 | 122  | 
      try { (options.set_section("") /: ops) { case (opts, op) => op(opts) } }
 | 
| 48992 | 123  | 
      catch { case ERROR(msg) => error(msg + Position.here(file.position)) }
 | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
124  | 
}  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
125  | 
}  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
126  | 
|
| 
64186
 
49816908ae42
support for separate sub-system options, independent of main Isabelle options;
 
wenzelm 
parents: 
64151 
diff
changeset
 | 
127  | 
def load(file: Path): Options =  | 
| 
 
49816908ae42
support for separate sub-system options, independent of main Isabelle options;
 
wenzelm 
parents: 
64151 
diff
changeset
 | 
128  | 
Parser.parse_file(options_syntax, Parser.option_entry, empty, file)  | 
| 
 
49816908ae42
support for separate sub-system options, independent of main Isabelle options;
 
wenzelm 
parents: 
64151 
diff
changeset
 | 
129  | 
|
| 48807 | 130  | 
def init_defaults(): Options =  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
131  | 
  {
 | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
132  | 
var options = empty  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
133  | 
    for {
 | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
134  | 
dir <- Isabelle_System.components()  | 
| 48548 | 135  | 
file = dir + OPTIONS if file.is_file  | 
| 48807 | 136  | 
    } { options = Parser.parse_file(options_syntax, Parser.option_entry, options, file) }
 | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
137  | 
options  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
138  | 
}  | 
| 48457 | 139  | 
|
| 48807 | 140  | 
def init(): Options = init_defaults().load_prefs()  | 
141  | 
||
| 48457 | 142  | 
|
143  | 
/* encode */  | 
|
144  | 
||
145  | 
val encode: XML.Encode.T[Options] = (options => options.encode)  | 
|
| 
48693
 
ceeea46bdeba
"isabelle options" prints Isabelle system options;
 
wenzelm 
parents: 
48605 
diff
changeset
 | 
146  | 
|
| 
 
ceeea46bdeba
"isabelle options" prints Isabelle system options;
 
wenzelm 
parents: 
48605 
diff
changeset
 | 
147  | 
|
| 62832 | 148  | 
/* Isabelle tool wrapper */  | 
| 
48693
 
ceeea46bdeba
"isabelle options" prints Isabelle system options;
 
wenzelm 
parents: 
48605 
diff
changeset
 | 
149  | 
|
| 62832 | 150  | 
  val isabelle_tool = Isabelle_Tool("option", "print Isabelle system options", args =>
 | 
| 
48693
 
ceeea46bdeba
"isabelle options" prints Isabelle system options;
 
wenzelm 
parents: 
48605 
diff
changeset
 | 
151  | 
  {
 | 
| 62832 | 152  | 
var build_options = false  | 
153  | 
var get_option = ""  | 
|
154  | 
var list_options = false  | 
|
155  | 
var export_file = ""  | 
|
| 62437 | 156  | 
|
| 62832 | 157  | 
    val getopts = Getopts("""
 | 
| 62437 | 158  | 
Usage: isabelle options [OPTIONS] [MORE_OPTIONS ...]  | 
| 
48693
 
ceeea46bdeba
"isabelle options" prints Isabelle system options;
 
wenzelm 
parents: 
48605 
diff
changeset
 | 
159  | 
|
| 62437 | 160  | 
Options are:  | 
161  | 
-b include $ISABELLE_BUILD_OPTIONS  | 
|
162  | 
-g OPTION get value of OPTION  | 
|
163  | 
-l list options  | 
|
164  | 
-x FILE export options to FILE in YXML format  | 
|
165  | 
||
166  | 
Report Isabelle system options, augmented by MORE_OPTIONS given as  | 
|
167  | 
arguments NAME=VAL or NAME.  | 
|
168  | 
""",  | 
|
| 62832 | 169  | 
"b" -> (_ => build_options = true),  | 
170  | 
"g:" -> (arg => get_option = arg),  | 
|
171  | 
"l" -> (_ => list_options = true),  | 
|
172  | 
"x:" -> (arg => export_file = arg))  | 
|
| 
52737
 
7b396ef36af6
clarified meaning of options for "isabelle options";
 
wenzelm 
parents: 
52735 
diff
changeset
 | 
173  | 
|
| 62832 | 174  | 
val more_options = getopts(args)  | 
175  | 
if (get_option == "" && !list_options && export_file == "") getopts.usage()  | 
|
| 
52737
 
7b396ef36af6
clarified meaning of options for "isabelle options";
 
wenzelm 
parents: 
52735 
diff
changeset
 | 
176  | 
|
| 62832 | 177  | 
val options =  | 
178  | 
    {
 | 
|
179  | 
val options0 = Options.init()  | 
|
180  | 
val options1 =  | 
|
181  | 
if (build_options)  | 
|
182  | 
          (options0 /: Word.explode(Isabelle_System.getenv("ISABELLE_BUILD_OPTIONS")))(_ + _)
 | 
|
183  | 
else options0  | 
|
184  | 
(options1 /: more_options)(_ + _)  | 
|
185  | 
}  | 
|
| 
48693
 
ceeea46bdeba
"isabelle options" prints Isabelle system options;
 
wenzelm 
parents: 
48605 
diff
changeset
 | 
186  | 
|
| 62832 | 187  | 
if (get_option != "")  | 
188  | 
Console.println(options.check_name(get_option).value)  | 
|
| 62437 | 189  | 
|
| 62832 | 190  | 
if (export_file != "")  | 
191  | 
File.write(Path.explode(export_file), YXML.string_of_body(options.encode))  | 
|
| 62437 | 192  | 
|
| 62832 | 193  | 
if (get_option == "" && export_file == "")  | 
194  | 
Console.println(options.print)  | 
|
195  | 
})  | 
|
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
196  | 
}  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
197  | 
|
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
198  | 
|
| 49270 | 199  | 
final class Options private(  | 
| 49296 | 200  | 
val options: Map[String, Options.Opt] = Map.empty,  | 
| 49270 | 201  | 
val section: String = "")  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
202  | 
{
 | 
| 
64186
 
49816908ae42
support for separate sub-system options, independent of main Isabelle options;
 
wenzelm 
parents: 
64151 
diff
changeset
 | 
203  | 
  override def toString: String = options.iterator.mkString("Options(", ",", ")")
 | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
204  | 
|
| 54347 | 205  | 
private def print_opt(opt: Options.Opt): String =  | 
206  | 
if (opt.public) "public " + opt.print else opt.print  | 
|
207  | 
||
208  | 
def print: String = cat_lines(options.toList.sortBy(_._1).map(p => print_opt(p._2)))  | 
|
| 
48693
 
ceeea46bdeba
"isabelle options" prints Isabelle system options;
 
wenzelm 
parents: 
48605 
diff
changeset
 | 
209  | 
|
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
210  | 
def description(name: String): String = check_name(name).description  | 
| 
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
211  | 
|
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
212  | 
|
| 48370 | 213  | 
/* check */  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
214  | 
|
| 49246 | 215  | 
def check_name(name: String): Options.Opt =  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
216  | 
    options.get(name) match {
 | 
| 48860 | 217  | 
case Some(opt) if !opt.unknown => opt  | 
218  | 
      case _ => error("Unknown option " + quote(name))
 | 
|
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
219  | 
}  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
220  | 
|
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
221  | 
private def check_type(name: String, typ: Options.Type): Options.Opt =  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
222  | 
  {
 | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
223  | 
val opt = check_name(name)  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
224  | 
if (opt.typ == typ) opt  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
225  | 
    else error("Ill-typed option " + quote(name) + " : " + opt.typ.print + " vs. " + typ.print)
 | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
226  | 
}  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
227  | 
|
| 48370 | 228  | 
|
229  | 
/* basic operations */  | 
|
230  | 
||
231  | 
private def put[A](name: String, typ: Options.Type, value: String): Options =  | 
|
232  | 
  {
 | 
|
233  | 
val opt = check_type(name, typ)  | 
|
| 49270 | 234  | 
new Options(options + (name -> opt.copy(value = value)), section)  | 
| 48370 | 235  | 
}  | 
236  | 
||
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
237  | 
private def get[A](name: String, typ: Options.Type, parse: String => Option[A]): A =  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
238  | 
  {
 | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
239  | 
val opt = check_type(name, typ)  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
240  | 
    parse(opt.value) match {
 | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
241  | 
case Some(x) => x  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
242  | 
case None =>  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
243  | 
        error("Malformed value for option " + quote(name) +
 | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
244  | 
" : " + typ.print + " =\n" + quote(opt.value))  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
245  | 
}  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
246  | 
}  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
247  | 
|
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
248  | 
|
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
249  | 
/* internal lookup and update */  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
250  | 
|
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
251  | 
class Bool_Access  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
252  | 
  {
 | 
| 63805 | 253  | 
def apply(name: String): Boolean = get(name, Options.Bool, Value.Boolean.unapply)  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
254  | 
def update(name: String, x: Boolean): Options =  | 
| 63805 | 255  | 
put(name, Options.Bool, Value.Boolean(x))  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
256  | 
}  | 
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
257  | 
val bool = new Bool_Access  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
258  | 
|
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
259  | 
class Int_Access  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
260  | 
  {
 | 
| 63805 | 261  | 
def apply(name: String): Int = get(name, Options.Int, Value.Int.unapply)  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
262  | 
def update(name: String, x: Int): Options =  | 
| 63805 | 263  | 
put(name, Options.Int, Value.Int(x))  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
264  | 
}  | 
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
265  | 
val int = new Int_Access  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
266  | 
|
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
267  | 
class Real_Access  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
268  | 
  {
 | 
| 63805 | 269  | 
def apply(name: String): Double = get(name, Options.Real, Value.Double.unapply)  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
270  | 
def update(name: String, x: Double): Options =  | 
| 63805 | 271  | 
put(name, Options.Real, Value.Double(x))  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
272  | 
}  | 
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
273  | 
val real = new Real_Access  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
274  | 
|
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
275  | 
class String_Access  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
276  | 
  {
 | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
277  | 
def apply(name: String): String = get(name, Options.String, s => Some(s))  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
278  | 
def update(name: String, x: String): Options = put(name, Options.String, x)  | 
| 
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
279  | 
}  | 
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
280  | 
val string = new String_Access  | 
| 48370 | 281  | 
|
| 50207 | 282  | 
class Seconds_Access  | 
283  | 
  {
 | 
|
284  | 
def apply(name: String): Time = Time.seconds(real(name))  | 
|
285  | 
}  | 
|
286  | 
val seconds = new Seconds_Access  | 
|
287  | 
||
| 48370 | 288  | 
|
| 48807 | 289  | 
/* external updates */  | 
| 48370 | 290  | 
|
291  | 
private def check_value(name: String): Options =  | 
|
292  | 
  {
 | 
|
293  | 
val opt = check_name(name)  | 
|
294  | 
    opt.typ match {
 | 
|
295  | 
case Options.Bool => bool(name); this  | 
|
296  | 
case Options.Int => int(name); this  | 
|
297  | 
case Options.Real => real(name); this  | 
|
298  | 
case Options.String => string(name); this  | 
|
| 48860 | 299  | 
case Options.Unknown => this  | 
| 48370 | 300  | 
}  | 
301  | 
}  | 
|
302  | 
||
| 56465 | 303  | 
def declare(  | 
304  | 
public: Boolean,  | 
|
305  | 
pos: Position.T,  | 
|
306  | 
name: String,  | 
|
307  | 
typ_name: String,  | 
|
308  | 
value: String,  | 
|
309  | 
description: String): Options =  | 
|
| 48370 | 310  | 
  {
 | 
311  | 
    options.get(name) match {
 | 
|
| 56465 | 312  | 
case Some(other) =>  | 
313  | 
        error("Duplicate declaration of option " + quote(name) + Position.here(pos) +
 | 
|
314  | 
Position.here(other.pos))  | 
|
| 48370 | 315  | 
case None =>  | 
316  | 
val typ =  | 
|
317  | 
          typ_name match {
 | 
|
318  | 
case "bool" => Options.Bool  | 
|
319  | 
case "int" => Options.Int  | 
|
320  | 
case "real" => Options.Real  | 
|
321  | 
case "string" => Options.String  | 
|
| 56465 | 322  | 
case _ =>  | 
323  | 
              error("Unknown type for option " + quote(name) + " : " + quote(typ_name) +
 | 
|
324  | 
Position.here(pos))  | 
|
| 48370 | 325  | 
}  | 
| 56465 | 326  | 
val opt = Options.Opt(public, pos, name, typ, value, value, description, section)  | 
| 49270 | 327  | 
(new Options(options + (name -> opt), section)).check_value(name)  | 
| 48370 | 328  | 
}  | 
329  | 
}  | 
|
330  | 
||
| 48860 | 331  | 
def add_permissive(name: String, value: String): Options =  | 
332  | 
  {
 | 
|
333  | 
if (options.isDefinedAt(name)) this + (name, value)  | 
|
| 56465 | 334  | 
    else {
 | 
335  | 
val opt = Options.Opt(false, Position.none, name, Options.Unknown, value, value, "", "")  | 
|
336  | 
new Options(options + (name -> opt), section)  | 
|
337  | 
}  | 
|
| 48860 | 338  | 
}  | 
339  | 
||
| 48807 | 340  | 
def + (name: String, value: String): Options =  | 
| 48370 | 341  | 
  {
 | 
342  | 
val opt = check_name(name)  | 
|
| 49270 | 343  | 
(new Options(options + (name -> opt.copy(value = value)), section)).check_value(name)  | 
| 48370 | 344  | 
}  | 
345  | 
||
| 48807 | 346  | 
def + (name: String, opt_value: Option[String]): Options =  | 
| 48370 | 347  | 
  {
 | 
348  | 
val opt = check_name(name)  | 
|
349  | 
    opt_value match {
 | 
|
| 48807 | 350  | 
case Some(value) => this + (name, value)  | 
351  | 
case None if opt.typ == Options.Bool => this + (name, "true")  | 
|
| 48370 | 352  | 
      case None => error("Missing value for option " + quote(name) + " : " + opt.typ.print)
 | 
353  | 
}  | 
|
354  | 
}  | 
|
355  | 
||
| 48807 | 356  | 
def + (str: String): Options =  | 
| 48370 | 357  | 
  {
 | 
358  | 
    str.indexOf('=') match {
 | 
|
| 48807 | 359  | 
case -1 => this + (str, None)  | 
360  | 
case i => this + (str.substring(0, i), str.substring(i + 1))  | 
|
| 48370 | 361  | 
}  | 
362  | 
}  | 
|
| 
48456
 
d8ff14f44a40
added ML version of stand-alone options, with XML.encode/decode operations (unidirectional from Scala to ML);
 
wenzelm 
parents: 
48421 
diff
changeset
 | 
363  | 
|
| 48807 | 364  | 
def ++ (specs: List[Options.Spec]): Options =  | 
365  | 
    (this /: specs)({ case (x, (y, z)) => x + (y, z) })
 | 
|
366  | 
||
| 
48456
 
d8ff14f44a40
added ML version of stand-alone options, with XML.encode/decode operations (unidirectional from Scala to ML);
 
wenzelm 
parents: 
48421 
diff
changeset
 | 
367  | 
|
| 49270 | 368  | 
/* sections */  | 
369  | 
||
370  | 
def set_section(new_section: String): Options =  | 
|
371  | 
new Options(options, new_section)  | 
|
372  | 
||
373  | 
def sections: List[(String, List[Options.Opt])] =  | 
|
374  | 
    options.groupBy(_._2.section).toList.map({ case (a, opts) => (a, opts.toList.map(_._2)) })
 | 
|
375  | 
||
376  | 
||
| 
48456
 
d8ff14f44a40
added ML version of stand-alone options, with XML.encode/decode operations (unidirectional from Scala to ML);
 
wenzelm 
parents: 
48421 
diff
changeset
 | 
377  | 
/* encode */  | 
| 
 
d8ff14f44a40
added ML version of stand-alone options, with XML.encode/decode operations (unidirectional from Scala to ML);
 
wenzelm 
parents: 
48421 
diff
changeset
 | 
378  | 
|
| 
 
d8ff14f44a40
added ML version of stand-alone options, with XML.encode/decode operations (unidirectional from Scala to ML);
 
wenzelm 
parents: 
48421 
diff
changeset
 | 
379  | 
def encode: XML.Body =  | 
| 
 
d8ff14f44a40
added ML version of stand-alone options, with XML.encode/decode operations (unidirectional from Scala to ML);
 
wenzelm 
parents: 
48421 
diff
changeset
 | 
380  | 
  {
 | 
| 48860 | 381  | 
val opts =  | 
| 56465 | 382  | 
for ((_, opt) <- options.toList; if !opt.unknown)  | 
383  | 
yield (opt.pos, (opt.name, (opt.typ.print, opt.value)))  | 
|
| 48860 | 384  | 
|
| 56465 | 385  | 
    import XML.Encode.{string => string_, _}
 | 
386  | 
list(pair(properties, pair(string_, pair(string_, string_))))(opts)  | 
|
| 
48456
 
d8ff14f44a40
added ML version of stand-alone options, with XML.encode/decode operations (unidirectional from Scala to ML);
 
wenzelm 
parents: 
48421 
diff
changeset
 | 
387  | 
}  | 
| 48807 | 388  | 
|
389  | 
||
390  | 
/* user preferences */  | 
|
391  | 
||
392  | 
def load_prefs(): Options =  | 
|
393  | 
if (Options.PREFS.is_file)  | 
|
394  | 
Options.Parser.parse_file(  | 
|
395  | 
Options.prefs_syntax, Options.Parser.prefs_entry, this, Options.PREFS)  | 
|
396  | 
else this  | 
|
397  | 
||
398  | 
def save_prefs()  | 
|
399  | 
  {
 | 
|
| 48860 | 400  | 
val defaults = Options.init_defaults()  | 
| 48807 | 401  | 
val changed =  | 
402  | 
      (for {
 | 
|
| 48860 | 403  | 
(name, opt2) <- options.iterator  | 
404  | 
opt1 = defaults.options.get(name)  | 
|
| 60215 | 405  | 
if opt1.isEmpty || opt1.get.value != opt2.value  | 
| 48860 | 406  | 
} yield (name, opt2.value, if (opt1.isEmpty) " (* unknown *)" else "")).toList  | 
407  | 
||
| 48807 | 408  | 
val prefs =  | 
409  | 
changed.sortBy(_._1)  | 
|
| 48860 | 410  | 
        .map({ case (x, y, z) => x + " = " + Outer_Syntax.quote_string(y) + z + "\n" }).mkString
 | 
| 48807 | 411  | 
|
| 
50893
 
d55eb82ae77b
Isabelle_System.mkdirs with explicit error checking (in accordance to ML version), e.g. relevant with read-only DMG file-system on Mac OS X;
 
wenzelm 
parents: 
50793 
diff
changeset
 | 
412  | 
Isabelle_System.mkdirs(Options.PREFS_DIR)  | 
| 64151 | 413  | 
File.write_backup(Options.PREFS, "(* generated by Isabelle " + Date.now() + " *)\n\n" + prefs)  | 
| 48807 | 414  | 
}  | 
| 
48365
 
d88aefda01c4
basic support for stand-alone options with external string representation;
 
wenzelm 
parents:  
diff
changeset
 | 
415  | 
}  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
416  | 
|
| 
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
417  | 
|
| 
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
418  | 
class Options_Variable  | 
| 
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
419  | 
{
 | 
| 
62227
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
420  | 
private var options: Option[Options] = None  | 
| 
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
421  | 
|
| 
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
422  | 
  def store(new_options: Options): Unit = synchronized { options = Some(new_options) }
 | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
423  | 
|
| 
62227
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
424  | 
  def value: Options = synchronized {
 | 
| 
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
425  | 
    options match {
 | 
| 
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
426  | 
case Some(opts) => opts  | 
| 
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
427  | 
      case None => error("Uninitialized Isabelle system options")
 | 
| 
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
428  | 
}  | 
| 
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
429  | 
}  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
430  | 
|
| 
62227
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
431  | 
  private def upd(f: Options => Options): Unit = synchronized { options = Some(f(value)) }
 | 
| 
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
432  | 
|
| 
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
433  | 
def + (name: String, x: String): Unit = upd(opts => opts + (name, x))  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
434  | 
|
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
435  | 
class Bool_Access  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
436  | 
  {
 | 
| 
62227
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
437  | 
def apply(name: String): Boolean = value.bool(name)  | 
| 
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
438  | 
def update(name: String, x: Boolean): Unit = upd(opts => opts.bool.update(name, x))  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
439  | 
}  | 
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
440  | 
val bool = new Bool_Access  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
441  | 
|
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
442  | 
class Int_Access  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
443  | 
  {
 | 
| 
62227
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
444  | 
def apply(name: String): Int = value.int(name)  | 
| 
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
445  | 
def update(name: String, x: Int): Unit = upd(opts => opts.int.update(name, x))  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
446  | 
}  | 
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
447  | 
val int = new Int_Access  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
448  | 
|
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
449  | 
class Real_Access  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
450  | 
  {
 | 
| 
62227
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
451  | 
def apply(name: String): Double = value.real(name)  | 
| 
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
452  | 
def update(name: String, x: Double): Unit = upd(opts => opts.real.update(name, x))  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
453  | 
}  | 
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
454  | 
val real = new Real_Access  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
455  | 
|
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
456  | 
class String_Access  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
457  | 
  {
 | 
| 
62227
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
458  | 
def apply(name: String): String = value.string(name)  | 
| 
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
459  | 
def update(name: String, x: String): Unit = upd(opts => opts.string.update(name, x))  | 
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
460  | 
}  | 
| 
49954
 
44658062d822
more explicit auxiliary classes to avoid warning "reflective access of structural type member method" of scala-2.10.0-RC1;
 
wenzelm 
parents: 
49296 
diff
changeset
 | 
461  | 
val string = new String_Access  | 
| 50207 | 462  | 
|
463  | 
class Seconds_Access  | 
|
464  | 
  {
 | 
|
| 
62227
 
6eeaaefcea56
clarified errors: more explicit treatment of uninitialized state;
 
wenzelm 
parents: 
61579 
diff
changeset
 | 
465  | 
def apply(name: String): Time = value.seconds(name)  | 
| 50207 | 466  | 
}  | 
467  | 
val seconds = new Seconds_Access  | 
|
| 
49245
 
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
 
wenzelm 
parents: 
48992 
diff
changeset
 | 
468  | 
}  |