author | wenzelm |
Mon, 14 Dec 2020 22:01:54 +0100 | |
changeset 72927 | 69f768aff611 |
parent 72135 | f67e83608745 |
child 72928 | 25cc8f5184e5 |
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 |
||
71497 | 12 |
import java.awt.{Frame, Point} |
57627
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 |
|
67004
af72fa58f71b
clarified lazy Completion within Outer_Syntax: measurable speedup of Sessions.deps;
wenzelm
parents:
66984
diff
changeset
|
40 |
private val ml_syntax: Outer_Syntax = |
af72fa58f71b
clarified lazy Completion within Outer_Syntax: measurable speedup of Sessions.deps;
wenzelm
parents:
66984
diff
changeset
|
41 |
Outer_Syntax.empty.no_tokens. |
55749 | 42 |
set_language_context(Completion.Language_Context.ML_outer) |
55616 | 43 |
|
67004
af72fa58f71b
clarified lazy Completion within Outer_Syntax: measurable speedup of Sessions.deps;
wenzelm
parents:
66984
diff
changeset
|
44 |
private val sml_syntax: Outer_Syntax = |
af72fa58f71b
clarified lazy Completion within Outer_Syntax: measurable speedup of Sessions.deps;
wenzelm
parents:
66984
diff
changeset
|
45 |
Outer_Syntax.empty.no_tokens. |
56278
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 |
|
67004
af72fa58f71b
clarified lazy Completion within Outer_Syntax: measurable speedup of Sessions.deps;
wenzelm
parents:
66984
diff
changeset
|
48 |
private val news_syntax: Outer_Syntax = |
af72fa58f71b
clarified lazy Completion within Outer_Syntax: measurable speedup of Sessions.deps;
wenzelm
parents:
66984
diff
changeset
|
49 |
Outer_Syntax.empty.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 { |
66720 | 53 |
case "isabelle" => Some(PIDE.resources.session_base.overall_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] = |
63868 | 64 |
if (buffer == null) None |
65 |
else |
|
64813 | 66 |
(JEdit_Lib.buffer_mode(buffer), Document_Model.get(buffer)) match { |
63868 | 67 |
case ("isabelle", Some(model)) => |
68 |
Some(PIDE.session.recent_syntax(model.node_name)) |
|
69 |
case (mode, _) => mode_syntax(mode) |
|
70 |
} |
|
59074 | 71 |
|
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
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 |
|
59076
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
75 |
private val mode_markers: Map[String, TokenMarker] = |
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
76 |
Map(modes.map(mode => (mode, new Token_Markup.Marker(mode, None))): _*) + |
66120 | 77 |
("bibtex" -> new JEdit_Bibtex.Token_Marker) |
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
78 |
|
59076
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
79 |
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
|
80 |
|
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
81 |
def buffer_token_marker(buffer: Buffer): Option[TokenMarker] = |
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
82 |
{ |
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
83 |
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
|
84 |
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
|
85 |
else mode_token_marker(mode) |
59076
65babcd8b0e6
clarified token marker / syntax for mode vs. buffer;
wenzelm
parents:
59075
diff
changeset
|
86 |
} |
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
87 |
|
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
88 |
|
63422 | 89 |
/* text structure */ |
63421 | 90 |
|
63422 | 91 |
def indent_rule(mode: String): Option[IndentRule] = |
63444 | 92 |
mode match { |
93 |
case "isabelle" | "isabelle-options" | "isabelle-root" => |
|
94 |
Some(Text_Structure.Indent_Rule) |
|
95 |
case _ => None |
|
96 |
} |
|
63421 | 97 |
|
63422 | 98 |
def structure_matchers(mode: String): List[StructureMatcher] = |
99 |
if (mode == "isabelle") List(Text_Structure.Matcher) else Nil |
|
58748 | 100 |
|
101 |
||
50208 | 102 |
/* dockable windows */ |
103 |
||
104 |
private def wm(view: View): DockableWindowManager = view.getDockableWindowManager |
|
105 |
||
60749 | 106 |
def debugger_dockable(view: View): Option[Debugger_Dockable] = |
107 |
wm(view).getDockableWindow("isabelle-debugger") match { |
|
108 |
case dockable: Debugger_Dockable => Some(dockable) |
|
109 |
case _ => None |
|
110 |
} |
|
111 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
112 |
def documentation_dockable(view: View): Option[Documentation_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
113 |
wm(view).getDockableWindow("isabelle-documentation") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
114 |
case dockable: Documentation_Dockable => Some(dockable) |
50208 | 115 |
case _ => None |
116 |
} |
|
117 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
118 |
def monitor_dockable(view: View): Option[Monitor_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
119 |
wm(view).getDockableWindow("isabelle-monitor") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
120 |
case dockable: Monitor_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
121 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
122 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
123 |
|
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
124 |
def output_dockable(view: View): Option[Output_Dockable] = |
50208 | 125 |
wm(view).getDockableWindow("isabelle-output") match { |
126 |
case dockable: Output_Dockable => Some(dockable) |
|
127 |
case _ => None |
|
128 |
} |
|
129 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
130 |
def protocol_dockable(view: View): Option[Protocol_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
131 |
wm(view).getDockableWindow("isabelle-protocol") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
132 |
case dockable: Protocol_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
133 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
134 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
135 |
|
56879
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
136 |
def query_dockable(view: View): Option[Query_Dockable] = |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
137 |
wm(view).getDockableWindow("isabelle-query") match { |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
138 |
case dockable: Query_Dockable => Some(dockable) |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
139 |
case _ => None |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
140 |
} |
ee2b61f37ad9
renamed "Find" to "Query", with more general operations;
wenzelm
parents:
56662
diff
changeset
|
141 |
|
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
142 |
def raw_output_dockable(view: View): Option[Raw_Output_Dockable] = |
50208 | 143 |
wm(view).getDockableWindow("isabelle-raw-output") match { |
144 |
case dockable: Raw_Output_Dockable => Some(dockable) |
|
145 |
case _ => None |
|
146 |
} |
|
147 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
148 |
def simplifier_trace_dockable(view: View): Option[Simplifier_Trace_Dockable] = |
55557 | 149 |
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
|
150 |
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
|
151 |
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
|
152 |
} |
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
|
153 |
|
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
154 |
def sledgehammer_dockable(view: View): Option[Sledgehammer_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
155 |
wm(view).getDockableWindow("isabelle-sledgehammer") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
156 |
case dockable: Sledgehammer_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
157 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
158 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
159 |
|
61208 | 160 |
def state_dockable(view: View): Option[State_Dockable] = |
161 |
wm(view).getDockableWindow("isabelle-state") match { |
|
162 |
case dockable: State_Dockable => Some(dockable) |
|
163 |
case _ => None |
|
164 |
} |
|
165 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
166 |
def symbols_dockable(view: View): Option[Symbols_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
167 |
wm(view).getDockableWindow("isabelle-symbols") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
168 |
case dockable: Symbols_Dockable => Some(dockable) |
50208 | 169 |
case _ => None |
170 |
} |
|
171 |
||
55558
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
172 |
def syslog_dockable(view: View): Option[Syslog_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
173 |
wm(view).getDockableWindow("isabelle-syslog") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
174 |
case dockable: Syslog_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
175 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
176 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
177 |
|
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
178 |
def theories_dockable(view: View): Option[Theories_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
179 |
wm(view).getDockableWindow("isabelle-theories") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
180 |
case dockable: Theories_Dockable => Some(dockable) |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
181 |
case _ => None |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
182 |
} |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
183 |
|
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
184 |
def timing_dockable(view: View): Option[Timing_Dockable] = |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
185 |
wm(view).getDockableWindow("isabelle-timing") match { |
298274c970b6
more uniform treatment of dockables and their standard actions;
wenzelm
parents:
55557
diff
changeset
|
186 |
case dockable: Timing_Dockable => Some(dockable) |
50433
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
187 |
case _ => None |
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
188 |
} |
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
189 |
|
50208 | 190 |
|
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
191 |
/* 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 |
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
|
194 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
195 |
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
|
196 |
def continuous_checking_=(b: Boolean): Unit = |
38a64cc17403
GUI controls for ML_statistics, for more digestible protocol dump;
wenzelm
parents:
59077
diff
changeset
|
197 |
GUI_Thread.require { |
38a64cc17403
GUI controls for ML_statistics, for more digestible protocol dump;
wenzelm
parents:
59077
diff
changeset
|
198 |
if (continuous_checking != b) { |
38a64cc17403
GUI controls for ML_statistics, for more digestible protocol dump;
wenzelm
parents:
59077
diff
changeset
|
199 |
PIDE.options.bool(CONTINUOUS_CHECKING) = b |
61725 | 200 |
PIDE.session.update_options(PIDE.options.value) |
60074
38a64cc17403
GUI controls for ML_statistics, for more digestible protocol dump;
wenzelm
parents:
59077
diff
changeset
|
201 |
} |
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
202 |
} |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
203 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
204 |
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
|
205 |
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
|
206 |
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
|
207 |
|
53715 | 208 |
class Continuous_Checking extends CheckBox("Continuous checking") |
209 |
{ |
|
210 |
tooltip = "Continuous checking of proof document (visible and required parts)" |
|
211 |
reactions += { case ButtonClicked(_) => continuous_checking = selected } |
|
212 |
def load() { selected = continuous_checking } |
|
213 |
load() |
|
214 |
} |
|
215 |
||
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
216 |
|
61211 | 217 |
/* update state */ |
218 |
||
219 |
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
|
220 |
state_dockable(view).foreach(_.update_request()) |
61211 | 221 |
|
222 |
||
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
223 |
/* 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
|
224 |
|
64817 | 225 |
def set_node_required(view: View) { Document_Model.view_node_required(view, set = true) } |
226 |
def reset_node_required(view: View) { Document_Model.view_node_required(view, set = false) } |
|
227 |
def toggle_node_required(view: View) { Document_Model.view_node_required(view, toggle = true) } |
|
52815
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 |
|
50198
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
230 |
/* font size */ |
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
231 |
|
55827 | 232 |
def reset_font_size() { |
233 |
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
|
234 |
} |
55827 | 235 |
def increase_font_size() { Font_Info.main_change.step(1) } |
236 |
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
|
237 |
|
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
238 |
|
53497 | 239 |
/* structured edits */ |
50341
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
240 |
|
66180 | 241 |
def indent_enabled(buffer: JEditBuffer, option: String): Boolean = |
242 |
indent_rule(JEdit_Lib.buffer_mode(buffer)).isDefined && |
|
243 |
buffer.getStringProperty("autoIndent") == "full" && |
|
244 |
PIDE.options.bool(option) |
|
245 |
||
246 |
def indent_input(text_area: TextArea) |
|
247 |
{ |
|
248 |
val buffer = text_area.getBuffer |
|
249 |
val line = text_area.getCaretLine |
|
250 |
val caret = text_area.getCaretPosition |
|
251 |
||
252 |
if (text_area.isEditable && indent_enabled(buffer, "jedit_indent_input")) { |
|
253 |
buffer_syntax(buffer) match { |
|
66183 | 254 |
case Some(syntax) => |
255 |
val nav = new Text_Structure.Navigator(syntax, buffer, true) |
|
66180 | 256 |
nav.iterator(line, 1).toStream.headOption match { |
257 |
case Some(Text.Info(range, tok)) |
|
258 |
if range.stop == caret && syntax.keywords.is_indent_command(tok) => |
|
259 |
buffer.indentLine(line, true) |
|
260 |
case _ => |
|
261 |
} |
|
66183 | 262 |
case None => |
66180 | 263 |
} |
264 |
} |
|
265 |
} |
|
266 |
||
63455
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
267 |
def newline(text_area: TextArea) |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
268 |
{ |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
269 |
if (!text_area.isEditable()) text_area.getToolkit().beep() |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
270 |
else { |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
271 |
val buffer = text_area.getBuffer |
66182 | 272 |
val line = text_area.getCaretLine |
273 |
val caret = text_area.getCaretPosition |
|
274 |
||
63455
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
275 |
def nl { text_area.userInput('\n') } |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
276 |
|
66180 | 277 |
if (indent_enabled(buffer, "jedit_indent_newline")) { |
278 |
buffer_syntax(buffer) match { |
|
66182 | 279 |
case Some(syntax) => |
63484 | 280 |
val keywords = syntax.keywords |
281 |
||
66173 | 282 |
val (toks1, toks2) = Text_Structure.split_line_content(buffer, keywords, line, caret) |
63455
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
283 |
|
66174 | 284 |
if (toks1.isEmpty) buffer.removeTrailingWhiteSpace(Array(line)) |
285 |
else if (keywords.is_indent_command(toks1.head)) buffer.indentLine(line, true) |
|
63455
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
286 |
|
66469
a6ec0172211a
avoid compound edit: it causes confusion about the context of the last line, e.g. final "end";
wenzelm
parents:
66183
diff
changeset
|
287 |
if (toks2.isEmpty || keywords.is_indent_command(toks2.head)) { |
a6ec0172211a
avoid compound edit: it causes confusion about the context of the last line, e.g. final "end";
wenzelm
parents:
66183
diff
changeset
|
288 |
text_area.setSelectedText("\n") |
a6ec0172211a
avoid compound edit: it causes confusion about the context of the last line, e.g. final "end";
wenzelm
parents:
66183
diff
changeset
|
289 |
if (!buffer.indentLine(line + 1, true)) text_area.goToStartOfWhiteSpace(false) |
a6ec0172211a
avoid compound edit: it causes confusion about the context of the last line, e.g. final "end";
wenzelm
parents:
66183
diff
changeset
|
290 |
} |
63455
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
291 |
else nl |
66182 | 292 |
case None => nl |
63455
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
293 |
} |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
294 |
} |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
295 |
else nl |
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 |
} |
019856db2bb6
added action "isabelle.newline" (shortcut ENTER);
wenzelm
parents:
63444
diff
changeset
|
298 |
|
50341
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
299 |
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
|
300 |
{ |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
301 |
val buffer = text_area.getBuffer |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
302 |
JEdit_Lib.buffer_edit(buffer) { |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
303 |
val text1 = |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
304 |
if (text_area.getSelectionCount == 0) { |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
305 |
def pad(range: Text.Range): String = |
67014 | 306 |
if (JEdit_Lib.get_text(buffer, range) == Some("\n")) "" else "\n" |
50341
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
307 |
|
56592
5157f7615e99
prefer direct caret_range for update_dictionary actions, which usually happen outside the flow of editing;
wenzelm
parents:
56587
diff
changeset
|
308 |
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
|
309 |
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
|
310 |
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
|
311 |
} |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
312 |
else text |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
313 |
text_area.setSelectedText(text1) |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
314 |
} |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
315 |
} |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
316 |
|
53497 | 317 |
def edit_command( |
318 |
snapshot: Document.Snapshot, |
|
63508 | 319 |
text_area: TextArea, |
53497 | 320 |
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
|
321 |
id: Document_ID.Generic, |
63508 | 322 |
text: String) |
53497 | 323 |
{ |
63508 | 324 |
val buffer = text_area.getBuffer |
325 |
if (!snapshot.is_outdated && text != "") { |
|
64813 | 326 |
(snapshot.find_command(id), Document_Model.get(buffer)) match { |
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
|
327 |
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
|
328 |
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
|
329 |
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
|
330 |
JEdit_Lib.buffer_edit(buffer) { |
68728 | 331 |
val range = command.core_range + start |
63508 | 332 |
JEdit_Lib.buffer_edit(buffer) { |
333 |
if (padding) { |
|
334 |
text_area.moveCaretPosition(start + range.length) |
|
64456
f630e9385d7e
more accurate start_line: avoid changing the original command (e.g. 'try', 'sledgehammer');
wenzelm
parents:
63868
diff
changeset
|
335 |
val start_line = text_area.getCaretLine + 1 |
63508 | 336 |
text_area.setSelectedText("\n" + text) |
337 |
val end_line = text_area.getCaretLine |
|
338 |
buffer.indentLines(start_line, end_line) |
|
339 |
} |
|
340 |
else { |
|
341 |
buffer.remove(start, range.length) |
|
342 |
text_area.moveCaretPosition(start) |
|
343 |
text_area.setSelectedText(text) |
|
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 |
} |
53497 | 346 |
} |
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
|
347 |
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
|
348 |
} |
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
|
349 |
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
|
350 |
} |
53497 | 351 |
} |
352 |
} |
|
353 |
||
50341
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
354 |
|
63236 | 355 |
/* selection */ |
356 |
||
357 |
def select_entity(text_area: JEditTextArea) |
|
358 |
{ |
|
71495 | 359 |
for (doc_view <- Document_View.get(text_area)) { |
360 |
val rendering = doc_view.get_rendering() |
|
63236 | 361 |
val caret_range = JEdit_Lib.caret_range(text_area) |
72927
69f768aff611
clarified caret focus modifier, depending on option "jedit_focus_modifier";
wenzelm
parents:
72135
diff
changeset
|
362 |
val active_focus = rendering.caret_focus_ranges(caret_range, Text.Range.full) |
63236 | 363 |
if (active_focus.nonEmpty) { |
364 |
text_area.selectNone() |
|
365 |
for (r <- active_focus) |
|
366 |
text_area.addToSelection(new Selection.Range(r.start, r.stop)) |
|
367 |
} |
|
368 |
} |
|
369 |
} |
|
370 |
||
371 |
||
53293
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
372 |
/* completion */ |
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
373 |
|
56586 | 374 |
def complete(view: View, word_only: Boolean) |
53293
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
375 |
{ |
57424
966b12f636b9
removed slightly odd fall-back on complete-word (NB: connection to default menu action is unclear);
wenzelm
parents:
56879
diff
changeset
|
376 |
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
|
377 |
} |
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 |
|
50183 | 380 |
/* control styles */ |
381 |
||
382 |
def control_sub(text_area: JEditTextArea) |
|
65259 | 383 |
{ Syntax_Style.edit_control_style(text_area, Symbol.sub) } |
50183 | 384 |
|
385 |
def control_sup(text_area: JEditTextArea) |
|
65259 | 386 |
{ Syntax_Style.edit_control_style(text_area, Symbol.sup) } |
50183 | 387 |
|
388 |
def control_bold(text_area: JEditTextArea) |
|
65259 | 389 |
{ Syntax_Style.edit_control_style(text_area, Symbol.bold) } |
50183 | 390 |
|
61483 | 391 |
def control_emph(text_area: JEditTextArea) |
65259 | 392 |
{ Syntax_Style.edit_control_style(text_area, Symbol.emph) } |
61483 | 393 |
|
50183 | 394 |
def control_reset(text_area: JEditTextArea) |
65259 | 395 |
{ Syntax_Style.edit_control_style(text_area, "") } |
50183 | 396 |
|
397 |
||
398 |
/* block styles */ |
|
399 |
||
400 |
private def enclose_input(text_area: JEditTextArea, s1: String, s2: String) |
|
401 |
{ |
|
71601 | 402 |
s1.foreach(text_area.userInput) |
403 |
s2.foreach(text_area.userInput) |
|
50183 | 404 |
s2.foreach(_ => text_area.goToPrevCharacter(false)) |
405 |
} |
|
406 |
||
407 |
def input_bsub(text_area: JEditTextArea) |
|
408 |
{ enclose_input(text_area, Symbol.bsub_decoded, Symbol.esub_decoded) } |
|
409 |
||
410 |
def input_bsup(text_area: JEditTextArea) |
|
411 |
{ enclose_input(text_area, Symbol.bsup_decoded, Symbol.esup_decoded) } |
|
56574
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
412 |
|
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
413 |
|
67132 | 414 |
/* antiquoted cartouche */ |
415 |
||
416 |
def antiquoted_cartouche(text_area: TextArea) |
|
417 |
{ |
|
418 |
val buffer = text_area.getBuffer |
|
419 |
for { |
|
420 |
doc_view <- Document_View.get(text_area) |
|
421 |
rendering = doc_view.get_rendering() |
|
422 |
caret_range = JEdit_Lib.caret_range(text_area) |
|
423 |
antiq_range <- rendering.antiquoted(caret_range) |
|
424 |
antiq_text <- JEdit_Lib.get_text(buffer, antiq_range) |
|
425 |
body_text <- Antiquote.read_antiq_body(antiq_text) |
|
426 |
(name, arg) <- Token.read_antiq_arg(Keyword.Keywords.empty, body_text) |
|
427 |
if Symbol.is_ascii_identifier(name) |
|
428 |
} { |
|
429 |
val op_text = |
|
430 |
Isabelle_Encoding.perhaps_decode(buffer, |
|
431 |
Symbol.control_prefix + name + Symbol.control_suffix) |
|
432 |
val arg_text = |
|
433 |
if (arg.isEmpty) "" |
|
434 |
else if (Isabelle_Encoding.is_active(buffer)) Symbol.cartouche_decoded(arg.get) |
|
435 |
else Symbol.cartouche(arg.get) |
|
436 |
||
437 |
buffer.remove(antiq_range.start, antiq_range.length) |
|
438 |
text_area.moveCaretPosition(antiq_range.start) |
|
67148
d24dcac5eb4c
more robust, e.g. when Sidekick produces multi-selection;
wenzelm
parents:
67132
diff
changeset
|
439 |
text_area.selectNone |
67132 | 440 |
text_area.setSelectedText(op_text + arg_text) |
441 |
} |
|
442 |
} |
|
443 |
||
444 |
||
56574
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
445 |
/* spell-checker dictionary */ |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
446 |
|
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
447 |
def update_dictionary(text_area: JEditTextArea, include: Boolean, permanent: Boolean) |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
448 |
{ |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
449 |
for { |
65239
509a9b0ad02e
avoid global variables with implicit initialization;
wenzelm
parents:
65224
diff
changeset
|
450 |
spell_checker <- PIDE.plugin.spell_checker.get |
64882 | 451 |
doc_view <- Document_View.get(text_area) |
56576 | 452 |
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
|
453 |
range = JEdit_Lib.caret_range(text_area) |
66116 | 454 |
Text.Info(_, word) <- Spell_Checker.current_word(rendering, range) |
56575 | 455 |
} { |
456 |
spell_checker.update(word, include, permanent) |
|
457 |
JEdit_Lib.jedit_views().foreach(_.repaint()) |
|
458 |
} |
|
56574
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
459 |
} |
2b38472a4695
some actions to maintain spell-checker dictionary;
wenzelm
parents:
56394
diff
changeset
|
460 |
|
56578 | 461 |
def reset_dictionary() |
56575 | 462 |
{ |
65239
509a9b0ad02e
avoid global variables with implicit initialization;
wenzelm
parents:
65224
diff
changeset
|
463 |
for (spell_checker <- PIDE.plugin.spell_checker.get) |
56575 | 464 |
{ |
465 |
spell_checker.reset() |
|
466 |
JEdit_Lib.jedit_views().foreach(_.repaint()) |
|
467 |
} |
|
468 |
} |
|
57627
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
469 |
|
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
470 |
|
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60843
diff
changeset
|
471 |
/* debugger */ |
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60843
diff
changeset
|
472 |
|
60890 | 473 |
def toggle_breakpoint(text_area: JEditTextArea): Unit = |
65224 | 474 |
{ |
475 |
GUI_Thread.require {} |
|
476 |
||
65247 | 477 |
if (PIDE.session.debugger.is_active()) { |
65224 | 478 |
Debugger_Dockable.get_breakpoint(text_area, text_area.getCaretPosition) match { |
479 |
case Some((command, breakpoint)) => |
|
65247 | 480 |
PIDE.session.debugger.toggle_breakpoint(command, breakpoint) |
65224 | 481 |
jEdit.propertiesChanged() |
482 |
case None => |
|
483 |
} |
|
60890 | 484 |
} |
65224 | 485 |
} |
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60843
diff
changeset
|
486 |
|
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60843
diff
changeset
|
487 |
|
57627
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
488 |
/* plugin options */ |
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
489 |
|
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
490 |
def plugin_options(frame: Frame) |
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
491 |
{ |
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
492 |
GUI_Thread.require {} |
61024
7b7f01afab71
avoid deprecated PluginOptions with its unbounded window size;
wenzelm
parents:
60890
diff
changeset
|
493 |
jEdit.setProperty("Plugin Options.last", "isabelle-general") |
7b7f01afab71
avoid deprecated PluginOptions with its unbounded window size;
wenzelm
parents:
60890
diff
changeset
|
494 |
new CombinedOptions(frame, 1) |
57627
65fc7ae1bf66
added action "isabelle.options" (despite problems with initial window size);
wenzelm
parents:
57612
diff
changeset
|
495 |
} |
65240 | 496 |
|
497 |
||
498 |
/* popups */ |
|
499 |
||
500 |
def dismissed_popups(view: View): Boolean = |
|
501 |
{ |
|
502 |
var dismissed = false |
|
503 |
||
504 |
JEdit_Lib.jedit_text_areas(view).foreach(text_area => |
|
505 |
if (Completion_Popup.Text_Area.dismissed(text_area)) dismissed = true) |
|
506 |
||
507 |
if (Pretty_Tooltip.dismissed_all()) dismissed = true |
|
508 |
||
509 |
dismissed |
|
510 |
} |
|
71497 | 511 |
|
512 |
||
513 |
/* tooltips */ |
|
514 |
||
515 |
def show_tooltip(view: View, control: Boolean) |
|
516 |
{ |
|
517 |
GUI_Thread.require {} |
|
518 |
||
519 |
val text_area = view.getTextArea |
|
520 |
val painter = text_area.getPainter |
|
521 |
val caret_range = JEdit_Lib.caret_range(text_area) |
|
522 |
for { |
|
523 |
doc_view <- Document_View.get(text_area) |
|
524 |
rendering = doc_view.get_rendering() |
|
525 |
tip <- rendering.tooltip(caret_range, control) |
|
526 |
loc0 <- Option(text_area.offsetToXY(caret_range.start)) |
|
527 |
} { |
|
71504 | 528 |
val loc = new Point(loc0.x, loc0.y + painter.getLineHeight * 3 / 4) |
71497 | 529 |
val results = rendering.snapshot.command_results(tip.range) |
530 |
Pretty_Tooltip(view, painter, loc, rendering, results, tip) |
|
531 |
} |
|
532 |
} |
|
71499 | 533 |
|
534 |
||
535 |
/* error navigation */ |
|
536 |
||
537 |
private def goto_error( |
|
71502 | 538 |
view: View, |
539 |
range: Text.Range, |
|
540 |
avoid_range: Text.Range = Text.Range.offside, |
|
541 |
which: String = "")(get: List[Text.Markup] => Option[Text.Markup]) |
|
71499 | 542 |
{ |
543 |
GUI_Thread.require {} |
|
544 |
||
545 |
val text_area = view.getTextArea |
|
546 |
for (doc_view <- Document_View.get(text_area)) { |
|
547 |
val rendering = doc_view.get_rendering() |
|
71502 | 548 |
val errs = rendering.errors(range).filterNot(_.range.overlaps(avoid_range)) |
549 |
get(errs) match { |
|
71499 | 550 |
case Some(err) => |
551 |
PIDE.editor.goto_buffer(false, view, view.getBuffer, err.range.start) |
|
552 |
case None => |
|
553 |
view.getStatus.setMessageAndClear("No " + which + "error in current document snapshot") |
|
554 |
} |
|
555 |
} |
|
556 |
} |
|
557 |
||
558 |
def goto_first_error(view: View): Unit = |
|
559 |
goto_error(view, JEdit_Lib.buffer_range(view.getBuffer))(_.headOption) |
|
560 |
||
561 |
def goto_last_error(view: View): Unit = |
|
562 |
goto_error(view, JEdit_Lib.buffer_range(view.getBuffer))(_.lastOption) |
|
563 |
||
71502 | 564 |
def goto_prev_error(view: View) |
565 |
{ |
|
566 |
val caret_range = JEdit_Lib.caret_range(view.getTextArea) |
|
567 |
val range = Text.Range(0, caret_range.stop) |
|
568 |
goto_error(view, range, avoid_range = caret_range, which = "previous ")(_.lastOption) |
|
569 |
} |
|
71499 | 570 |
|
71502 | 571 |
def goto_next_error(view: View) |
572 |
{ |
|
573 |
val caret_range = JEdit_Lib.caret_range(view.getTextArea) |
|
574 |
val range = Text.Range(caret_range.start, view.getBuffer.getLength) |
|
575 |
goto_error(view, range, avoid_range = caret_range, which = "next ")(_.headOption) |
|
576 |
} |
|
71520 | 577 |
|
578 |
||
579 |
/* jconsole */ |
|
580 |
||
581 |
def jconsole(view: View) { |
|
582 |
Future.thread(name = "jconsole", daemon = true) { |
|
583 |
try { Isabelle_System.jconsole() } |
|
584 |
catch { |
|
585 |
case exn: Throwable => |
|
586 |
GUI_Thread.later { |
|
587 |
GUI.error_dialog(view, "System error", GUI.scrollable_text(Exn.message(exn))) |
|
588 |
} |
|
589 |
} |
|
590 |
} |
|
591 |
} |
|
50183 | 592 |
} |