Author: mkrueger
Date: 2008-02-08 05:44:26 -0500 (Fri, 08 Feb 2008)
New Revision: 95232
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxMode.cs
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxModeService.cs
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/Document.cs
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/LineSplitter.cs
Log:
* Mono.TextEditor/Document.cs, Mono.TextEditor/LineSplitter.cs,
Mono.TextEditor.Highlighting/SyntaxMode.cs,
Mono.TextEditor.Highlighting/SyntaxModeService.cs: Fixed
highlighting bug.
Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-08
10:44:07 UTC (rev 95231)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-08
10:44:26 UTC (rev 95232)
@@ -1,3 +1,10 @@
+2008-02-08 Mike Krüger <[EMAIL PROTECTED]>
+
+ * Mono.TextEditor/Document.cs, Mono.TextEditor/LineSplitter.cs,
+ Mono.TextEditor.Highlighting/SyntaxMode.cs,
+ Mono.TextEditor.Highlighting/SyntaxModeService.cs: Fixed highlighting
+ bug.
+
2008-02-07 Mike Krüger <[EMAIL PROTECTED]>
* Mono.TextEditor/TextEditor.cs, Mono.TextEditor/TextEditorOptions.cs:
Color
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/Document.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/Document.cs
2008-02-08 10:44:07 UTC (rev 95231)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/Document.cs
2008-02-08 10:44:26 UTC (rev 95232)
@@ -111,12 +111,14 @@
redoStack.Clear ();
}
};
+
+ splitter = new LineSplitter (buffer);
+
buffer.TextReplaced += delegate(object sender,
ReplaceEventArgs args) {
- if (this.syntaxMode != null)
+ splitter.TextReplaced (sender, args);
+ if (this.syntaxMode != null)
Mono.TextEditor.Highlighting.SyntaxModeService.StartUpdate (this,
this.syntaxMode, args.Offset, args.Offset + args.Count);
};
-
- splitter = new LineSplitter (buffer);
}
class UndoOperation
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/LineSplitter.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/LineSplitter.cs
2008-02-08 10:44:07 UTC (rev 95231)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/LineSplitter.cs
2008-02-08 10:44:26 UTC (rev 95232)
@@ -59,7 +59,6 @@
public LineSplitter (IBuffer buffer)
{
lines.Clear ();
- buffer.TextReplaced += new
EventHandler<ReplaceEventArgs> (TextReplaced);
}
public LineSegment Get (int number)
@@ -86,7 +85,7 @@
return 0;
}
- void TextReplaced (object sender, ReplaceEventArgs args)
+ internal void TextReplaced (object sender, ReplaceEventArgs
args)
{
if (args.Count > 0)
TextRemove (args.Offset, args.Count);
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxMode.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxMode.cs
2008-02-08 10:44:07 UTC (rev 95231)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxMode.cs
2008-02-08 10:44:26 UTC (rev 95232)
@@ -164,15 +164,15 @@
pair = null;
curChunk = new Chunk (offset, 0, GetSpanStyle
(spanStack));
maxEnd = System.Math.Min (offset + length,
line.Offset + line.EditableLength);
-
+
int endOffset = 0;
SetSpan ();
SetTree ();
bool isNoKeyword = false;
for (int i = offset; i < maxEnd; i++) {
char ch = doc.Buffer.GetCharAt (i);
- if (curSpan != null) {
- if (!String.IsNullOrEmpty
(curSpan.End) && curSpan.End[endOffset] == ch) {
+ if (curSpan != null &&
!String.IsNullOrEmpty (curSpan.End)) {
+ if (curSpan.End[endOffset] ==
ch) {
endOffset++;
if (endOffset >=
curSpan.End.Length) {
curChunk.Length
-= curSpan.End.Length - 1;
@@ -184,8 +184,12 @@
endOffset = 0;
continue;
}
- } else {
+ } else if (endOffset != 0) {
endOffset = 0;
+ if
(curSpan.End[endOffset] == ch) {
+ i--;
+ continue;
+ }
}
}
if (spanTree != null &&
spanTree.ContainsKey (ch)) {
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxModeService.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxModeService.cs
2008-02-08 10:44:07 UTC (rev 95231)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxModeService.cs
2008-02-08 10:44:26 UTC (rev 95232)
@@ -98,36 +98,52 @@
public static void ScanSpans (Document doc, Rule rule,
Stack<Span> spanStack, int start, int end)
{
- Dictionary<char, Rule.Pair<Span, object>> tree =
rule.spanTree;
- Rule.Pair<Span, object> pair = null;
+ Dictionary<char, Rule.Pair<Span, object>> spanTree =
rule.spanTree;
+ Rule.Pair<Span, object> spanPair = null;
int endOffset = 0;
end = System.Math.Min (end, doc.Buffer.Length);
+ Span curSpan = spanStack.Count > 0 ? spanStack.Peek ()
: null;
for (int offset = start; offset < end; offset++) {
char ch = doc.Buffer.GetCharAt (offset);
- Span curSpan = spanStack.Count > 0 ?
spanStack.Peek () : null;
if (curSpan != null && !String.IsNullOrEmpty
(curSpan.End)) {
- if (endOffset < curSpan.End.Length &&
curSpan.End[endOffset] == ch) {
+ if (curSpan.End[endOffset] == ch) {
endOffset++;
if (endOffset >=
curSpan.End.Length) {
spanStack.Pop ();
+ curSpan =
spanStack.Count > 0 ? spanStack.Peek () : null;
+ endOffset = 0;
+ continue;
}
+ } else if (endOffset != 0) {
+ endOffset = 0;
+ if (curSpan.End[endOffset] ==
ch) {
+ offset--;
+ continue;
+ }
+ }
+ }
+ if (spanTree != null && spanTree.ContainsKey
(ch)) {
+ spanPair = spanTree[ch];
+ spanTree = (Dictionary<char,
Rule.Pair<Span, object>>)spanPair.o2;
+ if (spanPair.o1 != null) {
+ Span span = spanPair.o1;
+ if
(!String.IsNullOrEmpty(span.Constraint)) {
+ if
(span.Constraint.Length == 2 && span.Constraint.StartsWith ("!") && offset + 1
< end) {
+ if
(doc.Buffer.GetCharAt (offset + 1) == span.Constraint [1])
+ goto
skip;
+ }
+ }
+ spanStack.Push (span);
+ curSpan = span;
continue;
}
+ } else {
+ spanPair = null;
+ spanTree = rule.spanTree;
}
- endOffset = 0;
- if (!tree.ContainsKey (ch)) {
- tree = rule.spanTree;
- if (pair != null && pair.o1 != null)
- spanStack.Push (pair.o1);
- pair = null;
- endOffset = 0;
- continue;
- }
- pair = tree[ch];
- tree = (Dictionary<char, Rule.Pair<Span,
object>>)pair.o2;
+ skip:
+ ;
}
- if (pair != null && pair.o1 != null)
- spanStack.Push (pair.o1);
}
static void Update (object o)
@@ -137,13 +153,14 @@
SyntaxMode mode = (SyntaxMode)data[1];
int startOffset = (int)data[2];
int endOffset = (int)data[3];
+ int lineOffset = 0;
bool foundEndLine = false;
RedBlackTree<LineSegmentTree.TreeNode>.RedBlackTreeIterator iter =
doc.Splitter.GetByOffset (startOffset).Iter;
LineSegment endLine = doc.Splitter.GetByOffset
(endOffset);
Stack<Span> spanStack = iter.Current.StartSpan != null
? new Stack<Span> (iter.Current.StartSpan) : new Stack<Span> ();
do {
LineSegment line = iter.Current;
- int lineOffset = line.Offset;
+ lineOffset = line.Offset;
if (lineOffset < 0)
break;
Span[] newSpans = spanStack.ToArray ();
@@ -175,7 +192,12 @@
foundEndLine = true;
}
} while (iter.MoveNext ());
+ if (lineOffset > endLine.Offset) {
+ doc.RequestUpdate (new UpdateAll ());
+ doc.CommitDocumentUpdate ();
+ }
}
+
static Thread updateThread = null;
public static void StartUpdate (Document doc, SyntaxMode mode,
int startOffset, int endOffset)
{
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches