Class GenericTextArea

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, MARSTextEditingArea

public class GenericTextArea extends JTextArea implements MARSTextEditingArea
See Also:
Serialized Form
  • Constructor Details

  • Method Details

    • setLineHighlightEnabled

      public void setLineHighlightEnabled(boolean highlight)
      Does nothing, but required by the interface. This editor does not support highlighting of the line currently being edited.
      Specified by:
      setLineHighlightEnabled in interface MARSTextEditingArea
    • updateSyntaxStyles

      public void updateSyntaxStyles()
      Does nothing, but required by the interface. This editor does not support syntax styling (colors, bold/italic).
      Specified by:
      updateSyntaxStyles in interface MARSTextEditingArea
    • 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
    • getOuterComponent

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

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

      public void discardAllUndoableEdits()
      Tell UndoManager to discard all its collected undoable edits.
      Specified by:
      discardAllUndoableEdits in interface MARSTextEditingArea
    • setText

      public void setText(String s)
      Override inherited setText to temporarily remove UndoableEditListener because this operation is not undoable.
      Specified by:
      setText in interface MARSTextEditingArea
      Overrides:
      setText in class JTextComponent
      Parameters:
      s - String with new contents for the editing area. Replaces current content.
    • 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
    • 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
    • toggleComment

      public void toggleComment()
      TODO
      Specified by:
      toggleComment 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.
    • nextIndex

      public int nextIndex(String input, String find, int start, boolean caseSensitive)
      Returns next posn of word in text - forward search. If end of string is reached during the search, will wrap around to the beginning one time.
      Parameters:
      input - the string to search
      find - the string to find
      start - the character position to start the search
      caseSensitive - true for case sensitive. false to ignore case
      Returns:
      next indexed position of found text or -1 if not found
    • doReplace

      public int doReplace(String find, String replace, boolean caseSensitive)
      Finds and replaces next occurrence of text in a string in a forward search. If cursor is initially at end of matching selection, will immediately replace then find and select the next occurrence if any. Otherwise it performs a find operation. The replace can be undone with one undo operation.
      Specified by:
      doReplace 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:
      Returns TEXT_FOUND if not initially at end of selected match and matching occurrence is found. Returns TEXT_NOT_FOUND if the text is not matched. Returns TEXT_REPLACED_NOT_FOUND_NEXT if replacement is successful but there are no additional matches. Returns TEXT_REPLACED_FOUND_NEXT if reaplacement is successful and there is at least one additional match.
    • 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.