Package jade.tools.gui
Class ACLTextArea
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- jade.tools.gui.ACLTextArea
-
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable
public class ACLTextArea extends JComponent
jEdit's text area component. The original file is written by Slava Pestov and altered to fit ACL/SL- Version:
- $Id$
- Author:
- Slava Pestov
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classACLTextArea.TextUtilities-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanbiasLeftprotected booleanblinkprotected static StringBOTTOMprotected intbracketLineprotected intbracketPositionprotected booleancaretBlinksprotected jade.tools.gui.ACLTextArea.MutableCaretEventcaretEventprotected static TimercaretTimerprotected booleancaretVisibleprotected static StringCENTERprotected ACLSyntaxDocumentdocumentprotected jade.tools.gui.ACLTextArea.DocumentHandlerdocumentHandlerprotected booleaneditableprotected intelectricScrollprotected intfirstLineprotected static ACLTextAreafocusedComponentprotected JScrollBarhorizontalprotected inthorizontalOffsetprotected jade.tools.gui.ACLTextArea.InputHandlerinputHandlerprotected SegmentlineSegmentprotected EventListenerListlistenerListprotected intmagicCaretprotected booleanoverwriteprotected ACLTextAreaPainterpainterprotected JPopupMenupopupprotected static StringRIGHTprotected booleanscrollBarsInitializedprotected TimerscrollTimerprotected intselectionEndprotected intselectionEndLineprotected intselectionStartprotected intselectionStartLineprotected JScrollBarverticalprotected intvisibleLines-
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description ACLTextArea()Creates a new JEditTextArea with the default settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCaretListener(CaretListener listener)Adds a caret change listener to this text area.voidblinkCaret()Blinks the caret.voidcopy()Places the selected text into the clipboard.voidcut()Deletes the selected text from the text area and places it into the clipboard.protected voiddocumentChanged(DocumentEvent evt)protected voidfireCaretEvent()voidfocusLost(FocusEvent e)Description of the MethodintgetBracketLine()Returns the line of the highlighted bracket (the bracket matching the one before the caret)intgetBracketPosition()Returns the position of the highlighted bracket (the bracket matching the one before the caret)intgetCaretLine()Returns the caret line.intgetCaretPosition()Returns the caret position.ACLSyntaxDocumentgetDocument()Returns the document this text area is editing.intgetDocumentLength()Returns the length of the document.intgetElectricScroll()Returns the number of lines from the top and button of the text area that are always visible.intgetFirstLine()Returns the line displayed at the text area's origin.intgetHorizontalOffset()Returns the horizontal offset of drawn lines.jade.tools.gui.ACLTextArea.InputHandlergetInputHandler()Returns the input handler.intgetLineCount()Returns the number of lines in the document.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.StringgetLineText(int lineIndex)Returns the text on the specified line.voidgetLineText(int lineIndex, Segment segment)Copies the text on the specified line into a segment.intgetMagicCaretPosition()Returns the `magic' caret position.intgetMarkLine()Returns the mark line.intgetMarkPosition()Returns the mark position.ACLTextAreaPaintergetPainter()Returns the object responsible for painting this text area.JPopupMenugetRightClickPopup()Returns the right click popup menu.StringgetSelectedText()Returns the selected text, or null if no selection is active.intgetSelectionEnd()Returns the selection end offset.intgetSelectionEndLine()Returns the selection end line.intgetSelectionStart()Returns the selection start offset.intgetSelectionStartLine()Returns the selection start line.StringgetText()Returns the entire text of this text area.StringgetText(int start, int len)Returns the specified substring of the document.voidgetText(int start, int len, Segment segment)Copies the specified substring of the document into a segment.ACLSLTokenMarkergetTokenMarker()Returns the document's token marker.intgetVisibleLines()Returns the number of lines visible in this text area.booleanisCaretBlinkEnabled()Returns true if the caret is blinking, false otherwise.booleanisCaretVisible()Returns true if the caret is visible, false otherwise.booleanisEditable()Returns true if this text area is editable, false otherwise.booleanisManagingFocus()Returns if this component can be traversed by pressing the Tab key.booleanisOverwriteEnabled()Returns true if overwrite mode is enabled, false otherwise.intlineToY(int line)Converts a line index to a y co-ordinate.intoffsetToX(int line, int offset)Converts an offset in a line into an x co-ordinate.voidoverwriteSetSelectedText(String str)Similar tosetSelectedText(), but overstrikes the appropriate number of characters if overwrite mode is enabled.voidpaste()Inserts the clipboard contents into the text.protected voidprocessFocusEvent(FocusEvent e)Description of the MethodvoidrecalculateVisibleLines()Recalculates the number of visible lines.voidregister(Object arg, String fieldName)Description of the MethodvoidremoveCaretListener(CaretListener listener)Removes a caret change listener from this text area.voidremoveNotify()Called by the AWT when this component is removed from it's parent.booleanscrollTo(int line, int offset)Ensures that the specified line and offset is visible by scrolling the text area if necessary.booleanscrollToCaret()Ensures that the caret is visible by scrolling the text area if necessary.voidselect(int start, int end)Selects from the start offset to the end offset.voidselectAll()Selects all text in the document.voidsetCaretBlinkEnabled(boolean caretBlinks)Toggles caret blinking.voidsetCaretPosition(int caret)Sets the caret position.voidsetCaretVisible(boolean caretVisible)Sets if the caret should be visible.voidsetDocument(ACLSyntaxDocument document)Sets the document this text area is editing.voidsetEditable(boolean editable)Sets if this component is editable.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 line displayed at the text area's origin without updating the scroll bars.voidsetHorizontalOffset(int horizontalOffset)Sets the horizontal offset of drawn lines.voidsetInputHandler(jade.tools.gui.ACLTextArea.InputHandler inputHandler)Sets the input handler.voidsetMagicCaretPosition(int magicCaret)Sets the `magic' caret position.booleansetOrigin(int firstLine, int horizontalOffset)A fast way of changing both the first line and horizontal offset.voidsetOverwriteEnabled(boolean overwrite)Sets if overwrite mode should be enabled.voidsetRightClickPopup(JPopupMenu popup)Sets the right click popup menu.voidsetSelectedText(String selectedText)Replaces the selection with the specified text.voidsetSelectionEnd(int selectionEnd)Sets the selection end.voidsetSelectionStart(int selectionStart)Sets the selection start.voidsetText(String text)Sets the entire text of this text area.voidsetTokenMarker(ACLSLTokenMarker tokenMarker)Sets the document's token marker.voidunregister(Object arg, String str)Description of the Methodvoidupdate()protected voidupdateBracketHighlight(int newCaretPosition)voidupdateScrollBars()Updates the state of the scroll bars.intxToOffset(int line, int x)Converts an x co-ordinate to an offset within a line.intxyToOffset(int x, int y)Converts a point to an offset, from the start of the text.intyToLine(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, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, 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, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
CENTER
protected static String CENTER
-
RIGHT
protected static String RIGHT
-
BOTTOM
protected static String BOTTOM
-
focusedComponent
protected static ACLTextArea focusedComponent
-
caretTimer
protected static Timer caretTimer
-
painter
protected ACLTextAreaPainter painter
-
popup
protected JPopupMenu popup
-
scrollTimer
protected Timer scrollTimer
-
listenerList
protected EventListenerList listenerList
-
caretEvent
protected jade.tools.gui.ACLTextArea.MutableCaretEvent caretEvent
-
caretBlinks
protected boolean caretBlinks
-
caretVisible
protected boolean caretVisible
-
blink
protected boolean blink
-
editable
protected boolean editable
-
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 jade.tools.gui.ACLTextArea.InputHandler inputHandler
-
document
protected ACLSyntaxDocument document
-
documentHandler
protected jade.tools.gui.ACLTextArea.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
-
-
Method Detail
-
isManagingFocus
public final boolean isManagingFocus()
Returns if this component can be traversed by pressing the Tab key. This returns false.- Overrides:
isManagingFocusin classJComponent- Returns:
- The ManagingFocus value
-
getPainter
public final ACLTextAreaPainter getPainter()
Returns the object responsible for painting this text area.- Returns:
- The Painter value
-
getInputHandler
public final jade.tools.gui.ACLTextArea.InputHandler getInputHandler()
Returns the input handler.- Returns:
- The InputHandler value
-
isCaretBlinkEnabled
public final boolean isCaretBlinkEnabled()
Returns true if the caret is blinking, false otherwise.- Returns:
- The CaretBlinkEnabled value
-
isCaretVisible
public final boolean isCaretVisible()
Returns true if the caret is visible, false otherwise.- Returns:
- The CaretVisible value
-
getElectricScroll
public final int getElectricScroll()
Returns the number of lines from the top and button of the text area that are always visible.- Returns:
- The ElectricScroll value
-
getFirstLine
public final int getFirstLine()
Returns the line displayed at the text area's origin.- Returns:
- The FirstLine value
-
getVisibleLines
public final int getVisibleLines()
Returns the number of lines visible in this text area.- Returns:
- The VisibleLines value
-
getHorizontalOffset
public final int getHorizontalOffset()
Returns the horizontal offset of drawn lines.- Returns:
- The HorizontalOffset value
-
getDocument
public final ACLSyntaxDocument getDocument()
Returns the document this text area is editing.- Returns:
- The Document value
-
getTokenMarker
public final ACLSLTokenMarker getTokenMarker()
Returns the document's token marker. Equivalent to callinggetDocument().getTokenMarker().- Returns:
- The TokenMarker value
-
getDocumentLength
public final int getDocumentLength()
Returns the length of the document. Equivalent to callinggetDocument().getLength().- Returns:
- The DocumentLength value
-
getLineCount
public final int getLineCount()
Returns the number of lines in the document.- Returns:
- The LineCount value
-
getLineOfOffset
public final int getLineOfOffset(int offset)
Returns the line containing the specified offset.- Parameters:
offset- The offset- Returns:
- The LineOfOffset value
-
getText
public final String getText(int start, int len)
Returns the specified substring of the document.- Parameters:
start- The start offsetlen- 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 offsetlen- The length of the substringsegment- 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 linesegment- Description of Parameter
-
getSelectionStart
public final int getSelectionStart()
Returns the selection start offset.- Returns:
- The SelectionStart value
-
getSelectionStartLine
public final int getSelectionStartLine()
Returns the selection start line.- Returns:
- The SelectionStartLine value
-
getSelectionEnd
public final int getSelectionEnd()
Returns the selection end offset.- Returns:
- The SelectionEnd value
-
getSelectionEndLine
public final int getSelectionEndLine()
Returns the selection end line.- Returns:
- The SelectionEndLine value
-
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.- Returns:
- The CaretPosition value
-
getCaretLine
public final int getCaretLine()
Returns the caret line.- Returns:
- The CaretLine value
-
getMarkPosition
public final int getMarkPosition()
Returns the mark position. This will be the opposite selection bound to the caret position.- Returns:
- The MarkPosition value
- See Also:
getCaretPosition()
-
getMarkLine
public final int getMarkLine()
Returns the mark line.- Returns:
- The MarkLine value
-
getSelectedText
public final String getSelectedText()
Returns the selected text, or null if no selection is active.- Returns:
- The SelectedText value
-
isEditable
public final boolean isEditable()
Returns true if this text area is editable, false otherwise.- Returns:
- The Editable value
-
getRightClickPopup
public final JPopupMenu getRightClickPopup()
Returns the right click popup menu.- Returns:
- The RightClickPopup value
-
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.- Returns:
- The MagicCaretPosition value
-
isOverwriteEnabled
public final boolean isOverwriteEnabled()
Returns true if overwrite mode is enabled, false otherwise.- Returns:
- The OverwriteEnabled value
-
getBracketPosition
public final int getBracketPosition()
Returns the position of the highlighted bracket (the bracket matching the one before the caret)- Returns:
- The BracketPosition value
-
getBracketLine
public final int getBracketLine()
Returns the line of the highlighted bracket (the bracket matching the one before the caret)- Returns:
- The BracketLine value
-
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
-
setTokenMarker
public final void setTokenMarker(ACLSLTokenMarker tokenMarker)
Sets the document's token marker. Equivalent to calinggetDocument().setTokenMarker().- Parameters:
tokenMarker- The token marker
-
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)
-
setSelectionEnd
public final void setSelectionEnd(int selectionEnd)
Sets the selection end. The new selection will be the old selection start and the bew selection end.- Parameters:
selectionEnd- The selection end- See Also:
select(int,int)
-
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)
-
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
-
setRightClickPopup
public final void setRightClickPopup(JPopupMenu popup)
Sets the right click popup menu.- Parameters:
popup- The popup
-
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
-
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.
-
blinkCaret
public final void blinkCaret()
Blinks the caret.
-
recalculateVisibleLines
public final void recalculateVisibleLines()
Recalculates the number of visible lines. This should not be called directly.
-
selectAll
public final void selectAll()
Selects all text in the document.
-
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
-
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- Returns:
- The LineLength value
-
getText
public String getText()
Returns the entire text of this text area.- Returns:
- The Text value
-
setInputHandler
public void setInputHandler(jade.tools.gui.ACLTextArea.InputHandler inputHandler)
Sets the input handler.- Parameters:
inputHandler- The new input handler
-
setCaretBlinkEnabled
public void setCaretBlinkEnabled(boolean caretBlinks)
Toggles caret blinking.- Parameters:
caretBlinks- True if the caret should blink, 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
-
setFirstLine
public void setFirstLine(int firstLine)
Sets the line displayed at the text area's origin without updating the scroll bars.- Parameters:
firstLine- The new FirstLine value
-
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 linehorizontalOffset- The new horizontal offset- Returns:
- True if any of the values were changed, false otherwise
-
setDocument
public void setDocument(ACLSyntaxDocument document)
Sets the document this text area is editing.- Parameters:
document- The document
-
setText
public void setText(String text)
Sets the entire text of this text area.- Parameters:
text- The new Text value
-
setSelectedText
public void setSelectedText(String selectedText)
Replaces the selection with the specified text.- Parameters:
selectedText- The replacement text for the selection
-
update
public void update()
-
register
public void register(Object arg, String fieldName)
Description of the Method- Parameters:
arg- Description of ParameterfieldName- Description of Parameter
-
unregister
public void unregister(Object arg, String str)
Description of the Method- Parameters:
arg- Description of Parameterstr- Description of Parameter
-
focusLost
public void focusLost(FocusEvent e)
Description of the Method- Parameters:
e- Description of Parameter
-
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.
-
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 tooffset- 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- Returns:
- Description of the Returned Value
-
yToLine
public int yToLine(int y)
Converts a y co-ordinate to a line index.- Parameters:
y- The y co-ordinate- Returns:
- Description of the Returned Value
-
offsetToX
public int offsetToX(int line, int offset)Converts an offset in a line into an x co-ordinate.- Parameters:
line- The lineoffset- The offset, from the start of the line- Returns:
- Description of the Returned Value
-
xToOffset
public int xToOffset(int line, int x)Converts an x co-ordinate to an offset within a line.- Parameters:
line- The linex- The x co-ordinate- Returns:
- Description of the Returned Value
-
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 pointy- The y co-ordinate of the point- Returns:
- Description of the Returned Value
-
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 offsetend- The end offset
-
overwriteSetSelectedText
public void overwriteSetSelectedText(String str)
Similar tosetSelectedText(), but overstrikes the appropriate number of characters if overwrite mode is enabled.- Parameters:
str- The string- See Also:
setSelectedText(String),isOverwriteEnabled()
-
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 any autoscrolling and clears the currently focused component.- Overrides:
removeNotifyin classJComponent
-
processFocusEvent
protected void processFocusEvent(FocusEvent e)
Description of the Method- Overrides:
processFocusEventin classComponent- Parameters:
e- Description of Parameter
-
fireCaretEvent
protected void fireCaretEvent()
-
updateBracketHighlight
protected void updateBracketHighlight(int newCaretPosition)
-
documentChanged
protected void documentChanged(DocumentEvent evt)
-
-