author | wenzelm |
Tue, 07 Nov 2023 12:02:34 +0100 | |
changeset 78908 | f38153e58f21 |
parent 78614 | 4da5cdaa4dcd |
child 78909 | 65acbafc70e5 |
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 |
|
75393 | 10 |
object Options { |
77624 | 11 |
val empty: Options = new Options() |
48421 | 12 |
|
77626
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
13 |
object Spec { |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
14 |
def make(s: String): Spec = |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
15 |
s match { |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
16 |
case Properties.Eq(a, b) => Spec(a, Some(b)) |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
17 |
case _ => Spec(s) |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
18 |
} |
77628 | 19 |
|
20 |
def ISABELLE_BUILD_OPTIONS: List[Spec] = |
|
21 |
Word.explode(Isabelle_System.getenv("ISABELLE_BUILD_OPTIONS")).map(make) |
|
78560 | 22 |
|
23 |
def print_value(s: String): String = |
|
24 |
s match { |
|
25 |
case Value.Boolean(_) => s |
|
26 |
case Value.Long(_) => s |
|
27 |
case Value.Double(_) => s |
|
28 |
case _ => Token.quote_name(specs_syntax.keywords, s) |
|
29 |
} |
|
30 |
||
31 |
def print(name: String, value: String): String = Properties.Eq(name, print_value(value)) |
|
78908
f38153e58f21
proper Option.Spec.toString for bash script: avoid Token.quote_name of Options.Spec.print_value (amending 3d1746a716fa, see also 39f6f180008d);
wenzelm
parents:
78614
diff
changeset
|
32 |
|
f38153e58f21
proper Option.Spec.toString for bash script: avoid Token.quote_name of Options.Spec.print_value (amending 3d1746a716fa, see also 39f6f180008d);
wenzelm
parents:
78614
diff
changeset
|
33 |
def bash_strings(opts: Iterable[Spec]): String = |
f38153e58f21
proper Option.Spec.toString for bash script: avoid Token.quote_name of Options.Spec.print_value (amending 3d1746a716fa, see also 39f6f180008d);
wenzelm
parents:
78614
diff
changeset
|
34 |
opts.iterator.map(opt => "-o " + Bash.string(opt.toString)).mkString(" ", " ", " ") |
77626
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
35 |
} |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
36 |
|
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
37 |
sealed case class Spec(name: String, value: Option[String] = None, permissive: Boolean = false) { |
77625 | 38 |
override def toString: String = name + if_proper(value, "=" + value.get) |
78560 | 39 |
def print: String = name + if_proper(value, "=" + Spec.print_value(value.get)) |
77625 | 40 |
} |
48421 | 41 |
|
77623 | 42 |
sealed case class Change(name: String, value: String, unknown: Boolean) { |
77626
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
43 |
def spec: Spec = Spec(name, Some(value)) |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
44 |
|
77623 | 45 |
def print_prefs: String = |
46 |
name + " = " + Outer_Syntax.quote_string(value) + |
|
47 |
if_proper(unknown, " (* unknown *)") + "\n" |
|
48 |
} |
|
49 |
||
48421 | 50 |
|
75847 | 51 |
/* typed access */ |
75842 | 52 |
|
75846 | 53 |
abstract class Access[A](val options: Options) { |
75842 | 54 |
def apply(name: String): A |
55 |
def update(name: String, x: A): Options |
|
75847 | 56 |
def change(name: String, f: A => A): Options = update(name, f(apply(name))) |
75842 | 57 |
} |
58 |
||
75847 | 59 |
class Access_Variable[A]( |
60 |
val options: Options_Variable, |
|
61 |
val pure_access: Options => Access[A] |
|
62 |
) { |
|
63 |
def apply(name: String): A = pure_access(options.value)(name) |
|
64 |
def update(name: String, x: A): Unit = |
|
65 |
options.change(options => pure_access(options).update(name, x)) |
|
66 |
def change(name: String, f: A => A): Unit = update(name, f(apply(name))) |
|
75842 | 67 |
} |
68 |
||
69 |
||
48421 | 70 |
/* representation */ |
71 |
||
75393 | 72 |
sealed abstract class Type { |
56599 | 73 |
def print: String = Word.lowercase(toString) |
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
74 |
} |
49246 | 75 |
case object Bool extends Type |
76 |
case object Int extends Type |
|
77 |
case object Real extends Type |
|
78 |
case object String extends Type |
|
79 |
case object Unknown extends Type |
|
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
80 |
|
77611 | 81 |
val TAG_CONTENT = "content" // formal theory content |
82 |
val TAG_DOCUMENT = "document" // document preparation |
|
83 |
val TAG_BUILD = "build" // relavant for "isabelle build" |
|
84 |
val TAG_UPDATE = "update" // relevant for "isabelle update" |
|
85 |
val TAG_CONNECTION = "connection" // private information about connections (password etc.) |
|
77612 | 86 |
val TAG_COLOR_DIALOG = "color_dialog" // special color selection dialog |
77603 | 87 |
|
77605 | 88 |
case class Entry( |
56465 | 89 |
public: Boolean, |
90 |
pos: Position.T, |
|
91 |
name: String, |
|
92 |
typ: Type, |
|
93 |
value: String, |
|
94 |
default_value: String, |
|
74827
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
95 |
standard_value: Option[String], |
77603 | 96 |
tags: List[String], |
56465 | 97 |
description: String, |
75393 | 98 |
section: String |
99 |
) { |
|
74827
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
100 |
private def print_value(x: String): String = if (typ == Options.String) quote(x) else x |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
101 |
private def print_standard: String = |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
102 |
standard_value match { |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
103 |
case None => "" |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
104 |
case Some(s) if s == default_value => " (standard)" |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
105 |
case Some(s) => " (standard " + print_value(s) + ")" |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
106 |
} |
75393 | 107 |
private def print(default: Boolean): String = { |
49289 | 108 |
val x = if (default) default_value else value |
74827
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
109 |
"option " + name + " : " + typ.print + " = " + print_value(x) + print_standard + |
77504 | 110 |
if_proper(description, "\n -- " + quote(description)) |
49289 | 111 |
} |
112 |
||
113 |
def print: String = print(false) |
|
114 |
def print_default: String = print(true) |
|
49247 | 115 |
|
75393 | 116 |
def title(strip: String = ""): String = { |
56600 | 117 |
val words = Word.explode('_', name) |
49270 | 118 |
val words1 = |
119 |
words match { |
|
120 |
case word :: rest if word == strip => rest |
|
121 |
case _ => words |
|
122 |
} |
|
78614 | 123 |
Word.implode(words1.map(Word.perhaps_capitalized)) |
49270 | 124 |
} |
76579 | 125 |
def title_jedit: String = title("jedit") |
49270 | 126 |
|
48860 | 127 |
def unknown: Boolean = typ == Unknown |
77603 | 128 |
|
77617 | 129 |
def for_tag(tag: String): Boolean = tags.contains(tag) |
130 |
def for_content: Boolean = for_tag(TAG_CONTENT) |
|
131 |
def for_document: Boolean = for_tag(TAG_DOCUMENT) |
|
132 |
def for_color_dialog: Boolean = for_tag(TAG_COLOR_DIALOG) |
|
133 |
||
134 |
def session_content: Boolean = for_content || for_document |
|
48860 | 135 |
} |
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
136 |
|
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
137 |
|
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
138 |
/* parsing */ |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
139 |
|
49270 | 140 |
private val SECTION = "section" |
52065
78f2475aa126
explicit notion of public options, which are shown in the editor options dialog;
wenzelm
parents:
51945
diff
changeset
|
141 |
private val PUBLIC = "public" |
48795
bece259ee055
clarified format of etc/options: only declarations, not re-definitions;
wenzelm
parents:
48718
diff
changeset
|
142 |
private val OPTION = "option" |
74827
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
143 |
private val STANDARD = "standard" |
77603 | 144 |
private val FOR = "for" |
48807 | 145 |
private val OPTIONS = Path.explode("etc/options") |
67845 | 146 |
private val PREFS = Path.explode("$ISABELLE_HOME_USER/etc/preferences") |
48713
de26cf3191a3
more token markers, based on actual outer syntax;
wenzelm
parents:
48693
diff
changeset
|
147 |
|
71601 | 148 |
val options_syntax: Outer_Syntax = |
74827
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
149 |
Outer_Syntax.empty + ":" + "=" + "--" + "(" + ")" + |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
150 |
Symbol.comment + Symbol.comment_decoded + |
63441 | 151 |
(SECTION, Keyword.DOCUMENT_HEADING) + |
152 |
(PUBLIC, Keyword.BEFORE_COMMAND) + |
|
74827
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
153 |
(OPTION, Keyword.THY_DECL) + |
77603 | 154 |
STANDARD + FOR |
49270 | 155 |
|
71601 | 156 |
val prefs_syntax: Outer_Syntax = Outer_Syntax.empty + "=" |
78407
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
157 |
val specs_syntax: Outer_Syntax = prefs_syntax + "," |
48713
de26cf3191a3
more token markers, based on actual outer syntax;
wenzelm
parents:
48693
diff
changeset
|
158 |
|
75405 | 159 |
trait Parsers extends Parse.Parsers { |
71601 | 160 |
val option_name: Parser[String] = atom("option name", _.is_name) |
161 |
val option_type: Parser[String] = atom("option type", _.is_name) |
|
162 |
val option_value: Parser[String] = |
|
48807 | 163 |
opt(token("-", tok => tok.is_sym_ident && tok.content == "-")) ~ atom("nat", _.is_nat) ^^ |
164 |
{ case s ~ n => if (s.isDefined) "-" + n else n } | |
|
165 |
atom("option value", tok => tok.is_name || tok.is_float) |
|
74827
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
166 |
val option_standard: Parser[Option[String]] = |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
167 |
$$$("(") ~! $$$(STANDARD) ~ opt(option_value) ~ $$$(")") ^^ { case _ ~ _ ~ a ~ _ => a } |
77603 | 168 |
val option_tag: Parser[String] = atom("option tag", _.is_name) |
169 |
val option_tags: Parser[List[String]] = |
|
170 |
$$$(FOR) ~! rep(option_tag) ^^ { case _ ~ x => x } | success(Nil) |
|
78407
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
171 |
val option_spec: Parser[Spec] = |
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
172 |
option_name ~ opt($$$("=") ~! option_value ^^ { case _ ~ x => x }) ^^ |
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
173 |
{ case x ~ y => Options.Spec(x, y) } |
62968 | 174 |
} |
48807 | 175 |
|
75405 | 176 |
private object Parsers extends Parsers { |
61579 | 177 |
def comment_marker: Parser[String] = |
178 |
$$$("--") | $$$(Symbol.comment) | $$$(Symbol.comment_decoded) |
|
179 |
||
75393 | 180 |
val option_entry: Parser[Options => Options] = { |
49270 | 181 |
command(SECTION) ~! text ^^ |
49295 | 182 |
{ case _ ~ a => (options: Options) => options.set_section(a) } | |
60133
a90982bbe8b4
clarified keywords for quasi-command spans and Sidekick structure;
wenzelm
parents:
59811
diff
changeset
|
183 |
opt($$$(PUBLIC)) ~ command(OPTION) ~! (position(option_name) ~ $$$(":") ~ option_type ~ |
77603 | 184 |
$$$("=") ~ option_value ~ opt(option_standard) ~ option_tags ~ |
74827
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
185 |
(comment_marker ~! text ^^ { case _ ~ x => x } | success(""))) ^^ |
77603 | 186 |
{ case a ~ _ ~ ((b, pos) ~ _ ~ c ~ _ ~ d ~ e ~ f ~ g) => |
187 |
(options: Options) => options.declare(a.isDefined, pos, b, c, d, e, f, g) } |
|
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
188 |
} |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
189 |
|
75393 | 190 |
val prefs_entry: Parser[Options => Options] = { |
58908 | 191 |
option_name ~ ($$$("=") ~! option_value) ^^ |
77626
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
192 |
{ case a ~ (_ ~ b) => (options: Options) => |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
193 |
options + Options.Spec(a, Some(b), permissive = true) } |
48807 | 194 |
} |
195 |
||
75393 | 196 |
def parse_file( |
197 |
options: Options, |
|
198 |
file_name: String, |
|
199 |
content: String, |
|
67845 | 200 |
syntax: Outer_Syntax = options_syntax, |
75393 | 201 |
parser: Parser[Options => Options] = option_entry |
202 |
): Options = { |
|
67845 | 203 |
val toks = Token.explode(syntax.keywords, content) |
48807 | 204 |
val ops = |
67845 | 205 |
parse_all(rep(parser), Token.reader(toks, Token.Pos.file(file_name))) match { |
48807 | 206 |
case Success(result, _) => result |
207 |
case bad => error(bad.toString) |
|
208 |
} |
|
73359 | 209 |
try { ops.foldLeft(options.set_section("")) { case (opts, op) => op(opts) } } |
73166 | 210 |
catch { case ERROR(msg) => error(msg + Position.here(Position.File(file_name))) } |
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
211 |
} |
67845 | 212 |
|
213 |
def parse_prefs(options: Options, content: String): Options = |
|
69366 | 214 |
parse_file(options, PREFS.file_name, content, syntax = prefs_syntax, parser = prefs_entry) |
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
215 |
} |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
216 |
|
67845 | 217 |
def read_prefs(file: Path = PREFS): String = |
218 |
if (file.is_file) File.read(file) else "" |
|
64186
49816908ae42
support for separate sub-system options, independent of main Isabelle options;
wenzelm
parents:
64151
diff
changeset
|
219 |
|
78407
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
220 |
def parse_specs(content: String): List[Spec] = { |
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
221 |
val parser = Parsers.repsep(Parsers.option_spec, Parsers.$$$(",")) |
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
222 |
val reader = Token.reader(Token.explode(specs_syntax.keywords, content), Token.Pos.none) |
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
223 |
Parsers.parse_all(parser, reader) match { |
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
224 |
case Parsers.Success(result, _) => result |
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
225 |
case bad => error(bad.toString) |
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
226 |
} |
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
227 |
} |
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
228 |
|
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
229 |
def inline(content: String): Options = Parsers.parse_file(empty, "inline", content) |
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
230 |
|
77628 | 231 |
def init(prefs: String = read_prefs(file = PREFS), specs: List[Spec] = Nil): Options = { |
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
232 |
var options = empty |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
233 |
for { |
73815 | 234 |
dir <- Components.directories() |
48548 | 235 |
file = dir + OPTIONS if file.is_file |
75405 | 236 |
} { options = Parsers.parse_file(options, file.implode, File.read(file)) } |
77628 | 237 |
Parsers.parse_prefs(options, prefs) ++ specs |
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
238 |
} |
48457 | 239 |
|
77609 | 240 |
def init0(): Options = init(prefs = "") |
241 |
||
48457 | 242 |
|
62832 | 243 |
/* Isabelle tool wrapper */ |
48693
ceeea46bdeba
"isabelle options" prints Isabelle system options;
wenzelm
parents:
48605
diff
changeset
|
244 |
|
72763 | 245 |
val isabelle_tool = Isabelle_Tool("options", "print Isabelle system options", |
75394 | 246 |
Scala_Project.here, |
247 |
{ args => |
|
248 |
var build_options = false |
|
249 |
var get_option = "" |
|
250 |
var list_options = false |
|
77616 | 251 |
var list_tags = List.empty[String] |
75394 | 252 |
var export_file = "" |
62437 | 253 |
|
75394 | 254 |
val getopts = Getopts(""" |
62437 | 255 |
Usage: isabelle options [OPTIONS] [MORE_OPTIONS ...] |
48693
ceeea46bdeba
"isabelle options" prints Isabelle system options;
wenzelm
parents:
48605
diff
changeset
|
256 |
|
62437 | 257 |
Options are: |
258 |
-b include $ISABELLE_BUILD_OPTIONS |
|
259 |
-g OPTION get value of OPTION |
|
260 |
-l list options |
|
77616 | 261 |
-t TAGS restrict list to given tags (comma-separated) |
62437 | 262 |
-x FILE export options to FILE in YXML format |
263 |
||
264 |
Report Isabelle system options, augmented by MORE_OPTIONS given as |
|
265 |
arguments NAME=VAL or NAME. |
|
266 |
""", |
|
75394 | 267 |
"b" -> (_ => build_options = true), |
268 |
"g:" -> (arg => get_option = arg), |
|
269 |
"l" -> (_ => list_options = true), |
|
77616 | 270 |
"t:" -> (arg => list_tags = space_explode(',', arg)), |
75394 | 271 |
"x:" -> (arg => export_file = arg)) |
52737
7b396ef36af6
clarified meaning of options for "isabelle options";
wenzelm
parents:
52735
diff
changeset
|
272 |
|
75394 | 273 |
val more_options = getopts(args) |
274 |
if (get_option == "" && !list_options && export_file == "") getopts.usage() |
|
52737
7b396ef36af6
clarified meaning of options for "isabelle options";
wenzelm
parents:
52735
diff
changeset
|
275 |
|
75394 | 276 |
val options = { |
277 |
val options0 = Options.init() |
|
278 |
val options1 = |
|
77628 | 279 |
if (build_options) options0 ++ Options.Spec.ISABELLE_BUILD_OPTIONS else options0 |
75394 | 280 |
more_options.foldLeft(options1)(_ + _) |
281 |
} |
|
48693
ceeea46bdeba
"isabelle options" prints Isabelle system options;
wenzelm
parents:
48605
diff
changeset
|
282 |
|
77613 | 283 |
if (get_option != "") { |
75394 | 284 |
Output.writeln(options.check_name(get_option).value, stdout = true) |
77613 | 285 |
} |
62437 | 286 |
|
77613 | 287 |
if (export_file != "") { |
75394 | 288 |
File.write(Path.explode(export_file), YXML.string_of_body(options.encode)) |
77613 | 289 |
} |
62437 | 290 |
|
77613 | 291 |
if (get_option == "" && export_file == "") { |
77616 | 292 |
val filter: Options.Entry => Boolean = |
293 |
if (list_tags.isEmpty) (_ => true) |
|
77617 | 294 |
else opt => list_tags.exists(opt.for_tag) |
77616 | 295 |
Output.writeln(options.print(filter = filter), stdout = true) |
77613 | 296 |
} |
75394 | 297 |
}) |
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
298 |
} |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
299 |
|
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
300 |
|
49270 | 301 |
final class Options private( |
77605 | 302 |
options: Map[String, Options.Entry] = Map.empty, |
75393 | 303 |
val section: String = "" |
304 |
) { |
|
78407
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
305 |
def defined(name: String): Boolean = options.isDefinedAt(name) |
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
306 |
|
77605 | 307 |
def iterator: Iterator[Options.Entry] = options.valuesIterator |
75844
7d27944d7141
clarified signature: avoid public representation;
wenzelm
parents:
75843
diff
changeset
|
308 |
|
77605 | 309 |
override def toString: String = iterator.mkString("Options(", ",", ")") |
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
310 |
|
77605 | 311 |
private def print_entry(opt: Options.Entry): String = |
77614 | 312 |
if_proper(opt.public, "public ") + opt.print |
54347 | 313 |
|
77616 | 314 |
def print(filter: Options.Entry => Boolean = _ => true): String = |
315 |
cat_lines(iterator.filter(filter).toList.sortBy(_.name).map(print_entry)) |
|
48693
ceeea46bdeba
"isabelle options" prints Isabelle system options;
wenzelm
parents:
48605
diff
changeset
|
316 |
|
49245
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
48992
diff
changeset
|
317 |
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
|
318 |
|
78559 | 319 |
def spec(name: String): Options.Spec = |
320 |
Options.Spec(name, Some(check_name(name).value)) |
|
321 |
||
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
322 |
|
48370 | 323 |
/* check */ |
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
324 |
|
77605 | 325 |
def get(name: String): Option[Options.Entry] = options.get(name) |
75844
7d27944d7141
clarified signature: avoid public representation;
wenzelm
parents:
75843
diff
changeset
|
326 |
|
77605 | 327 |
def check_name(name: String): Options.Entry = |
75844
7d27944d7141
clarified signature: avoid public representation;
wenzelm
parents:
75843
diff
changeset
|
328 |
get(name) match { |
48860 | 329 |
case Some(opt) if !opt.unknown => opt |
330 |
case _ => error("Unknown option " + quote(name)) |
|
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
331 |
} |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
332 |
|
77605 | 333 |
private def check_type(name: String, typ: Options.Type): Options.Entry = { |
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
334 |
val opt = check_name(name) |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
335 |
if (opt.typ == typ) opt |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
336 |
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
|
337 |
} |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
338 |
|
48370 | 339 |
|
340 |
/* basic operations */ |
|
341 |
||
75843 | 342 |
private def put(name: String, typ: Options.Type, value: String): Options = { |
48370 | 343 |
val opt = check_type(name, typ) |
49270 | 344 |
new Options(options + (name -> opt.copy(value = value)), section) |
48370 | 345 |
} |
346 |
||
75393 | 347 |
private def get[A](name: String, typ: Options.Type, parse: String => Option[A]): A = { |
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
348 |
val opt = check_type(name, typ) |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
349 |
parse(opt.value) match { |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
350 |
case Some(x) => x |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
351 |
case None => |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
352 |
error("Malformed value for option " + quote(name) + |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
353 |
" : " + typ.print + " =\n" + quote(opt.value)) |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
354 |
} |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
355 |
} |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
356 |
|
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
357 |
|
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
358 |
/* internal lookup and update */ |
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
359 |
|
75846 | 360 |
val bool: Options.Access[Boolean] = |
361 |
new Options.Access[Boolean](this) { |
|
362 |
def apply(name: String): Boolean = get(name, Options.Bool, Value.Boolean.unapply) |
|
363 |
def update(name: String, x: Boolean): Options = put(name, Options.Bool, Value.Boolean(x)) |
|
364 |
} |
|
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
365 |
|
75846 | 366 |
val int: Options.Access[Int] = |
367 |
new Options.Access[Int](this) { |
|
368 |
def apply(name: String): Int = get(name, Options.Int, Value.Int.unapply) |
|
369 |
def update(name: String, x: Int): Options = put(name, Options.Int, Value.Int(x)) |
|
370 |
} |
|
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
371 |
|
75846 | 372 |
val real: Options.Access[Double] = |
373 |
new Options.Access[Double](this) { |
|
374 |
def apply(name: String): Double = get(name, Options.Real, Value.Double.unapply) |
|
375 |
def update(name: String, x: Double): Options = put(name, Options.Real, Value.Double(x)) |
|
376 |
} |
|
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
377 |
|
75846 | 378 |
val string: Options.Access[String] = |
379 |
new Options.Access[String](this) { |
|
380 |
def apply(name: String): String = get(name, Options.String, Some(_)) |
|
381 |
def update(name: String, x: String): Options = put(name, Options.String, x) |
|
382 |
} |
|
48370 | 383 |
|
69073 | 384 |
def seconds(name: String): Time = Time.seconds(real(name)) |
50207 | 385 |
|
48370 | 386 |
|
48807 | 387 |
/* external updates */ |
48370 | 388 |
|
75393 | 389 |
private def check_value(name: String): Options = { |
48370 | 390 |
val opt = check_name(name) |
391 |
opt.typ match { |
|
392 |
case Options.Bool => bool(name); this |
|
393 |
case Options.Int => int(name); this |
|
394 |
case Options.Real => real(name); this |
|
395 |
case Options.String => string(name); this |
|
48860 | 396 |
case Options.Unknown => this |
48370 | 397 |
} |
398 |
} |
|
399 |
||
56465 | 400 |
def declare( |
401 |
public: Boolean, |
|
402 |
pos: Position.T, |
|
403 |
name: String, |
|
404 |
typ_name: String, |
|
405 |
value: String, |
|
74827
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
406 |
standard: Option[Option[String]], |
77603 | 407 |
tags: List[String], |
75393 | 408 |
description: String |
409 |
): Options = { |
|
75844
7d27944d7141
clarified signature: avoid public representation;
wenzelm
parents:
75843
diff
changeset
|
410 |
get(name) match { |
56465 | 411 |
case Some(other) => |
412 |
error("Duplicate declaration of option " + quote(name) + Position.here(pos) + |
|
413 |
Position.here(other.pos)) |
|
48370 | 414 |
case None => |
415 |
val typ = |
|
416 |
typ_name match { |
|
417 |
case "bool" => Options.Bool |
|
418 |
case "int" => Options.Int |
|
419 |
case "real" => Options.Real |
|
420 |
case "string" => Options.String |
|
56465 | 421 |
case _ => |
422 |
error("Unknown type for option " + quote(name) + " : " + quote(typ_name) + |
|
423 |
Position.here(pos)) |
|
48370 | 424 |
} |
74827
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
425 |
val standard_value = |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
426 |
standard match { |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
427 |
case None => None |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
428 |
case Some(_) if typ == Options.Bool => |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
429 |
error("Illegal standard value for option " + quote(name) + " : " + typ_name + |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
430 |
Position.here) |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
431 |
case Some(s) => Some(s.getOrElse(value)) |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
432 |
} |
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74144
diff
changeset
|
433 |
val opt = |
77605 | 434 |
Options.Entry( |
77603 | 435 |
public, pos, name, typ, value, value, standard_value, tags, description, section) |
49270 | 436 |
(new Options(options + (name -> opt), section)).check_value(name) |
48370 | 437 |
} |
438 |
} |
|
439 |
||
77626
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
440 |
def + (spec: Options.Spec): Options = { |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
441 |
val name = spec.name |
78407
b262ecc98319
more operations for independent "inline" options;
wenzelm
parents:
77668
diff
changeset
|
442 |
if (spec.permissive && !defined(name)) { |
77626
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
443 |
val value = spec.value.getOrElse("") |
77603 | 444 |
val opt = |
77605 | 445 |
Options.Entry(false, Position.none, name, Options.Unknown, value, value, None, Nil, "", "") |
56465 | 446 |
new Options(options + (name -> opt), section) |
447 |
} |
|
77626
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
448 |
else { |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
449 |
val opt = check_name(name) |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
450 |
def put(value: String): Options = |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
451 |
(new Options(options + (name -> opt.copy(value = value)), section)).check_value(name) |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
452 |
spec.value orElse opt.standard_value match { |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
453 |
case Some(value) => put(value) |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
454 |
case None if opt.typ == Options.Bool => put("true") |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
455 |
case None => error("Missing value for option " + quote(name) + " : " + opt.typ.print) |
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
456 |
} |
48370 | 457 |
} |
458 |
} |
|
459 |
||
77626
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
460 |
def + (s: String): Options = this + Options.Spec.make(s) |
48456
d8ff14f44a40
added ML version of stand-alone options, with XML.encode/decode operations (unidirectional from Scala to ML);
wenzelm
parents:
48421
diff
changeset
|
461 |
|
77626
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
462 |
def ++ (specs: List[Options.Spec]): Options = specs.foldLeft(this)(_ + _) |
48807 | 463 |
|
48456
d8ff14f44a40
added ML version of stand-alone options, with XML.encode/decode operations (unidirectional from Scala to ML);
wenzelm
parents:
48421
diff
changeset
|
464 |
|
49270 | 465 |
/* sections */ |
466 |
||
467 |
def set_section(new_section: String): Options = |
|
468 |
new Options(options, new_section) |
|
469 |
||
77605 | 470 |
def sections: List[(String, List[Options.Entry])] = |
49270 | 471 |
options.groupBy(_._2.section).toList.map({ case (a, opts) => (a, opts.toList.map(_._2)) }) |
472 |
||
473 |
||
48456
d8ff14f44a40
added ML version of stand-alone options, with XML.encode/decode operations (unidirectional from Scala to ML);
wenzelm
parents:
48421
diff
changeset
|
474 |
/* encode */ |
d8ff14f44a40
added ML version of stand-alone options, with XML.encode/decode operations (unidirectional from Scala to ML);
wenzelm
parents:
48421
diff
changeset
|
475 |
|
75393 | 476 |
def encode: XML.Body = { |
48860 | 477 |
val opts = |
56465 | 478 |
for ((_, opt) <- options.toList; if !opt.unknown) |
479 |
yield (opt.pos, (opt.name, (opt.typ.print, opt.value))) |
|
48860 | 480 |
|
56465 | 481 |
import XML.Encode.{string => string_, _} |
482 |
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
|
483 |
} |
48807 | 484 |
|
485 |
||
77622
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
486 |
/* changed options */ |
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
487 |
|
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
488 |
def changed( |
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
489 |
defaults: Options = Options.init0(), |
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
490 |
filter: Options.Entry => Boolean = _ => true |
77623 | 491 |
): List[Options.Change] = { |
77622
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
492 |
List.from( |
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
493 |
for { |
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
494 |
(name, opt2) <- options.iterator |
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
495 |
opt1 = defaults.get(name) |
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
496 |
if (opt1.isEmpty || opt1.get.value != opt2.value) && filter(opt2) |
77668
5cb7fd36223b
proper sorting of result (amending f458547b4f0f);
wenzelm
parents:
77628
diff
changeset
|
497 |
} yield Options.Change(name, opt2.value, opt1.isEmpty)).sortBy(_.name) |
77622
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
498 |
} |
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
499 |
|
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
500 |
|
77608 | 501 |
/* preferences */ |
48807 | 502 |
|
77603 | 503 |
def make_prefs( |
77609 | 504 |
defaults: Options = Options.init0(), |
77605 | 505 |
filter: Options.Entry => Boolean = _ => true |
77622
f458547b4f0f
clarified signature (again, see also 8c64e51d9dde and 268bf61631ec);
wenzelm
parents:
77621
diff
changeset
|
506 |
): String = changed(defaults = defaults, filter = filter).map(_.print_prefs).mkString |
77374
268bf61631ec
more robust options in "prefs" format: avoid odd control character;
wenzelm
parents:
77366
diff
changeset
|
507 |
|
77609 | 508 |
def save_prefs(file: Path = Options.PREFS, defaults: Options = Options.init0()): Unit = { |
77374
268bf61631ec
more robust options in "prefs" format: avoid odd control character;
wenzelm
parents:
77366
diff
changeset
|
509 |
val prefs = make_prefs(defaults = defaults) |
72375 | 510 |
Isabelle_System.make_directory(file.dir) |
67845 | 511 |
File.write_backup(file, "(* generated by Isabelle " + Date.now() + " *)\n\n" + prefs) |
48807 | 512 |
} |
48365
d88aefda01c4
basic support for stand-alone options with external string representation;
wenzelm
parents:
diff
changeset
|
513 |
} |
49245
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
48992
diff
changeset
|
514 |
|
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
48992
diff
changeset
|
515 |
|
75393 | 516 |
class Options_Variable(init_options: Options) { |
75846 | 517 |
private var _options = init_options |
49245
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
48992
diff
changeset
|
518 |
|
75846 | 519 |
def value: Options = synchronized { _options } |
520 |
def change(f: Options => Options): Unit = synchronized { _options = f(_options) } |
|
77626
af8ac22d97f0
clarified signature: more explicit type Options.Spec, which incorporates all variants of Options.+;
wenzelm
parents:
77625
diff
changeset
|
521 |
def += (name: String, x: String): Unit = change(options => options + Options.Spec(name, Some(x))) |
49245
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
48992
diff
changeset
|
522 |
|
75846 | 523 |
val bool: Options.Access_Variable[Boolean] = |
75847 | 524 |
new Options.Access_Variable[Boolean](this, _.bool) |
49245
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
48992
diff
changeset
|
525 |
|
75846 | 526 |
val int: Options.Access_Variable[Int] = |
75847 | 527 |
new Options.Access_Variable[Int](this, _.int) |
49245
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
48992
diff
changeset
|
528 |
|
75846 | 529 |
val real: Options.Access_Variable[Double] = |
75847 | 530 |
new Options.Access_Variable[Double](this, _.real) |
49245
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
48992
diff
changeset
|
531 |
|
75846 | 532 |
val string: Options.Access_Variable[String] = |
75847 | 533 |
new Options.Access_Variable[String](this, _.string) |
50207 | 534 |
|
69073 | 535 |
def seconds(name: String): Time = value.seconds(name) |
49245
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
48992
diff
changeset
|
536 |
} |