Moderator: robert
Next steps: test this a lot more, and then think about ways to optimize this approach (currently the whole document till the current line is scanned to find the tokens for a line).
Index: src/org/fife/ui/rsyntaxtextarea/TokenMakerBase.java
===================================================================
--- src/org/fife/ui/rsyntaxtextarea/TokenMakerBase.java (revision 720)
+++ src/org/fife/ui/rsyntaxtextarea/TokenMakerBase.java (working copy)
@@ -9,6 +9,7 @@
package org.fife.ui.rsyntaxtextarea;
import javax.swing.Action;
+import javax.swing.event.DocumentEvent;
import javax.swing.text.Segment;
@@ -132,7 +133,10 @@
}
-
+ // Doc change hooks added by Lalit
+ public void onInsert(DocumentEvent e) {}
+ public void onRemove(DocumentEvent e) {}
+
/**
* Returns whether this programming language uses curly braces
* ('<tt>{</tt>' and '<tt>}</tt>') to denote code blocks.<p>
Index: src/org/fife/ui/rsyntaxtextarea/TokenMaker.java
===================================================================
--- src/org/fife/ui/rsyntaxtextarea/TokenMaker.java (revision 720)
+++ src/org/fife/ui/rsyntaxtextarea/TokenMaker.java (working copy)
@@ -10,6 +10,7 @@
package org.fife.ui.rsyntaxtextarea;
import javax.swing.Action;
+import javax.swing.event.DocumentEvent;
import javax.swing.text.Segment;
@@ -135,7 +136,11 @@
public Token getTokenList(Segment text, int initialTokenType,
int startOffset);
-
+
+ // Doc change hooks added by Lalit
+ public void onInsert(DocumentEvent e);
+ public void onRemove(DocumentEvent e);
+
/**
* Returns whether this language is a markup language.
*
Index: src/org/fife/ui/rsyntaxtextarea/RSyntaxDocument.java
===================================================================
--- src/org/fife/ui/rsyntaxtextarea/RSyntaxDocument.java (revision 720)
+++ src/org/fife/ui/rsyntaxtextarea/RSyntaxDocument.java (working copy)
@@ -114,7 +114,8 @@
* @param e The change.
*/
protected void fireInsertUpdate(DocumentEvent e) {
-
+
+ tokenMaker.onInsert(e);
/*
* Now that the text is actually inserted into the content and
* element structure, we can update our token elements and "last
@@ -187,6 +188,8 @@
*/
protected void fireRemoveUpdate(DocumentEvent chng) {
+ tokenMaker.onRemove(chng);
+
Element lineMap = getDefaultRootElement();
int numLines = lineMap.getElementCount();
Users browsing this forum: No registered users and 2 guests