Package org.gjt.sp.jedit.textarea
Class TextArea
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.gjt.sp.jedit.textarea.TextArea
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.accessibility.Accessible
- Direct Known Subclasses:
JEditEmbeddedTextArea,JEditTextArea,StandaloneTextArea
public abstract class TextArea extends javax.swing.JPanelAbstract TextArea component. The concrete instance used by jEdit itself is called the JEditTextArea. This class uses a minimal set of jEdit APIs because it is the base class of the JEditEmbeddedTextArea and StandaloneTextArea, so it needs to be embeddable and separable.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description protected JEditBufferbufferprotected intcaretprotected intcaretLinestatic intELECTRIC_SCROLLprotected InputHandlerProviderinputHandlerProviderprotected booleanmultiFlag that tells if multiple selection is on.static intNO_SCROLLstatic intNORMAL_SCROLLprotected TextAreaPainterpainterprotected javax.swing.JPopupMenupopup-
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
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTextArea(IPropertyManager propertyManager, InputHandlerProvider inputHandlerProvider)Creates a new JEditTextArea.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddActionSet(JEditActionSet<JEditBeanShellAction> actionSet)Adds a new action set to the textarea's list of ActionSets.voidaddBottomLeftComponent(java.awt.Component comp)Adds a component below the gutter.voidaddBottomRightComponent(java.awt.Component comp)Adds a component below the vertical scroll bar.voidaddCaretListener(javax.swing.event.CaretListener listener)Adds a caret change listener to this text area.voidaddExplicitFold()Surrounds the selection with explicit fold markers.protected intaddExplicitFold(int caretStart, int caretEnd, int lineStart, int lineEnd)Add an explicit fold.voidaddLeftOfScrollBar(java.awt.Component comp)Adds a component to the left side of the box left of the vertical scroll bar.voidaddNotify()Called by the AWT when this component is added to a parent.voidaddScrollListener(ScrollListener listener)Adds a scroll listener to this text area.voidaddStatusListener(StatusListener listener)Adds a scroll listener to this text area.voidaddStructureMatcher(StructureMatcher matcher)Adds a structure matcher.voidaddTopComponent(java.awt.Component comp)Adds a component above the gutter, text area, and vertical scroll bar.voidaddTopLeftComponent(java.awt.Component comp)Adds a component above the gutter.voidaddTopRightComponent(java.awt.Component comp)Adds a component above the vertical scroll bar.voidaddToSelection(Selection selection)Adds to the selection.voidaddToSelection(Selection[] selection)Adds to the selection.voidbackspace()Deletes the character before the caret, or the selection, if one is active.voidbackspaceWord()Deletes the word before the caret.voidbackspaceWord(boolean eatWhitespace)Deletes the word before the caret.voidbackspaceWord(boolean eatWhitespace, boolean eatOnlyAfterWord)Deletes the word before the caret.voidblinkCaret()Blinks the caret.booleancaretAutoScroll()Return if change in buffer should scroll this text area.voidcenterCaret()Centers the caret on the screen.voidcollapseFold()LikeDisplayManager.collapseFold(int), but also moves the caret to the first line of the fold.voidcollapseFold(int line)LikeDisplayManager.collapseFold(int), but also moves the caret to the first line of the fold.voidcreatePopupMenu(java.awt.event.MouseEvent evt)Creates the popup menu.voiddelete()Deletes the character after the caret.voiddeleteLine()Deletes the line containing the caret.voiddeleteParagraph()Deletes the paragraph containing the caret.voiddeleteToEndOfLine()Deletes from the caret to the end of the current line.voiddeleteToStartOfLine()Deletes from the caret to the beginning of the current line.voiddeleteWord()Deletes the word in front of the caret.voiddeleteWord(boolean eatWhitespace)Deletes the word in front of the caret.voiddispose()Plugins and macros should not call this method.protected booleandoWordWrap(boolean spaceInserted)Does hard wrap.voidend(boolean select)a dumb end action which only has 2 states: end of whitespace or end of linevoidexpandFold(boolean fully)LikeDisplayManager.expandFold(int,boolean), but also moves the caret to the first sub-fold.voidextendSelection(int offset, int end)Extends the selection at the specified offset, or creates a new one if there is no selection at the specified offset.voidextendSelection(int offset, int end, int extraStartVirt, int extraEndVirt)Extends the selection at the specified offset, or creates a new one if there is no selection at the specified offset.voidformatParagraph()Formats the paragraph containing the caret.JEditActionContext<JEditBeanShellAction,JEditActionSet<JEditBeanShellAction>>getActionContext()JEditBuffergetBuffer()Returns the buffer this text area is editing.intgetBufferLength()Returns the length of the buffer.intgetCaretLine()Returns the line number containing the caret.intgetCaretPosition()Returns a zero-based index of the caret position.DisplayManagergetDisplayManager()intgetElectricScroll()intgetFirstLine()Returns the vertical scroll bar position.intgetFirstPhysicalLine()Returns the first visible physical line index.booleangetFocusCycleRoot()Java 1.4 compatibility fix to make Tab traversal work in a sane manner.booleangetFocusTraversalKeysEnabled()Java 1.4 compatibility fix to make Tab key work.FoldPaintergetFoldPainter()GuttergetGutter()Returns the gutter to the left of the text area or null if the gutter is disabledintgetHorizontalOffset()Returns the horizontal offset of drawn lines.AbstractInputHandlergetInputHandler()java.awt.im.InputMethodRequestsgetInputMethodRequests()booleangetJoinNonWordChars()If set, double clicking will join non-word characters to form one "word".intgetLastPhysicalLine()Returns the last visible physical line index.intgetLastScreenLine()Returns the last screen line index, it is different fromgetVisibleLines()because the buffer can have less lines than the visible linesintgetLineCount()Returns the number of physical lines in the buffer.intgetLineEndOffset(int line)Returns the end offset of the specified line.intgetLineLength(int line)Returns the length of the specified line.intgetLineOfOffset(int offset)Returns the line containing the specified offset.intgetLineStartOffset(int line)Returns the start offset of the specified line.java.lang.StringgetLineText(int lineIndex)Returns the text on the specified line.voidgetLineText(int lineIndex, javax.swing.text.Segment segment)Copies the text on the specified line into a Segment.intgetMagicCaretPosition()Returns an internal position used to keep the caret in one column while moving around lines of varying lengths.intgetMarkPosition()Deprecated.Do not use.TextAreaPaintergetPainter()Returns the object responsible for painting this text area.intgetPhysicalLineOfScreenLine(int screenLine)Returns the physical line number that contains the specified screen line.javax.swing.JPopupMenugetRightClickPopup()Returns the right click popup menu.intgetScreenLineEndOffset(int line)Returns the end offset of the specified screen (wrapped) line.intgetScreenLineOfOffset(int offset)Returns the screen (wrapped) line containing the specified offset.intgetScreenLineStartOffset(int line)Returns the start offset of the specified screen (wrapped) line.int[]getSelectedLines()Returns a sorted array of line numbers on which a selection or selections are present.java.lang.StringgetSelectedText()Returns the text in all active selections, with a newline between each text chunk.java.lang.StringgetSelectedText(java.lang.String separator)Returns the text in all active selections.java.lang.StringgetSelectedText(Selection s)Returns the text in the specified selection.Selection[]getSelection()Returns the current selection.SelectiongetSelection(int index)Returns the selection with the specified index.SelectiongetSelectionAtOffset(int offset)Returns the selection containing the specific offset, ornullif there is no selection at that offset.intgetSelectionCount()Returns the number of selections.java.util.Iterator<Selection>getSelectionIterator()Returns the current selection.StructureMatcher.MatchgetStructureMatch()Returns the structure element (bracket, or XML tag, etc) matching the one before the caret.javax.swing.text.TabExpandergetTabExpander()java.lang.StringgetText()Returns the entire text of this text area.java.lang.StringgetText(int start, int len)Returns the specified substring of the buffer.voidgetText(int start, int len, javax.swing.text.Segment segment)Copies the specified substring of the buffer into a segment.intgetVisibleLines()Returns the number of lines visible in this text area.java.lang.CharSequencegetVisibleLineSegment(int screenLine)Returns the visible part of the given line in a CharSequence.java.lang.StringgetVisibleLineText(int screenLine)Returns the visible part of the given linevoidgetVisibleLineText(int screenLine, javax.swing.text.Segment segment)Returns the visible part of the given linevoidgoToBufferEnd(boolean select)Moves the caret to the end of the buffer.voidgoToBufferStart(boolean select)Moves the caret to the beginning of the buffer.voidgoToEndOfCode(boolean select)Moves the caret to the end of the code present on the current line, before the comments and whitespace.voidgoToEndOfLine(boolean select)Moves the caret to the end of the current line.voidgoToEndOfWhiteSpace(boolean select)Moves the caret to the last non-whitespace character of the current line.voidgoToFirstVisibleLine(boolean select)Moves the caret to the first visible line.voidgoToLastVisibleLine(boolean select)Moves the caret to the last visible line.voidgoToMatchingBracket()Moves the caret to the bracket matching the one before the caret.voidgoToNextBracket(boolean select)Moves the caret to the next closing bracket.voidgoToNextCharacter(boolean select)Moves the caret to the next character.voidgoToNextFold(boolean select)Moves the caret to the next fold.voidgoToNextLine(boolean select)Move the caret to the next line.voidgoToNextPage(boolean select)Moves the caret to the next screenful.voidgoToNextParagraph(boolean select)Moves the caret to the start of the next paragraph.voidgoToNextWord(boolean select)Moves the caret to the start of the next word.voidgoToNextWord(boolean select, boolean eatWhitespace)Moves the caret to the start of the next word.voidgoToParentFold()Moves the caret to the fold containing the one at the caret position.voidgoToPrevBracket(boolean select)Moves the caret to the previous bracket.voidgoToPrevCharacter(boolean select)Moves the caret to the previous character.voidgoToPrevFold(boolean select)Moves the caret to the previous fold.voidgoToPrevLine(boolean select)Moves the caret to the previous line.voidgoToPrevPage(boolean select)Moves the caret to the previous screenful.voidgoToPrevParagraph(boolean select)Moves the caret to the start of the previous paragraph.voidgoToPrevWord(boolean select)Moves the caret to the start of the previous word.voidgoToPrevWord(boolean select, boolean eatWhitespace)Moves the caret to the start of the previous word.voidgoToPrevWord(boolean select, boolean eatWhitespace, boolean eatOnlyAfterWord)Moves the caret to the start of the previous word.voidgoToStartOfLine(boolean select)Moves the caret to the beginning of the current line.voidgoToStartOfWhiteSpace(boolean select)Moves the caret to the first non-whitespace character of the current line.voidhandlePopupTrigger(java.awt.event.MouseEvent evt)Do the same thing as right-clicking on the text area.voidhome(boolean select)A "dumb home" action which only has 2 states: start of the whitespace or start of linevoidindentSelectedLines()Indents all selected lines.voidinitInputHandler()Creates an actionContext and initializes the input handler for this textarea.protected voidinsert(java.lang.String str, boolean indent)voidinsertEnterAndIndent()Inserts a line break and indents the new line.voidinsertTabAndIndent()voidinvalidateLine(int line)Marks a line as needing a repaint.voidinvalidateLineRange(int start, int end)Marks a range of physical lines as needing a repaint.voidinvalidateScreenLineRange(int start, int end)Marks a range of screen lines as needing a repaint.voidinvertSelection()Inverts the selection.booleanisCaretBlinkEnabled()booleanisCaretVisible()Returns true if the caret is visible, false otherwise.booleanisCtrlForRectangularSelection()If set, CTRL enables rectangular selection mode while pressed.booleanisDragEnabled()Returns if drag and drop of text is enabled.booleanisEditable()Returns true if this text area is editable, false otherwise.booleanisMultipleSelectionEnabled()Returns if multiple selection is enabled.booleanisOverwriteEnabled()Returns true if overwrite mode is enabled, false otherwise.booleanisQuickCopyEnabled()Returns if clicking the middle mouse button pastes the most recent selection (% register), and if Control-dragging inserts the selection at the caret.booleanisRectangularSelectionEnabled()Returns if rectangular selection is enabled.booleanisRightClickPopupEnabled()Returns if the right click popup menu is enabled.voidjoinLines()Joins the current and the next line, or joins all lines in selections.voidlineComment()Prepends each line of the selection with the line comment string.booleanlineInStructureScope(int line)Returns if the specified line is contained in the currently matched structure's scope.voidmoveCaretPosition(int newCaret)Sets the caret position without deactivating the selection.voidmoveCaretPosition(int newCaret, boolean doElectricScroll)Sets the caret position without deactivating the selection.voidmoveCaretPosition(int newCaret, int scrollMode)Sets the caret position without deactivating the selection.voidnarrowToFold()Hides all lines except those in the fold containing the caret.voidnarrowToSelection()Hides all lines except those in the selection.java.awt.PointoffsetToXY(int offset)Converts an offset into a point in the text area painter's co-ordinate space.java.awt.PointoffsetToXY(int line, int offset)Converts an offset into a point in the text area painter's co-ordinate space.java.awt.PointoffsetToXY(int line, int offset, java.awt.Point retVal)Converts a line,offset pair into an x,y (pixel) point relative to the upper left corner (0,0) of the text area.voidprocessKeyEvent(java.awt.event.KeyEvent evt)voidpropertiesChanged()Called by jEdit when necessary.voidrangeComment()Adds comment start and end strings to the beginning and end of the selection.voidremoveCaretListener(javax.swing.event.CaretListener listener)Removes a caret change listener from this text area.voidremoveFromSelection(int offset)Deactivates the selection at the specified offset.voidremoveFromSelection(Selection sel)Deactivates the specified selection.voidremoveLeftOfScrollBar(java.awt.Component comp)Removes a component from the box left of the vertical scroll bar.voidremoveNotify()Called by the AWT when this component is removed from it's parent.voidremoveScrollListener(ScrollListener listener)Removes a scroll listener from this text area.voidremoveStatusListener(StatusListener listener)Removes a scroll listener from this text area.voidremoveStructureMatcher(StructureMatcher matcher)Removes a structure matcher.voidremoveTopComponent(java.awt.Component comp)Removes a component from above the gutter, text area, and vertical scroll bar.voidremoveTrailingWhiteSpace()Removes trailing whitespace from all lines in the selection.intreplaceSelection(java.lang.String selectedText)Set the selection, but does not deactivate it, and does not move the caret.voidresizeSelection(int offset, int end, int extraEndVirt, boolean rect)Resizes the selection at the specified offset, or creates a new one if there is no selection at the specified offset.voidscrollAndCenterCaret()Tries to scroll the textArea so that the caret is centered on the screen.voidscrollDownLine()Scrolls down by one line.voidscrollDownPage()Scrolls down by one page.voidscrollTo(int offset, boolean doElectricScroll)Ensures that the specified location in the buffer is visible.voidscrollTo(int line, int offset, boolean doElectricScroll)Ensures that the specified location in the buffer is visible.voidscrollToCaret(boolean doElectricScroll)Ensures that the caret is visible by scrolling the text area if necessary.voidscrollUpLine()Scrolls up by one line.voidscrollUpPage()Scrolls up by one page.voidselectAll()Selects all text in the buffer.voidselectBlock()Selects the code block surrounding the caret.voidselectFold()Selects the fold that contains the caret line number.voidselectFold(int line)Selects the fold that contains the specified line number.voidselectLine()Selects the current line.voidselectNone()Deselects everything.voidselectParagraph()Selects the paragraph at the caret position.voidselectToMatchingBracket()Selects from the bracket at the caret position to the corresponding bracket.SelectionselectToMatchingBracket(int position, boolean quickCopy)Selects from the bracket at the specified position to the corresponding bracket.voidselectWord()Selects the word at the caret position.voidsetBuffer(JEditBuffer buffer)Sets the buffer this text area is editing.voidsetCaretBlinkEnabled(boolean caretBlinks)Toggles caret blinking.voidsetCaretPosition(int newCaret)Sets the caret position and deactivates the selection.voidsetCaretPosition(int newCaret, boolean doElectricScroll)Sets the caret position and deactivates the selection.voidsetCtrlForRectangularSelection(boolean ctrlForRectangularSelection)If set, CTRL enables rectangular selection mode while pressed.voidsetDragEnabled(boolean dndEnabled)Sets if drag and drop of text is enabled.voidsetElectricScroll(int electricScroll)Sets the number of lines from the top and bottom of the text area that are always visiblevoidsetFirstLine(int firstLine)Sets the vertical scroll bar positionvoidsetFirstPhysicalLine(int physFirstLine)Sets the vertical scroll bar position.voidsetFirstPhysicalLine(int physFirstLine, int skew)Sets the vertical scroll bar position.voidsetHorizontalOffset(int horizontalOffset)Sets the horizontal offset of drawn lines.voidsetJoinNonWordChars(boolean joinNonWordChars)If set, double clicking will join non-word characters to form one "word".voidsetMagicCaretPosition(int magicCaret)Sets the `magic' caret position.voidsetMouseHandler(javax.swing.event.MouseInputAdapter mouseInputAdapter)voidsetMultipleSelectionEnabled(boolean multi)Set multiple selection on or off according to the value ofmulti.voidsetOverwriteEnabled(boolean overwrite)Sets overwrite mode.voidsetQuickCopyEnabled(boolean quickCopy)Sets if clicking the middle mouse button pastes the most recent selection (% register), and if Control-dragging inserts the selection at the caret.voidsetRectangularSelectionEnabled(boolean rectangularSelectionMode)Set rectangular selection on or off according to the value ofrectangularSelectionMode.voidsetRightClickPopup(javax.swing.JPopupMenu popup)Sets the right click popup menu.voidsetRightClickPopupEnabled(boolean popupEnabled)Sets if the right click popup menu is enabled.voidsetSelectedText(java.lang.String selectedText)Replaces the selection at the caret with the specified text.voidsetSelectedText(java.lang.String selectedText, boolean moveCaret)Replaces the selection at the caret with the specified text.voidsetSelectedText(Selection s, java.lang.String selectedText)Replaces the selection with the specified text.voidsetSelection(Selection selection)Sets the selection.voidsetSelection(Selection[] selection)Sets the selection.voidsetText(java.lang.String text)Sets the entire text of this text area.voidsetTransferHandler(javax.swing.TransferHandler newHandler)voidshiftIndentLeft()Shifts the indent to the left.voidshiftIndentRight()Shifts the indent to the right.voidshowPopupMenu()Shows the popup menu below the current caret position.static voidshowPopupMenu(javax.swing.JPopupMenu popup, java.awt.Component comp, int x, int y, boolean point)voidsmartEnd(boolean select)Has 4 states based on # of invocations: 1.voidsmartHome(boolean select)On subsequent invocations, first moves the caret to the first non-whitespace character of the line, then the beginning of the line, then to the first visible line.voidspacesToTabs()Converts spaces to tabs in the selection.voidtabsToSpaces()Converts tabs to spaces in the selection.voidtoggleMultipleSelectionEnabled()Toggles multiple selection.voidtoggleOverwriteEnabled()Toggles overwrite mode.voidtoggleRectangularSelectionEnabled()Toggles rectangular selection.voidtoLowerCase()Converts the selected text to lower case.java.lang.StringtoString()voidtoUpperCase()Converts the selected text to upper case.voidturnOnElasticTabstops()Turn ON elastic tab stops.voiduserInput(char ch)Handles the insertion of the specified character.protected voiduserInputTab()intxToScreenLineOffset(int screenLine, int x, boolean round)Converts a point in a given screen line to an offset.intxyToOffset(int x, int y)Converts a point to an offset.intxyToOffset(int x, int y, boolean round)Converts a point to an offset.-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, 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, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
NO_SCROLL
public static final int NO_SCROLL
- See Also:
- Constant Field Values
-
NORMAL_SCROLL
public static final int NORMAL_SCROLL
- See Also:
- Constant Field Values
-
ELECTRIC_SCROLL
public static final int ELECTRIC_SCROLL
- See Also:
- Constant Field Values
-
popup
protected javax.swing.JPopupMenu popup
-
painter
protected final TextAreaPainter painter
-
inputHandlerProvider
protected InputHandlerProvider inputHandlerProvider
-
buffer
protected JEditBuffer buffer
-
caret
protected int caret
-
caretLine
protected int caretLine
-
multi
protected boolean multi
Flag that tells if multiple selection is on.
-
-
Constructor Detail
-
TextArea
protected TextArea(IPropertyManager propertyManager, InputHandlerProvider inputHandlerProvider)
Creates a new JEditTextArea.- Parameters:
propertyManager- the property manager that contains informations like shortcut bindingsinputHandlerProvider- the inputHandlerProvider
-
-
Method Detail
-
getFoldPainter
public FoldPainter getFoldPainter()
-
initInputHandler
public void initInputHandler()
Creates an actionContext and initializes the input handler for this textarea. Called when creating a standalone textarea from within jEdit.
-
getActionContext
public JEditActionContext<JEditBeanShellAction,JEditActionSet<JEditBeanShellAction>> getActionContext()
-
setMouseHandler
public void setMouseHandler(javax.swing.event.MouseInputAdapter mouseInputAdapter)
-
setTransferHandler
public void setTransferHandler(javax.swing.TransferHandler newHandler)
- Overrides:
setTransferHandlerin classjavax.swing.JComponent
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.awt.Component
-
dispose
public void dispose()
Plugins and macros should not call this method.- Since:
- jEdit 4.2pre1
-
getInputHandler
public AbstractInputHandler getInputHandler()
- Since:
- jEdit 4.3pre1
-
getPainter
public final TextAreaPainter getPainter()
Returns the object responsible for painting this text area.
-
getGutter
public final Gutter getGutter()
Returns the gutter to the left of the text area or null if the gutter is disabled
-
getDisplayManager
public DisplayManager getDisplayManager()
- Returns:
- the display manager used by this text area.
- Since:
- jEdit 4.2pre1
-
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
-
getElectricScroll
public final int getElectricScroll()
- Returns:
- the minimum distance (in number of lines) from the caret to the nearest edge of the screen (top or bottom edge).
-
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
-
isQuickCopyEnabled
public final boolean isQuickCopyEnabled()
Returns if clicking the middle mouse button pastes the most recent selection (% register), and if Control-dragging inserts the selection at the caret.
-
setQuickCopyEnabled
public final void setQuickCopyEnabled(boolean quickCopy)
Sets if clicking the middle mouse button pastes the most recent selection (% register), and if Control-dragging inserts the selection at the caret.- Parameters:
quickCopy- A boolean flag
-
getBuffer
public final JEditBuffer getBuffer()
Returns the buffer this text area is editing.- Since:
- jedit 4.3pre3 Prior to 4.3pre3, this function returned a "Buffer" type. If this causes your code to break, try calling view.getBuffer() instead of view.getTextArea().getBuffer().
-
setBuffer
public void setBuffer(JEditBuffer buffer)
Sets the buffer this text area is editing. If you don't run a standalone textarea in jEdit please do not call this method - useEditPane.setBuffer(org.gjt.sp.jedit.Buffer)instead.- Parameters:
buffer- The buffer
-
isEditable
public final boolean isEditable()
Returns true if this text area is editable, false otherwise.
-
isDragEnabled
public boolean isDragEnabled()
Returns if drag and drop of text is enabled.- Since:
- jEdit 4.2pre5
-
setDragEnabled
public void setDragEnabled(boolean dndEnabled)
Sets if drag and drop of text is enabled.- Since:
- jEdit 4.2pre5
-
getJoinNonWordChars
public boolean getJoinNonWordChars()
If set, double clicking will join non-word characters to form one "word".- Since:
- jEdit 4.3pre2
-
setJoinNonWordChars
public void setJoinNonWordChars(boolean joinNonWordChars)
If set, double clicking will join non-word characters to form one "word".- Since:
- jEdit 4.3pre2
-
isCtrlForRectangularSelection
public boolean isCtrlForRectangularSelection()
If set, CTRL enables rectangular selection mode while pressed.- Since:
- jEdit 4.3pre10
-
setCtrlForRectangularSelection
public void setCtrlForRectangularSelection(boolean ctrlForRectangularSelection)
If set, CTRL enables rectangular selection mode while pressed.- Since:
- jEdit 4.3pre10
-
getFirstLine
public final int getFirstLine()
Returns the vertical scroll bar position.- Since:
- jEdit 4.2pre1
-
setFirstLine
public void setFirstLine(int firstLine)
Sets the vertical scroll bar position- Parameters:
firstLine- The scroll bar position
-
getFirstPhysicalLine
public final int getFirstPhysicalLine()
Returns the first visible physical line index.- Since:
- jEdit 4.0pre4
-
setFirstPhysicalLine
public void setFirstPhysicalLine(int physFirstLine)
Sets the vertical scroll bar position.- Parameters:
physFirstLine- The first physical line to display- Since:
- jEdit 4.2pre1
-
setFirstPhysicalLine
public void setFirstPhysicalLine(int physFirstLine, int skew)Sets the vertical scroll bar position.- Parameters:
physFirstLine- The first physical line to displayskew- A local screen line delta- Since:
- jEdit 4.2pre1
-
getLastPhysicalLine
public final int getLastPhysicalLine()
Returns the last visible physical line index.- Since:
- jEdit 4.0pre4
-
getLastScreenLine
public int getLastScreenLine()
Returns the last screen line index, it is different fromgetVisibleLines()because the buffer can have less lines than the visible lines- Returns:
- the last screen line index.
- Since:
- jEdit 4.3pre1
-
getVisibleLines
public int getVisibleLines()
Returns the number of lines visible in this text area.- Returns:
- the number of visible lines in the textarea
-
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
-
scrollUpLine
public void scrollUpLine()
Scrolls up by one line.- Since:
- jEdit 2.7pre2
-
scrollUpPage
public void scrollUpPage()
Scrolls up by one page.- Since:
- jEdit 2.7pre2
-
scrollDownLine
public void scrollDownLine()
Scrolls down by one line.- Since:
- jEdit 2.7pre2
-
scrollDownPage
public void scrollDownPage()
Scrolls down by one page.- Since:
- jEdit 2.7pre2
-
scrollToCaret
public void scrollToCaret(boolean doElectricScroll)
Ensures that the caret is visible by scrolling the text area if necessary.- Parameters:
doElectricScroll- If true, electric scrolling will be performed
-
scrollTo
public void scrollTo(int offset, boolean doElectricScroll)Ensures that the specified location in the buffer is visible.- Parameters:
offset- The offset from the start of the bufferdoElectricScroll- If true, electric scrolling will be performed- Since:
- jEdit 4.2pre3
-
scrollTo
public void scrollTo(int line, int offset, boolean doElectricScroll)Ensures that the specified location in the buffer is visible.- Parameters:
line- The line numberoffset- The offset from the start of the linedoElectricScroll- If true, electric scrolling will be performed- Since:
- jEdit 4.0pre6
-
addScrollListener
public final void addScrollListener(ScrollListener listener)
Adds a scroll listener to this text area.- Parameters:
listener- The listener- Since:
- jEdit 3.2pre2
-
removeScrollListener
public final void removeScrollListener(ScrollListener listener)
Removes a scroll listener from this text area.- Parameters:
listener- The listener- Since:
- jEdit 3.2pre2
-
getPhysicalLineOfScreenLine
public int getPhysicalLineOfScreenLine(int screenLine)
Returns the physical line number that contains the specified screen line.- Parameters:
screenLine- The screen line- Since:
- jEdit 4.0pre6
-
getScreenLineOfOffset
public int getScreenLineOfOffset(int offset)
Returns the screen (wrapped) line containing the specified offset. Returns -1 if the line is not currently visible on the screen.- Parameters:
offset- The offset- Since:
- jEdit 4.0pre4
-
getScreenLineStartOffset
public int getScreenLineStartOffset(int line)
Returns the start offset of the specified screen (wrapped) line.- Parameters:
line- The line- Since:
- jEdit 4.0pre4
-
getScreenLineEndOffset
public int getScreenLineEndOffset(int line)
Returns the end offset of the specified screen (wrapped) line.- Parameters:
line- The line- Since:
- jEdit 4.0pre4
-
xyToOffset
public int xyToOffset(int x, int y)Converts a point to an offset. Note that unlike in previous jEdit versions, this method now returns -1 if the y co-ordinate is out of bounds.- Parameters:
x- The x co-ordinate of the pointy- The y co-ordinate of the point
-
xyToOffset
public int xyToOffset(int x, int y, boolean round)Converts a point to an offset. Note that unlike in previous jEdit versions, this method now returns -1 if the y co-ordinate is out of bounds.- Parameters:
x- The x co-ordinate of the pointy- The y co-ordinate of the pointround- Round up to next character if past the middle of a character?- Since:
- jEdit 3.2pre6
-
xToScreenLineOffset
public int xToScreenLineOffset(int screenLine, int x, boolean round)Converts a point in a given screen line to an offset.- Parameters:
x- The x co-ordinate of the pointscreenLine- The screen lineround- Round up to next character if past the middle of a character?- Since:
- jEdit 3.2pre6
-
offsetToXY
public java.awt.Point offsetToXY(int offset)
Converts an offset into a point in the text area painter's co-ordinate space.- Parameters:
offset- The offset- Returns:
- The location of the offset on screen, or
nullif the specified offset is not visible
-
offsetToXY
public java.awt.Point offsetToXY(int line, int offset)Converts an offset into a point in the text area painter's co-ordinate space.- Parameters:
line- The lineoffset- The offset- Returns:
- The location of the offset on screen, or
nullif the specified offset is not visible
-
offsetToXY
public java.awt.Point offsetToXY(int line, int offset, java.awt.Point retVal)Converts a line,offset pair into an x,y (pixel) point relative to the upper left corner (0,0) of the text area.- Parameters:
line- The physical line number (from top of document)offset- The offset in characters, from the start of the lineretVal- The point to store the return value in- Returns:
retValfor convenience, ornullif the specified offset is not visible- Since:
- jEdit 4.0pre4
-
invalidateScreenLineRange
public void invalidateScreenLineRange(int start, int end)Marks a range of screen lines as needing a repaint.- Parameters:
start- The first lineend- The last line- Since:
- jEdit 4.0pre4
-
invalidateLine
public void invalidateLine(int line)
Marks a line as needing a repaint.- Parameters:
line- The physical line to invalidate
-
invalidateLineRange
public void invalidateLineRange(int start, int end)Marks a range of physical lines as needing a repaint.- Parameters:
start- The first line to invalidateend- The last line to invalidate
-
getBufferLength
public final int getBufferLength()
Returns the length of the buffer.
-
getLineCount
public final int getLineCount()
Returns the number of physical lines in the buffer.
-
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 (physical 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 (physical 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 final java.lang.String getText(int start, int len)Returns the specified substring of the buffer.- Parameters:
start- The start offsetlen- The length of the substring- Returns:
- The substring
-
getText
public final void getText(int start, int len, javax.swing.text.Segment segment)Copies the specified substring of the buffer into a segment.- Parameters:
start- The start offsetlen- The length of the substringsegment- The segment
-
getText
public java.lang.String getText()
Returns the entire text of this text area.
-
getLineText
public final java.lang.String getLineText(int lineIndex)
Returns the text on the specified line.- Parameters:
lineIndex- the line number- Returns:
- The text, or null if the lineIndex is invalid
-
getLineText
public final void getLineText(int lineIndex, javax.swing.text.Segment segment)Copies the text on the specified line into a Segment. If lineIndex is invalid, the segment will contain a null string.- Parameters:
lineIndex- The line number (physical line)segment- the segment into which the data will be stored.
-
getVisibleLineText
public java.lang.String getVisibleLineText(int screenLine)
Returns the visible part of the given line- Parameters:
screenLine- the screenLine- Returns:
- the visible text
- Since:
- 4.5pre1
-
getVisibleLineText
public void getVisibleLineText(int screenLine, javax.swing.text.Segment segment)Returns the visible part of the given line- Parameters:
screenLine- the screenLinesegment- the segment into which the data will be stored.- Since:
- 4.5pre1
-
getVisibleLineSegment
public java.lang.CharSequence getVisibleLineSegment(int screenLine)
Returns the visible part of the given line in a CharSequence. The buffer data are not copied. so this should be used in EDT thread- Parameters:
screenLine- the screenLine- Returns:
- the visible text
- Since:
- 4.5pre1
-
setText
public void setText(java.lang.String text)
Sets the entire text of this text area.- Parameters:
text- the new content of the buffer
-
selectAll
public final void selectAll()
Selects all text in the buffer. Preserves the scroll position.
-
selectLine
public void selectLine()
Selects the current line.- Since:
- jEdit 2.7pre2
-
selectParagraph
public void selectParagraph()
Selects the paragraph at the caret position.- Since:
- jEdit 2.7pre2
-
selectWord
public void selectWord()
Selects the word at the caret position.- Since:
- jEdit 2.7pre2
-
selectToMatchingBracket
public Selection selectToMatchingBracket(int position, boolean quickCopy)
Selects from the bracket at the specified position to the corresponding bracket.- Since:
- jEdit 4.2pre1
-
selectToMatchingBracket
public void selectToMatchingBracket()
Selects from the bracket at the caret position to the corresponding bracket.- Since:
- jEdit 4.0pre2
-
selectBlock
public void selectBlock()
Selects the code block surrounding the caret.- Since:
- jEdit 2.7pre2
-
lineInStructureScope
public boolean lineInStructureScope(int line)
Returns if the specified line is contained in the currently matched structure's scope.- Since:
- jEdit 4.2pre3
-
invertSelection
public final void invertSelection()
Inverts the selection.- Since:
- jEdit 4.0pre1
-
getSelectionCount
public int getSelectionCount()
Returns the number of selections. This can be used to test for the existence of selections.- Since:
- jEdit 3.2pre2
-
getSelection
@Nonnull public Selection[] getSelection()
Returns the current selection.- Since:
- jEdit 3.2pre1
-
getSelection
public Selection getSelection(int index)
Returns the selection with the specified index. This must be between 0 and the return value ofgetSelectionCount().- Parameters:
index- the index of the selection you want- Since:
- jEdit 4.3pre1
-
getSelectionIterator
public java.util.Iterator<Selection> getSelectionIterator()
Returns the current selection.- Since:
- jEdit 4.3pre1
-
selectNone
public void selectNone()
Deselects everything.
-
setSelection
public void setSelection(Selection[] selection)
Sets the selection. Nested and overlapping selections are merged where possible. Null elements of the array are ignored.- Parameters:
selection- The new selection since jEdit 3.2pre1
-
setSelection
public void setSelection(Selection selection)
Sets the selection. Nested and overlapping selections are merged where possible.- Parameters:
selection- The new selection since jEdit 3.2pre1
-
addToSelection
public void addToSelection(Selection[] selection)
Adds to the selection. Nested and overlapping selections are merged where possible.- Parameters:
selection- The new selection since jEdit 3.2pre1
-
addToSelection
public void addToSelection(Selection selection)
Adds to the selection. Nested and overlapping selections are merged where possible.- Parameters:
selection- The new selection since jEdit 3.2pre1
-
getSelectionAtOffset
public Selection getSelectionAtOffset(int offset)
Returns the selection containing the specific offset, ornullif there is no selection at that offset.- Parameters:
offset- The offset- Since:
- jEdit 3.2pre1
-
removeFromSelection
public void removeFromSelection(Selection sel)
Deactivates the specified selection.- Parameters:
sel- The selection- Since:
- jEdit 3.2pre1
-
removeFromSelection
public void removeFromSelection(int offset)
Deactivates the selection at the specified offset. If there is no selection at that offset, does nothing.- Parameters:
offset- The offset- Since:
- jEdit 3.2pre1
-
resizeSelection
public void resizeSelection(int offset, int end, int extraEndVirt, boolean rect)Resizes the selection at the specified offset, or creates a new one if there is no selection at the specified offset. This is a utility method that is mainly useful in the mouse event handler because it handles the case of end being before offset gracefully (unlike the rest of the selection API).- Parameters:
offset- The offsetend- The new selection endextraEndVirt- Only for rectangular selections - specifies how far it extends into virtual space.rect- Make the selection rectangular?- Since:
- jEdit 3.2pre1
-
extendSelection
public void extendSelection(int offset, int end)Extends the selection at the specified offset, or creates a new one if there is no selection at the specified offset. This is different from resizing in that the new chunk is added to the selection in question, instead of replacing it.- Parameters:
offset- The offsetend- The new selection end- Since:
- jEdit 3.2pre1
-
extendSelection
public void extendSelection(int offset, int end, int extraStartVirt, int extraEndVirt)Extends the selection at the specified offset, or creates a new one if there is no selection at the specified offset. This is different from resizing in that the new chunk is added to the selection in question, instead of replacing it.- Parameters:
offset- The offsetend- The new selection endextraStartVirt- Extra virtual space at the startextraEndVirt- Extra virtual space at the end- Since:
- jEdit 4.2pre1
-
getSelectedText
public java.lang.String getSelectedText(Selection s)
Returns the text in the specified selection.- Parameters:
s- The selection- Since:
- jEdit 3.2pre1
-
getSelectedText
public java.lang.String getSelectedText(java.lang.String separator)
Returns the text in all active selections.- Parameters:
separator- The string to insert between each text chunk (for example, a newline)- Since:
- jEdit 3.2pre1
-
getSelectedText
public java.lang.String getSelectedText()
Returns the text in all active selections, with a newline between each text chunk.
-
setSelectedText
public void setSelectedText(Selection s, java.lang.String selectedText)
Replaces the selection with the specified text.- Parameters:
s- The selectionselectedText- The new text- Since:
- jEdit 3.2pre1
-
setSelectedText
public void setSelectedText(java.lang.String selectedText)
Replaces the selection at the caret with the specified text. If there is no selection at the caret, the text is inserted at the caret position.
-
setSelectedText
public void setSelectedText(java.lang.String selectedText, boolean moveCaret)Replaces the selection at the caret with the specified text. If there is no selection at the caret, the text is inserted at the caret position.- Parameters:
selectedText- The new selectionmoveCaret- Move caret to insertion location if necessary- Since:
- jEdit 4.2pre5
-
replaceSelection
public int replaceSelection(java.lang.String selectedText)
Set the selection, but does not deactivate it, and does not move the caret. Please usesetSelectedText(String)instead.- Parameters:
selectedText- The new selection- Returns:
- The new caret position
- Since:
- 4.3pre1
-
getSelectedLines
public int[] getSelectedLines()
Returns a sorted array of line numbers on which a selection or selections are present.This method is the most convenient way to iterate through selected lines in a buffer. The line numbers in the array returned by this method can be passed as a parameter to such methods as
JEditBuffer.getLineText(int).- Returns:
- Non-null, non-zero sized array of line indexes. If no lines are actually selected, return the caret line in the array.
- Since:
- jEdit 3.2pre1
-
caretAutoScroll
public boolean caretAutoScroll()
Return if change in buffer should scroll this text area.- Since:
- jEdit 4.3pre2
-
addStructureMatcher
public void addStructureMatcher(StructureMatcher matcher)
Adds a structure matcher.- Since:
- jEdit 4.2pre3
-
removeStructureMatcher
public void removeStructureMatcher(StructureMatcher matcher)
Removes a structure matcher.- Since:
- jEdit 4.2pre3
-
getStructureMatch
public StructureMatcher.Match getStructureMatch()
Returns the structure element (bracket, or XML tag, etc) matching the one before the caret.- Since:
- jEdit 4.2pre3
-
blinkCaret
public final void blinkCaret()
Blinks the caret.
-
centerCaret
public void centerCaret()
Centers the caret on the screen.- Since:
- jEdit 2.7pre2
-
scrollAndCenterCaret
public void scrollAndCenterCaret()
Tries to scroll the textArea so that the caret is centered on the screen. Sometimes gets confused by folds but at least makes the caret visible and guesses better on subsequent attempts.- Since:
- jEdit 4.3pre15
-
setCaretPosition
public void setCaretPosition(int newCaret)
Sets the caret position and deactivates the selection.- Parameters:
newCaret- The caret position
-
setCaretPosition
public void setCaretPosition(int newCaret, boolean doElectricScroll)Sets the caret position and deactivates the selection.- Parameters:
newCaret- The caret positiondoElectricScroll- Do electric scrolling?
-
moveCaretPosition
public void moveCaretPosition(int newCaret)
Sets the caret position without deactivating the selection.- Parameters:
newCaret- The caret position
-
moveCaretPosition
public void moveCaretPosition(int newCaret, boolean doElectricScroll)Sets the caret position without deactivating the selection.- Parameters:
newCaret- The caret positiondoElectricScroll- Do electric scrolling?
-
moveCaretPosition
public void moveCaretPosition(int newCaret, int scrollMode)Sets the caret position without deactivating the selection.- Parameters:
newCaret- The caret positionscrollMode- The scroll mode (NO_SCROLL, NORMAL_SCROLL, or ELECTRIC_SCROLL).- Since:
- jEdit 4.2pre1
-
getCaretPosition
public int getCaretPosition()
Returns a zero-based index of the caret position.
-
getCaretLine
public int getCaretLine()
Returns the line number containing the caret.
-
getMagicCaretPosition
public int getMagicCaretPosition()
Returns an internal position used to keep the caret in one column while moving around lines of varying lengths.- Since:
- jEdit 4.2pre1
-
setMagicCaretPosition
public 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- Since:
- jEdit 4.2pre1
-
addCaretListener
public final void addCaretListener(javax.swing.event.CaretListener listener)
Adds a caret change listener to this text area.- Parameters:
listener- The listener
-
removeCaretListener
public final void removeCaretListener(javax.swing.event.CaretListener listener)
Removes a caret change listener from this text area.- Parameters:
listener- The listener
-
goToNextBracket
public void goToNextBracket(boolean select)
Moves the caret to the next closing bracket.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2.
-
goToNextCharacter
public void goToNextCharacter(boolean select)
Moves the caret to the next character.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2.
-
goToNextLine
public void goToNextLine(boolean select)
Move the caret to the next line.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToNextPage
public void goToNextPage(boolean select)
Moves the caret to the next screenful.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2.
-
goToNextParagraph
public void goToNextParagraph(boolean select)
Moves the caret to the start of the next paragraph.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToNextWord
public void goToNextWord(boolean select)
Moves the caret to the start of the next word. Note that if the "view.eatWhitespace" boolean propery is false, this method moves the caret to the end of the current word instead.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToNextWord
public void goToNextWord(boolean select, boolean eatWhitespace)Moves the caret to the start of the next word.- Since:
- jEdit 4.1pre5
-
goToPrevBracket
public void goToPrevBracket(boolean select)
Moves the caret to the previous bracket.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToPrevCharacter
public void goToPrevCharacter(boolean select)
Moves the caret to the previous character.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2.
-
goToPrevLine
public void goToPrevLine(boolean select)
Moves the caret to the previous line.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToPrevPage
public void goToPrevPage(boolean select)
Moves the caret to the previous screenful.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToPrevParagraph
public void goToPrevParagraph(boolean select)
Moves the caret to the start of the previous paragraph.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToPrevWord
public void goToPrevWord(boolean select)
Moves the caret to the start of the previous word.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToPrevWord
public void goToPrevWord(boolean select, boolean eatWhitespace)Moves the caret to the start of the previous word.- Parameters:
eatWhitespace- If true, will eat whitespace- Since:
- jEdit 4.1pre5
-
goToPrevWord
public void goToPrevWord(boolean select, boolean eatWhitespace, boolean eatOnlyAfterWord)Moves the caret to the start of the previous word.- Parameters:
eatWhitespace- If true, will eat whitespaceeatOnlyAfterWord- Eat only whitespace after a word, in effect this goes to actual word starts even if eating- Since:
- jEdit 4.4pre1
-
home
public void home(boolean select)
A "dumb home" action which only has 2 states: start of the whitespace or start of line- Parameters:
select- true if we also want to select from the cursor- Since:
- jedit 4.3pre18
-
end
public void end(boolean select)
a dumb end action which only has 2 states: end of whitespace or end of line- Parameters:
select- true if we also want to select from the cursor- Since:
- jedit 4.3pre18
-
smartHome
public void smartHome(boolean select)
On subsequent invocations, first moves the caret to the first non-whitespace character of the line, then the beginning of the line, then to the first visible line.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 4.3pre7
-
smartEnd
public void smartEnd(boolean select)
Has 4 states based on # of invocations: 1. last character of code (before inline comment) 2. last non whitespace character of the line 3. end of line 4. end of last visible line- Parameters:
select- true if you want to extend selection- Since:
- jEdit 4.3pre18
-
goToStartOfLine
public void goToStartOfLine(boolean select)
Moves the caret to the beginning of the current line.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToEndOfLine
public void goToEndOfLine(boolean select)
Moves the caret to the end of the current line.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToEndOfCode
public void goToEndOfCode(boolean select)
Moves the caret to the end of the code present on the current line, before the comments and whitespace.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 4.3pre18
-
goToStartOfWhiteSpace
public void goToStartOfWhiteSpace(boolean select)
Moves the caret to the first non-whitespace character of the current line.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToEndOfWhiteSpace
public void goToEndOfWhiteSpace(boolean select)
Moves the caret to the last non-whitespace character of the current line.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToFirstVisibleLine
public void goToFirstVisibleLine(boolean select)
Moves the caret to the first visible line.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToLastVisibleLine
public void goToLastVisibleLine(boolean select)
Moves the caret to the last visible line.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 2.7pre2
-
goToBufferStart
public void goToBufferStart(boolean select)
Moves the caret to the beginning of the buffer.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 4.0pre3
-
goToBufferEnd
public void goToBufferEnd(boolean select)
Moves the caret to the end of the buffer.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 4.0pre3
-
goToMatchingBracket
public void goToMatchingBracket()
Moves the caret to the bracket matching the one before the caret.- Since:
- jEdit 2.7pre3
-
userInput
public void userInput(char ch)
Handles the insertion of the specified character. It performs the following operations above and beyond simply inserting the text:- Inserting a TAB with a selection will shift to the right
- Inserting a BACK_SPACE or a DELETE will remove a character
- Inserting an indent open/close bracket will re-indent the current line as necessary
- Parameters:
ch- The character- Since:
- jEdit 4.3pre7
- 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 overwrite mode.
-
toggleOverwriteEnabled
public final void toggleOverwriteEnabled()
Toggles overwrite mode.- Since:
- jEdit 2.7pre2
-
backspace
public void backspace()
Deletes the character before the caret, or the selection, if one is active.- Since:
- jEdit 2.7pre2
-
backspaceWord
public void backspaceWord()
Deletes the word before the caret.- Since:
- jEdit 2.7pre2
-
backspaceWord
public void backspaceWord(boolean eatWhitespace)
Deletes the word before the caret.- Parameters:
eatWhitespace- If true, will eat whitespace- Since:
- jEdit 4.2pre5
-
backspaceWord
public void backspaceWord(boolean eatWhitespace, boolean eatOnlyAfterWord)Deletes the word before the caret.- Parameters:
eatWhitespace- If true, will eat whitespaceeatOnlyAfterWord- Eat only whitespace after a word, in effect this goes to actual word starts even if eating- Since:
- jEdit 4.4pre1
-
delete
public void delete()
Deletes the character after the caret.- Since:
- jEdit 2.7pre2
-
deleteToEndOfLine
public void deleteToEndOfLine()
Deletes from the caret to the end of the current line.- Since:
- jEdit 2.7pre2
-
deleteLine
public void deleteLine()
Deletes the line containing the caret.- Since:
- jEdit 2.7pre2
-
deleteParagraph
public void deleteParagraph()
Deletes the paragraph containing the caret.- Since:
- jEdit 2.7pre2
-
deleteToStartOfLine
public void deleteToStartOfLine()
Deletes from the caret to the beginning of the current line.- Since:
- jEdit 2.7pre2
-
deleteWord
public void deleteWord()
Deletes the word in front of the caret.- Since:
- jEdit 2.7pre2
-
deleteWord
public void deleteWord(boolean eatWhitespace)
Deletes the word in front of the caret. . * @param eatWhitespace If true, will eat whitespace- Since:
- jEdit 4.2pre5
-
isMultipleSelectionEnabled
public final boolean isMultipleSelectionEnabled()
Returns if multiple selection is enabled.- Since:
- jEdit 3.2pre1
-
toggleMultipleSelectionEnabled
public final void toggleMultipleSelectionEnabled()
Toggles multiple selection.- Since:
- jEdit 3.2pre1
-
setMultipleSelectionEnabled
public final void setMultipleSelectionEnabled(boolean multi)
Set multiple selection on or off according to the value ofmulti. This only affects the ability to make multiple selections in the user interface; macros and plugins can manipulate them regardless of the setting of this flag. In fact, in most cases, calling this method should not be necessary.- Parameters:
multi- Should multiple selection be enabled?- Since:
- jEdit 3.2pre1
-
isRectangularSelectionEnabled
public final boolean isRectangularSelectionEnabled()
Returns if rectangular selection is enabled.- Since:
- jEdit 4.2pre1
-
toggleRectangularSelectionEnabled
public final void toggleRectangularSelectionEnabled()
Toggles rectangular selection.- Since:
- jEdit 4.2pre1
-
setRectangularSelectionEnabled
public final void setRectangularSelectionEnabled(boolean rectangularSelectionMode)
Set rectangular selection on or off according to the value ofrectangularSelectionMode. This only affects the ability to make multiple selections from the keyboard. A rectangular selection can always be created by dragging with the mouse by holding down Control, regardless of the state of this flag.- Parameters:
rectangularSelectionMode- Should rectangular selection be enabled?- Since:
- jEdit 4.2pre1
-
goToParentFold
public void goToParentFold()
Moves the caret to the fold containing the one at the caret position.- Since:
- jEdit 4.0pre3
-
goToNextFold
public void goToNextFold(boolean select)
Moves the caret to the next fold.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 4.0pre3
-
goToPrevFold
public void goToPrevFold(boolean select)
Moves the caret to the previous fold.- Parameters:
select- true if you want to extend selection- Since:
- jEdit 4.0pre3
-
collapseFold
public void collapseFold()
LikeDisplayManager.collapseFold(int), but also moves the caret to the first line of the fold.- Since:
- jEdit 4.0pre3
-
collapseFold
public void collapseFold(int line)
LikeDisplayManager.collapseFold(int), but also moves the caret to the first line of the fold.- Parameters:
line- the physical line index of the fold that we want to collapse- Since:
- jEdit 4.3pre7
-
expandFold
public void expandFold(boolean fully)
LikeDisplayManager.expandFold(int,boolean), but also moves the caret to the first sub-fold.- Parameters:
fully- If true, all subfolds will also be expanded- Since:
- jEdit 4.0pre3
-
selectFold
public void selectFold()
Selects the fold that contains the caret line number.- Since:
- jEdit 3.1pre3
-
selectFold
public void selectFold(int line)
Selects the fold that contains the specified line number.- Parameters:
line- The line number- Since:
- jEdit 4.0pre1
-
narrowToFold
public void narrowToFold()
Hides all lines except those in the fold containing the caret.- Since:
- jEdit 4.0pre1
-
narrowToSelection
public void narrowToSelection()
Hides all lines except those in the selection.- Since:
- jEdit 4.0pre1
-
addExplicitFold
public void addExplicitFold() throws TextAreaExceptionSurrounds the selection with explicit fold markers.- Throws:
TextAreaException- an exception thrown if the folding mode is not explicit- Since:
- jEdit 4.0pre3
-
lineComment
public void lineComment()
Prepends each line of the selection with the line comment string.- Since:
- jEdit 3.2pre1
-
rangeComment
public void rangeComment()
Adds comment start and end strings to the beginning and end of the selection.- Since:
- jEdit 3.2pre1
-
formatParagraph
public void formatParagraph() throws TextAreaExceptionFormats the paragraph containing the caret.- Throws:
TextAreaException- Since:
- jEdit 2.7pre2
-
spacesToTabs
public void spacesToTabs()
Converts spaces to tabs in the selection.- Since:
- jEdit 2.7pre2
-
tabsToSpaces
public void tabsToSpaces()
Converts tabs to spaces in the selection.- Since:
- jEdit 2.7pre2
-
toUpperCase
public void toUpperCase()
Converts the selected text to upper case.- Since:
- jEdit 2.7pre2
-
toLowerCase
public void toLowerCase()
Converts the selected text to lower case.- Since:
- jEdit 2.7pre2
-
removeTrailingWhiteSpace
public void removeTrailingWhiteSpace()
Removes trailing whitespace from all lines in the selection.- Since:
- jEdit 2.7pre2
-
insertEnterAndIndent
public void insertEnterAndIndent()
Inserts a line break and indents the new line. Moves the caret to the first non-whitespace character of the new line. If the newline character is an electric key the current line will also be re-indented.
-
insertTabAndIndent
public void insertTabAndIndent()
-
indentSelectedLines
public void indentSelectedLines()
Indents all selected lines.- Since:
- jEdit 3.1pre3
-
turnOnElasticTabstops
public void turnOnElasticTabstops()
Turn ON elastic tab stops.
-
shiftIndentLeft
public void shiftIndentLeft()
Shifts the indent to the left.- Since:
- jEdit 2.7pre2
-
shiftIndentRight
public void shiftIndentRight()
Shifts the indent to the right.- Since:
- jEdit 2.7pre2
-
joinLines
public void joinLines()
Joins the current and the next line, or joins all lines in selections.- Since:
- jEdit 2.7pre2
-
addLeftOfScrollBar
public void addLeftOfScrollBar(java.awt.Component comp)
Adds a component to the left side of the box left of the vertical scroll bar. The ErrorList plugin uses this to show a global error overview, for example. It is possible for more than one component to be added, each is added to the left side of the box in turn. Adding to the left ensures the scrollbar is always right of all added components.- Parameters:
comp- The component- Since:
- jEdit 4.2pre1
-
removeLeftOfScrollBar
public void removeLeftOfScrollBar(java.awt.Component comp)
Removes a component from the box left of the vertical scroll bar.- Parameters:
comp- The component- Since:
- jEdit 4.2pre1
-
addNotify
public void addNotify()
Called by the AWT when this component is added to a parent. Adds document listener.- Overrides:
addNotifyin classjavax.swing.JComponent
-
removeNotify
public void removeNotify()
Called by the AWT when this component is removed from it's parent. This clears the pointer to the currently focused component. Also removes document listener.- Overrides:
removeNotifyin classjavax.swing.JComponent
-
getFocusTraversalKeysEnabled
public boolean getFocusTraversalKeysEnabled()
Java 1.4 compatibility fix to make Tab key work.- Overrides:
getFocusTraversalKeysEnabledin classjava.awt.Component- Since:
- jEdit 3.2pre4
-
getFocusCycleRoot
public boolean getFocusCycleRoot()
Java 1.4 compatibility fix to make Tab traversal work in a sane manner.- Since:
- jEdit 4.2pre3
-
processKeyEvent
public void processKeyEvent(java.awt.event.KeyEvent evt)
- Overrides:
processKeyEventin classjavax.swing.JComponent
-
addTopComponent
public void addTopComponent(java.awt.Component comp)
Adds a component above the gutter, text area, and vertical scroll bar.- Since:
- jEdit 4.2pre3
-
removeTopComponent
public void removeTopComponent(java.awt.Component comp)
Removes a component from above the gutter, text area, and vertical scroll bar.- Since:
- jEdit 4.2pre3
-
addTopLeftComponent
public void addTopLeftComponent(java.awt.Component comp)
Adds a component above the gutter.- Since:
- jEdit 5.2pre1
-
addTopRightComponent
public void addTopRightComponent(java.awt.Component comp)
Adds a component above the vertical scroll bar.- Since:
- jEdit 5.2pre1
-
addBottomLeftComponent
public void addBottomLeftComponent(java.awt.Component comp)
Adds a component below the gutter.- Since:
- jEdit 5.2pre1
-
addBottomRightComponent
public void addBottomRightComponent(java.awt.Component comp)
Adds a component below the vertical scroll bar.- Since:
- jEdit 5.2pre1
-
getInputMethodRequests
public java.awt.im.InputMethodRequests getInputMethodRequests()
- Overrides:
getInputMethodRequestsin classjava.awt.Component
-
addStatusListener
public final void addStatusListener(StatusListener listener)
Adds a scroll listener to this text area.- Parameters:
listener- The listener- Since:
- jEdit 4.3pre2
-
removeStatusListener
public final void removeStatusListener(StatusListener listener)
Removes a scroll listener from this text area.- Parameters:
listener- The listener- Since:
- jEdit 4.3pre2
-
propertiesChanged
public void propertiesChanged()
Called by jEdit when necessary. Plugins should not call this method.
-
addActionSet
public void addActionSet(JEditActionSet<JEditBeanShellAction> actionSet)
Adds a new action set to the textarea's list of ActionSets. Call this only on standalone textarea- Parameters:
actionSet- the actionSet to add- Since:
- jEdit 4.3pre13
-
getMarkPosition
@Deprecated public final int getMarkPosition()
Deprecated.Do not use.
-
isCaretVisible
public final boolean isCaretVisible()
Returns true if the caret is visible, false otherwise.
-
insert
protected void insert(java.lang.String str, boolean indent)
-
userInputTab
protected void userInputTab()
-
doWordWrap
protected boolean doWordWrap(boolean spaceInserted)
Does hard wrap.
-
addExplicitFold
protected int addExplicitFold(int caretStart, int caretEnd, int lineStart, int lineEnd)Add an explicit fold. You should call this method inside a compoundEdit in the buffer. You must also check if the buffer fold mode is explicit before calling this method.- Parameters:
caretStart- the starting offsetcaretEnd- the end offsetlineStart- the start linelineEnd- the end line- Since:
- jEdit 4.3pre3
-
isRightClickPopupEnabled
public boolean isRightClickPopupEnabled()
Returns if the right click popup menu is enabled. The Gestures plugin uses this API.- Since:
- jEdit 4.2pre13
-
setRightClickPopupEnabled
public void setRightClickPopupEnabled(boolean popupEnabled)
Sets if the right click popup menu is enabled. The Gestures plugin uses this API.- Since:
- jEdit 4.2pre13
-
getRightClickPopup
public final javax.swing.JPopupMenu getRightClickPopup()
Returns the right click popup menu.
-
setRightClickPopup
public final void setRightClickPopup(javax.swing.JPopupMenu popup)
Sets the right click popup menu.- Parameters:
popup- The popup
-
handlePopupTrigger
public void handlePopupTrigger(java.awt.event.MouseEvent evt)
Do the same thing as right-clicking on the text area. The Gestures plugin uses this API.- Since:
- jEdit 4.2pre13
-
createPopupMenu
public void createPopupMenu(java.awt.event.MouseEvent evt)
Creates the popup menu. If you want a popup menu, don't forget in your class to callsetRightClickPopupEnabled(boolean)to enable the popup menu- Since:
- 4.3pre15
-
showPopupMenu
public void showPopupMenu()
Shows the popup menu below the current caret position.- Since:
- 4.3pre10
-
showPopupMenu
@Deprecated public static void showPopupMenu(javax.swing.JPopupMenu popup, java.awt.Component comp, int x, int y, boolean point)Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.- Parameters:
popup- The popup menucomp- The component to show it forx- The x co-ordinatey- The y co-ordinatepoint- If true, then the popup originates from a single point; otherwise it will originate from the component itself. This affects positioning in the case where the popup does not fit onscreen. FIXME: move parts of GUIUtilities compatible with standalone TextArea in a separate class, to prevent such copies- Since:
- jEdit 4.1pre1
-
getTabExpander
public javax.swing.text.TabExpander getTabExpander()
-
-