author | wenzelm |
Tue, 07 Sep 2010 13:16:45 +0200 | |
changeset 39167 | 803431dcc7fb |
parent 39043 | a0d7e9b580ec |
child 39241 | e9a442606db3 |
permissions | -rw-r--r-- |
36760 | 1 |
/* Title: Tools/jEdit/src/jedit/plugin.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Main Isabelle/jEdit plugin setup. |
|
5 |
*/ |
|
34407 | 6 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle.jedit |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
8 |
|
34429 | 9 |
|
36015 | 10 |
import isabelle._ |
11 |
||
34429 | 12 |
import java.io.{FileInputStream, IOException} |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
13 |
import java.awt.Font |
34822 | 14 |
import javax.swing.JTextArea |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
15 |
|
34497 | 16 |
import scala.collection.mutable |
34406
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34337
diff
changeset
|
17 |
|
34429 | 18 |
import org.gjt.sp.jedit.{jEdit, EBMessage, EBPlugin, Buffer, EditPane, ServiceManager, View} |
34406
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34337
diff
changeset
|
19 |
import org.gjt.sp.jedit.buffer.JEditBuffer |
39043 | 20 |
import org.gjt.sp.jedit.textarea.{JEditTextArea, TextArea} |
37557
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37241
diff
changeset
|
21 |
import org.gjt.sp.jedit.msg.{BufferUpdate, EditPaneUpdate, PropertiesChanged} |
37068 | 22 |
import org.gjt.sp.jedit.gui.DockableWindowManager |
34429 | 23 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
24 |
|
34618 | 25 |
object Isabelle |
26 |
{ |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
27 |
/* plugin instance */ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
28 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
29 |
var system: Isabelle_System = null |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
30 |
var session: Session = null |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
31 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
32 |
|
34618 | 33 |
/* properties */ |
34 |
||
35 |
val OPTION_PREFIX = "options.isabelle." |
|
36 |
||
37 |
object Property |
|
38 |
{ |
|
36814
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
39 |
def apply(name: String): String = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
40 |
jEdit.getProperty(OPTION_PREFIX + name) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
41 |
def apply(name: String, default: String): String = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
42 |
jEdit.getProperty(OPTION_PREFIX + name, default) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
43 |
def update(name: String, value: String) = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
44 |
jEdit.setProperty(OPTION_PREFIX + name, value) |
34468
9d4b4f290676
maintain Isabelle properties via object Isabelle.Property with apply/update methods;
wenzelm
parents:
34463
diff
changeset
|
45 |
} |
34433 | 46 |
|
34618 | 47 |
object Boolean_Property |
48 |
{ |
|
36814
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
49 |
def apply(name: String): Boolean = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
50 |
jEdit.getBooleanProperty(OPTION_PREFIX + name) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
51 |
def apply(name: String, default: Boolean): Boolean = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
52 |
jEdit.getBooleanProperty(OPTION_PREFIX + name, default) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
53 |
def update(name: String, value: Boolean) = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
54 |
jEdit.setBooleanProperty(OPTION_PREFIX + name, value) |
34618 | 55 |
} |
56 |
||
57 |
object Int_Property |
|
58 |
{ |
|
36814
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
59 |
def apply(name: String): Int = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
60 |
jEdit.getIntegerProperty(OPTION_PREFIX + name) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
61 |
def apply(name: String, default: Int): Int = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
62 |
jEdit.getIntegerProperty(OPTION_PREFIX + name, default) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
63 |
def update(name: String, value: Int) = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
64 |
jEdit.setIntegerProperty(OPTION_PREFIX + name, value) |
34618 | 65 |
} |
66 |
||
37164 | 67 |
|
68 |
/* font */ |
|
69 |
||
70 |
def font_family(): String = jEdit.getProperty("view.font") |
|
71 |
||
37019 | 72 |
def font_size(): Float = |
73 |
(jEdit.getIntegerProperty("view.fontsize", 16) * |
|
74 |
Int_Property("relative-font-size", 100)).toFloat / 100 |
|
36814
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
75 |
|
34618 | 76 |
|
39043 | 77 |
/* text area ranges */ |
78 |
||
79 |
case class Gfx_Range(val x: Int, val y: Int, val length: Int) |
|
80 |
||
81 |
def gfx_range(text_area: TextArea, range: Text.Range): Option[Gfx_Range] = |
|
82 |
{ |
|
83 |
val p = text_area.offsetToXY(range.start) |
|
84 |
val q = text_area.offsetToXY(range.stop) |
|
85 |
if (p != null && q != null && p.y == q.y) Some(new Gfx_Range(p.x, p.y, q.x - p.x)) |
|
86 |
else None |
|
87 |
} |
|
88 |
||
89 |
||
37201
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
90 |
/* tooltip markup */ |
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
91 |
|
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
92 |
def tooltip(text: String): String = |
37203
c4261f3bbdd7
more flexibile font size via CSS <style> instead of old <font> element;
wenzelm
parents:
37201
diff
changeset
|
93 |
"<html><pre style=\"font-family: " + font_family() + "; font-size: " + |
c4261f3bbdd7
more flexibile font size via CSS <style> instead of old <font> element;
wenzelm
parents:
37201
diff
changeset
|
94 |
Int_Property("tooltip-font-size", 10).toString + "px; \">" + // FIXME proper scaling (!?) |
c4261f3bbdd7
more flexibile font size via CSS <style> instead of old <font> element;
wenzelm
parents:
37201
diff
changeset
|
95 |
HTML.encode(text) + "</pre></html>" |
37201
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
96 |
|
38854
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
97 |
def tooltip_dismiss_delay(): Int = |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
98 |
Int_Property("tooltip-dismiss-delay", 8000) max 500 |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
99 |
|
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
100 |
def setup_tooltips() |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
101 |
{ |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
102 |
Swing_Thread.now { |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
103 |
val manager = javax.swing.ToolTipManager.sharedInstance |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
104 |
manager.setDismissDelay(tooltip_dismiss_delay()) |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
105 |
} |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
106 |
} |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
107 |
|
37201
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
108 |
|
34618 | 109 |
/* settings */ |
110 |
||
34782
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
111 |
def default_logic(): String = |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
112 |
{ |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
113 |
val logic = system.getenv("JEDIT_LOGIC") |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
114 |
if (logic != "") logic |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
115 |
else system.getenv_strict("ISABELLE_LOGIC") |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
116 |
} |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
117 |
|
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
118 |
def isabelle_args(): List[String] = |
34618 | 119 |
{ |
34780 | 120 |
val modes = system.getenv("JEDIT_PRINT_MODE").split(",").toList.map("-m" + _) |
121 |
val logic = { |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
122 |
val logic = Property("logic") |
34782
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
123 |
if (logic != null && logic != "") logic |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
124 |
else default_logic() |
34780 | 125 |
} |
126 |
modes ++ List(logic) |
|
34502 | 127 |
} |
128 |
||
34618 | 129 |
|
38221 | 130 |
/* main jEdit components */ |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
131 |
|
37177 | 132 |
def jedit_buffers(): Iterator[Buffer] = jEdit.getBuffers().iterator |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
133 |
|
37177 | 134 |
def jedit_views(): Iterator[View] = jEdit.getViews().iterator |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
135 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
136 |
def jedit_text_areas(view: View): Iterator[JEditTextArea] = |
37177 | 137 |
view.getEditPanes().iterator.map(_.getTextArea) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
138 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
139 |
def jedit_text_areas(): Iterator[JEditTextArea] = |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
140 |
jedit_views().flatMap(jedit_text_areas(_)) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
141 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
142 |
def jedit_text_areas(buffer: JEditBuffer): Iterator[JEditTextArea] = |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
143 |
jedit_text_areas().filter(_.getBuffer == buffer) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
144 |
|
38843 | 145 |
def buffer_lock[A](buffer: JEditBuffer)(body: => A): A = |
38640 | 146 |
{ |
147 |
try { buffer.readLock(); body } |
|
148 |
finally { buffer.readUnlock() } |
|
149 |
} |
|
150 |
||
38843 | 151 |
def swing_buffer_lock[A](buffer: JEditBuffer)(body: => A): A = |
152 |
Swing_Thread.now { buffer_lock(buffer) { body } } |
|
153 |
||
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
154 |
|
37068 | 155 |
/* dockable windows */ |
156 |
||
157 |
private def wm(view: View): DockableWindowManager = view.getDockableWindowManager |
|
158 |
||
159 |
def docked_output(view: View): Option[Output_Dockable] = |
|
160 |
wm(view).getDockableWindow("isabelle-output") match { |
|
161 |
case dockable: Output_Dockable => Some(dockable) |
|
162 |
case _ => None |
|
163 |
} |
|
164 |
||
165 |
def docked_raw_output(view: View): Option[Raw_Output_Dockable] = |
|
166 |
wm(view).getDockableWindow("isabelle-raw-output") match { |
|
167 |
case dockable: Raw_Output_Dockable => Some(dockable) |
|
168 |
case _ => None |
|
169 |
} |
|
170 |
||
171 |
def docked_protocol(view: View): Option[Protocol_Dockable] = |
|
172 |
wm(view).getDockableWindow("isabelle-protocol") match { |
|
173 |
case dockable: Protocol_Dockable => Some(dockable) |
|
174 |
case _ => None |
|
175 |
} |
|
176 |
||
177 |
||
38221 | 178 |
/* manage prover */ // FIXME async!? |
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
179 |
|
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
180 |
private def prover_started(view: View): Boolean = |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
181 |
{ |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
182 |
val timeout = Int_Property("startup-timeout") max 1000 |
38221 | 183 |
session.started(timeout, Isabelle.isabelle_args()) match { |
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
184 |
case Some(err) => |
34822 | 185 |
val text = new JTextArea(err); text.setEditable(false) |
186 |
Library.error_dialog(view, null, "Failed to start Isabelle process", text) |
|
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
187 |
false |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
188 |
case None => true |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
189 |
} |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
190 |
} |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
191 |
|
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
192 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
193 |
/* activation */ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
194 |
|
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
195 |
def activate_buffer(view: View, buffer: Buffer) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
196 |
{ |
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
197 |
if (prover_started(view)) { |
38222
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38221
diff
changeset
|
198 |
// FIXME proper error handling |
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38221
diff
changeset
|
199 |
val (_, thy_name) = Thy_Header.split_thy_path(Isabelle.system.posix_path(buffer.getPath)) |
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38221
diff
changeset
|
200 |
|
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38221
diff
changeset
|
201 |
val model = Document_Model.init(session, buffer, thy_name) |
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
202 |
for (text_area <- jedit_text_areas(buffer)) |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
203 |
Document_View.init(model, text_area) |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
204 |
} |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
205 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
206 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
207 |
def deactivate_buffer(buffer: Buffer) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
208 |
{ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
209 |
session.stop() // FIXME not yet |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
210 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
211 |
for (text_area <- jedit_text_areas(buffer)) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
212 |
Document_View.exit(text_area) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
213 |
Document_Model.exit(buffer) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
214 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
215 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
216 |
def switch_active(view: View) = |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
217 |
{ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
218 |
val buffer = view.getBuffer |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34787
diff
changeset
|
219 |
if (Document_Model(buffer).isDefined) deactivate_buffer(buffer) |
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
220 |
else activate_buffer(view, buffer) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
221 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
222 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
223 |
def is_active(view: View): Boolean = |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34787
diff
changeset
|
224 |
Document_Model(view.getBuffer).isDefined |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
225 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
226 |
|
34429 | 227 |
|
34618 | 228 |
class Plugin extends EBPlugin |
229 |
{ |
|
230 |
/* main plugin plumbing */ |
|
34433 | 231 |
|
34767 | 232 |
override def handleMessage(message: EBMessage) |
34618 | 233 |
{ |
34767 | 234 |
message match { |
37557
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37241
diff
changeset
|
235 |
case msg: BufferUpdate |
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37241
diff
changeset
|
236 |
if msg.getWhat == BufferUpdate.PROPERTIES_CHANGED => |
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37241
diff
changeset
|
237 |
Document_Model(msg.getBuffer) match { |
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37241
diff
changeset
|
238 |
case Some(model) => model.refresh() |
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37241
diff
changeset
|
239 |
case _ => |
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37241
diff
changeset
|
240 |
} |
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37241
diff
changeset
|
241 |
|
34767 | 242 |
case msg: EditPaneUpdate => |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
243 |
val edit_pane = msg.getEditPane |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
244 |
val buffer = edit_pane.getBuffer |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
245 |
val text_area = edit_pane.getTextArea |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
246 |
|
34787
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
247 |
def init_view() |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
248 |
{ |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34787
diff
changeset
|
249 |
Document_Model(buffer) match { |
34787
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
250 |
case Some(model) => Document_View.init(model, text_area) |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
251 |
case None => |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
252 |
} |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
253 |
} |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
254 |
def exit_view() |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
255 |
{ |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34787
diff
changeset
|
256 |
if (Document_View(text_area).isDefined) |
34787
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
257 |
Document_View.exit(text_area) |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
258 |
} |
34767 | 259 |
msg.getWhat match { |
34787
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
260 |
case EditPaneUpdate.BUFFER_CHANGED => exit_view(); init_view() |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
261 |
case EditPaneUpdate.CREATED => init_view() |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
262 |
case EditPaneUpdate.DESTROYED => exit_view() |
34671 | 263 |
case _ => |
264 |
} |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
265 |
|
34777
91d6089cef88
class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
34774
diff
changeset
|
266 |
case msg: PropertiesChanged => |
37241
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37203
diff
changeset
|
267 |
Swing_Thread.now { |
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37203
diff
changeset
|
268 |
for (text_area <- Isabelle.jedit_text_areas if Document_View(text_area).isDefined) |
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37203
diff
changeset
|
269 |
Document_View(text_area).get.extend_styles() |
38854
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
270 |
|
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
271 |
Isabelle.setup_tooltips() |
37241
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37203
diff
changeset
|
272 |
} |
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37203
diff
changeset
|
273 |
|
34791 | 274 |
Isabelle.session.global_settings.event(Session.Global_Settings) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
275 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
276 |
case _ => |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
277 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
278 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
279 |
|
34618 | 280 |
override def start() |
281 |
{ |
|
34615 | 282 |
Isabelle.system = new Isabelle_System |
34774 | 283 |
Isabelle.system.install_fonts() |
34777
91d6089cef88
class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
34774
diff
changeset
|
284 |
Isabelle.session = new Session(Isabelle.system) // FIXME dialog!? |
38854
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
285 |
|
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
286 |
Isabelle.setup_tooltips() |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
287 |
} |
34618 | 288 |
|
39167
803431dcc7fb
slightly more robust Plugin.stop -- components might refer to Isabelle.system even after shutdown;
wenzelm
parents:
39043
diff
changeset
|
289 |
override def stop() // FIXME fragile |
34618 | 290 |
{ |
34777
91d6089cef88
class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
34774
diff
changeset
|
291 |
Isabelle.session.stop() // FIXME dialog!? |
91d6089cef88
class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
34774
diff
changeset
|
292 |
Isabelle.session = null |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
293 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
294 |
} |