Package mars.venus.editor.jeditsyntax
Class JEditBasedTextArea
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
mars.venus.editor.jeditsyntax.JEditTextArea
mars.venus.editor.jeditsyntax.JEditBasedTextArea
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,MARSTextEditingArea
Adaptor subclass for
JEditTextArea
.
Provides those methods required by the MARSTextEditingArea interface that are not defined by JEditTextArea. This permits JEditTextArea to be used within MARS largely without modification.
- Since:
- MARS 4.0
- Author:
- Pete Sanderson 4-20-2010
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class mars.venus.editor.jeditsyntax.JEditTextArea
JEditTextArea.AdjustHandler, JEditTextArea.CaretUndo, JEditTextArea.ComponentHandler, JEditTextArea.DocumentHandler, JEditTextArea.DragHandler, JEditTextArea.FocusHandler, JEditTextArea.MouseHandler, JEditTextArea.MouseWheelHandler, JEditTextArea.MutableCaretEvent, JEditTextArea.ScrollLayout
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields inherited from class mars.venus.editor.jeditsyntax.JEditTextArea
biasLeft, blink, BOTTOM, bracketLine, bracketPosition, caretBlinkRate, caretBlinks, caretEvent, caretTimer, caretVisible, CENTER, document, documentHandler, editable, electricScroll, firstLine, focusedComponent, horizontal, horizontalOffset, inputHandler, LEFT_OF_SCROLLBAR, lineSegment, listenerList, magicCaret, overwrite, painter, popup, rectSelect, RIGHT, scrollBarsInitialized, selectionEnd, selectionEndLine, selectionStart, selectionStartLine, unredoing, vertical, visibleLines
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Fields inherited from interface mars.venus.editor.MARSTextEditingArea
TEXT_FOUND, TEXT_NOT_FOUND, TEXT_REPLACED_FOUND_NEXT, TEXT_REPLACED_NOT_FOUND_NEXT
-
Constructor Summary
ConstructorsConstructorDescriptionJEditBasedTextArea
(FileEditorTab fileEditorTab, Settings settings, JComponent lineNumbers) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Comment or uncomment highlighted lines or line at cursor.void
Get rid of any accumulated undoable edits.int
doFindText
(String text, boolean caseSensitive) Finds next occurrence of text in a forward search of a string.int
Finds and replaces next occurrence of text in a string in a forward search.int
doReplaceAll
(String find, String replace, boolean caseSensitive) Finds and replaces ALL occurrences of text in a string in a forward search.getFont()
Returns the undo manager for this editing area.int
Returns next index of word in text - forward search.void
redo()
Redo previous edit.void
replaceLine
(int lineNumber, String text) Replace a line in the document with text.void
replaceSelection
(String replacementText) Same asJEditTextArea.setSelectedText(String)
but named for compatibility with JTextComponent method replaceSelection.void
setCaretBlinkRate
(int rate) Set the caret blinking rate in milliseconds.void
void
setLineHighlightEnabled
(boolean highlight) Set whether highlighting of the line currently being edited is enabled.void
setSelectionVisible
(boolean visible) void
setSourceCode
(String text, boolean editable) void
setTabSize
(int chars) Set the number of characters a tab will expand to.void
undo()
Undo previous edit.void
Update the syntax style table, which is obtained fromSyntaxUtilities
.Methods inherited from class mars.venus.editor.jeditsyntax.JEditTextArea
_offsetToX, addCaretListener, blinkCaret, copy, cut, documentChanged, fireCaretEvent, getAutoIndent, getBracketLine, getBracketPosition, getCaretLine, getCaretPosition, getDocument, getDocumentLength, getElectricScroll, getFirstLine, getHorizontalOffset, getInputHandler, getLeadingWhiteSpace, getLineCount, getLineEndOffset, getLineLength, getLineOfOffset, getLineStartOffset, getLineText, getLineText, getMagicCaretPosition, getMarkLine, getMarkPosition, getPainter, getRightClickPopup, getSelectedText, getSelectionEnd, getSelectionEnd, getSelectionEndLine, getSelectionStart, getSelectionStart, getSelectionStartLine, getSyntaxSensitiveToolTipText, getText, getText, getText, getTokenMarker, getVisibleLines, isCaretBlinkEnabled, isCaretVisible, isEditable, isOverwriteEnabled, isSelectionRectangular, lineToY, offsetToX, overwriteSetSelectedText, paste, processKeyEvent, recalculateVisibleLines, removeCaretListener, removeNotify, scrollTo, scrollToCaret, select, selectAll, selectNone, setCaretBlinkEnabled, setCaretPosition, setCaretVisible, setDocument, setEditable, setElectricScroll, setFirstLine, setHorizontalOffset, setInputHandler, setMagicCaretPosition, setOrigin, setOverwriteEnabled, setRightClickPopup, setSelectedText, setSelectionEnd, setSelectionRectangular, setSelectionStart, setText, setTokenMarker, updateBracketHighlight, updateScrollBars, xToOffset, xyToOffset, yToLine
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface mars.venus.editor.MARSTextEditingArea
copy, cut, getCaretPosition, getDocument, getFontMetrics, getSelectedText, getSelectionEnd, getSelectionStart, getText, grabFocus, paste, requestFocusInWindow, revalidate, select, selectAll, setBackground, setCaretPosition, setCaretVisible, setEditable, setEnabled, setSelectionEnd, setSelectionStart, setText
-
Constructor Details
-
JEditBasedTextArea
-
-
Method Details
-
setFont
- Specified by:
setFont
in interfaceMARSTextEditingArea
- Overrides:
setFont
in classJComponent
-
getFont
- Specified by:
getFont
in interfaceMARSTextEditingArea
- Specified by:
getFont
in interfaceMenuContainer
- Overrides:
getFont
in classComponent
-
setLineHighlightEnabled
public void setLineHighlightEnabled(boolean highlight) Set whether highlighting of the line currently being edited is enabled.- Specified by:
setLineHighlightEnabled
in interfaceMARSTextEditingArea
- 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 or less, blinking is disabled.- Specified by:
setCaretBlinkRate
in interfaceMARSTextEditingArea
- Parameters:
rate
- Blinking rate in milliseconds.
-
setTabSize
public void setTabSize(int chars) Set the number of characters a tab will expand to.- Specified by:
setTabSize
in interfaceMARSTextEditingArea
- Parameters:
chars
- number of characters
-
updateSyntaxStyles
public void updateSyntaxStyles()Update the syntax style table, which is obtained fromSyntaxUtilities
.- Specified by:
updateSyntaxStyles
in interfaceMARSTextEditingArea
-
getOuterComponent
- Specified by:
getOuterComponent
in interfaceMARSTextEditingArea
-
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 interfaceMARSTextEditingArea
-
replaceSelection
Same asJEditTextArea.setSelectedText(String)
but named for compatibility with JTextComponent method replaceSelection. DPS, 14 Apr 2010- Specified by:
replaceSelection
in interfaceMARSTextEditingArea
- Parameters:
replacementText
- The replacement text for the selection
-
setSelectionVisible
public void setSelectionVisible(boolean visible) - Specified by:
setSelectionVisible
in interfaceMARSTextEditingArea
-
setSourceCode
- Specified by:
setSourceCode
in interfaceMARSTextEditingArea
-
getUndoManager
Returns the undo manager for this editing area.- Specified by:
getUndoManager
in interfaceMARSTextEditingArea
- Returns:
- The undo manager.
-
undo
public void undo()Undo previous edit.- Specified by:
undo
in interfaceMARSTextEditingArea
-
redo
public void redo()Redo previous edit.- Specified by:
redo
in interfaceMARSTextEditingArea
-
commentLines
public void commentLines()Comment or uncomment highlighted lines or line at cursor.- Specified by:
commentLines
in interfaceMARSTextEditingArea
-
replaceLine
Replace a line in the document with text.- Parameters:
lineNumber
- line number to replacetext
- text to replace the line with
-
doFindText
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 interfaceMARSTextEditingArea
- Parameters:
text
- 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
Returns next index 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 searchfind
- the string to findstart
- the character index to start the searchcaseSensitive
- true for case sensitive. false to ignore case- Returns:
- next indexed position of found text or -1 if not found
-
doReplace
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 interfaceMARSTextEditingArea
- Parameters:
text
- the text to locate in the stringreplace
- the text to replace the find text with - if the find text existscaseSensitive
- 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 replacement is successful and there is at least one additional match.
-
doReplaceAll
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 interfaceMARSTextEditingArea
- Parameters:
find
- the text to locate in the stringreplace
- the text to replace the find text with - if the find text existscaseSensitive
- true for case sensitive. false to ignore case- Returns:
- the number of occurrences that were matched and replaced.
-