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