author | wenzelm |
Fri, 30 Aug 2013 12:44:39 +0200 | |
changeset 53322 | a4cd032172e0 |
parent 53293 | fd27b8f5a479 |
child 53497 | 07bb77881b8d |
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 |
||
50198
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
12 |
import org.gjt.sp.jedit.{jEdit, View, Buffer} |
50183 | 13 |
import org.gjt.sp.jedit.textarea.JEditTextArea |
53293
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
14 |
import org.gjt.sp.jedit.gui.{DockableWindowManager, CompleteWord} |
50183 | 15 |
|
16 |
||
50208 | 17 |
object Isabelle |
50183 | 18 |
{ |
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
19 |
/* editor modes */ |
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
20 |
|
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
21 |
val modes = |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
22 |
List( |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
23 |
"isabelle", // theory source |
53281
251e1a2aa792
clarified SideKick parser name, which serves as quasi "mode" here;
wenzelm
parents:
53280
diff
changeset
|
24 |
"isabelle-markup", // SideKick markup tree |
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
25 |
"isabelle-news", // NEWS |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
26 |
"isabelle-options", // etc/options |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
27 |
"isabelle-output", // pretty text area output |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
28 |
"isabelle-root") // session ROOT |
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
29 |
|
53280
c63a016805b9
explicit indication of outer syntax with no tokens;
wenzelm
parents:
53277
diff
changeset
|
30 |
private lazy val news_syntax = Outer_Syntax.init().no_tokens |
53276 | 31 |
|
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
32 |
def mode_syntax(name: String): Option[Outer_Syntax] = |
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
33 |
name match { |
53281
251e1a2aa792
clarified SideKick parser name, which serves as quasi "mode" here;
wenzelm
parents:
53280
diff
changeset
|
34 |
case "isabelle" | "isabelle-markup" => |
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
35 |
val syntax = PIDE.session.recent_syntax |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
36 |
if (syntax == Outer_Syntax.empty) None else Some(syntax) |
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
37 |
case "isabelle-options" => Some(Options.options_syntax) |
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
38 |
case "isabelle-root" => Some(Build.root_syntax) |
53276 | 39 |
case "isabelle-news" => Some(news_syntax) |
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
40 |
case "isabelle-output" => None |
53274
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
41 |
case _ => None |
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
42 |
} |
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
43 |
|
1760c01f1c78
maintain Completion_Popup.Text_Area as client property like Document_View;
wenzelm
parents:
53272
diff
changeset
|
44 |
|
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
45 |
/* token markers */ |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
46 |
|
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
47 |
private val markers = |
53280
c63a016805b9
explicit indication of outer syntax with no tokens;
wenzelm
parents:
53277
diff
changeset
|
48 |
Map(modes.map(name => (name, new Token_Markup.Marker(name))): _*) |
53277
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
49 |
|
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
50 |
def token_marker(name: String): Option[Token_Markup.Marker] = markers.get(name) |
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
51 |
|
6aa348237973
more uniform configuration of editor modes and token markers;
wenzelm
parents:
53276
diff
changeset
|
52 |
|
50208 | 53 |
/* dockable windows */ |
54 |
||
55 |
private def wm(view: View): DockableWindowManager = view.getDockableWindowManager |
|
56 |
||
50299 | 57 |
def docked_theories(view: View): Option[Theories_Dockable] = |
58 |
wm(view).getDockableWindow("isabelle-theories") match { |
|
59 |
case dockable: Theories_Dockable => Some(dockable) |
|
50208 | 60 |
case _ => None |
61 |
} |
|
62 |
||
51533 | 63 |
def docked_timing(view: View): Option[Timing_Dockable] = |
64 |
wm(view).getDockableWindow("isabelle-timing") match { |
|
65 |
case dockable: Timing_Dockable => Some(dockable) |
|
66 |
case _ => None |
|
67 |
} |
|
68 |
||
50208 | 69 |
def docked_output(view: View): Option[Output_Dockable] = |
70 |
wm(view).getDockableWindow("isabelle-output") match { |
|
71 |
case dockable: Output_Dockable => Some(dockable) |
|
72 |
case _ => None |
|
73 |
} |
|
74 |
||
75 |
def docked_raw_output(view: View): Option[Raw_Output_Dockable] = |
|
76 |
wm(view).getDockableWindow("isabelle-raw-output") match { |
|
77 |
case dockable: Raw_Output_Dockable => Some(dockable) |
|
78 |
case _ => None |
|
79 |
} |
|
80 |
||
81 |
def docked_protocol(view: View): Option[Protocol_Dockable] = |
|
82 |
wm(view).getDockableWindow("isabelle-protocol") match { |
|
83 |
case dockable: Protocol_Dockable => Some(dockable) |
|
84 |
case _ => None |
|
85 |
} |
|
86 |
||
50433
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
87 |
def docked_monitor(view: View): Option[Monitor_Dockable] = |
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
88 |
wm(view).getDockableWindow("isabelle-monitor") match { |
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
89 |
case dockable: Monitor_Dockable => Some(dockable) |
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
90 |
case _ => None |
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
91 |
} |
9131dadb2bf7
basic monitor panel, using the powerful jfreechart library;
wenzelm
parents:
50341
diff
changeset
|
92 |
|
50208 | 93 |
|
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
94 |
/* continuous checking */ |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
95 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
96 |
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
|
97 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
98 |
def continuous_checking: Boolean = PIDE.options.bool(CONTINUOUS_CHECKING) |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
99 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
100 |
def continuous_checking_=(b: Boolean) |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
101 |
{ |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
102 |
Swing_Thread.require() |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
103 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
104 |
if (continuous_checking != b) { |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
105 |
PIDE.options.bool(CONTINUOUS_CHECKING) = b |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
106 |
PIDE.options_changed() |
52974 | 107 |
PIDE.editor.flush() |
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
108 |
} |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
109 |
} |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
110 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
115 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
116 |
/* 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
|
117 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
118 |
private def node_required_update(view: View, toggle: Boolean = false, set: Boolean = false) |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
119 |
{ |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
120 |
Swing_Thread.require() |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
121 |
PIDE.document_model(view.getBuffer) match { |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
122 |
case Some(model) => |
52816
c608e0ade554
home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents:
52815
diff
changeset
|
123 |
model.node_required = (if (toggle) !model.node_required else set) |
52815
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
124 |
case None => |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
125 |
} |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
126 |
} |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
127 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
128 |
def set_node_required(view: View) { node_required_update(view, set = true) } |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
129 |
def reset_node_required(view: View) { node_required_update(view, set = false) } |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
130 |
def toggle_node_required(view: View) { node_required_update(view, toggle = true) } |
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
131 |
|
eaad5fe7bb1b
actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents:
51533
diff
changeset
|
132 |
|
50198
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
133 |
/* font size */ |
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
134 |
|
53272 | 135 |
def reset_font_size(view: View): Unit = |
136 |
Rendering.font_size_change(view, _ => PIDE.options.int("jedit_reset_font_size")) |
|
50198
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
137 |
|
53272 | 138 |
def increase_font_size(view: View): Unit = |
139 |
Rendering.font_size_change(view, i => i + ((i / 10) max 1)) |
|
140 |
||
141 |
def decrease_font_size(view: View): Unit = |
|
142 |
Rendering.font_size_change(view, i => i - ((i / 10) max 1)) |
|
50198
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
143 |
|
0c7b351a6871
added convenience actions isabelle.increase-font-size and isabelle.decrease-font-size;
wenzelm
parents:
50187
diff
changeset
|
144 |
|
50341
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
145 |
/* structured insert */ |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
146 |
|
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
147 |
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
|
148 |
{ |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
149 |
val buffer = text_area.getBuffer |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
150 |
JEdit_Lib.buffer_edit(buffer) { |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
151 |
val text1 = |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
152 |
if (text_area.getSelectionCount == 0) { |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
153 |
def pad(range: Text.Range): String = |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
154 |
if (JEdit_Lib.try_get_text(buffer, range) == Some("\n")) "" else "\n" |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
155 |
|
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
156 |
val caret = JEdit_Lib.point_range(buffer, text_area.getCaretPosition) |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
157 |
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
|
158 |
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
|
159 |
} |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
160 |
else text |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
161 |
text_area.setSelectedText(text1) |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
162 |
} |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
163 |
} |
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
164 |
|
0c65a7cfc0f3
provide general insert_line_padding as convenience operation, e.g. for BeanShell macros;
wenzelm
parents:
50299
diff
changeset
|
165 |
|
53293
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
166 |
/* completion */ |
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
167 |
|
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
168 |
def complete(view: View) |
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
169 |
{ |
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
170 |
Completion_Popup.Text_Area(view.getTextArea) match { |
53322 | 171 |
case Some(text_area_completion) => |
172 |
text_area_completion.action(immediate = true, explicit = true) |
|
53293
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
173 |
case None => CompleteWord.completeWord(view) |
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
174 |
} |
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
175 |
} |
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
176 |
|
fd27b8f5a479
added action isabelle.complete, using standard jEdit keyboard shortcut;
wenzelm
parents:
53281
diff
changeset
|
177 |
|
50183 | 178 |
/* control styles */ |
179 |
||
180 |
def control_sub(text_area: JEditTextArea) |
|
50187
b5a09812abc4
special handling of control symbols in Symbols dockable;
wenzelm
parents:
50183
diff
changeset
|
181 |
{ Token_Markup.edit_control_style(text_area, Symbol.sub_decoded) } |
50183 | 182 |
|
183 |
def control_sup(text_area: JEditTextArea) |
|
50187
b5a09812abc4
special handling of control symbols in Symbols dockable;
wenzelm
parents:
50183
diff
changeset
|
184 |
{ Token_Markup.edit_control_style(text_area, Symbol.sup_decoded) } |
50183 | 185 |
|
186 |
def control_bold(text_area: JEditTextArea) |
|
50187
b5a09812abc4
special handling of control symbols in Symbols dockable;
wenzelm
parents:
50183
diff
changeset
|
187 |
{ Token_Markup.edit_control_style(text_area, Symbol.bold_decoded) } |
50183 | 188 |
|
189 |
def control_reset(text_area: JEditTextArea) |
|
50187
b5a09812abc4
special handling of control symbols in Symbols dockable;
wenzelm
parents:
50183
diff
changeset
|
190 |
{ Token_Markup.edit_control_style(text_area, "") } |
50183 | 191 |
|
192 |
||
193 |
/* block styles */ |
|
194 |
||
195 |
private def enclose_input(text_area: JEditTextArea, s1: String, s2: String) |
|
196 |
{ |
|
197 |
s1.foreach(text_area.userInput(_)) |
|
198 |
s2.foreach(text_area.userInput(_)) |
|
199 |
s2.foreach(_ => text_area.goToPrevCharacter(false)) |
|
200 |
} |
|
201 |
||
202 |
def input_bsub(text_area: JEditTextArea) |
|
203 |
{ enclose_input(text_area, Symbol.bsub_decoded, Symbol.esub_decoded) } |
|
204 |
||
205 |
def input_bsup(text_area: JEditTextArea) |
|
206 |
{ enclose_input(text_area, Symbol.bsup_decoded, Symbol.esup_decoded) } |
|
207 |
} |
|
208 |