Class RSyntaxBasedTextArea

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextArea
org.fife.ui.rtextarea.RTextAreaBase
org.fife.ui.rtextarea.RTextArea
org.fife.ui.rsyntaxtextarea.RSyntaxTextArea
mars.venus.editors.rsyntax.RSyntaxBasedTextArea
All Implemented Interfaces:
ImageObserver, MenuContainer, Printable, Serializable, Accessible, Scrollable, MARSTextEditingArea, org.fife.ui.rsyntaxtextarea.SyntaxConstants

public class RSyntaxBasedTextArea extends org.fife.ui.rsyntaxtextarea.RSyntaxTextArea implements MARSTextEditingArea
Adapter subclass for RSyntaxTextArea Provides those methods required by the MARSTextEditingArea interface that are not defined by RSyntaxTextArea. This permits RSyntaxTextArea to be used within MARS largely without modification.
Version:
May 2021
Author:
Valerio Colella
See Also:
Serialized Form
  • Constructor Details

    • RSyntaxBasedTextArea

      public RSyntaxBasedTextArea(EditPane editPain, boolean lineNumbers)
  • Method Details

    • setSourceCode

      public void setSourceCode(String code, boolean editable)
      For initializing the source code when opening an ASM file
      Specified by:
      setSourceCode in interface MARSTextEditingArea
      Parameters:
      code - String containing text
      editable - true if code is editable else false
    • getUndoManager

      public UndoManager getUndoManager()
      Returns the undo manager for this editing area
      Specified by:
      getUndoManager in interface MARSTextEditingArea
      Returns:
      the undo manager
    • undo

      public void undo()
      Undo previous edit
      Specified by:
      undo in interface MARSTextEditingArea
    • redo

      public void redo()
      Redo previous edit
      Specified by:
      redo in interface MARSTextEditingArea
    • discardAllUndoableEdits

      public void discardAllUndoableEdits()
      Get rid of any accumulated undoable edits. It is useful to call this method after opening a file into the text area. The act of setting its text content upon reading the file will generate an undoable edit. Normally you don't want a freshly-opened file to appear with its Undo action enabled. But it will unless you call this after setting the text.
      Specified by:
      discardAllUndoableEdits in interface MARSTextEditingArea
    • doFindText

      public int doFindText(String find, boolean caseSensitive)
      Finds next occurrence of text in a forward search of a string. Search begins at the current cursor location, and wraps around when the end of the string is reached.
      Specified by:
      doFindText in interface MARSTextEditingArea
      Parameters:
      find - the text to locate in the string
      caseSensitive - true if search is to be case-sensitive, false otherwise
      Returns:
      TEXT_FOUND or TEXT_NOT_FOUND, depending on the result.
    • doReplace

      public int doReplace(String find, String replace, boolean caseSensitive)
      Specified by:
      doReplace in interface MARSTextEditingArea
    • doReplaceAll

      public int doReplaceAll(String find, String replace, boolean caseSensitive)
      Finds and replaces ALL occurrences of text in a string in a forward search. All replacements are bundled into one CompoundEdit, so one Undo operation will undo all of them.
      Specified by:
      doReplaceAll in interface MARSTextEditingArea
      Parameters:
      find - the text to locate in the string
      replace - the text to replace the find text with - if the find text exists
      caseSensitive - true for case sensitive. false to ignore case
      Returns:
      the number of occurrences that were matched and replaced.
    • setCaretVisible

      public void setCaretVisible(boolean vis)
      Control caret visibility
      Specified by:
      setCaretVisible in interface MARSTextEditingArea
      Parameters:
      vis - true to display caret, false to hide it
    • setSelectionVisible

      public void setSelectionVisible(boolean vis)
      Control selection visibility
      Specified by:
      setSelectionVisible in interface MARSTextEditingArea
      Parameters:
      vis - true to display selection, false to hide it
    • setLineHighlightEnabled

      public void setLineHighlightEnabled(boolean highlight)
      Use for highlighting the line currently being edited.
      Specified by:
      setLineHighlightEnabled in interface MARSTextEditingArea
      Parameters:
      highlight - true to enable line highlighting, false to disable.
    • setCaretBlinkRate

      public void setCaretBlinkRate(int rate)
      Set the caret blinking rate in milliseconds. If rate is 0 it will not blink. If negative, do nothing.
      Specified by:
      setCaretBlinkRate in interface MARSTextEditingArea
      Parameters:
      rate - blinking rate in milliseconds
    • updateSyntaxStyles

      public void updateSyntaxStyles()
      Specified by:
      updateSyntaxStyles in interface MARSTextEditingArea
    • getOuterComponent

      public Component getOuterComponent()
      Specified by:
      getOuterComponent in interface MARSTextEditingArea
    • toggleComment

      public void toggleComment()
      Specified by:
      toggleComment in interface MARSTextEditingArea