Author: mkrueger
Date: 2008-02-11 17:43:03 -0500 (Mon, 11 Feb 2008)
New Revision: 95473
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
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/LineSegment.cs
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
Log:
* Mono.TextEditor/TextViewMargin.cs, Mono.TextEditor/Document.cs,
Mono.TextEditor/LineSegment.cs,
Mono.TextEditor.Highlighting/SyntaxModeService.cs: Syntax
highlighting update is now faster. (produced too many redraws)
Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-11
22:41:47 UTC (rev 95472)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-11
22:43:03 UTC (rev 95473)
@@ -1,3 +1,10 @@
+2008-02-12 Mike Krüger <[EMAIL PROTECTED]>
+
+ * Mono.TextEditor/TextViewMargin.cs, Mono.TextEditor/Document.cs,
+ Mono.TextEditor/LineSegment.cs,
+ Mono.TextEditor.Highlighting/SyntaxModeService.cs: Syntax highlighting
+ update is now faster. (produced too many redraws)
+
2008-02-11 Mike Krüger <[EMAIL PROTECTED]>
* TangoLightStyle.xml, Mono.TextEditor.Highlighting/Style.cs,
C64Style.xml:
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-11 22:41:47 UTC (rev 95472)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/Document.cs
2008-02-11 22:43:03 UTC (rev 95473)
@@ -301,7 +301,6 @@
bool needsUpdate = foldSegments.Count !=
newSegments.Count;
foldSegments = newSegments;
if (needsUpdate) {
- System.Console.WriteLine("UPDATE!!!");
RequestUpdate (new UpdateAll ());
CommitDocumentUpdate ();
@@ -437,6 +436,7 @@
public void RequestUpdate (DocumentUpdateRequest request)
{
+// System.Console.WriteLine(request);
updateRequests.Add (request);
}
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/LineSegment.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/LineSegment.cs
2008-02-11 22:41:47 UTC (rev 95472)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/LineSegment.cs
2008-02-11 22:43:03 UTC (rev 95473)
@@ -133,7 +133,7 @@
public override string ToString ()
{
- return String.Format ("[LineSegment: Offset={0},
Length={1}, DelimiterLength={2}]", this.Offset, this.Length,
this.DelimiterLength);
+ return String.Format ("[LineSegment: Offset={0},
Length={1}, DelimiterLength={2}, StartSpan={3}]", this.Offset, this.Length,
this.DelimiterLength, StartSpan == null ? "null" : StartSpan.Length.ToString());
}
public void Dispose ()
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
2008-02-11 22:41:47 UTC (rev 95472)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
2008-02-11 22:43:03 UTC (rev 95473)
@@ -366,7 +366,7 @@
{
inSelectionDrag = false;
inDrag = false;
- if (button == 1) {
+ if (button == 1 || button == 2) {
clickLocation = VisualToDocumentLocation (x, y);
int offset = Document.LocationToOffset
(clickLocation);
if (offset < 0) {
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-11 22:41:47 UTC (rev 95472)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxModeService.cs
2008-02-11 22:43:03 UTC (rev 95473)
@@ -145,6 +145,22 @@
;
}
}
+ static bool IsEqual (Span[] spans1, Span[] spans2)
+ {
+ if (spans1 == null || spans1.Length == 0) {
+ if (spans2 == null || spans2.Length == 0)
+ return true;
+ return false;
+ }
+ if (spans1.Length != spans2.Length)
+ return false;
+ for (int i = 0; i < spans1.Length; i++) {
+ if (spans1[i] != spans2[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
static void Update (object o)
{
@@ -153,49 +169,37 @@
SyntaxMode mode = (SyntaxMode)data[1];
int startOffset = (int)data[2];
int endOffset = (int)data[3];
- int lineOffset = 0;
- bool foundEndLine = false;
- bool equal = false;
+ bool doUpdate = false;
+ LineSegment endLine = doc.Splitter.GetByOffset
(endOffset);
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;
- lineOffset = line.Offset;
- if (lineOffset < 0)
+ if (line == null || line.Offset < 0)
break;
Span[] newSpans = spanStack.ToArray ();
- if (foundEndLine) {
- if (line.StartSpan == null
|| newSpans.Length == line.StartSpan.Length) {
- equal = false;
- if (line.StartSpan != null) {
- equal = true;
- for (int i = 0; i <
newSpans.Length; i++) {
- if
(line.StartSpan[i] != newSpans[i]) {
- equal =
false;
- break;
- }
- }
- }
- if (equal)
- break;
- }
+ if (line.Offset >= endOffset) {
+ bool equal = IsEqual (line.StartSpan,
newSpans);
+ doUpdate |= !equal;
+ if (equal)
+ break;
}
line.StartSpan = newSpans.Length > 0 ? newSpans
: null;
Rule rule = mode;
if (spanStack.Count > 0 &&
!String.IsNullOrEmpty (spanStack.Peek ().Rule)) {
rule = mode.GetRule (spanStack.Peek
().Rule) ?? mode;
}
- ScanSpans (doc, rule, spanStack, lineOffset,
lineOffset + line.EditableLength);
+ ScanSpans (doc, rule, spanStack, line.Offset,
line.Offset + line.EditableLength);
+ System.Console.WriteLine(spanStack.Count);
while (spanStack.Count > 0 && spanStack.Peek
().StopAtEol)
spanStack.Pop ();
- if (line == endLine) {
- foundEndLine = true;
- }
} while (iter.MoveNext ());
- if (!equal) {
- doc.RequestUpdate (new UpdateAll ());
- doc.CommitDocumentUpdate ();
+ if (doUpdate) {
+ GLib.Timeout.Add (0, delegate {
+ doc.RequestUpdate (new UpdateAll ());
+ doc.CommitDocumentUpdate ();
+ return false;
+ });
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches