author | wenzelm |
Wed, 13 Jul 2016 20:14:16 +0200 | |
changeset 63484 | 2033a3960c36 |
parent 63477 | f5c81436b930 |
child 63508 | 348599644887 |
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} |
59074 | 18 |
import org.gjt.sp.jedit.buffer.JEditBuffer |
63455
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
19 |
import org.gjt.sp.jedit.textarea.{JEditTextArea, TextArea, StructureMatcher, Selection} |
58529 | 20 |
import org.gjt.sp.jedit.syntax.TokenMarker |
63421 | 21 |
import org.gjt.sp.jedit.indent.IndentRule |
53293
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
22 |
import org.gjt.sp.jedit.gui.{DockableWindowManager, CompleteWord} |
61024
7b7f01afab71
avoid deprecated PluginOptions with its unbounded window size;
wenzelm
parents:
60890
diff
changeset
|
23 |
import org.jedit.options.CombinedOptions |
50183 | 24 |
|
25 |
||
50208 | 26 |
object Isabelle |
50183 | 27 |
{ |
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
28 |
/* editor modes */ |
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
29 |
|
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
30 |
val modes = |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
31 |
List( |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
32 |
"isabelle", // theory source |
55500 | 33 |
"isabelle-ml", // ML source |
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
34 |
"isabelle-news", // NEWS |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
35 |
"isabelle-options", // etc/options |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
36 |
"isabelle-output", // pretty text area output |
56277
c4f75e733812
separate "sml" mode, suppress old "ml" mode altogether;
wenzelm
parents:
56170
diff
changeset
|
37 |
"isabelle-root", // session ROOT |
c4f75e733812
separate "sml" mode, suppress old "ml" mode altogether;
wenzelm
parents:
56170
diff
changeset
|
38 |
"sml") // Standard ML (not Isabelle/ML) |
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
39 |
|
55616 | 40 |
private lazy val ml_syntax: Outer_Syntax = |
41 |
Outer_Syntax.init().no_tokens. |
|
55749 | 42 |
set_language_context(Completion.Language_Context.ML_outer) |
55616 | 43 |
|
56278
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56277
diff
changeset
|
44 |
private lazy val sml_syntax: Outer_Syntax = |
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56277
diff
changeset
|
45 |
Outer_Syntax.init().no_tokens. |
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56277
diff
changeset
|
46 |
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
|
47 |
|
55616 | 48 |
private lazy val news_syntax: Outer_Syntax = |
49 |
Outer_Syntax.init().no_tokens |
|
53276 | 50 |
|
59076
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
51 |
def mode_syntax(mode: String): Option[Outer_Syntax] = |
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
52 |
mode match { |
59077
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
59076
diff
changeset
|
53 |
case "isabelle" => Some(PIDE.resources.base_syntax.asInstanceOf[Outer_Syntax]) |
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
54 |
case "isabelle-options" => Some(Options.options_syntax) |
62631 | 55 |
case "isabelle-root" => Some(Sessions.root_syntax) |
55616 | 56 |
case "isabelle-ml" => Some(ml_syntax) |
57 |
case "isabelle-news" => Some(news_syntax) |
|
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
58 |
case "isabelle-output" => None |
56278
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56277
diff
changeset
|
59 |
case "sml" => Some(sml_syntax) |
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
60 |
case _ => None |
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
61 |
} |
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
62 |
|
59074 | 63 |
def buffer_syntax(buffer: JEditBuffer): Option[Outer_Syntax] = |
59077
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
59076
diff
changeset
|
64 |
(JEdit_Lib.buffer_mode(buffer), PIDE.document_model(buffer)) match { |
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
59076
diff
changeset
|
65 |
case ("isabelle", Some(model)) => |
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
59076
diff
changeset
|
66 |
Some(PIDE.session.recent_syntax(model.node_name).asInstanceOf[Outer_Syntax]) |
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
59076
diff
changeset
|
67 |
case (mode, _) => mode_syntax(mode) |
59076
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
68 |
} |
59074 | 69 |
|
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
70 |
|
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
71 |
/* token markers */ |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
72 |
|
59076
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
73 |
private val mode_markers: Map[String, TokenMarker] = |
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
74 |
Map(modes.map(mode => (mode, new Token_Markup.Marker(mode, None))): _*) + |
58546 | 75 |
("bibtex" -> new Bibtex_JEdit.Token_Marker) |
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
76 |
|
59076
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
77 |
def mode_token_marker(mode: String): Option[TokenMarker] = mode_markers.get(mode) |
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
78 |
|
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
79 |
def buffer_token_marker(buffer: Buffer): Option[TokenMarker] = |
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
80 |
{ |
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
81 |
val mode = JEdit_Lib.buffer_mode(buffer) |
60274
c2837a39da01
more conservative Document_Model.init: avoid Document.Node.Clear due to change of token marker (e.g. due to change of jEdit mode properties);
wenzelm
parents:
60074
diff
changeset
|
82 |
if (mode == "isabelle") Some(new Token_Markup.Marker(mode, Some(buffer))) |
c2837a39da01
more conservative Document_Model.init: avoid Document.Node.Clear due to change of token marker (e.g. due to change of jEdit mode properties);
wenzelm
parents:
60074
diff
changeset
|
83 |
else mode_token_marker(mode) |
59076
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
84 |
} |
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
85 |
|
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
86 |
|
63422 | 87 |
/* text structure */ |
63421 | 88 |
|
63422 | 89 |
def indent_rule(mode: String): Option[IndentRule] = |
63444 | 90 |
mode match { |
91 |
case "isabelle" | "isabelle-options" | "isabelle-root" => |
|
92 |
Some(Text_Structure.Indent_Rule) |
|
93 |
case _ => None |
|
94 |
} |
|
63421 | 95 |
|
63422 | 96 |
def structure_matchers(mode: String): List[StructureMatcher] = |
97 |
if (mode == "isabelle") List(Text_Structure.Matcher) else Nil |
|
58748 | 98 |
|
99 |
||
50208 | 100 |
/* dockable windows */ |
101 |
||
102 |
private def wm(view: View): DockableWindowManager = view.getDockableWindowManager |
|
103 |
||
60749 | 104 |
def debugger_dockable(view: View): Option[Debugger_Dockable] = |
105 |
wm(view).getDockableWindow("isabelle-debugger") match { |
|
106 |
case dockable: Debugger_Dockable => Some(dockable) |
|
107 |
case _ => None |
|
108 |
} |
|
109 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
110 |
def documentation_dockable(view: View): Option[Documentation_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
111 |
wm(view).getDockableWindow("isabelle-documentation") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
112 |
case dockable: Documentation_Dockable => Some(dockable) |
50208 | 113 |
case _ => None |
114 |
} |
|
115 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
116 |
def monitor_dockable(view: View): Option[Monitor_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
117 |
wm(view).getDockableWindow("isabelle-monitor") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
118 |
case dockable: Monitor_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
119 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
120 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
121 |
|
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
122 |
def output_dockable(view: View): Option[Output_Dockable] = |
50208 | 123 |
wm(view).getDockableWindow("isabelle-output") match { |
124 |
case dockable: Output_Dockable => Some(dockable) |
|
125 |
case _ => None |
|
126 |
} |
|
127 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
128 |
def protocol_dockable(view: View): Option[Protocol_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
129 |
wm(view).getDockableWindow("isabelle-protocol") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
130 |
case dockable: Protocol_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 |
|
56879
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
134 |
def query_dockable(view: View): Option[Query_Dockable] = |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
135 |
wm(view).getDockableWindow("isabelle-query") match { |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
136 |
case dockable: Query_Dockable => Some(dockable) |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
137 |
case _ => None |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
138 |
} |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
139 |
|
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
140 |
def raw_output_dockable(view: View): Option[Raw_Output_Dockable] = |
50208 | 141 |
wm(view).getDockableWindow("isabelle-raw-output") match { |
142 |
case dockable: Raw_Output_Dockable => Some(dockable) |
|
143 |
case _ => None |
|
144 |
} |
|
145 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
146 |
def simplifier_trace_dockable(view: View): Option[Simplifier_Trace_Dockable] = |
55557 | 147 |
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
|
148 |
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
|
149 |
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
|
150 |
} |
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
|
151 |
|
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
152 |
def sledgehammer_dockable(view: View): Option[Sledgehammer_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
153 |
wm(view).getDockableWindow("isabelle-sledgehammer") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
154 |
case dockable: Sledgehammer_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
155 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
156 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
157 |
|
61208 | 158 |
def state_dockable(view: View): Option[State_Dockable] = |
159 |
wm(view).getDockableWindow("isabelle-state") match { |
|
160 |
case dockable: State_Dockable => Some(dockable) |
|
161 |
case _ => None |
|
162 |
} |
|
163 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
164 |
def symbols_dockable(view: View): Option[Symbols_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
165 |
wm(view).getDockableWindow("isabelle-symbols") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
166 |
case dockable: Symbols_Dockable => Some(dockable) |
50208 | 167 |
case _ => None |
168 |
} |
|
169 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
170 |
def syslog_dockable(view: View): Option[Syslog_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
171 |
wm(view).getDockableWindow("isabelle-syslog") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
172 |
case dockable: Syslog_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
173 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
174 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
175 |
|
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
176 |
def theories_dockable(view: View): Option[Theories_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
177 |
wm(view).getDockableWindow("isabelle-theories") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
178 |
case dockable: Theories_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
179 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
180 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
181 |
|
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
182 |
def timing_dockable(view: View): Option[Timing_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
183 |
wm(view).getDockableWindow("isabelle-timing") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
184 |
case dockable: Timing_Dockable => Some(dockable) |
50433
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
185 |
case _ => None |
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
186 |
} |
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
187 |
|
50208 | 188 |
|
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
189 |
/* continuous checking */ |
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 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
|
192 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
193 |
def continuous_checking: Boolean = PIDE.options.bool(CONTINUOUS_CHECKING) |
60074
38a64cc17403
GUI controls for ML_statistics, for more digestible protocol dump;
wenzelm
parents:
59077
diff
changeset
|
194 |
def continuous_checking_=(b: Boolean): Unit = |
38a64cc17403
GUI controls for ML_statistics, for more digestible protocol dump;
wenzelm
parents:
59077
diff
changeset
|
195 |
GUI_Thread.require { |
38a64cc17403
GUI controls for ML_statistics, for more digestible protocol dump;
wenzelm
parents:
59077
diff
changeset
|
196 |
if (continuous_checking != b) { |
38a64cc17403
GUI controls for ML_statistics, for more digestible protocol dump;
wenzelm
parents:
59077
diff
changeset
|
197 |
PIDE.options.bool(CONTINUOUS_CHECKING) = b |
61725 | 198 |
PIDE.session.update_options(PIDE.options.value) |
60074
38a64cc17403
GUI controls for ML_statistics, for more digestible protocol dump;
wenzelm
parents:
59077
diff
changeset
|
199 |
} |
52815
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 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
202 |
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
|
203 |
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
|
204 |
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
|
205 |
|
53715 | 206 |
class Continuous_Checking extends CheckBox("Continuous checking") |
207 |
{ |
|
208 |
tooltip = "Continuous checking of proof document (visible and required parts)" |
|
209 |
reactions += { case ButtonClicked(_) => continuous_checking = selected } |
|
210 |
def load() { selected = continuous_checking } |
|
211 |
load() |
|
212 |
} |
|
213 |
||
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
214 |
|
61211 | 215 |
/* update state */ |
216 |
||
217 |
def update_state(view: View): Unit = |
|
61802
1d81de0bddc4
more thorough update request: semantic state of command may have changed elsewise;
wenzelm
parents:
61725
diff
changeset
|
218 |
state_dockable(view).foreach(_.update_request()) |
61211 | 219 |
|
220 |
||
60074
38a64cc17403
GUI controls for ML_statistics, for more digestible protocol dump;
wenzelm
parents:
59077
diff
changeset
|
221 |
/* ML statistics */ |
38a64cc17403
GUI controls for ML_statistics, for more digestible protocol dump;
wenzelm
parents:
59077
diff
changeset
|
222 |
|
60843 | 223 |
class ML_Stats extends |
224 |
JEdit_Options.Check_Box("ML_statistics", "ML statistics", "Enable ML runtime system statistics") |
|
60074
38a64cc17403
GUI controls for ML_statistics, for more digestible protocol dump;
wenzelm
parents:
59077
diff
changeset
|
225 |
|
38a64cc17403
GUI controls for ML_statistics, for more digestible protocol dump;
wenzelm
parents:
59077
diff
changeset
|
226 |
|
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
227 |
/* 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
|
228 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
229 |
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
|
230 |
{ |
57612
990ffb84489b
clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents:
57424
diff
changeset
|
231 |
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
|
232 |
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
|
233 |
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
|
234 |
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
|
235 |
case None => |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
236 |
} |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
237 |
} |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
238 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
239 |
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
|
240 |
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
|
241 |
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
|
242 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
243 |
|
50198
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
244 |
/* font size */ |
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
245 |
|
55827 | 246 |
def reset_font_size() { |
247 |
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
|
248 |
} |
55827 | 249 |
def increase_font_size() { Font_Info.main_change.step(1) } |
250 |
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
|
251 |
|
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
252 |
|
53497 | 253 |
/* structured edits */ |
50341
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
254 |
|
63455
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
255 |
def newline(text_area: TextArea) |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
256 |
{ |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
257 |
if (!text_area.isEditable()) text_area.getToolkit().beep() |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
258 |
else { |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
259 |
val buffer = text_area.getBuffer |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
260 |
def nl { text_area.userInput('\n') } |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
261 |
|
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
262 |
if (indent_rule(JEdit_Lib.buffer_mode(buffer)).isDefined && |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
263 |
buffer.getStringProperty("autoIndent") == "full" && |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
264 |
PIDE.options.bool("jedit_indent_newline")) |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
265 |
{ |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
266 |
Isabelle.buffer_syntax(buffer) match { |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
267 |
case Some(syntax) if buffer.isInstanceOf[Buffer] => |
63484 | 268 |
val keywords = syntax.keywords |
269 |
||
63455
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
270 |
val caret = text_area.getCaretPosition |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
271 |
val line = text_area.getCaretLine |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
272 |
val line_range = JEdit_Lib.line_range(buffer, line) |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
273 |
|
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
274 |
def line_content(start: Text.Offset, stop: Text.Offset, context: Scan.Line_Context) |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
275 |
: (List[Token], Scan.Line_Context) = |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
276 |
{ |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
277 |
val text = JEdit_Lib.try_get_text(buffer, Text.Range(start, stop)).getOrElse("") |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
278 |
val (toks, context1) = Token.explode_line(syntax.keywords, text, context) |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
279 |
val toks1 = toks.filterNot(_.is_space) |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
280 |
(toks1, context1) |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
281 |
} |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
282 |
|
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
283 |
val context0 = Token_Markup.Line_Context.prev(buffer, line).get_context |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
284 |
val (tokens1, context1) = line_content(line_range.start, caret, context0) |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
285 |
val (tokens2, _) = line_content(caret, line_range.stop, context1) |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
286 |
|
63484 | 287 |
if (tokens1.nonEmpty && |
288 |
(tokens1.head.is_begin_or_command || keywords.is_quasi_command(tokens1.head))) |
|
63477
f5c81436b930
clarified indentation: 'begin' is treated like a separate command without indent;
wenzelm
parents:
63455
diff
changeset
|
289 |
buffer.indentLine(line, true) |
63455
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
290 |
|
63484 | 291 |
if (tokens2.isEmpty || |
292 |
tokens2.head.is_begin_or_command || keywords.is_quasi_command(tokens2.head)) |
|
63455
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
293 |
JEdit_Lib.buffer_edit(buffer) { |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
294 |
text_area.setSelectedText("\n") |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
295 |
if (!buffer.indentLine(line + 1, true)) text_area.goToStartOfWhiteSpace(false) |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
296 |
} |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
297 |
else nl |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
298 |
case _ => nl |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
299 |
} |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
300 |
} |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
301 |
else nl |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
302 |
} |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
303 |
} |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
304 |
|
50341
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
305 |
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
|
306 |
{ |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
307 |
val buffer = text_area.getBuffer |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
308 |
JEdit_Lib.buffer_edit(buffer) { |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
309 |
val text1 = |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
310 |
if (text_area.getSelectionCount == 0) { |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
311 |
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
|
312 |
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
|
313 |
|
56592
5157f7615e99
prefer direct caret_range for update_dictionary actions, which usually happen outside the flow of editing;
wenzelm
parents:
56587
diff
changeset
|
314 |
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
|
315 |
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
|
316 |
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
|
317 |
} |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
318 |
else text |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
319 |
text_area.setSelectedText(text1) |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
320 |
} |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
321 |
} |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
322 |
|
53497 | 323 |
def edit_command( |
324 |
snapshot: Document.Snapshot, |
|
325 |
buffer: Buffer, |
|
326 |
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
|
327 |
id: Document_ID.Generic, |
53497 | 328 |
s: String) |
329 |
{ |
|
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
|
330 |
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
|
331 |
(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
|
332 |
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
|
333 |
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
|
334 |
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
|
335 |
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
|
336 |
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
|
337 |
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
|
338 |
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
|
339 |
} |
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
|
340 |
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
|
341 |
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
|
342 |
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
|
343 |
} |
53497 | 344 |
} |
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
|
345 |
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
|
346 |
} |
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
|
347 |
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
|
348 |
} |
53497 | 349 |
} |
350 |
} |
|
351 |
||
50341
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
352 |
|
63236 | 353 |
/* selection */ |
354 |
||
355 |
def select_entity(text_area: JEditTextArea) |
|
356 |
{ |
|
357 |
for { |
|
358 |
doc_view <- PIDE.document_view(text_area) |
|
359 |
rendering = doc_view.get_rendering() |
|
360 |
} { |
|
361 |
val caret_range = JEdit_Lib.caret_range(text_area) |
|
362 |
val buffer_range = JEdit_Lib.buffer_range(text_area.getBuffer) |
|
363 |
val active_focus = rendering.caret_focus_ranges(caret_range, buffer_range) |
|
364 |
if (active_focus.nonEmpty) { |
|
365 |
text_area.selectNone() |
|
366 |
for (r <- active_focus) |
|
367 |
text_area.addToSelection(new Selection.Range(r.start, r.stop)) |
|
368 |
} |
|
369 |
} |
|
370 |
} |
|
371 |
||
372 |
||
53293
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
373 |
/* completion */ |
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
374 |
|
56586 | 375 |
def complete(view: View, word_only: Boolean) |
53293
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
376 |
{ |
57424
966b12f636b9
removed slightly odd fall-back on complete-word (NB: connection to default menu action is unclear);
wenzelm
parents:
56879
diff
changeset
|
377 |
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
|
378 |
} |
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
379 |
|
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
380 |
|
50183 | 381 |
/* control styles */ |
382 |
||
383 |
def control_sub(text_area: JEditTextArea) |
|
62104
fb73c0d7bb37
clarified symbol insertion, depending on buffer encoding;
wenzelm
parents:
61802
diff
changeset
|
384 |
{ Token_Markup.edit_control_style(text_area, Symbol.sub) } |
50183 | 385 |
|
386 |
def control_sup(text_area: JEditTextArea) |
|
62104
fb73c0d7bb37
clarified symbol insertion, depending on buffer encoding;
wenzelm
parents:
61802
diff
changeset
|
387 |
{ Token_Markup.edit_control_style(text_area, Symbol.sup) } |
50183 | 388 |
|
389 |
def control_bold(text_area: JEditTextArea) |
|
62104
fb73c0d7bb37
clarified symbol insertion, depending on buffer encoding;
wenzelm
parents:
61802
diff
changeset
|
390 |
{ Token_Markup.edit_control_style(text_area, Symbol.bold) } |
50183 | 391 |
|
61483 | 392 |
def control_emph(text_area: JEditTextArea) |
62104
fb73c0d7bb37
clarified symbol insertion, depending on buffer encoding;
wenzelm
parents:
61802
diff
changeset
|
393 |
{ Token_Markup.edit_control_style(text_area, Symbol.emph) } |
61483 | 394 |
|
50183 | 395 |
def control_reset(text_area: JEditTextArea) |
50187
b5a09812abc4
special handling of control symbols in Symbols dockable;
wenzelm
parents:
50183
diff
changeset
|
396 |
{ Token_Markup.edit_control_style(text_area, "") } |
50183 | 397 |
|
398 |
||
399 |
/* block styles */ |
|
400 |
||
401 |
private def enclose_input(text_area: JEditTextArea, s1: String, s2: String) |
|
402 |
{ |
|
403 |
s1.foreach(text_area.userInput(_)) |
|
404 |
s2.foreach(text_area.userInput(_)) |
|
405 |
s2.foreach(_ => text_area.goToPrevCharacter(false)) |
|
406 |
} |
|
407 |
||
408 |
def input_bsub(text_area: JEditTextArea) |
|
409 |
{ enclose_input(text_area, Symbol.bsub_decoded, Symbol.esub_decoded) } |
|
410 |
||
411 |
def input_bsup(text_area: JEditTextArea) |
|
412 |
{ enclose_input(text_area, Symbol.bsup_decoded, Symbol.esup_decoded) } |
|
56574
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
413 |
|
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
414 |
|
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
415 |
/* spell-checker dictionary */ |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
416 |
|
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
417 |
def update_dictionary(text_area: JEditTextArea, include: Boolean, permanent: Boolean) |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
418 |
{ |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
419 |
for { |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
420 |
spell_checker <- PIDE.spell_checker.get |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
421 |
doc_view <- PIDE.document_view(text_area) |
56576 | 422 |
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
|
423 |
range = JEdit_Lib.caret_range(text_area) |
56576 | 424 |
Text.Info(_, word) <- Spell_Checker.current_word(text_area, rendering, range) |
56575 | 425 |
} { |
426 |
spell_checker.update(word, include, permanent) |
|
427 |
JEdit_Lib.jedit_views().foreach(_.repaint()) |
|
428 |
} |
|
56574
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
429 |
} |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
430 |
|
56578 | 431 |
def reset_dictionary() |
56575 | 432 |
{ |
433 |
for (spell_checker <- PIDE.spell_checker.get) |
|
434 |
{ |
|
435 |
spell_checker.reset() |
|
436 |
JEdit_Lib.jedit_views().foreach(_.repaint()) |
|
437 |
} |
|
438 |
} |
|
57627
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
439 |
|
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
440 |
|
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60843
diff
changeset
|
441 |
/* debugger */ |
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60843
diff
changeset
|
442 |
|
60890 | 443 |
def toggle_breakpoint(text_area: JEditTextArea): Unit = |
444 |
if (Debugger.is_active()) { |
|
445 |
for { |
|
446 |
(command, serial) <- Debugger_Dockable.get_breakpoint(text_area, text_area.getCaretPosition) |
|
447 |
} Debugger_Dockable.toggle_breakpoint(command, serial) |
|
448 |
} |
|
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60843
diff
changeset
|
449 |
|
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60843
diff
changeset
|
450 |
|
57627
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
451 |
/* plugin options */ |
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
452 |
|
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
453 |
def plugin_options(frame: Frame) |
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
454 |
{ |
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
455 |
GUI_Thread.require {} |
61024
7b7f01afab71
avoid deprecated PluginOptions with its unbounded window size;
wenzelm
parents:
60890
diff
changeset
|
456 |
jEdit.setProperty("Plugin Options.last", "isabelle-general") |
7b7f01afab71
avoid deprecated PluginOptions with its unbounded window size;
wenzelm
parents:
60890
diff
changeset
|
457 |
new CombinedOptions(frame, 1) |
57627
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
458 |
} |
50183 | 459 |
} |