author | wenzelm |
Mon, 07 Mar 2016 18:20:22 +0100 | |
changeset 62545 | 8ebffdaf2ce2 |
parent 62475 | 43e64c770f28 |
child 62556 | c115e69f457f |
permissions | -rw-r--r-- |
49246 | 1 |
/* Title: Tools/jEdit/src/isabelle_logic.scala |
2 |
Author: Makarius |
|
3 |
||
61288 | 4 |
Isabelle logic session. |
49246 | 5 |
*/ |
6 |
||
7 |
package isabelle.jedit |
|
8 |
||
9 |
||
10 |
import isabelle._ |
|
11 |
||
12 |
import scala.swing.ComboBox |
|
13 |
import scala.swing.event.SelectionChanged |
|
14 |
||
15 |
||
16 |
object Isabelle_Logic |
|
17 |
{ |
|
50403
87868964733c
more uniform default logic, using settings, options, args etc.;
wenzelm
parents:
50380
diff
changeset
|
18 |
private val option_name = "jedit_logic" |
87868964733c
more uniform default logic, using settings, options, args etc.;
wenzelm
parents:
50380
diff
changeset
|
19 |
|
61288 | 20 |
def session_name(): String = |
50403
87868964733c
more uniform default logic, using settings, options, args etc.;
wenzelm
parents:
50380
diff
changeset
|
21 |
Isabelle_System.default_logic( |
87868964733c
more uniform default logic, using settings, options, args etc.;
wenzelm
parents:
50380
diff
changeset
|
22 |
Isabelle_System.getenv("JEDIT_LOGIC"), |
87868964733c
more uniform default logic, using settings, options, args etc.;
wenzelm
parents:
50380
diff
changeset
|
23 |
PIDE.options.string(option_name)) |
49246 | 24 |
|
25 |
private class Logic_Entry(val name: String, val description: String) |
|
26 |
{ |
|
57912 | 27 |
override def toString: String = description |
49246 | 28 |
} |
29 |
||
30 |
def logic_selector(autosave: Boolean): Option_Component = |
|
31 |
{ |
|
57612
990ffb84489b
clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents:
56890
diff
changeset
|
32 |
GUI_Thread.require {} |
49246 | 33 |
|
34 |
val entries = |
|
61288 | 35 |
new Logic_Entry("", "default (" + session_name() + ")") :: |
50380 | 36 |
Isabelle_Logic.session_list().map(name => new Logic_Entry(name, name)) |
49246 | 37 |
|
38 |
val component = new ComboBox(entries) with Option_Component { |
|
50375
c101127a7f37
clarified logic argument: session name, not path name;
wenzelm
parents:
50205
diff
changeset
|
39 |
name = option_name |
49270 | 40 |
val title = "Logic" |
49247 | 41 |
def load: Unit = |
42 |
{ |
|
50375
c101127a7f37
clarified logic argument: session name, not path name;
wenzelm
parents:
50205
diff
changeset
|
43 |
val logic = PIDE.options.string(option_name) |
49247 | 44 |
entries.find(_.name == logic) match { |
45 |
case Some(entry) => selection.item = entry |
|
46 |
case None => |
|
47 |
} |
|
48 |
} |
|
50375
c101127a7f37
clarified logic argument: session name, not path name;
wenzelm
parents:
50205
diff
changeset
|
49 |
def save: Unit = PIDE.options.string(option_name) = selection.item.name |
49246 | 50 |
} |
51 |
||
49247 | 52 |
component.load() |
49246 | 53 |
if (autosave) { |
54 |
component.listenTo(component.selection) |
|
55 |
component.reactions += { case SelectionChanged(_) => component.save() } |
|
56 |
} |
|
50380 | 57 |
component.tooltip = "Logic session name (change requires restart)" |
49246 | 58 |
component |
59 |
} |
|
60 |
||
61288 | 61 |
def session_build_mode(): String = Isabelle_System.getenv("JEDIT_BUILD_MODE") |
62 |
||
63 |
def session_build(progress: Progress = Ignore_Progress, no_build: Boolean = false): Int = |
|
49246 | 64 |
{ |
61288 | 65 |
val mode = session_build_mode() |
66 |
||
67 |
Build.build(options = PIDE.options.value, progress = progress, |
|
68 |
build_heap = true, no_build = no_build, system_mode = mode == "" || mode == "system", |
|
69 |
dirs = session_dirs(), sessions = List(session_name())) |
|
70 |
} |
|
71 |
||
62545
8ebffdaf2ce2
Bash.process always uses a closed script instead of an open argument list, for extra robustness on Windows, where quoting is not well-defined;
wenzelm
parents:
62475
diff
changeset
|
72 |
def session_args(): List[String] = |
61288 | 73 |
{ |
62545
8ebffdaf2ce2
Bash.process always uses a closed script instead of an open argument list, for extra robustness on Windows, where quoting is not well-defined;
wenzelm
parents:
62475
diff
changeset
|
74 |
(space_explode(',', PIDE.options.string("jedit_print_mode")) ::: |
8ebffdaf2ce2
Bash.process always uses a closed script instead of an open argument list, for extra robustness on Windows, where quoting is not well-defined;
wenzelm
parents:
62475
diff
changeset
|
75 |
space_explode(',', Isabelle_System.getenv("JEDIT_PRINT_MODE"))). |
8ebffdaf2ce2
Bash.process always uses a closed script instead of an open argument list, for extra robustness on Windows, where quoting is not well-defined;
wenzelm
parents:
62475
diff
changeset
|
76 |
map(m => List("-m", m)).flatten ::: List("-q", session_name()) |
49246 | 77 |
} |
78 |
||
62305 | 79 |
def session_start(): Unit = PIDE.session.start("Isabelle", session_args()) |
80 |
||
50380 | 81 |
def session_dirs(): List[Path] = Path.split(Isabelle_System.getenv("JEDIT_SESSION_DIRS")) |
82 |
||
83 |
def session_list(): List[String] = |
|
84 |
{ |
|
56890 | 85 |
val session_tree = Build.find_sessions(PIDE.options.value, dirs = session_dirs()) |
50574
0706797501a0
offer sessions of group "main" first to increase chances that the user makes a sensible choice;
wenzelm
parents:
50403
diff
changeset
|
86 |
val (main_sessions, other_sessions) = |
0706797501a0
offer sessions of group "main" first to increase chances that the user makes a sensible choice;
wenzelm
parents:
50403
diff
changeset
|
87 |
session_tree.topological_order.partition(p => p._2.groups.contains("main")) |
0706797501a0
offer sessions of group "main" first to increase chances that the user makes a sensible choice;
wenzelm
parents:
50403
diff
changeset
|
88 |
main_sessions.map(_._1).sorted ::: other_sessions.map(_._1).sorted |
50380 | 89 |
} |
90 |
||
49246 | 91 |
def session_content(inlined_files: Boolean): Build.Session_Content = |
92 |
{ |
|
61288 | 93 |
val content = |
94 |
Build.session_content(PIDE.options.value, inlined_files, session_dirs(), session_name()) |
|
56801
8dd9df88f647
some support for session-qualified theories: allow to refer to resources via qualified name instead of odd file-system path;
wenzelm
parents:
56662
diff
changeset
|
95 |
content.copy(known_theories = |
60992 | 96 |
content.known_theories.mapValues(name => name.map(File.platform_path(_)))) |
49246 | 97 |
} |
98 |
} |