equal
deleted
inserted
replaced
37 val commandInfo = new EventSource[CommandChangeInfo] |
37 val commandInfo = new EventSource[CommandChangeInfo] |
38 val outputInfo = new EventSource[String] |
38 val outputInfo = new EventSource[String] |
39 val allInfo = new EventSource[Result] |
39 val allInfo = new EventSource[Result] |
40 var document = null : Document |
40 var document = null : Document |
41 |
41 |
|
42 |
|
43 def swing(body: => Unit) = |
|
44 SwingUtilities.invokeAndWait(new Runnable { def run = body }) |
|
45 |
|
46 def swing_async(body: => Unit) = |
|
47 SwingUtilities.invokeLater(new Runnable { def run = body }) |
|
48 |
|
49 |
42 def fireChange(c : Command) = |
50 def fireChange(c : Command) = |
43 inUIThread(() => commandInfo.fire(new CommandChangeInfo(c))) |
51 swing { commandInfo.fire(new CommandChangeInfo(c)) } |
44 |
52 |
45 var workerThread = new Thread("isabelle.Prover: worker") { |
53 var workerThread = new Thread("isabelle.Prover: worker") { |
46 override def run() : Unit = { |
54 override def run() : Unit = { |
47 while (true) { |
55 while (true) { |
48 val r = process.get_result |
56 val r = process.get_result |
52 |
60 |
53 if (r.kind == IsabelleProcess.Kind.EXIT) |
61 if (r.kind == IsabelleProcess.Kind.EXIT) |
54 return |
62 return |
55 else if (r.kind == IsabelleProcess.Kind.STDOUT |
63 else if (r.kind == IsabelleProcess.Kind.STDOUT |
56 || r.kind == IsabelleProcess.Kind.STDIN) |
64 || r.kind == IsabelleProcess.Kind.STDIN) |
57 inUIThread(() => outputInfo.fire(r.result)) |
65 swing { outputInfo.fire(r.result) } |
58 else if (r.kind == IsabelleProcess.Kind.WRITELN && !initialized) { |
66 else if (r.kind == IsabelleProcess.Kind.WRITELN && !initialized) { |
59 initialized = true |
67 initialized = true |
60 inUIThread(() => |
68 swing { |
61 if (document != null) { |
69 if (document != null) { |
62 document.activate() |
70 document.activate() |
63 activated.fire(()) |
71 activated.fire(()) |
64 } |
72 } |
65 ) |
73 } |
66 } |
74 } |
67 else { |
75 else { |
68 val tree = parse_failsafe(isabelle_symbols.decode(r.result)) |
76 val tree = parse_failsafe(isabelle_symbols.decode(r.result)) |
69 if (st == null || (st.phase != Phase.REMOVED && st.phase != Phase.REMOVE)) |
77 if (st == null || (st.phase != Phase.REMOVED && st.phase != Phase.REMOVE)) |
70 tree match { |
78 tree match { |
159 |
167 |
160 def stop() { |
168 def stop() { |
161 process.kill |
169 process.kill |
162 } |
170 } |
163 |
171 |
164 private def inUIThread(runnable : () => Unit) { |
|
165 SwingUtilities invokeAndWait new Runnable() { |
|
166 override def run() { runnable () } |
|
167 } |
|
168 } |
|
169 |
|
170 def setDocument(text : Text, path : String) { |
172 def setDocument(text : Text, path : String) { |
171 this.document = new Document(text, this) |
173 this.document = new Document(text, this) |
172 process.ML("ThyLoad.add_path " + encode_string(path)) |
174 process.ML("ThyLoad.add_path " + encode_string(path)) |
173 |
175 |
174 document.structuralChanges.add(changes => { |
176 document.structuralChanges.add(changes => { |