200 PIDE.options.bool(CONTINUOUS_CHECKING) = b |
200 PIDE.options.bool(CONTINUOUS_CHECKING) = b |
201 PIDE.session.update_options(PIDE.options.value) |
201 PIDE.session.update_options(PIDE.options.value) |
202 } |
202 } |
203 } |
203 } |
204 |
204 |
205 def set_continuous_checking() { continuous_checking = true } |
205 def set_continuous_checking(): Unit = { continuous_checking = true } |
206 def reset_continuous_checking() { continuous_checking = false } |
206 def reset_continuous_checking(): Unit = { continuous_checking = false } |
207 def toggle_continuous_checking() { continuous_checking = !continuous_checking } |
207 def toggle_continuous_checking(): Unit = { continuous_checking = !continuous_checking } |
208 |
208 |
209 class Continuous_Checking extends CheckBox("Continuous checking") |
209 class Continuous_Checking extends CheckBox("Continuous checking") |
210 { |
210 { |
211 tooltip = "Continuous checking of proof document (visible and required parts)" |
211 tooltip = "Continuous checking of proof document (visible and required parts)" |
212 reactions += { case ButtonClicked(_) => continuous_checking = selected } |
212 reactions += { case ButtonClicked(_) => continuous_checking = selected } |
213 def load() { selected = continuous_checking } |
213 def load(): Unit = { selected = continuous_checking } |
214 load() |
214 load() |
215 } |
215 } |
216 |
216 |
217 |
217 |
218 /* update state */ |
218 /* update state */ |
221 state_dockable(view).foreach(_.update_request()) |
221 state_dockable(view).foreach(_.update_request()) |
222 |
222 |
223 |
223 |
224 /* required document nodes */ |
224 /* required document nodes */ |
225 |
225 |
226 def set_node_required(view: View) { Document_Model.view_node_required(view, set = true) } |
226 def set_node_required(view: View): Unit = Document_Model.view_node_required(view, set = true) |
227 def reset_node_required(view: View) { Document_Model.view_node_required(view, set = false) } |
227 def reset_node_required(view: View): Unit = Document_Model.view_node_required(view, set = false) |
228 def toggle_node_required(view: View) { Document_Model.view_node_required(view, toggle = true) } |
228 def toggle_node_required(view: View): Unit = Document_Model.view_node_required(view, toggle = true) |
229 |
229 |
230 |
230 |
231 /* full screen */ |
231 /* full screen */ |
232 |
232 |
233 // see toggleFullScreen() method in jEdit/org/gjt/sp/jedit/View.java |
233 // see toggleFullScreen() method in jEdit/org/gjt/sp/jedit/View.java |
234 def toggle_full_screen(view: View) |
234 def toggle_full_screen(view: View): Unit = |
235 { |
235 { |
236 if (PIDE.options.bool("jedit_toggle_full_screen") || |
236 if (PIDE.options.bool("jedit_toggle_full_screen") || |
237 Untyped.get[Boolean](view, "fullScreenMode")) view.toggleFullScreen() |
237 Untyped.get[Boolean](view, "fullScreenMode")) view.toggleFullScreen() |
238 else { |
238 else { |
239 Untyped.set[Boolean](view, "fullScreenMode", true) |
239 Untyped.set[Boolean](view, "fullScreenMode", true) |
255 } |
255 } |
256 |
256 |
257 |
257 |
258 /* font size */ |
258 /* font size */ |
259 |
259 |
260 def reset_font_size() { |
260 def reset_font_size(): Unit = |
261 Font_Info.main_change.reset(PIDE.options.int("jedit_reset_font_size").toFloat) |
261 Font_Info.main_change.reset(PIDE.options.int("jedit_reset_font_size").toFloat) |
262 } |
262 def increase_font_size(): Unit = Font_Info.main_change.step(1) |
263 def increase_font_size() { Font_Info.main_change.step(1) } |
263 def decrease_font_size(): Unit = Font_Info.main_change.step(-1) |
264 def decrease_font_size() { Font_Info.main_change.step(-1) } |
|
265 |
264 |
266 |
265 |
267 /* structured edits */ |
266 /* structured edits */ |
268 |
267 |
269 def indent_enabled(buffer: JEditBuffer, option: String): Boolean = |
268 def indent_enabled(buffer: JEditBuffer, option: String): Boolean = |
270 indent_rule(JEdit_Lib.buffer_mode(buffer)).isDefined && |
269 indent_rule(JEdit_Lib.buffer_mode(buffer)).isDefined && |
271 buffer.getStringProperty("autoIndent") == "full" && |
270 buffer.getStringProperty("autoIndent") == "full" && |
272 PIDE.options.bool(option) |
271 PIDE.options.bool(option) |
273 |
272 |
274 def indent_input(text_area: TextArea) |
273 def indent_input(text_area: TextArea): Unit = |
275 { |
274 { |
276 val buffer = text_area.getBuffer |
275 val buffer = text_area.getBuffer |
277 val line = text_area.getCaretLine |
276 val line = text_area.getCaretLine |
278 val caret = text_area.getCaretPosition |
277 val caret = text_area.getCaretPosition |
279 |
278 |
290 case None => |
289 case None => |
291 } |
290 } |
292 } |
291 } |
293 } |
292 } |
294 |
293 |
295 def newline(text_area: TextArea) |
294 def newline(text_area: TextArea): Unit = |
296 { |
295 { |
297 if (!text_area.isEditable()) text_area.getToolkit().beep() |
296 if (!text_area.isEditable()) text_area.getToolkit().beep() |
298 else { |
297 else { |
299 val buffer = text_area.getBuffer |
298 val buffer = text_area.getBuffer |
300 val line = text_area.getCaretLine |
299 val line = text_area.getCaretLine |
301 val caret = text_area.getCaretPosition |
300 val caret = text_area.getCaretPosition |
302 |
301 |
303 def nl { text_area.userInput('\n') } |
302 def nl: Unit = text_area.userInput('\n') |
304 |
303 |
305 if (indent_enabled(buffer, "jedit_indent_newline")) { |
304 if (indent_enabled(buffer, "jedit_indent_newline")) { |
306 buffer_syntax(buffer) match { |
305 buffer_syntax(buffer) match { |
307 case Some(syntax) => |
306 case Some(syntax) => |
308 val keywords = syntax.keywords |
307 val keywords = syntax.keywords |
345 def edit_command( |
344 def edit_command( |
346 snapshot: Document.Snapshot, |
345 snapshot: Document.Snapshot, |
347 text_area: TextArea, |
346 text_area: TextArea, |
348 padding: Boolean, |
347 padding: Boolean, |
349 id: Document_ID.Generic, |
348 id: Document_ID.Generic, |
350 text: String) |
349 text: String): Unit = |
351 { |
350 { |
352 val buffer = text_area.getBuffer |
351 val buffer = text_area.getBuffer |
353 if (!snapshot.is_outdated && text != "") { |
352 if (!snapshot.is_outdated && text != "") { |
354 (snapshot.find_command(id), Document_Model.get(buffer)) match { |
353 (snapshot.find_command(id), Document_Model.get(buffer)) match { |
355 case (Some((node, command)), Some(model)) if command.node_name == model.node_name => |
354 case (Some((node, command)), Some(model)) if command.node_name == model.node_name => |
380 } |
379 } |
381 |
380 |
382 |
381 |
383 /* formal entities */ |
382 /* formal entities */ |
384 |
383 |
385 def goto_entity(view: View) |
384 def goto_entity(view: View): Unit = |
386 { |
385 { |
387 val text_area = view.getTextArea |
386 val text_area = view.getTextArea |
388 for { |
387 for { |
389 doc_view <- Document_View.get(text_area) |
388 doc_view <- Document_View.get(text_area) |
390 rendering = doc_view.get_rendering() |
389 rendering = doc_view.get_rendering() |
391 caret_range = JEdit_Lib.caret_range(text_area) |
390 caret_range = JEdit_Lib.caret_range(text_area) |
392 link <- rendering.hyperlink_entity(caret_range) |
391 link <- rendering.hyperlink_entity(caret_range) |
393 } link.info.follow(view) |
392 } link.info.follow(view) |
394 } |
393 } |
395 |
394 |
396 def select_entity(text_area: JEditTextArea) |
395 def select_entity(text_area: JEditTextArea): Unit = |
397 { |
396 { |
398 for (doc_view <- Document_View.get(text_area)) { |
397 for (doc_view <- Document_View.get(text_area)) { |
399 val rendering = doc_view.get_rendering() |
398 val rendering = doc_view.get_rendering() |
400 val caret_range = JEdit_Lib.caret_range(text_area) |
399 val caret_range = JEdit_Lib.caret_range(text_area) |
401 val buffer_range = JEdit_Lib.buffer_range(text_area.getBuffer) |
400 val buffer_range = JEdit_Lib.buffer_range(text_area.getBuffer) |
409 } |
408 } |
410 |
409 |
411 |
410 |
412 /* completion */ |
411 /* completion */ |
413 |
412 |
414 def complete(view: View, word_only: Boolean) |
413 def complete(view: View, word_only: Boolean): Unit = |
415 { |
|
416 Completion_Popup.Text_Area.action(view.getTextArea, word_only) |
414 Completion_Popup.Text_Area.action(view.getTextArea, word_only) |
417 } |
|
418 |
415 |
419 |
416 |
420 /* control styles */ |
417 /* control styles */ |
421 |
418 |
422 def control_sub(text_area: JEditTextArea) |
419 def control_sub(text_area: JEditTextArea): Unit = |
423 { Syntax_Style.edit_control_style(text_area, Symbol.sub) } |
420 Syntax_Style.edit_control_style(text_area, Symbol.sub) |
424 |
421 |
425 def control_sup(text_area: JEditTextArea) |
422 def control_sup(text_area: JEditTextArea): Unit = |
426 { Syntax_Style.edit_control_style(text_area, Symbol.sup) } |
423 Syntax_Style.edit_control_style(text_area, Symbol.sup) |
427 |
424 |
428 def control_bold(text_area: JEditTextArea) |
425 def control_bold(text_area: JEditTextArea): Unit = |
429 { Syntax_Style.edit_control_style(text_area, Symbol.bold) } |
426 Syntax_Style.edit_control_style(text_area, Symbol.bold) |
430 |
427 |
431 def control_emph(text_area: JEditTextArea) |
428 def control_emph(text_area: JEditTextArea): Unit = |
432 { Syntax_Style.edit_control_style(text_area, Symbol.emph) } |
429 Syntax_Style.edit_control_style(text_area, Symbol.emph) |
433 |
430 |
434 def control_reset(text_area: JEditTextArea) |
431 def control_reset(text_area: JEditTextArea): Unit = |
435 { Syntax_Style.edit_control_style(text_area, "") } |
432 Syntax_Style.edit_control_style(text_area, "") |
436 |
433 |
437 |
434 |
438 /* block styles */ |
435 /* block styles */ |
439 |
436 |
440 private def enclose_input(text_area: JEditTextArea, s1: String, s2: String) |
437 private def enclose_input(text_area: JEditTextArea, s1: String, s2: String): Unit = |
441 { |
438 { |
442 s1.foreach(text_area.userInput) |
439 s1.foreach(text_area.userInput) |
443 s2.foreach(text_area.userInput) |
440 s2.foreach(text_area.userInput) |
444 s2.foreach(_ => text_area.goToPrevCharacter(false)) |
441 s2.foreach(_ => text_area.goToPrevCharacter(false)) |
445 } |
442 } |
446 |
443 |
447 def input_bsub(text_area: JEditTextArea) |
444 def input_bsub(text_area: JEditTextArea): Unit = |
448 { enclose_input(text_area, Symbol.bsub_decoded, Symbol.esub_decoded) } |
445 enclose_input(text_area, Symbol.bsub_decoded, Symbol.esub_decoded) |
449 |
446 |
450 def input_bsup(text_area: JEditTextArea) |
447 def input_bsup(text_area: JEditTextArea): Unit = |
451 { enclose_input(text_area, Symbol.bsup_decoded, Symbol.esup_decoded) } |
448 enclose_input(text_area, Symbol.bsup_decoded, Symbol.esup_decoded) |
452 |
449 |
453 |
450 |
454 /* antiquoted cartouche */ |
451 /* antiquoted cartouche */ |
455 |
452 |
456 def antiquoted_cartouche(text_area: TextArea) |
453 def antiquoted_cartouche(text_area: TextArea): Unit = |
457 { |
454 { |
458 val buffer = text_area.getBuffer |
455 val buffer = text_area.getBuffer |
459 for { |
456 for { |
460 doc_view <- Document_View.get(text_area) |
457 doc_view <- Document_View.get(text_area) |
461 rendering = doc_view.get_rendering() |
458 rendering = doc_view.get_rendering() |
496 spell_checker.update(word, include, permanent) |
493 spell_checker.update(word, include, permanent) |
497 JEdit_Lib.jedit_views().foreach(_.repaint()) |
494 JEdit_Lib.jedit_views().foreach(_.repaint()) |
498 } |
495 } |
499 } |
496 } |
500 |
497 |
501 def reset_dictionary() |
498 def reset_dictionary(): Unit = |
502 { |
499 { |
503 for (spell_checker <- PIDE.plugin.spell_checker.get) |
500 for (spell_checker <- PIDE.plugin.spell_checker.get) |
504 { |
501 { |
505 spell_checker.reset() |
502 spell_checker.reset() |
506 JEdit_Lib.jedit_views().foreach(_.repaint()) |
503 JEdit_Lib.jedit_views().foreach(_.repaint()) |
576 |
573 |
577 private def goto_error( |
574 private def goto_error( |
578 view: View, |
575 view: View, |
579 range: Text.Range, |
576 range: Text.Range, |
580 avoid_range: Text.Range = Text.Range.offside, |
577 avoid_range: Text.Range = Text.Range.offside, |
581 which: String = "")(get: List[Text.Markup] => Option[Text.Markup]) |
578 which: String = "")(get: List[Text.Markup] => Option[Text.Markup]): Unit = |
582 { |
579 { |
583 GUI_Thread.require {} |
580 GUI_Thread.require {} |
584 |
581 |
585 val text_area = view.getTextArea |
582 val text_area = view.getTextArea |
586 for (doc_view <- Document_View.get(text_area)) { |
583 for (doc_view <- Document_View.get(text_area)) { |
599 goto_error(view, JEdit_Lib.buffer_range(view.getBuffer))(_.headOption) |
596 goto_error(view, JEdit_Lib.buffer_range(view.getBuffer))(_.headOption) |
600 |
597 |
601 def goto_last_error(view: View): Unit = |
598 def goto_last_error(view: View): Unit = |
602 goto_error(view, JEdit_Lib.buffer_range(view.getBuffer))(_.lastOption) |
599 goto_error(view, JEdit_Lib.buffer_range(view.getBuffer))(_.lastOption) |
603 |
600 |
604 def goto_prev_error(view: View) |
601 def goto_prev_error(view: View): Unit = |
605 { |
602 { |
606 val caret_range = JEdit_Lib.caret_range(view.getTextArea) |
603 val caret_range = JEdit_Lib.caret_range(view.getTextArea) |
607 val range = Text.Range(0, caret_range.stop) |
604 val range = Text.Range(0, caret_range.stop) |
608 goto_error(view, range, avoid_range = caret_range, which = "previous ")(_.lastOption) |
605 goto_error(view, range, avoid_range = caret_range, which = "previous ")(_.lastOption) |
609 } |
606 } |
610 |
607 |
611 def goto_next_error(view: View) |
608 def goto_next_error(view: View): Unit = |
612 { |
609 { |
613 val caret_range = JEdit_Lib.caret_range(view.getTextArea) |
610 val caret_range = JEdit_Lib.caret_range(view.getTextArea) |
614 val range = Text.Range(caret_range.start, view.getBuffer.getLength) |
611 val range = Text.Range(caret_range.start, view.getBuffer.getLength) |
615 goto_error(view, range, avoid_range = caret_range, which = "next ")(_.headOption) |
612 goto_error(view, range, avoid_range = caret_range, which = "next ")(_.headOption) |
616 } |
613 } |