author | wenzelm |
Thu, 23 Sep 2010 16:48:12 +0200 | |
changeset 39628 | f6e82967b5cd |
parent 39518 | 96180281c3b2 |
child 39630 | 44181423183a |
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 |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
14 |
|
34497 | 15 |
import scala.collection.mutable |
39517 | 16 |
import scala.swing.ComboBox |
34406
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34337
diff
changeset
|
17 |
|
39241 | 18 |
import org.gjt.sp.jedit.{jEdit, GUIUtilities, EBMessage, EBPlugin, |
19 |
Buffer, EditPane, ServiceManager, View} |
|
34406
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34337
diff
changeset
|
20 |
import org.gjt.sp.jedit.buffer.JEditBuffer |
39043 | 21 |
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
|
22 |
import org.gjt.sp.jedit.msg.{BufferUpdate, EditPaneUpdate, PropertiesChanged} |
37068 | 23 |
import org.gjt.sp.jedit.gui.DockableWindowManager |
34429 | 24 |
|
39241 | 25 |
import org.gjt.sp.util.Log |
26 |
||
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
27 |
|
34618 | 28 |
object Isabelle |
29 |
{ |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
30 |
/* plugin instance */ |
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 |
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
|
33 |
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
|
34 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
35 |
|
34618 | 36 |
/* properties */ |
37 |
||
38 |
val OPTION_PREFIX = "options.isabelle." |
|
39 |
||
40 |
object Property |
|
41 |
{ |
|
36814
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
42 |
def apply(name: String): String = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
43 |
jEdit.getProperty(OPTION_PREFIX + name) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
44 |
def apply(name: String, default: String): String = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
45 |
jEdit.getProperty(OPTION_PREFIX + name, default) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
46 |
def update(name: String, value: String) = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
47 |
jEdit.setProperty(OPTION_PREFIX + name, value) |
34468
9d4b4f290676
maintain Isabelle properties via object Isabelle.Property with apply/update methods;
wenzelm
parents:
34463
diff
changeset
|
48 |
} |
34433 | 49 |
|
34618 | 50 |
object Boolean_Property |
51 |
{ |
|
36814
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
52 |
def apply(name: String): Boolean = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
53 |
jEdit.getBooleanProperty(OPTION_PREFIX + name) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
54 |
def apply(name: String, default: Boolean): Boolean = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
55 |
jEdit.getBooleanProperty(OPTION_PREFIX + name, default) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
56 |
def update(name: String, value: Boolean) = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
57 |
jEdit.setBooleanProperty(OPTION_PREFIX + name, value) |
34618 | 58 |
} |
59 |
||
60 |
object Int_Property |
|
61 |
{ |
|
36814
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
62 |
def apply(name: String): Int = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
63 |
jEdit.getIntegerProperty(OPTION_PREFIX + name) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
64 |
def apply(name: String, default: Int): Int = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
65 |
jEdit.getIntegerProperty(OPTION_PREFIX + name, default) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
66 |
def update(name: String, value: Int) = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
67 |
jEdit.setIntegerProperty(OPTION_PREFIX + name, value) |
34618 | 68 |
} |
69 |
||
37164 | 70 |
|
71 |
/* font */ |
|
72 |
||
73 |
def font_family(): String = jEdit.getProperty("view.font") |
|
74 |
||
37019 | 75 |
def font_size(): Float = |
76 |
(jEdit.getIntegerProperty("view.fontsize", 16) * |
|
77 |
Int_Property("relative-font-size", 100)).toFloat / 100 |
|
36814
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
78 |
|
34618 | 79 |
|
39043 | 80 |
/* text area ranges */ |
81 |
||
82 |
case class Gfx_Range(val x: Int, val y: Int, val length: Int) |
|
83 |
||
84 |
def gfx_range(text_area: TextArea, range: Text.Range): Option[Gfx_Range] = |
|
85 |
{ |
|
86 |
val p = text_area.offsetToXY(range.start) |
|
87 |
val q = text_area.offsetToXY(range.stop) |
|
88 |
if (p != null && q != null && p.y == q.y) Some(new Gfx_Range(p.x, p.y, q.x - p.x)) |
|
89 |
else None |
|
90 |
} |
|
91 |
||
92 |
||
37201
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
93 |
/* tooltip markup */ |
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
94 |
|
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
95 |
def tooltip(text: String): String = |
37203
c4261f3bbdd7
more flexibile font size via CSS <style> instead of old <font> element;
wenzelm
parents:
37201
diff
changeset
|
96 |
"<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
|
97 |
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
|
98 |
HTML.encode(text) + "</pre></html>" |
37201
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
99 |
|
38854
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
100 |
def tooltip_dismiss_delay(): Int = |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
101 |
Int_Property("tooltip-dismiss-delay", 8000) max 500 |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
102 |
|
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
103 |
def setup_tooltips() |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
104 |
{ |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
105 |
Swing_Thread.now { |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
106 |
val manager = javax.swing.ToolTipManager.sharedInstance |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
107 |
manager.setDismissDelay(tooltip_dismiss_delay()) |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
108 |
} |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
109 |
} |
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
110 |
|
37201
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
111 |
|
39241 | 112 |
/* icons */ |
113 |
||
114 |
def load_icon(name: String): javax.swing.Icon = |
|
115 |
{ |
|
116 |
val icon = GUIUtilities.loadIcon(name) |
|
117 |
if (icon.getIconWidth < 0 || icon.getIconHeight < 0) |
|
118 |
Log.log(Log.ERROR, icon, "Bad icon: " + name); |
|
119 |
icon |
|
120 |
} |
|
121 |
||
122 |
||
38221 | 123 |
/* 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
|
124 |
|
37177 | 125 |
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
|
126 |
|
37177 | 127 |
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
|
128 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
129 |
def jedit_text_areas(view: View): Iterator[JEditTextArea] = |
37177 | 130 |
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
|
131 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
132 |
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
|
133 |
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
|
134 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
135 |
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
|
136 |
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
|
137 |
|
38843 | 138 |
def buffer_lock[A](buffer: JEditBuffer)(body: => A): A = |
38640 | 139 |
{ |
140 |
try { buffer.readLock(); body } |
|
141 |
finally { buffer.readUnlock() } |
|
142 |
} |
|
143 |
||
38843 | 144 |
def swing_buffer_lock[A](buffer: JEditBuffer)(body: => A): A = |
145 |
Swing_Thread.now { buffer_lock(buffer) { body } } |
|
146 |
||
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
147 |
|
37068 | 148 |
/* dockable windows */ |
149 |
||
150 |
private def wm(view: View): DockableWindowManager = view.getDockableWindowManager |
|
151 |
||
39515 | 152 |
def docked_session(view: View): Option[Session_Dockable] = |
153 |
wm(view).getDockableWindow("isabelle-session") match { |
|
154 |
case dockable: Session_Dockable => Some(dockable) |
|
155 |
case _ => None |
|
156 |
} |
|
157 |
||
37068 | 158 |
def docked_output(view: View): Option[Output_Dockable] = |
159 |
wm(view).getDockableWindow("isabelle-output") match { |
|
160 |
case dockable: Output_Dockable => Some(dockable) |
|
161 |
case _ => None |
|
162 |
} |
|
163 |
||
164 |
def docked_raw_output(view: View): Option[Raw_Output_Dockable] = |
|
165 |
wm(view).getDockableWindow("isabelle-raw-output") match { |
|
166 |
case dockable: Raw_Output_Dockable => Some(dockable) |
|
167 |
case _ => None |
|
168 |
} |
|
169 |
||
170 |
def docked_protocol(view: View): Option[Protocol_Dockable] = |
|
171 |
wm(view).getDockableWindow("isabelle-protocol") match { |
|
172 |
case dockable: Protocol_Dockable => Some(dockable) |
|
173 |
case _ => None |
|
174 |
} |
|
175 |
||
176 |
||
39517 | 177 |
/* logic image */ |
178 |
||
179 |
def default_logic(): String = |
|
180 |
{ |
|
181 |
val logic = system.getenv("JEDIT_LOGIC") |
|
182 |
if (logic != "") logic |
|
183 |
else system.getenv_strict("ISABELLE_LOGIC") |
|
184 |
} |
|
185 |
||
186 |
class Logic_Entry(val name: String, val description: String) |
|
187 |
{ |
|
188 |
override def toString = description |
|
189 |
} |
|
190 |
||
191 |
def logic_selector(logic: String): ComboBox[Logic_Entry] = |
|
192 |
{ |
|
193 |
val entries = |
|
194 |
new Logic_Entry("", "default (" + default_logic() + ")") :: |
|
195 |
system.find_logics().map(name => new Logic_Entry(name, name)) |
|
196 |
val component = new ComboBox(entries) |
|
197 |
entries.find(_.name == logic) match { |
|
198 |
case None => |
|
199 |
case Some(entry) => component.selection.item = entry |
|
200 |
} |
|
201 |
component |
|
202 |
} |
|
203 |
||
204 |
def isabelle_args(): List[String] = |
|
205 |
{ |
|
206 |
val modes = system.getenv("JEDIT_PRINT_MODE").split(",").toList.map("-m" + _) |
|
207 |
val logic = { |
|
208 |
val logic = Property("logic") |
|
209 |
if (logic != null && logic != "") logic |
|
210 |
else default_logic() |
|
211 |
} |
|
212 |
modes ++ List(logic) |
|
213 |
} |
|
214 |
||
215 |
||
38221 | 216 |
/* manage prover */ // FIXME async!? |
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
217 |
|
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
218 |
private def prover_started(view: View): Boolean = |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
219 |
{ |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
220 |
val timeout = Int_Property("startup-timeout") max 1000 |
38221 | 221 |
session.started(timeout, Isabelle.isabelle_args()) match { |
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
222 |
case Some(err) => |
39518 | 223 |
val text = new scala.swing.TextArea(err) |
224 |
text.editable = false |
|
34822 | 225 |
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
|
226 |
false |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
227 |
case None => true |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
228 |
} |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
229 |
} |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
230 |
|
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
231 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
232 |
/* activation */ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
233 |
|
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
234 |
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
|
235 |
{ |
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
236 |
if (prover_started(view)) { |
38222
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38221
diff
changeset
|
237 |
// FIXME proper error handling |
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38221
diff
changeset
|
238 |
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
|
239 |
|
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38221
diff
changeset
|
240 |
val model = Document_Model.init(session, buffer, thy_name) |
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
241 |
for (text_area <- jedit_text_areas(buffer)) |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
242 |
Document_View.init(model, text_area) |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
243 |
} |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
244 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
245 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
246 |
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
|
247 |
{ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
248 |
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
|
249 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
250 |
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
|
251 |
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
|
252 |
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
|
253 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
254 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
255 |
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
|
256 |
{ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
257 |
val buffer = view.getBuffer |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34787
diff
changeset
|
258 |
if (Document_Model(buffer).isDefined) deactivate_buffer(buffer) |
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
259 |
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
|
260 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
261 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
262 |
def is_active(view: View): Boolean = |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34787
diff
changeset
|
263 |
Document_Model(view.getBuffer).isDefined |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
264 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
265 |
|
34429 | 266 |
|
34618 | 267 |
class Plugin extends EBPlugin |
268 |
{ |
|
269 |
/* main plugin plumbing */ |
|
34433 | 270 |
|
34767 | 271 |
override def handleMessage(message: EBMessage) |
34618 | 272 |
{ |
34767 | 273 |
message match { |
37557
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37241
diff
changeset
|
274 |
case msg: BufferUpdate |
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37241
diff
changeset
|
275 |
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
|
276 |
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
|
277 |
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
|
278 |
case _ => |
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37241
diff
changeset
|
279 |
} |
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37241
diff
changeset
|
280 |
|
34767 | 281 |
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
|
282 |
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
|
283 |
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
|
284 |
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
|
285 |
|
34787
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
286 |
def init_view() |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
287 |
{ |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34787
diff
changeset
|
288 |
Document_Model(buffer) match { |
34787
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
289 |
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
|
290 |
case None => |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
291 |
} |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
292 |
} |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
293 |
def exit_view() |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
294 |
{ |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34787
diff
changeset
|
295 |
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
|
296 |
Document_View.exit(text_area) |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
297 |
} |
34767 | 298 |
msg.getWhat match { |
34787
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
299 |
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
|
300 |
case EditPaneUpdate.CREATED => init_view() |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
301 |
case EditPaneUpdate.DESTROYED => exit_view() |
34671 | 302 |
case _ => |
303 |
} |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
304 |
|
34777
91d6089cef88
class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
34774
diff
changeset
|
305 |
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
|
306 |
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
|
307 |
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
|
308 |
Document_View(text_area).get.extend_styles() |
38854
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
309 |
|
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
310 |
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
|
311 |
} |
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
|
312 |
|
34791 | 313 |
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
|
314 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
315 |
case _ => |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
316 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
317 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
318 |
|
34618 | 319 |
override def start() |
320 |
{ |
|
34615 | 321 |
Isabelle.system = new Isabelle_System |
34774 | 322 |
Isabelle.system.install_fonts() |
39628
f6e82967b5cd
Plugin.stop: refrain from invalidating Isabelle.session -- some actors/dockables out there might still refer to it;
wenzelm
parents:
39518
diff
changeset
|
323 |
Isabelle.session = new Session(Isabelle.system) |
38854
eb6a35be18ca
Isabelle/jEdit property for global tooltip dismiss delay;
wenzelm
parents:
38843
diff
changeset
|
324 |
Isabelle.setup_tooltips() |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
325 |
} |
34618 | 326 |
|
39628
f6e82967b5cd
Plugin.stop: refrain from invalidating Isabelle.session -- some actors/dockables out there might still refer to it;
wenzelm
parents:
39518
diff
changeset
|
327 |
override def stop() |
34618 | 328 |
{ |
39628
f6e82967b5cd
Plugin.stop: refrain from invalidating Isabelle.session -- some actors/dockables out there might still refer to it;
wenzelm
parents:
39518
diff
changeset
|
329 |
Isabelle.session.stop() |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
330 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
331 |
} |