11 package net.sf.gridarta.textedit.textarea;
13 import javax.swing.event.DocumentEvent;
14 import javax.swing.text.BadLocationException;
15 import javax.swing.text.Element;
16 import javax.swing.text.PlainDocument;
17 import javax.swing.text.Segment;
18 import javax.swing.undo.UndoableEdit;
20 import org.jetbrains.annotations.NotNull;
21 import org.jetbrains.annotations.Nullable;
53 if (tokenMarker == null) {
57 tokenMarker.
insertLines(0, getDefaultRootElement().getElementCount());
81 final Segment lineSegment =
new Segment();
82 final Element map = getDefaultRootElement();
84 final int end = len + start;
87 for (
int i = start; i < end; i++) {
88 final Element lineElement = map.getElement(i);
89 final int lineStart = lineElement.getStartOffset();
90 getText(lineStart, lineElement.getEndOffset() - lineStart - 1, lineSegment);
93 }
catch (
final BadLocationException bl) {
134 if (tokenMarker != null) {
135 final DocumentEvent.ElementChange ch = e.getChange(getDefaultRootElement());
137 tokenMarker.
insertLines(ch.getIndex() + 1, ch.getChildrenAdded().length - ch.getChildrenRemoved().length);
141 super.fireInsertUpdate(e);
150 if (tokenMarker != null) {
151 final DocumentEvent.ElementChange ch = e.getChange(getDefaultRootElement());
153 tokenMarker.
deleteLines(ch.getIndex() + 1, ch.getChildrenRemoved().length - ch.getChildrenAdded().length);
157 super.fireRemoveUpdate(e);
void insertLines(final int index, final int lines)
Informs the token marker that lines have been inserted into the document.
A document implementation that can be tokenized by the syntax highlighting system.
void deleteLines(final int index, final int lines)
Informs the token marker that line have been deleted from the document.
void fireRemoveUpdate(@NotNull final DocumentEvent e)
We overwrite this method to update the token marker state immediately so that any event listeners get...
Base package of all Gridarta classes.
TokenMarker getTokenMarker()
Returns the token marker that is to be used to split lines of this document up into tokens...
static void beginCompoundEdit()
Starts a compound edit that can be undone in one operation.
This package contains the other part of the script editor.
static void endCompoundEdit()
Ends a compound edit that can be undone in one operation.
List< Token > markTokens(final Segment line, final int lineIndex)
A wrapper for the lower-level.
A token marker that splits lines of text into tokens.
static final long serialVersionUID
Serial Version UID.
void tokenizeLines()
Re-parses the document, by passing all lines to the token marker.
static void addUndoableEdit(@NotNull final UndoableEdit edit)
Adds an undoable edit to this document's undo list.
void tokenizeLines(final int start, final int len)
Re-parses the document, by passing the specified lines to the token marker.
void setTokenMarker(@Nullable final TokenMarker tokenMarker)
Sets the token marker that is to be used to split lines of this document up into tokens.
void fireInsertUpdate(@NotNull final DocumentEvent e)
We overwrite this method to update the token marker state immediately so that any event listeners get...