public class JEditor
extends javax.swing.JComponent
implements javax.swing.Scrollable
To use it in your app, treat it like any other component, for example:
JEditor ta = new JEditor(); ta.setTokenMarker(new JavaTokenMarker()); ta.setText("public class Test {\n" + " public static void main(String[] args) {\n" + " System.out.println(\"Hello World\");\n" + " }\n" + "}");
Modifier and Type | Class and Description |
---|---|
protected class |
JEditor.CaretBlinker |
protected class |
JEditor.DocumentHandler |
static class |
JEditor.KeyBinding
Binding record for creating key bindings.
|
protected class |
JEditor.MutableCaretEvent |
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
BOTTOM |
protected static java.lang.String |
CENTER |
static java.lang.String |
DEFAULT_KEYMAP
The default keymap that will be shared by all
JEditor instances unless they have had a different keymap set. |
protected static java.lang.String |
LEFT |
static java.lang.String |
LEFT_OF_SCROLLBAR
Adding components with this name to the editor will place them left of the horizontal scroll bar.
|
protected static java.lang.String |
RIGHT |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
JEditor()
Creates a new JEditTextArea with the default settings.
|
JEditor(CodeEditorDefaults defaults)
Creates a new JEditTextArea with the specified settings.
|
Modifier and Type | Method and Description |
---|---|
void |
addCaretListener(javax.swing.event.CaretListener listener)
Adds a caret change listener to this editor.
|
void |
addEditorStateListener(EditorStateListener listener)
Add a state listener.
|
void |
addExceptionListener(EditorExceptionListener listener)
Add an exception listener to the editor.
|
static javax.swing.text.Keymap |
addKeymap(java.lang.String nm,
javax.swing.text.Keymap parent)
Adds a new keymap into the keymap hierarchy.
|
void |
addNotify()
Called by the AWT when this component is added to a parent.
|
void |
appendText(java.lang.String text)
Append text at the end of this editor.
|
void |
appendTextline(java.lang.String text)
Append a line of text at the end of this editor.
|
void |
blinkCaret()
Blinks the caret.
|
boolean |
canRedo()
Return true if redos are allowed.
|
boolean |
canUndo()
Return true if undos are allowed.
|
void |
copy()
Places the selected text into the clipboard.
|
void |
cut()
Deletes the selected text from the editor and places it into the clipboard.
|
protected void |
documentChanged(javax.swing.event.DocumentEvent evt)
This method is fired if the underlying document is changed.
|
int |
fastOffsetToX(int line,
int offset)
Converts an offset in a line into an x co-ordinate.
|
protected void |
fireCaretEvent() |
int |
getAnchorOffset() |
int |
getBracketLine()
Returns the line of the highlighted bracket (the bracket matching the one before the caret)
|
int |
getBracketPosition()
Returns the position of the highlighted bracket (the bracket matching the one before the caret)
|
int |
getCaretLine()
Returns the caret line.
|
int |
getCaretPosition()
Returns the caret position.
|
CodeEditorDefaults |
getCodeEditorDefaults()
Return the CodeEditorDefaults.
|
javax.swing.text.Document |
getDocument()
Returns the document this editor is editing.
|
int |
getDocumentLength()
Returns the length of the document.
|
java.util.List<EditorStateListener> |
getEditorStateListeners()
Return the list of state listeners.
|
int |
getElectricScroll()
Returns the number of lines from the top and button of the editor that are always visible.
|
int |
getFirstLine()
Returns the line displayed at the editor's origin.
|
Gutter |
getGutter()
Returns the gutter to the left of the editor or null if the gutter is disabled
|
GutterHandler |
getGutterHandler()
Return the gutter handler which draws specific graphcis and handles right clicks on the gutter.
|
int |
getHorizontalOffset()
Returns the horizontal offset of drawn lines.
|
javax.swing.JScrollBar |
getHorizontalScrollBar() |
InputHandler |
getInputHandler()
Returns the input handler.
|
javax.swing.text.Keymap |
getKeymap()
Fetches the keymap currently active in this text component.
|
static javax.swing.text.Keymap |
getKeymap(java.lang.String nm)
Fetches a named keymap previously added to the document.
|
int |
getLineCount()
Returns the number of lines in the document.
|
int |
getLineEndOffset(int line)
Returns the end offset of the specified line.
|
int |
getLineLength(int line)
Returns the length of the specified line.
|
int |
getLineNumberOffset()
Return the line number offset.
|
int |
getLineOfOffset(int offset)
Returns the line containing the specified offset.
|
int |
getLineStartOffset(int line)
Returns the start offset of the specified line.
|
java.lang.String |
getLineText(int lineIndex)
Returns the text on the specified line.
|
boolean |
getLineText(int lineIndex,
javax.swing.text.Segment segment)
Copies the text on the specified line into a segment.
|
java.awt.Point |
getLocation(int offset)
Retunr the location of a position in the document.
|
int |
getMagicCaretPosition()
Returns the `magic' caret position.
|
int |
getMarkLine()
Returns the mark line.
|
int |
getMarkPosition()
Returns the mark position.
|
int |
getMaxHorizontalScrollWidth()
Return the current maximum horizontal scroll width.
|
java.awt.Dimension |
getMinimumSize() |
CodeEditorPainter |
getPainter()
Returns the object responsible for painting this editor.
|
java.awt.Dimension |
getPreferredScrollableViewportSize() |
java.awt.Dimension |
getPreferredSize() |
javax.swing.JPopupMenu |
getRightClickPopup()
Returns the right click popup menu.
|
int |
getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction) |
boolean |
getScrollableTracksViewportHeight() |
boolean |
getScrollableTracksViewportWidth() |
int |
getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction) |
java.lang.String |
getSelectedText()
Returns the selected text, or null if no selection is active.
|
int |
getSelectionEnd()
Returns the selection end offset.
|
int |
getSelectionEnd(int line)
Returns the offset where the selection ends on the specified line.
|
int |
getSelectionEndLine()
Returns the selection end line.
|
int |
getSelectionStart()
Returns the selection start offset.
|
int |
getSelectionStart(int line)
Returns the offset where the selection starts on the specified line.
|
int |
getSelectionStartLine()
Returns the selection start line.
|
SyntaxDocument |
getSyntaxDocument()
Convenience method (returns same Document as getDocument()).
|
int |
getTabSize()
Return the size of the tab.
|
java.lang.String |
getText()
Returns the entire text of the editor.
|
java.lang.String |
getText(int start,
int len)
Returns the specified substring of the document.
|
void |
getText(int start,
int len,
javax.swing.text.Segment segment)
Copies the specified substring of the document into a segment.
|
TokenMarker |
getTokenMarker()
Returns the document's token marker.
|
java.lang.String |
getUIClassID()
Return the class ID for the UI.
|
javax.swing.JScrollBar |
getVerticalScrollBar() |
int |
getVisibleLines()
Returns the number of lines visible in this editor.
|
void |
gotoAnchor()
Go to anchor position
|
boolean |
insertText(int offset,
java.lang.String text)
Insert some text at an offset position.
|
boolean |
isCaretBlinkEnabled()
Returns true if the caret is blinking, false otherwise.
|
boolean |
isCaretVisible()
Returns true if the caret is visible, false otherwise.
|
boolean |
isChanged()
Return true if the editor is changed.
|
boolean |
isEditable()
Returns true if this editor is editable, false otherwise.
|
boolean |
isOverwriteEnabled()
Returns true if overwrite mode is enabled, false otherwise.
|
boolean |
isSelectionRectangular()
Returns true if the selection is rectangular, false otherwise.
|
int |
lineToY(int line)
Converts a line index to a y co-ordinate.
|
static void |
loadKeymap(javax.swing.text.Keymap map,
JEditor.KeyBinding[] bindings,
javax.swing.Action[] actions)
Loads a keymap with a bunch of bindings.
|
void |
manageEventforKey(java.awt.event.KeyEvent event) |
int |
offsetToX(int line,
int offset)
Converts an offset in a line into an x co-ordinate.
|
void |
offsetVerticalScroll(int verticaloffset)
Sets the line displayed at the editor's origin without updating the scroll bars.
|
void |
overwriteSetSelectedText(java.lang.String str)
Similar to
setSelectedText() , but overstrikes the appropriate number of characters if overwrite mode is enabled. |
void |
paste()
Inserts the clipboard contents into the text.
|
void |
recalculateVisibleLines()
Recalculates the number of visible lines.
|
boolean |
redo()
Apply a redo if redos are allowed.
|
void |
removeCaretListener(javax.swing.event.CaretListener listener)
Removes a caret change listener from this editor.
|
void |
removeEditorStateListener(EditorStateListener listener)
Remove a state listener.
|
void |
removeExceptionListener(EditorExceptionListener listener)
Removes an exception listener from this editor.
|
void |
removeHighlighter()
Remove the CodeEditorHighlighter.
|
static javax.swing.text.Keymap |
removeKeymap(java.lang.String nm)
Removes a named keymap previously added to the document.
|
void |
removeNotify()
Called by the AWT when this component is removed from it's parent.
|
boolean |
replaceText(int startSelection,
int endSelection,
java.lang.String text)
Replace some text at an offset position.
|
boolean |
scrollTo(int line,
int offset)
Ensures that the specified line and offset is visible by scrolling the editor if necessary.
|
boolean |
scrollToCaret()
Ensures that the caret is visible by scrolling the editor if necessary.
|
void |
search()
Open a Search dialog.
|
void |
search(int offset)
Open a Search dialog.
|
boolean |
select(int start,
int end)
Selects from the start offset to the end offset.
|
void |
selectAll()
Selects all text in the document.
|
boolean |
selectNone()
Moves the mark to the caret position.
|
void |
setAnchor()
Set the anchor postion.
|
void |
setCaretBlinkEnabled(boolean caretBlinks)
Toggles caret blinking.
|
boolean |
setCaretPosition(int caret)
Sets the caret position.
|
void |
setCaretVisible(boolean caretVisible)
Sets if the caret should be visible.
|
java.lang.String |
setDefaultKeymap() |
void |
setDefaults(CodeEditorDefaults defaults)
Set the CodeEditorDefaults.
|
void |
setDocument(SyntaxDocument document)
Sets the document this editor is editing.
|
void |
setEditable(boolean editable)
Sets if this component is editable.
|
void |
setElectricScroll(int electricScroll)
Sets the number of lines from the top and bottom of the text area that are always visible
|
void |
setFirstLine(int firstLine)
Sets the line displayed at the editor's origin without updating the scroll bars.
|
void |
setGutterHandler(GutterHandler gutterHandler)
Set the gutter handler for drawing specific graphcis and handling right clicks on the gutter.
|
void |
setHighlighter(CodeEditorHighlighter highlighter)
Set the CodeEditorHighlighter.
|
void |
setHorizontalOffset(int horizontalOffset)
Sets the horizontal offset of drawn lines.
|
void |
setInputHandler(InputHandler inputHandler)
Sets the input handler.
|
void |
setKeymap(javax.swing.text.Keymap map)
Sets the keymap to use for binding events to actions.
|
void |
setLineNumberOffset(int offset)
Set the line number offset.
|
void |
setMagicCaretPosition(int magicCaret)
Sets the `magic' caret position.
|
boolean |
setOrigin(int firstLine,
int horizontalOffset)
A fast way of changing both the first line and horizontal offset.
|
void |
setOverwriteEnabled(boolean overwrite)
Sets if overwrite mode should be enabled.
|
void |
setRightClickPopup(javax.swing.JPopupMenu popup)
Sets the right click popup menu.
|
void |
setSearchEngine(SearchEngine searchEngine)
Set the search engine.
|
void |
setSelectedText(java.lang.String selectedText)
Replaces the selection with the specified text.
|
void |
setSelectionEnd(int selectionEnd)
Sets the selection end.
|
void |
setSelectionRectangular(boolean rectSelect)
Sets if the selection should be rectangular.
|
void |
setSelectionStart(int selectionStart)
Sets the selection start.
|
boolean |
setSyntax(java.lang.String syntax)
Sets the document syntax.
|
void |
setText(java.io.File file) |
void |
setText(java.util.List<java.lang.String> vtext)
Sets the entire text of the editor.
|
void |
setText(java.lang.String text)
Sets the entire text of the editor.
|
void |
setTokenMarker(TokenMarker tokenMarker)
Sets the document's token marker.
|
void |
setUnchanged()
Set the editor as unchanged.
|
boolean |
undo()
Apply an undo if undos are allowed.
|
protected void |
updateBracketHighlight(int newCaretPosition) |
void |
updateCodeEditorDefaults()
This code allows to update the defaults if the content of the CodeEditorDefaults has been modified.
|
void |
updateScrollBars()
Updates the state of the scroll bars.
|
int |
xToOffset(int line,
int x)
Converts an x co-ordinate to an offset within a line.
|
int |
xyToOffset(int x,
int y)
Converts a point to an offset, from the start of the text.
|
int |
yToLine(int y)
Converts a y co-ordinate to a line index.
|
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, getNextFocusableComponent, getPopupLocation, 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, 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
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
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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final java.lang.String DEFAULT_KEYMAP
JEditor
instances unless they have had a different keymap set.public static java.lang.String LEFT_OF_SCROLLBAR
protected static java.lang.String CENTER
protected static java.lang.String LEFT
protected static java.lang.String RIGHT
protected static java.lang.String BOTTOM
public JEditor()
public JEditor(CodeEditorDefaults defaults)
defaults
- The default settingspublic CodeEditorDefaults getCodeEditorDefaults()
public void updateCodeEditorDefaults()
public void addEditorStateListener(EditorStateListener listener)
listener
- the listenerpublic java.util.List<EditorStateListener> getEditorStateListeners()
public void removeEditorStateListener(EditorStateListener listener)
listener
- the listenerpublic void setUnchanged()
public boolean isChanged()
public void setGutterHandler(GutterHandler gutterHandler)
Gutter.setGutterHandler(org.jeditor.gui.GutterHandler)
method.gutterHandler
- the gutter handlerpublic GutterHandler getGutterHandler()
public void setSearchEngine(SearchEngine searchEngine)
searchEngine
- the search enginepublic int getTabSize()
public java.lang.String getUIClassID()
getUIClassID
in class javax.swing.JComponent
JComponent.getUIClassID()
public javax.swing.text.Keymap getKeymap()
public static javax.swing.text.Keymap addKeymap(java.lang.String nm, javax.swing.text.Keymap parent)
nm
- the name of the keymap (must be unique within the collection of named keymaps in the document); the name may be
null
if the keymap is unnamed, but the caller is responsible for managing the reference returned as an unnamed keymap
can't be fetched by nameparent
- the parent keymap; this may be null
if unspecified bindings need not be resolved in some other keymappublic static javax.swing.text.Keymap removeKeymap(java.lang.String nm)
null
names may not be removed in this way.nm
- the name of the keymap to removepublic static javax.swing.text.Keymap getKeymap(java.lang.String nm)
null
-named keymaps.nm
- the name of the keymappublic void setKeymap(javax.swing.text.Keymap map)
null
effectively disables keyboard input. A
PropertyChange event ("keymap") is fired when a new keymap is installed.map
- the keymapgetKeymap()
public java.awt.Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize
in interface javax.swing.Scrollable
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface javax.swing.Scrollable
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableBlockIncrement
in interface javax.swing.Scrollable
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
public boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth
in interface javax.swing.Scrollable
public boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight
in interface javax.swing.Scrollable
public static void loadKeymap(javax.swing.text.Keymap map, JEditor.KeyBinding[] bindings, javax.swing.Action[] actions)
static final JTextComponent.KeyBinding[] defaultBindings = { new JTextComponent.KeyBinding( KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK), DefaultEditorKit.copyAction), new JTextComponent.KeyBinding( KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK), DefaultEditorKit.pasteAction), new JTextComponent.KeyBinding( KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK), DefaultEditorKit.cutAction), }; JTextComponent c = new JTextPane(); Keymap k = c.getKeymap(); JTextComponent.loadKeymap(k, defaultBindings, c.getActions());The sets of bindings and actions may be empty but must be non null.
map
- the keymapbindings
- the bindingsactions
- the set of actionspublic java.lang.String setDefaultKeymap()
public void manageEventforKey(java.awt.event.KeyEvent event)
public void setDefaults(CodeEditorDefaults defaults)
defaults
- the CodeEditorDefaultspublic void setHighlighter(CodeEditorHighlighter highlighter)
highlighter
- the CodeEditorHighlighterpublic void removeHighlighter()
public void setLineNumberOffset(int offset)
offset
- the line number offsetpublic int getLineNumberOffset()
public javax.swing.JScrollBar getHorizontalScrollBar()
public javax.swing.JScrollBar getVerticalScrollBar()
public final CodeEditorPainter getPainter()
public final Gutter getGutter()
public final InputHandler getInputHandler()
public void gotoAnchor()
public void setAnchor()
public int getAnchorOffset()
public void setInputHandler(InputHandler inputHandler)
inputHandler
- The new input handlerpublic final boolean isCaretBlinkEnabled()
public void setCaretBlinkEnabled(boolean caretBlinks)
caretBlinks
- True if the caret should blink, false otherwisepublic final boolean isCaretVisible()
public void setCaretVisible(boolean caretVisible)
caretVisible
- True if the caret should be visible, false otherwisepublic final void blinkCaret()
public final int getElectricScroll()
public final void setElectricScroll(int electricScroll)
electricScroll
- The number of lines always visible from the top or bottompublic void updateScrollBars()
public final int getMaxHorizontalScrollWidth()
public final int getFirstLine()
public void setFirstLine(int firstLine)
firstLine
- the first linepublic void offsetVerticalScroll(int verticaloffset)
verticaloffset
- the vertical offsetpublic final int getVisibleLines()
public final void recalculateVisibleLines()
public final int getHorizontalOffset()
public void setHorizontalOffset(int horizontalOffset)
horizontalOffset
- offset The new horizontal offsetpublic boolean setOrigin(int firstLine, int horizontalOffset)
firstLine
- The new first linehorizontalOffset
- The new horizontal offsetpublic boolean scrollToCaret()
public boolean scrollTo(int line, int offset)
line
- The line to scroll tooffset
- The offset in the line to scroll topublic int lineToY(int line)
line
- the linepublic java.awt.Point getLocation(int offset)
offset
- the offsetpublic int yToLine(int y)
y
- the y co-ordinatepublic final int offsetToX(int line, int offset)
line
- The lineoffset
- The offset, from the start of the linepublic int fastOffsetToX(int line, int offset)
line
- The lineoffset
- The offset, from the start of the linepublic int xToOffset(int line, int x)
line
- The linex
- The x co-ordinatepublic int xyToOffset(int x, int y)
x
- The x co-ordinate of the pointy
- The y co-ordinate of the pointpublic javax.swing.text.Document getDocument()
public SyntaxDocument getSyntaxDocument()
public void setDocument(SyntaxDocument document)
document
- The documentpublic final TokenMarker getTokenMarker()
getDocument().getTokenMarker()
.public final void setTokenMarker(TokenMarker tokenMarker)
getDocument().setTokenMarker()
.tokenMarker
- The token markerpublic final boolean setSyntax(java.lang.String syntax)
setTokenMarker(org.jeditor.scripts.base.TokenMarker)
.syntax
- The syntaxpublic final int getDocumentLength()
getDocument().getLength()
.public final int getLineCount()
public final int getLineOfOffset(int offset)
offset
- The offsetpublic int getLineStartOffset(int line)
line
- The linepublic int getLineEndOffset(int line)
line
- The linepublic int getLineLength(int line)
line
- the linepublic java.lang.String getText()
public void setText(java.io.File file)
public void setText(java.lang.String text)
text
- the textpublic boolean canUndo()
public boolean canRedo()
public boolean undo()
public boolean redo()
public void setText(java.util.List<java.lang.String> vtext)
vtext
- the textpublic void appendText(java.lang.String text)
text
- the textpublic void appendTextline(java.lang.String text)
text
- the textpublic final java.lang.String getText(int start, int len)
start
- The start offsetlen
- The length of the substringpublic final void getText(int start, int len, javax.swing.text.Segment segment)
start
- The start offsetlen
- The length of the substringsegment
- The segmentpublic final java.lang.String getLineText(int lineIndex)
lineIndex
- The linepublic final boolean getLineText(int lineIndex, javax.swing.text.Segment segment)
lineIndex
- The linesegment
- the segmentpublic final int getSelectionStart()
public int getSelectionStart(int line)
line
- the linepublic final int getSelectionStartLine()
public final void setSelectionStart(int selectionStart)
selectionStart
- The selection startselect(int,int)
public final int getSelectionEnd()
public int getSelectionEnd(int line)
line
- the linepublic final int getSelectionEndLine()
public final void setSelectionEnd(int selectionEnd)
selectionEnd
- The selection endselect(int,int)
public final int getCaretPosition()
public final int getCaretLine()
public final int getMarkPosition()
getCaretPosition()
public final int getMarkLine()
public final boolean setCaretPosition(int caret)
caret
- The caret positionselect(int,int)
public final void selectAll()
public final boolean selectNone()
public boolean select(int start, int end)
start
- The start offsetend
- The end offsetpublic final java.lang.String getSelectedText()
public boolean insertText(int offset, java.lang.String text)
offset
- the offsettext
- the textpublic boolean replaceText(int startSelection, int endSelection, java.lang.String text)
startSelection
- the selection start offsetendSelection
- the selection end offsettext
- the textpublic void setSelectedText(java.lang.String selectedText)
selectedText
- The replacement text for the selectionpublic final boolean isEditable()
public final void setEditable(boolean editable)
editable
- True if this editor should be editable, false otherwisepublic final javax.swing.JPopupMenu getRightClickPopup()
public final void setRightClickPopup(javax.swing.JPopupMenu popup)
popup
- The popuppublic final int getMagicCaretPosition()
public final void setMagicCaretPosition(int magicCaret)
magicCaret
- The magic caret positionpublic void overwriteSetSelectedText(java.lang.String str)
setSelectedText()
, but overstrikes the appropriate number of characters if overwrite mode is enabled.str
- The stringsetSelectedText(String)
,
isOverwriteEnabled()
public final boolean isOverwriteEnabled()
public final void setOverwriteEnabled(boolean overwrite)
overwrite
- True if overwrite mode should be enabled, false otherwise.public final boolean isSelectionRectangular()
public final void setSelectionRectangular(boolean rectSelect)
rectSelect
- True if the selection should be rectangular, false otherwise.public final int getBracketPosition()
public final int getBracketLine()
public final void addCaretListener(javax.swing.event.CaretListener listener)
listener
- The listenerpublic final void addExceptionListener(EditorExceptionListener listener)
listener
- the exception listenerpublic final void removeExceptionListener(EditorExceptionListener listener)
listener
- The listenerpublic final void removeCaretListener(javax.swing.event.CaretListener listener)
listener
- The listenerpublic void cut()
public void copy()
public void paste()
public void search()
public void search(int offset)
offset
- the search offsetpublic void addNotify()
addNotify
in class javax.swing.JComponent
public void removeNotify()
removeNotify
in class javax.swing.JComponent
protected void fireCaretEvent()
protected void updateBracketHighlight(int newCaretPosition)
protected void documentChanged(javax.swing.event.DocumentEvent evt)
evt
- the document eventCopyright © 2016, 2017, 2018, 2019, 2023 Herve Girod. All Rights Reserved. Documentation and source under the MIT licence