author | wenzelm |
Sun, 05 Oct 2014 15:05:26 +0200 | |
changeset 58543 | 9c1389befa56 |
parent 58529 | cd4439d8799c |
child 58546 | 72e2b2a609c4 |
permissions | -rw-r--r-- |
50208 | 1 |
/* Title: Tools/jEdit/src/isabelle.scala |
50183 | 2 |
Author: Makarius |
3 |
||
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
4 |
Global configuration and convenience operations for Isabelle/jEdit. |
50183 | 5 |
*/ |
6 |
||
7 |
package isabelle.jedit |
|
8 |
||
9 |
||
10 |
import isabelle._ |
|
11 |
||
57627
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
12 |
import java.awt.Frame |
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
13 |
|
53715 | 14 |
import scala.swing.CheckBox |
15 |
import scala.swing.event.ButtonClicked |
|
16 |
||
50198
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
17 |
import org.gjt.sp.jedit.{jEdit, View, Buffer} |
50183 | 18 |
import org.gjt.sp.jedit.textarea.JEditTextArea |
58529 | 19 |
import org.gjt.sp.jedit.syntax.TokenMarker |
53293
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
20 |
import org.gjt.sp.jedit.gui.{DockableWindowManager, CompleteWord} |
57627
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
21 |
import org.gjt.sp.jedit.options.PluginOptions |
50183 | 22 |
|
23 |
||
50208 | 24 |
object Isabelle |
50183 | 25 |
{ |
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
26 |
/* editor modes */ |
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
27 |
|
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
28 |
val modes = |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
29 |
List( |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
30 |
"isabelle", // theory source |
55500 | 31 |
"isabelle-ml", // ML source |
53281
251e1a2aa792
clarified SideKick parser name, which serves as quasi "mode" here;
wenzelm
parents:
53280
diff
changeset
|
32 |
"isabelle-markup", // SideKick markup tree |
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
33 |
"isabelle-news", // NEWS |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
34 |
"isabelle-options", // etc/options |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
35 |
"isabelle-output", // pretty text area output |
56277
c4f75e733812
separate "sml" mode, suppress old "ml" mode altogether;
wenzelm
parents:
56170
diff
changeset
|
36 |
"isabelle-root", // session ROOT |
c4f75e733812
separate "sml" mode, suppress old "ml" mode altogether;
wenzelm
parents:
56170
diff
changeset
|
37 |
"sml") // Standard ML (not Isabelle/ML) |
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
38 |
|
55616 | 39 |
private lazy val ml_syntax: Outer_Syntax = |
40 |
Outer_Syntax.init().no_tokens. |
|
55749 | 41 |
set_language_context(Completion.Language_Context.ML_outer) |
55616 | 42 |
|
56278
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56277
diff
changeset
|
43 |
private lazy val sml_syntax: Outer_Syntax = |
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56277
diff
changeset
|
44 |
Outer_Syntax.init().no_tokens. |
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56277
diff
changeset
|
45 |
set_language_context(Completion.Language_Context.SML_outer) |
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56277
diff
changeset
|
46 |
|
55616 | 47 |
private lazy val news_syntax: Outer_Syntax = |
48 |
Outer_Syntax.init().no_tokens |
|
53276 | 49 |
|
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
50 |
def mode_syntax(name: String): Option[Outer_Syntax] = |
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
51 |
name match { |
53281
251e1a2aa792
clarified SideKick parser name, which serves as quasi "mode" here;
wenzelm
parents:
53280
diff
changeset
|
52 |
case "isabelle" | "isabelle-markup" => |
56393
22f533e6a049
more abstract Prover.Syntax, as proposed by Carst Tankink;
wenzelm
parents:
56278
diff
changeset
|
53 |
PIDE.session.recent_syntax match { |
56394
bbf4d512f395
clarified Version.syntax -- avoid guessing initial situation;
wenzelm
parents:
56393
diff
changeset
|
54 |
case syntax: Outer_Syntax if syntax != Outer_Syntax.empty => Some(syntax) |
56393
22f533e6a049
more abstract Prover.Syntax, as proposed by Carst Tankink;
wenzelm
parents:
56278
diff
changeset
|
55 |
case _ => None |
22f533e6a049
more abstract Prover.Syntax, as proposed by Carst Tankink;
wenzelm
parents:
56278
diff
changeset
|
56 |
} |
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
57 |
case "isabelle-options" => Some(Options.options_syntax) |
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
58 |
case "isabelle-root" => Some(Build.root_syntax) |
55616 | 59 |
case "isabelle-ml" => Some(ml_syntax) |
60 |
case "isabelle-news" => Some(news_syntax) |
|
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
61 |
case "isabelle-output" => None |
56278
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56277
diff
changeset
|
62 |
case "sml" => Some(sml_syntax) |
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
63 |
case _ => None |
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
64 |
} |
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
65 |
|
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
66 |
|
58543 | 67 |
/* buffer types */ |
68 |
||
69 |
def is_bibtex(buffer: Buffer): Boolean = |
|
70 |
JEdit_Lib.buffer_name(buffer).endsWith(".bib") |
|
71 |
||
72 |
||
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
73 |
/* token markers */ |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
74 |
|
58529 | 75 |
private val markers: Map[String, TokenMarker] = |
76 |
Map(modes.map(name => (name, new Token_Markup.Marker(name))): _*) + |
|
77 |
("bibtex" -> new Bibtex_Token_Markup.Marker) |
|
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
78 |
|
58529 | 79 |
def token_marker(name: String): Option[TokenMarker] = markers.get(name) |
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
80 |
|
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
81 |
|
50208 | 82 |
/* dockable windows */ |
83 |
||
84 |
private def wm(view: View): DockableWindowManager = view.getDockableWindowManager |
|
85 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
86 |
def documentation_dockable(view: View): Option[Documentation_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
87 |
wm(view).getDockableWindow("isabelle-documentation") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
88 |
case dockable: Documentation_Dockable => Some(dockable) |
50208 | 89 |
case _ => None |
90 |
} |
|
91 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
92 |
def monitor_dockable(view: View): Option[Monitor_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
93 |
wm(view).getDockableWindow("isabelle-monitor") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
94 |
case dockable: Monitor_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
95 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
96 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
97 |
|
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
98 |
def output_dockable(view: View): Option[Output_Dockable] = |
50208 | 99 |
wm(view).getDockableWindow("isabelle-output") match { |
100 |
case dockable: Output_Dockable => Some(dockable) |
|
101 |
case _ => None |
|
102 |
} |
|
103 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
104 |
def protocol_dockable(view: View): Option[Protocol_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
105 |
wm(view).getDockableWindow("isabelle-protocol") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
106 |
case dockable: Protocol_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
107 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
108 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
109 |
|
56879
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
110 |
def query_dockable(view: View): Option[Query_Dockable] = |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
111 |
wm(view).getDockableWindow("isabelle-query") match { |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
112 |
case dockable: Query_Dockable => Some(dockable) |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
113 |
case _ => None |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
114 |
} |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
115 |
|
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
116 |
def raw_output_dockable(view: View): Option[Raw_Output_Dockable] = |
50208 | 117 |
wm(view).getDockableWindow("isabelle-raw-output") match { |
118 |
case dockable: Raw_Output_Dockable => Some(dockable) |
|
119 |
case _ => None |
|
120 |
} |
|
121 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
122 |
def simplifier_trace_dockable(view: View): Option[Simplifier_Trace_Dockable] = |
55557 | 123 |
wm(view).getDockableWindow("isabelle-simplifier-trace") match { |
55316
885500f4aa6a
interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
54640
diff
changeset
|
124 |
case dockable: Simplifier_Trace_Dockable => Some(dockable) |
885500f4aa6a
interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
54640
diff
changeset
|
125 |
case _ => None |
885500f4aa6a
interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
54640
diff
changeset
|
126 |
} |
885500f4aa6a
interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
54640
diff
changeset
|
127 |
|
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
128 |
def sledgehammer_dockable(view: View): Option[Sledgehammer_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
129 |
wm(view).getDockableWindow("isabelle-sledgehammer") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
130 |
case dockable: Sledgehammer_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
131 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
132 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
133 |
|
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
134 |
def symbols_dockable(view: View): Option[Symbols_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
135 |
wm(view).getDockableWindow("isabelle-symbols") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
136 |
case dockable: Symbols_Dockable => Some(dockable) |
50208 | 137 |
case _ => None |
138 |
} |
|
139 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
140 |
def syslog_dockable(view: View): Option[Syslog_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
141 |
wm(view).getDockableWindow("isabelle-syslog") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
142 |
case dockable: Syslog_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
143 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
144 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
145 |
|
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
146 |
def theories_dockable(view: View): Option[Theories_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
147 |
wm(view).getDockableWindow("isabelle-theories") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
148 |
case dockable: Theories_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
149 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
150 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
151 |
|
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
152 |
def timing_dockable(view: View): Option[Timing_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
153 |
wm(view).getDockableWindow("isabelle-timing") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
154 |
case dockable: Timing_Dockable => Some(dockable) |
50433
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
155 |
case _ => None |
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
156 |
} |
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
157 |
|
50208 | 158 |
|
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
159 |
/* continuous checking */ |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
160 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
161 |
private val CONTINUOUS_CHECKING = "editor_continuous_checking" |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
162 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
163 |
def continuous_checking: Boolean = PIDE.options.bool(CONTINUOUS_CHECKING) |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
164 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
165 |
def continuous_checking_=(b: Boolean) |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
166 |
{ |
57612
990ffb84489b
clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents:
57424
diff
changeset
|
167 |
GUI_Thread.require {} |
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
168 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
169 |
if (continuous_checking != b) { |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
170 |
PIDE.options.bool(CONTINUOUS_CHECKING) = b |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
171 |
PIDE.options_changed() |
52974 | 172 |
PIDE.editor.flush() |
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
173 |
} |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
174 |
} |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
175 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
176 |
def set_continuous_checking() { continuous_checking = true } |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
177 |
def reset_continuous_checking() { continuous_checking = false } |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
178 |
def toggle_continuous_checking() { continuous_checking = !continuous_checking } |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
179 |
|
53715 | 180 |
class Continuous_Checking extends CheckBox("Continuous checking") |
181 |
{ |
|
182 |
tooltip = "Continuous checking of proof document (visible and required parts)" |
|
183 |
reactions += { case ButtonClicked(_) => continuous_checking = selected } |
|
184 |
def load() { selected = continuous_checking } |
|
185 |
load() |
|
186 |
} |
|
187 |
||
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
188 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
189 |
/* required document nodes */ |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
190 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
191 |
private def node_required_update(view: View, toggle: Boolean = false, set: Boolean = false) |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
192 |
{ |
57612
990ffb84489b
clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents:
57424
diff
changeset
|
193 |
GUI_Thread.require {} |
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
194 |
PIDE.document_model(view.getBuffer) match { |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
195 |
case Some(model) => |
52816
c608e0ade554
home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents:
52815
diff
changeset
|
196 |
model.node_required = (if (toggle) !model.node_required else set) |
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
197 |
case None => |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
198 |
} |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
199 |
} |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
200 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
201 |
def set_node_required(view: View) { node_required_update(view, set = true) } |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
202 |
def reset_node_required(view: View) { node_required_update(view, set = false) } |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
203 |
def toggle_node_required(view: View) { node_required_update(view, toggle = true) } |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
204 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
205 |
|
50198
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
206 |
/* font size */ |
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
207 |
|
55827 | 208 |
def reset_font_size() { |
209 |
Font_Info.main_change.reset(PIDE.options.int("jedit_reset_font_size").toFloat) |
|
55823
0331b6d2ab0c
font size change with delay, to avoid GUI lagging behind user input;
wenzelm
parents:
55749
diff
changeset
|
210 |
} |
55827 | 211 |
def increase_font_size() { Font_Info.main_change.step(1) } |
212 |
def decrease_font_size() { Font_Info.main_change.step(-1) } |
|
50198
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
213 |
|
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
214 |
|
53497 | 215 |
/* structured edits */ |
50341
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
216 |
|
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
217 |
def insert_line_padding(text_area: JEditTextArea, text: String) |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
218 |
{ |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
219 |
val buffer = text_area.getBuffer |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
220 |
JEdit_Lib.buffer_edit(buffer) { |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
221 |
val text1 = |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
222 |
if (text_area.getSelectionCount == 0) { |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
223 |
def pad(range: Text.Range): String = |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
224 |
if (JEdit_Lib.try_get_text(buffer, range) == Some("\n")) "" else "\n" |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
225 |
|
56592
5157f7615e99
prefer direct caret_range for update_dictionary actions, which usually happen outside the flow of editing;
wenzelm
parents:
56587
diff
changeset
|
226 |
val caret = JEdit_Lib.caret_range(text_area) |
50341
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
227 |
val before_caret = JEdit_Lib.point_range(buffer, caret.start - 1) |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
228 |
pad(before_caret) + text + pad(caret) |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
229 |
} |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
230 |
else text |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
231 |
text_area.setSelectedText(text1) |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
232 |
} |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
233 |
} |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
234 |
|
53497 | 235 |
def edit_command( |
236 |
snapshot: Document.Snapshot, |
|
237 |
buffer: Buffer, |
|
238 |
padding: Boolean, |
|
54640
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
239 |
id: Document_ID.Generic, |
53497 | 240 |
s: String) |
241 |
{ |
|
54640
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
242 |
if (!snapshot.is_outdated) { |
57861
287e3b1298b3
restrict edit_command (for sendback) to current node -- no attempt to goto target buffer first, which might not be loaded;
wenzelm
parents:
57627
diff
changeset
|
243 |
(snapshot.state.find_command(snapshot.version, id), PIDE.document_model(buffer)) match { |
287e3b1298b3
restrict edit_command (for sendback) to current node -- no attempt to goto target buffer first, which might not be loaded;
wenzelm
parents:
57627
diff
changeset
|
244 |
case (Some((node, command)), Some(model)) if command.node_name == model.node_name => |
54640
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
245 |
node.command_start(command) match { |
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
246 |
case Some(start) => |
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
247 |
JEdit_Lib.buffer_edit(buffer) { |
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
248 |
val range = command.proper_range + start |
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
249 |
if (padding) { |
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
250 |
buffer.insert(start + range.length, "\n" + s) |
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
251 |
} |
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
252 |
else { |
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
253 |
buffer.remove(start, range.length) |
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
254 |
buffer.insert(start, s) |
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
255 |
} |
53497 | 256 |
} |
54640
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
257 |
case None => |
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
258 |
} |
57861
287e3b1298b3
restrict edit_command (for sendback) to current node -- no attempt to goto target buffer first, which might not be loaded;
wenzelm
parents:
57627
diff
changeset
|
259 |
case _ => |
54640
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53843
diff
changeset
|
260 |
} |
53497 | 261 |
} |
262 |
} |
|
263 |
||
50341
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
264 |
|
53293
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
265 |
/* completion */ |
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
266 |
|
56586 | 267 |
def complete(view: View, word_only: Boolean) |
53293
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
268 |
{ |
57424
966b12f636b9
removed slightly odd fall-back on complete-word (NB: connection to default menu action is unclear);
wenzelm
parents:
56879
diff
changeset
|
269 |
Completion_Popup.Text_Area.action(view.getTextArea, word_only) |
53293
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
270 |
} |
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
271 |
|
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
272 |
|
50183 | 273 |
/* control styles */ |
274 |
||
275 |
def control_sub(text_area: JEditTextArea) |
|
50187
b5a09812abc4
special handling of control symbols in Symbols dockable;
wenzelm
parents:
50183
diff
changeset
|
276 |
{ Token_Markup.edit_control_style(text_area, Symbol.sub_decoded) } |
50183 | 277 |
|
278 |
def control_sup(text_area: JEditTextArea) |
|
50187
b5a09812abc4
special handling of control symbols in Symbols dockable;
wenzelm
parents:
50183
diff
changeset
|
279 |
{ Token_Markup.edit_control_style(text_area, Symbol.sup_decoded) } |
50183 | 280 |
|
281 |
def control_bold(text_area: JEditTextArea) |
|
50187
b5a09812abc4
special handling of control symbols in Symbols dockable;
wenzelm
parents:
50183
diff
changeset
|
282 |
{ Token_Markup.edit_control_style(text_area, Symbol.bold_decoded) } |
50183 | 283 |
|
284 |
def control_reset(text_area: JEditTextArea) |
|
50187
b5a09812abc4
special handling of control symbols in Symbols dockable;
wenzelm
parents:
50183
diff
changeset
|
285 |
{ Token_Markup.edit_control_style(text_area, "") } |
50183 | 286 |
|
287 |
||
288 |
/* block styles */ |
|
289 |
||
290 |
private def enclose_input(text_area: JEditTextArea, s1: String, s2: String) |
|
291 |
{ |
|
292 |
s1.foreach(text_area.userInput(_)) |
|
293 |
s2.foreach(text_area.userInput(_)) |
|
294 |
s2.foreach(_ => text_area.goToPrevCharacter(false)) |
|
295 |
} |
|
296 |
||
297 |
def input_bsub(text_area: JEditTextArea) |
|
298 |
{ enclose_input(text_area, Symbol.bsub_decoded, Symbol.esub_decoded) } |
|
299 |
||
300 |
def input_bsup(text_area: JEditTextArea) |
|
301 |
{ enclose_input(text_area, Symbol.bsup_decoded, Symbol.esup_decoded) } |
|
56574
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
302 |
|
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
303 |
|
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
304 |
/* spell-checker dictionary */ |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
305 |
|
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
306 |
def update_dictionary(text_area: JEditTextArea, include: Boolean, permanent: Boolean) |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
307 |
{ |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
308 |
for { |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
309 |
spell_checker <- PIDE.spell_checker.get |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
310 |
doc_view <- PIDE.document_view(text_area) |
56576 | 311 |
rendering = doc_view.get_rendering() |
56592
5157f7615e99
prefer direct caret_range for update_dictionary actions, which usually happen outside the flow of editing;
wenzelm
parents:
56587
diff
changeset
|
312 |
range = JEdit_Lib.caret_range(text_area) |
56576 | 313 |
Text.Info(_, word) <- Spell_Checker.current_word(text_area, rendering, range) |
56575 | 314 |
} { |
315 |
spell_checker.update(word, include, permanent) |
|
316 |
JEdit_Lib.jedit_views().foreach(_.repaint()) |
|
317 |
} |
|
56574
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
318 |
} |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
319 |
|
56578 | 320 |
def reset_dictionary() |
56575 | 321 |
{ |
322 |
for (spell_checker <- PIDE.spell_checker.get) |
|
323 |
{ |
|
324 |
spell_checker.reset() |
|
325 |
JEdit_Lib.jedit_views().foreach(_.repaint()) |
|
326 |
} |
|
327 |
} |
|
57627
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
328 |
|
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
329 |
|
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
330 |
/* plugin options */ |
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
331 |
|
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
332 |
def plugin_options(frame: Frame) |
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
333 |
{ |
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
334 |
GUI_Thread.require {} |
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
335 |
new org.gjt.sp.jedit.options.PluginOptions(frame, "plugin.isabelle.jedit.Plugin") |
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
336 |
} |
50183 | 337 |
} |
338 |