## mars.venus.editors.jeditsyntax
Class JEditTextArea

    java.lang.Object
      java.awt.Component
          java.awt.Container
              javax.swing.JComponent
                  mars.venus.editors.jeditsyntax.JEditTextArea

All Implemented Interfaces:
  ImageObserver, MenuContainer, Serializable

Direct Known Subclasses:
  JEditBasedTextArea

    public class JEditTextArea

extends JComponent

jEdit's text area component. It is more suited for editing program source code than JEditorPane, because it drops the unnecessary features (images, variable-width lines, and so on) and adds a whole bunch of useful goodies such as:

- More flexible key binding scheme
- Supports macro recorders
- Rectangular selection
- Bracket highlighting
- Syntax highlighting
- Command repetition
- Block caret can be enabled

It is also faster and doesn't have as many problems. It can be used in other applications; the only other part of jEdit it depends on is the syntax package.

To use it in your app, treat it like any other component, for example:

    JEditTextArea ta = new JEditTextArea();
     ta.setTokenMarker(new JavaTokenMarker());
     ta.setText("public class Test {\n"
         + "    public static void main(String[] args) {\n"
         + "        System.out.println(\"Hello World\");\n"
         + "    }\n"
         + "}");

Author:
  Slava Pestov
See Also:
  Serialized Form

Nested Class Summary

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
`protected boolean` `biasLeft`
`protected boolean` `blink`
`protected static String` `BOTTOM`
`protected int` `bracketLine`
`protected int` `bracketPosition`
`protected int` `caretBlinkRate`
`protected boolean` `caretBlinks`
`protected mars.venus.editors.jeditsyntax.JEditTextArea.MutableCaretEvent` `caretEvent`
`protected static Timer` `caretTimer`
`protected boolean` `caretVisible`
`protected static String` `CENTER`
`protected SyntaxDocument` `document`
`protected mars.venus.editors.jeditsyntax.JEditTextArea.DocumentHandler` `documentHandler`
`protected boolean` `editable`
`protected int` `electricScroll`
`protected int` `firstLine`
`protected static JEditTextArea` `focusedComponent`
`protected JScrollBar` `horizontal`
`protected int` `horizontalOffset`
`protected InputHandler` `inputHandler`
`static String` `LEFT_OF_SCROLLBAR` Adding components with this name to the text area will place them left of the horizontal scroll bar.
`protected Segment` `lineSegment`
`protected EventListenerList` `listenerList`
`protected int` `magicCaret`
`protected boolean` `overwrite`
`protected TextAreaPainter` `painter`
`protected JPopupMenu` `popup`
`protected boolean` `rectSelect`
`protected static String` `RIGHT`
`protected boolean` `scrollBarsInitialized`
`protected int` `selectionEnd`
`protected int` `selectionEndLine`
`protected int` `selectionStart`
`protected int` `selectionStartLine`
`protected boolean` `unredoing`
`protected JScrollBar` `vertical`
`protected int` `visibleLines`

Fields inherited from class javax.swing.JComponent
`accessibleContext, 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
`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`

Constructor Summary
`JEditTextArea(JComponent lineNumbers)` Creates a new JEditTextArea with the default settings.
`JEditTextArea(TextAreaDefaults defaults, JComponent lineNumbers)`

Method Summary
`int` `_offsetToX(int line, int offset)` Converts an offset in a line into an x co-ordinate.
`void` `addCaretListener(CaretListener listener)` Adds a caret change listener to this text area.
`void` `blinkCaret()` Blinks the caret.
`void` `copy()` Places the selected text into the clipboard.
`void` `cut()` Deletes the selected text from the text area and places it into the clipboard.
`protected void` `documentChanged(DocumentEvent evt)`
`protected void` `fireCaretEvent()`
`String` `getAutoIndent()` Constructs string for auto-indent feature.
`int` `getBracketLine()` Returns the line of the highlighted bracket (the bracket matching the one before the caret)
`int` `getBracketPosition()` Returns the position of the highlighted bracket (the bracket matching the one before the caret)
`int` `getCaretLine()` Returns the caret line.
`int` `getCaretPosition()` Returns the caret position.
`Document` `getDocument()` Returns the document this text area is editing.
`int` `getDocumentLength()` Returns the length of the document.
`int` `getElectricScroll()` Returns the number of lines from the top and button of the text area that are always visible.
`int` `getFirstLine()` Returns the line displayed at the text area's origin.
`int` `getHorizontalOffset()` Returns the horizontal offset of drawn lines.
`InputHandler` `getInputHandler()` Returns the input handler.
`String` `getLeadingWhiteSpace()` Makes a copy of leading white space (tab or space) from the current line and returns it.
`int` `getLineCount()` Returns the number of lines in the document.
`int` `getLineEndOffset(int line)` Returns the end offset of the specified line.
`int` `getLineLength(int line)` Returns the length of the specified line.
`int` `getLineOfOffset(int offset)` Returns the line containing the specified offset.
`int` `getLineStartOffset(int line)` Returns the start offset of the specified line.
`String` `getLineText(int lineIndex)` Returns the text on the specified line.
`void` `getLineText(int lineIndex, Segment segment)` Copies the text on the specified line into a segment.
`int` `getMagicCaretPosition()` Returns the `magic' caret position.
`int` `getMarkLine()` Returns the mark line.
`int` `getMarkPosition()` Returns the mark position.
`TextAreaPainter` `getPainter()` Returns the object responsible for painting this text area.
`JPopupMenu` `getRightClickPopup()` Returns the right click popup menu.
`String` `getSelectedText()` Returns the selected text, or null if no selection is active.
`int` `getSelectionEnd()` Returns the selection end offset.
`int` `getSelectionEnd(int line)` Returns the offset where the selection ends on the specified line.
`int` `getSelectionEndLine()` Returns the selection end line.
`int` `getSelectionStart()` Returns the selection start offset.
`int` `getSelectionStart(int line)` Returns the offset where the selection starts on the specified line.
`int` `getSelectionStartLine()` Returns the selection start line.
`String` `getSyntaxSensitiveToolTipText(int x, int y)` Return any relevant tool tip text for token at specified position.
`String` `getText()` Returns the entire text of this text area.
`String` `getText(int start, int len)` Returns the specified substring of the document.
`void` `getText(int start, int len, Segment segment)` Copies the specified substring of the document into a segment.
`TokenMarker` `getTokenMarker()` Returns the document's token marker.
`int` `getVisibleLines()` Returns the number of lines visible in this text area.
`boolean` `isCaretBlinkEnabled()` Returns true if the caret is blinking, false otherwise.
`boolean` `isCaretVisible()` Returns true if the caret is visible, false otherwise.
`boolean` `isEditable()` Returns true if this text area is editable, false otherwise.
`boolean` `isOverwriteEnabled()` Returns true if overwrite mode is enabled, false otherwise.
`boolean` `isSelectionRectangular()` Returns true if the selection is rectangular, false otherwise.
`int` `lineToY(int line)` Converts a line index to a y co-ordinate.
`int` `offsetToX(int line, int offset)` Converts an offset in a line into an x co-ordinate.
`void` `overwriteSetSelectedText(String str)` Similar to `setSelectedText()`, but overstrikes the appropriate number of characters if overwrite mode is enabled.
`void` `paste()` Inserts the clipboard contents into the text.
`void` `processKeyEvent(KeyEvent evt)` Forwards key events directly to the input handler.
`void` `recalculateVisibleLines()` Recalculates the number of visible lines.
`void` `removeCaretListener(CaretListener listener)` Removes a caret change listener from this text area.
`void` `removeNotify()` Called by the AWT when this component is removed from it's parent.
`boolean` `scrollTo(int line, int offset)` Ensures that the specified line and offset is visible by scrolling the text area if necessary.
`boolean` `scrollToCaret()` Ensures that the caret is visible by scrolling the text area if necessary.
`void` `select(int start, int end)` Selects from the start offset to the end offset.
`void` `selectAll()` Selects all text in the document.
`void` `selectNone()` Moves the mark to the caret position.
`void` `setCaretBlinkEnabled(boolean caretBlinks)` Toggles caret blinking.
`void` `setCaretPosition(int caret)` Sets the caret position.
`void` `setCaretVisible(boolean caretVisible)` Sets if the caret should be visible.
`void` `setDocument(SyntaxDocument document)` Sets the document this text area is editing.
`void` `setEditable(boolean editable)` Sets if this component is editable.
`void` `setElectricScroll(int electricScroll)` Sets the number of lines from the top and bottom of the text area that are always visible
`void` `setFirstLine(int firstLine)` Sets the line displayed at the text area's origin and updates the scroll bars.
`void` `setHorizontalOffset(int horizontalOffset)` Sets the horizontal offset of drawn lines.
`void` `setInputHandler(InputHandler inputHandler)` Sets the input handler.
`void` `setMagicCaretPosition(int magicCaret)` Sets the `magic' caret position.
`boolean` `setOrigin(int firstLine, int horizontalOffset)` A fast way of changing both the first line and horizontal offset.
`void` `setOverwriteEnabled(boolean overwrite)` Sets if overwrite mode should be enabled.
`void` `setRightClickPopup(JPopupMenu popup)` Sets the right click popup menu.
`void` `setSelectedText(String selectedText)` Replaces the selection with the specified text.
`void` `setSelectionEnd(int selectionEnd)` Sets the selection end.
`void` `setSelectionRectangular(boolean rectSelect)` Sets if the selection should be rectangular.
`void` `setSelectionStart(int selectionStart)` Sets the selection start.
`void` `setText(String text)` Sets the entire text of this text area.
`void` `setTokenMarker(TokenMarker tokenMarker)` Sets the document's token marker.
`protected void` `updateBracketHighlight(int newCaretPosition)`
`void` `updateScrollBars()` Updates the state of the scroll bars.
`int` `xToOffset(int line, int x)` Converts an x co-ordinate to an offset within a line.
`int` `xyToOffset(int x, int y)` Converts a point to an offset, from the start of the text.
`int` `yToLine(int y)` Converts a y co-ordinate to a line index.

Methods inherited from class javax.swing.JComponent

`addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, setFont, 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, transferFocusBackward, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### LEFT_OF_SCROLLBAR

    public static String LEFT_OF_SCROLLBAR

  Adding components with this name to the text area will place them left of the horizontal scroll bar. In jEdit, the status bar is added this way.

### CENTER

    protected static String CENTER

### RIGHT

    protected static String RIGHT

### BOTTOM

    protected static String BOTTOM

### focusedComponent

    protected static JEditTextArea focusedComponent

### caretTimer

    protected static Timer caretTimer

### painter

    protected TextAreaPainter painter

### popup

    protected JPopupMenu popup

### listenerList

    protected EventListenerList listenerList

### caretEvent

    protected mars.venus.editors.jeditsyntax.JEditTextArea.MutableCaretEvent caretEvent

### caretBlinks

    protected boolean caretBlinks

### caretVisible

    protected boolean caretVisible

### blink

    protected boolean blink

### editable

    protected boolean editable

### caretBlinkRate

    protected int caretBlinkRate

### firstLine

    protected int firstLine

### visibleLines

    protected int visibleLines

### electricScroll

    protected int electricScroll

### horizontalOffset

    protected int horizontalOffset

### vertical

    protected JScrollBar vertical

### horizontal

    protected JScrollBar horizontal

### scrollBarsInitialized

    protected boolean scrollBarsInitialized

### inputHandler

    protected InputHandler inputHandler

### document

    protected SyntaxDocument document

### documentHandler

    protected mars.venus.editors.jeditsyntax.JEditTextArea.DocumentHandler documentHandler

### lineSegment

    protected Segment lineSegment

### selectionStart

    protected int selectionStart

### selectionStartLine

    protected int selectionStartLine

### selectionEnd

    protected int selectionEnd

### selectionEndLine

    protected int selectionEndLine

### biasLeft

    protected boolean biasLeft

### bracketPosition

    protected int bracketPosition

### bracketLine

    protected int bracketLine

### magicCaret

    protected int magicCaret

### overwrite

    protected boolean overwrite

### rectSelect

    protected boolean rectSelect

### unredoing

    protected boolean unredoing

Constructor Detail

### JEditTextArea

    public JEditTextArea(JComponent lineNumbers)

  Creates a new JEditTextArea with the default settings.

### JEditTextArea

    public JEditTextArea(TextAreaDefaults defaults,
                         JComponent lineNumbers)

Method Detail

### getPainter

    public final TextAreaPainter getPainter()

  Returns the object responsible for painting this text area.

### getInputHandler

    public final InputHandler getInputHandler()

  Returns the input handler.

### setInputHandler

    public void setInputHandler(InputHandler inputHandler)

  Sets the input handler.

  Parameters:
    `inputHandler` - The new input handler

### isCaretBlinkEnabled

    public final boolean isCaretBlinkEnabled()

  Returns true if the caret is blinking, false otherwise.

### setCaretBlinkEnabled

    public void setCaretBlinkEnabled(boolean caretBlinks)

  Toggles caret blinking.

  Parameters:
    `caretBlinks` - True if the caret should blink, false otherwise

### isCaretVisible

    public final boolean isCaretVisible()

  Returns true if the caret is visible, false otherwise.

### setCaretVisible

    public void setCaretVisible(boolean caretVisible)

  Sets if the caret should be visible.

  Parameters:
    `caretVisible` - True if the caret should be visible, false otherwise

### blinkCaret

    public final void blinkCaret()

  Blinks the caret.

### getElectricScroll

    public final int getElectricScroll()

  Returns the number of lines from the top and button of the text area that are always visible.

### setElectricScroll

    public final void setElectricScroll(int electricScroll)

  Sets the number of lines from the top and bottom of the text area that are always visible

  Parameters:
    `electricScroll` - The number of lines always visible from the top or bottom

### updateScrollBars

    public void updateScrollBars()

  Updates the state of the scroll bars. This should be called if the number of lines in the document changes, or when the size of the text are changes.

### getFirstLine

    public final int getFirstLine()

  Returns the line displayed at the text area's origin.

### setFirstLine

    public void setFirstLine(int firstLine)

  Sets the line displayed at the text area's origin and updates the scroll bars.

### getVisibleLines

    public final int getVisibleLines()

  Returns the number of lines visible in this text area.

### recalculateVisibleLines

    public final void recalculateVisibleLines()

  Recalculates the number of visible lines. This should not be called directly.

### getHorizontalOffset

    public final int getHorizontalOffset()

  Returns the horizontal offset of drawn lines.

### setHorizontalOffset

    public void setHorizontalOffset(int horizontalOffset)

  Sets the horizontal offset of drawn lines. This can be used to implement horizontal scrolling.

  Parameters:
    `horizontalOffset` - offset The new horizontal offset

### setOrigin

    public boolean setOrigin(int firstLine,
                             int horizontalOffset)

  A fast way of changing both the first line and horizontal offset.

  Parameters:
    `firstLine` - The new first line
    `horizontalOffset` - The new horizontal offset
  Returns:
    True if any of the values were changed, false otherwise

### scrollToCaret

    public boolean scrollToCaret()

  Ensures that the caret is visible by scrolling the text area if necessary.

  Returns:
    True if scrolling was actually performed, false if the caret was already visible

### scrollTo

    public boolean scrollTo(int line,
                            int offset)

  Ensures that the specified line and offset is visible by scrolling the text area if necessary.

  Parameters:
    `line` - The line to scroll to
    `offset` - The offset in the line to scroll to
  Returns:
    True if scrolling was actually performed, false if the line and offset was already visible

### lineToY

    public int lineToY(int line)

  Converts a line index to a y co-ordinate.

  Parameters:
    `line` - The line

### yToLine

    public int yToLine(int y)

  Converts a y co-ordinate to a line index.

  Parameters:
    `y` - The y co-ordinate

### offsetToX

    public final int offsetToX(int line,
                               int offset)

  Converts an offset in a line into an x co-ordinate. This is a slow version that can be used any time.

  Parameters:
    `line` - The line
    `offset` - The offset, from the start of the line

### _offsetToX

    public int _offsetToX(int line,
                          int offset)

  Converts an offset in a line into an x co-ordinate. This is a fast version that should only be used if no changes were made to the text since the last repaint.

  Parameters:
    `line` - The line
    `offset` - The offset, from the start of the line

### xToOffset

    public int xToOffset(int line,
                         int x)

  Converts an x co-ordinate to an offset within a line.

  Parameters:
    `line` - The line
    `x` - The x co-ordinate

### xyToOffset

    public int xyToOffset(int x,
                          int y)

  Converts a point to an offset, from the start of the text.

  Parameters:
    `x` - The x co-ordinate of the point
    `y` - The y co-ordinate of the point

### getDocument

    public final Document getDocument()

  Returns the document this text area is editing.

### setDocument

    public void setDocument(SyntaxDocument document)

  Sets the document this text area is editing.

  Parameters:
    `document` - The document

### getTokenMarker

    public final TokenMarker getTokenMarker()

  Returns the document's token marker. Equivalent to calling `getDocument().getTokenMarker()`.

### setTokenMarker

    public final void setTokenMarker(TokenMarker tokenMarker)

  Sets the document's token marker. Equivalent to caling `getDocument().setTokenMarker()`.

  Parameters:
    `tokenMarker` - The token marker

### getDocumentLength

    public final int getDocumentLength()

  Returns the length of the document. Equivalent to calling `getDocument().getLength()`.

### getLineCount

    public final int getLineCount()

  Returns the number of lines in the document.

### getLineOfOffset

    public final int getLineOfOffset(int offset)

  Returns the line containing the specified offset.

  Parameters:
    `offset` - The offset

### getLineStartOffset

    public int getLineStartOffset(int line)

  Returns the start offset of the specified line.

  Parameters:
    `line` - The line
  Returns:
    The start offset of the specified line, or -1 if the line is invalid

### getLineEndOffset

    public int getLineEndOffset(int line)

  Returns the end offset of the specified line.

  Parameters:
    `line` - The line
  Returns:
    The end offset of the specified line, or -1 if the line is invalid.

### getLineLength

    public int getLineLength(int line)

  Returns the length of the specified line.

  Parameters:
    `line` - The line

### getText

    public String getText()

  Returns the entire text of this text area.

### setText

    public void setText(String text)

  Sets the entire text of this text area.

### getText

    public final String getText(int start,
                                int len)

  Returns the specified substring of the document.

  Parameters:
    `start` - The start offset
    `len` - The length of the substring
  Returns:
    The substring, or null if the offsets are invalid

### getText

    public final void getText(int start,
                              int len,
                              Segment segment)

  Copies the specified substring of the document into a segment. If the offsets are invalid, the segment will contain a null string.

  Parameters:
    `start` - The start offset
    `len` - The length of the substring
    `segment` - The segment

### getLineText

    public final String getLineText(int lineIndex)

  Returns the text on the specified line.

  Parameters:
    `lineIndex` - The line
  Returns:
    The text, or null if the line is invalid

### getLineText

    public final void getLineText(int lineIndex,
                                  Segment segment)

  Copies the text on the specified line into a segment. If the line is invalid, the segment will contain a null string.

  Parameters:
    `lineIndex` - The line

### getSelectionStart

    public final int getSelectionStart()

  Returns the selection start offset.

### getSelectionStart

    public int getSelectionStart(int line)

  Returns the offset where the selection starts on the specified line.

### getSelectionStartLine

    public final int getSelectionStartLine()

  Returns the selection start line.

### setSelectionStart

    public final void setSelectionStart(int selectionStart)

  Sets the selection start. The new selection will be the new selection start and the old selection end.

  Parameters:
    `selectionStart` - The selection start
  See Also:
    `select(int,int)`

### getSelectionEnd

    public final int getSelectionEnd()

  Returns the selection end offset.

### getSelectionEnd

    public int getSelectionEnd(int line)

  Returns the offset where the selection ends on the specified line.

### getSelectionEndLine

    public final int getSelectionEndLine()

  Returns the selection end line.

### setSelectionEnd

    public final void setSelectionEnd(int selectionEnd)

  Sets the selection end. The new selection will be the old selection start and the new selection end.

  Parameters:
    `selectionEnd` - The selection end
  See Also:
    `select(int,int)`

### getCaretPosition

    public final int getCaretPosition()

  Returns the caret position. This will either be the selection start or the selection end, depending on which direction the selection was made in.

### getCaretLine

    public final int getCaretLine()

  Returns the caret line.

### getMarkPosition

    public final int getMarkPosition()

  Returns the mark position. This will be the opposite selection bound to the caret position.

  See Also:
    `getCaretPosition()`

### getMarkLine

    public final int getMarkLine()

  Returns the mark line.

### setCaretPosition

    public final void setCaretPosition(int caret)

  Sets the caret position. The new selection will consist of the caret position only (hence no text will be selected)

  Parameters:
    `caret` - The caret position
  See Also:
    `select(int,int)`

### selectAll

    public final void selectAll()

  Selects all text in the document.

### selectNone

    public final void selectNone()

  Moves the mark to the caret position.

### select

    public void select(int start,
                       int end)

  Selects from the start offset to the end offset. This is the general selection method used by all other selecting methods. The caret position will be start if start < end, and end if end > start.

  Parameters:
    `start` - The start offset
    `end` - The end offset

### getSelectedText

    public final String getSelectedText()

  Returns the selected text, or null if no selection is active.

### setSelectedText

    public void setSelectedText(String selectedText)

  Replaces the selection with the specified text.

  Parameters:
    `selectedText` - The replacement text for the selection

### isEditable

    public final boolean isEditable()

  Returns true if this text area is editable, false otherwise.

### setEditable

    public final void setEditable(boolean editable)

  Sets if this component is editable.

  Parameters:
    `editable` - True if this text area should be editable, false otherwise

### getRightClickPopup

    public final JPopupMenu getRightClickPopup()

  Returns the right click popup menu.

### setRightClickPopup

    public final void setRightClickPopup(JPopupMenu popup)

  Sets the right click popup menu.

  Parameters:
    `popup` - The popup

### getMagicCaretPosition

    public final int getMagicCaretPosition()

  Returns the `magic' caret position. This can be used to preserve the column position when moving up and down lines.

### setMagicCaretPosition

    public final void setMagicCaretPosition(int magicCaret)

  Sets the `magic' caret position. This can be used to preserve the column position when moving up and down lines.

  Parameters:
    `magicCaret` - The magic caret position

### overwriteSetSelectedText

    public void overwriteSetSelectedText(String str)

  Similar to `setSelectedText()`, but overstrikes the appropriate number of characters if overwrite mode is enabled.

  Parameters:
    `str` - The string
  See Also:
    `setSelectedText(String)`, `isOverwriteEnabled()`

### isOverwriteEnabled

    public final boolean isOverwriteEnabled()

  Returns true if overwrite mode is enabled, false otherwise.

### setOverwriteEnabled

    public final void setOverwriteEnabled(boolean overwrite)

  Sets if overwrite mode should be enabled.

  Parameters:
    `overwrite` - True if overwrite mode should be enabled, false otherwise.

### isSelectionRectangular

    public final boolean isSelectionRectangular()

  Returns true if the selection is rectangular, false otherwise.

### setSelectionRectangular

    public final void setSelectionRectangular(boolean rectSelect)

  Sets if the selection should be rectangular.

  Parameters:
    `overwrite` - True if the selection should be rectangular, false otherwise.

### getBracketPosition

    public final int getBracketPosition()

  Returns the position of the highlighted bracket (the bracket matching the one before the caret)

### getBracketLine

    public final int getBracketLine()

  Returns the line of the highlighted bracket (the bracket matching the one before the caret)

### addCaretListener

    public final void addCaretListener(CaretListener listener)

  Adds a caret change listener to this text area.

  Parameters:
    `listener` - The listener

### removeCaretListener

    public final void removeCaretListener(CaretListener listener)

  Removes a caret change listener from this text area.

  Parameters:
    `listener` - The listener

### cut

    public void cut()

  Deletes the selected text from the text area and places it into the clipboard.

### copy

    public void copy()

  Places the selected text into the clipboard.

### paste

    public void paste()

  Inserts the clipboard contents into the text.

### removeNotify

    public void removeNotify()

  Called by the AWT when this component is removed from it's parent. This stops clears the currently focused component.

  Overrides:
    `removeNotify` in class `JComponent`

### processKeyEvent

    public void processKeyEvent(KeyEvent evt)

  Forwards key events directly to the input handler. This is slightly faster than using a KeyListener because some Swing overhead is avoided.

  Overrides:
    `processKeyEvent` in class `JComponent`

### fireCaretEvent

    protected void fireCaretEvent()

### updateBracketHighlight

    protected void updateBracketHighlight(int newCaretPosition)

### documentChanged

    protected void documentChanged(DocumentEvent evt)

### getSyntaxSensitiveToolTipText

    public String getSyntaxSensitiveToolTipText(int x,
                                                int y)

  Return any relevant tool tip text for token at specified position. Keyword match must be exact. DPS 24-May-2010

  Parameters:
    `x` - x-coordinate of current position
    `y` - y-coordinate of current position
  Returns:
    String containing appropriate tool tip text. Possibly HTML-encoded.

### getAutoIndent

    public String getAutoIndent()

  Constructs string for auto-indent feature. Returns empty string if auto-intent is disabled or if line has no leading white space. Uses getLeadingWhiteSpace(). Is used by InputHandler when processing key press for Enter key. DPS 31-Dec-2010

  Returns:
    String containing auto-indent characters to be inserted into text

### getLeadingWhiteSpace

    public String getLeadingWhiteSpace()

  Makes a copy of leading white space (tab or space) from the current line and returns it. DPS 31-Dec-2010

  Returns:
    String containing leading white space of current line. Empty string if none.