[Monodevelop-patches-list] r483 - in trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src: Document Document/HighlightingStrategy Document/LineManager Gui Util
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Tue Jan 13 20:50:42 EST 2004
Author: tberman
Date: 2004-01-13 20:50:41 -0500 (Tue, 13 Jan 2004)
New Revision: 483
Modified:
trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/DefaultDocument.cs
trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs
trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/TextWord.cs
trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/LineManager/DefaultLineManager.cs
trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/TextArea.cs
trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/TextView.cs
trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Util/RtfWriter.cs
Log:
this code breaks the entire buffer under the new string implementation, which is actually correct, it was using a negative number as a startindex to a string.ctor (char[], int, int)
Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/DefaultDocument.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/DefaultDocument.cs 2004-01-13 23:35:27 UTC (rev 482)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/DefaultDocument.cs 2004-01-14 01:50:41 UTC (rev 483)
@@ -216,17 +216,17 @@
return;
}
OnDocumentAboutToBeChanged(new DocumentEventArgs(this, offset, -1, text));
- //DateTime time = DateTime.Now;
+ DateTime time = DateTime.Now;
textBufferStrategy.Insert(offset, text);
- //time = DateTime.Now;
+ time = DateTime.Now;
lineTrackingStrategy.Insert(offset, text);
- //time = DateTime.Now;
+ time = DateTime.Now;
undoStack.Push(new UndoableInsert(this, offset, text));
- //time = DateTime.Now;
+ time = DateTime.Now;
OnDocumentChanged(new DocumentEventArgs(this, offset, -1, text));
}
Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs 2004-01-13 23:35:27 UTC (rev 482)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs 2004-01-14 01:50:41 UTC (rev 483)
@@ -612,7 +612,7 @@
}
}
- words.Add(new TextWord(currentOffset, currentLength, DigitColor, false));
+ words.Add(new TextWord(document, currentLine, currentOffset, currentLength, DigitColor, false));
currentOffset += currentLength;
currentLength = 0;
continue;
@@ -625,7 +625,7 @@
PushCurWord(document, ref markNext, words);
string regex = currentLine.GetRegString(activeSpan.End, i, document);
currentLength += regex.Length;
- words.Add(new TextWord(currentOffset, currentLength, activeSpan.EndColor, false));
+ words.Add(new TextWord(document, currentLine, currentOffset, currentLength, activeSpan.EndColor, false));
currentOffset += currentLength;
currentLength = 0;
i += regex.Length - 1;
@@ -638,15 +638,12 @@
// check for SPAN BEGIN
if (activeRuleSet != null) {
- ArrayList spans = activeRuleSet.Spans;
- int c = spans.Count;
- for (int j = 0; j < c; j ++) { Span span = (Span) spans [j];
-
+ foreach (Span span in activeRuleSet.Spans) {
if (currentLine.MatchExpr(span.Begin, i, document)) {
PushCurWord(document, ref markNext, words);
string regex = currentLine.GetRegString(span.Begin, i, document);
currentLength += regex.Length;
- words.Add(new TextWord(currentOffset, currentLength, span.BeginColor, false));
+ words.Add(new TextWord(document, currentLine, currentOffset, currentLength, span.BeginColor, false));
currentOffset += currentLength;
currentLength = 0;
@@ -727,13 +724,13 @@
}
hasDefaultColor = true;
}
- words.Add(new TextWord(currentOffset, currentLength, markNext != null ? markNext : c, hasDefaultColor));
+ words.Add(new TextWord(document, currentLine, currentOffset, currentLength, markNext != null ? markNext : c, hasDefaultColor));
} else {
HighlightColor c = markNext != null ? markNext : GetColor(activeRuleSet, document, currentLine, currentOffset, currentLength);
if (c == null) {
- words.Add(new TextWord(currentOffset, currentLength, defaultColor, true));
+ words.Add(new TextWord(document, currentLine, currentOffset, currentLength, defaultColor, true));
} else {
- words.Add(new TextWord(currentOffset, currentLength, c, false));
+ words.Add(new TextWord(document, currentLine, currentOffset, currentLength, c, false));
}
}
Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/TextWord.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/TextWord.cs 2004-01-13 23:35:27 UTC (rev 482)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/TextWord.cs 2004-01-14 01:50:41 UTC (rev 483)
@@ -25,13 +25,18 @@
public class TextWord
{
HighlightColor color;
+ LineSegment word;
+ IDocument document;
int offset;
int length;
+ TextWordType type;
- static TextWord spaceWord = new TextWord (TextWordType.Space);
- static TextWord tabWord = new TextWord (TextWordType.Tab);
+ static TextWord spaceWord = new TextWord(TextWordType.Space);
+ static TextWord tabWord = new TextWord(TextWordType.Tab);
+ public bool hasDefaultColor;
+
static public TextWord Space {
get {
return spaceWord;
@@ -46,33 +51,34 @@
public int Length {
get {
- return length;
+ if (type == TextWordType.Word) {
+ return length;
+ }
+ return 1;
}
}
public bool HasDefaultColor {
get {
- return (offset & ~(1 << 31)) != 0;
+ return hasDefaultColor;
}
}
public TextWordType Type {
get {
- return
- this == spaceWord ? TextWordType.Space :
- this == tabWord ? TextWordType.Tab :
- TextWordType.Word ;
+ return type;
}
}
// string myword = null;
- public string GetWord (IDocument d, LineSegment l)
- {
- return d.GetText (l.Offset + offset, length);
+ public string Word {
+ get {
+ return document.GetText(word.Offset + offset, length);
// if (myword == null) {
// myword = document.GetText(word.Offset + offset, length);
// }
// return myword;
+ }
}
public Pango.FontDescription Font {
@@ -98,25 +104,29 @@
public bool IsWhiteSpace {
get {
- return this == spaceWord || this == tabWord;
+ return type == TextWordType.Space || type == TextWordType.Tab;
}
}
// TAB
private TextWord(TextWordType type)
- {
- length = 1;
+ {
+ this.type = type;
}
- public TextWord(int offset, int length, HighlightColor color, bool hasDefaultColor)
+ public TextWord(IDocument document, LineSegment word, int offset, int length, HighlightColor color, bool hasDefaultColor)
{
- Debug.Assert(color != null);
+ Debug.Assert(document != null);
+ Debug.Assert(word != null);
+ Debug.Assert(color != null);
+ this.document = document;
+ this.word = word;
this.offset = offset;
this.length = length;
this.color = color;
- if (hasDefaultColor)
- this.offset |= (1 << 31);
+ this.hasDefaultColor = hasDefaultColor;
+ this.type = TextWordType.Word;
}
/// <summary>
@@ -124,7 +134,7 @@
/// </summary>
public override string ToString()
{
- return "[TextWord: , Font = " + Font.Family + ", Color = " + Color + "]";
+ return "[TextWord: Word = " + Word + ", Font = " + Font.Family + ", Color = " + Color + "]";
}
}
}
Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/LineManager/DefaultLineManager.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/LineManager/DefaultLineManager.cs 2004-01-13 23:35:27 UTC (rev 482)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/LineManager/DefaultLineManager.cs 2004-01-14 01:50:41 UTC (rev 483)
@@ -295,7 +295,7 @@
void RunHighlighter()
{
- //DateTime time = DateTime.Now;
+ DateTime time = DateTime.Now;
if (highlightingStrategy != null) {
highlightingStrategy.MarkTokens(document, markLines);
}
Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/TextArea.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/TextArea.cs 2004-01-13 23:35:27 UTC (rev 482)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/TextArea.cs 2004-01-14 01:50:41 UTC (rev 483)
@@ -798,10 +798,11 @@
public void Invalidate()
{
- if (GdkWindow == null)
+ if (GdkWindow == null) {
return;
-
- Invalidate (new System.Drawing.Rectangle(0, 0, -1, -1));
+ }
+
+ Invalidate (new System.Drawing.Rectangle(0, 0, GdkWindow.Size.Width, GdkWindow.Size.Height));
}
internal void Invalidate (System.Drawing.Rectangle rect)
@@ -810,21 +811,19 @@
// FIXME Improve this
try {
- Gdk.Window w = GdkWindow;
-
- int x = Math.Max (rect.X, 0);
- int y = Math.Max (rect.Y, 0);
- int width = Math.Max (rect.Width, 0);
- int height = Math.Max (rect.Height, 0);
-
- if (rect.Width < 0)
- width = w.Size.Width;
-
- if (rect.Height < 0)
- height = w.Size.Height;
+ int x = Math.Max(rect.X, 0);
+ int y = Math.Max(rect.Y, 0);
+ int width = Math.Max(rect.Width, 0);
+ if (rect.Width < 0) {
+ width = GdkWindow.Size.Width;
+ }
+ int height = Math.Max(rect.Height, 0);
+ if (rect.Height < 0) {
+ height = GdkWindow.Size.Height;
+ }
//Console.WriteLine ("{0} {1} {2} {3}", x, y, width, height);
- w.InvalidateRect(new Gdk.Rectangle(x, y, width, height), false);
+ GdkWindow.InvalidateRect(new Gdk.Rectangle(x, y, width, height), false);
} catch {
//This try/catch seems to fix a bug when creating files
}
Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/TextView.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/TextView.cs 2004-01-13 23:35:27 UTC (rev 482)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/TextView.cs 2004-01-14 01:50:41 UTC (rev 483)
@@ -223,7 +223,7 @@
break;
case TextWordType.Word:
- string word = currentWord.GetWord (textArea.Document, currentLine);
+ string word = currentWord.Word;
float lastPos = physicalXPos;
if (ColumnRange.WholeColumn.Equals(selectionRange) || selectionRange.EndColumn - 1 >= word.Length + logicalColumn &&
@@ -348,19 +348,7 @@
public float GetWidth(char ch)
{
- if (ch == ' ') {
- return GetWidth('w'); // Hack! FIXME PEDRO
- }
- object width = charWitdh[ch];
- if (width == null) {
- //Pango.Layout ly = new Pango.Layout(TextArea.PangoContext);
- Pango.Layout ly = _layout;
- ly.SetText(ch.ToString());
-
- charWitdh[ch] = (float) (ly.Size.Width/1024.0f - 1); // Hack! I don't know why it works substracting 1. FIXME PEDRO
- return (float)charWitdh[ch];
- }
- return (float)width;
+ return GetWidth(TextArea.GdkWindow, ch);
}
public float GetWidth(Gdk.Drawable g, char ch)
@@ -454,7 +442,7 @@
break;
case TextWordType.Word:
- string word = currentWord.GetWord (textArea.Document, currentLine);
+ string word = currentWord.Word;
if (physicalXPos + MeasureString(FontContainer.DefaultFont, word) > xPos + spaceWidth/2) {
do {
@@ -506,7 +494,7 @@
break;
case TextWordType.Word:
- string word = currentWord.GetWord (textArea.Document, currentLine);
+ string word = currentWord.Word;
if (currentColumn + word.Length > logicalColumn) {
word = word.Substring(0, logicalColumn - currentColumn);
}
Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Util/RtfWriter.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Util/RtfWriter.cs 2004-01-13 23:35:27 UTC (rev 482)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Util/RtfWriter.cs 2004-01-14 01:50:41 UTC (rev 483)
@@ -98,9 +98,8 @@
case TextWordType.Word:
Color c = word.Color;
- string word_word = word.GetWord (textArea.Document, line);
- if (offset + word_word.Length > selectionOffset && offset < selectionEndOffset) {
+ if (offset + word.Word.Length > selectionOffset && offset < selectionEndOffset) {
string colorstr = c.R + ", " + c.G + ", " + c.B;
if (colors[colorstr] == null) {
@@ -143,11 +142,11 @@
}
string printWord;
if (offset < selectionOffset) {
- printWord = word_word.Substring(selectionOffset - offset);
- } else if (offset + word_word.Length > selectionEndOffset) {
- printWord = word_word.Substring(0, (offset + word_word.Length) - selectionEndOffset);
+ printWord = word.Word.Substring(selectionOffset - offset);
+ } else if (offset + word.Word.Length > selectionEndOffset) {
+ printWord = word.Word.Substring(0, (offset + word.Word.Length) - selectionEndOffset);
} else {
- printWord = word_word;
+ printWord = word.Word;
}
rtf.Append(printWord.Replace("{", "\\{").Replace("}", "\\}"));
More information about the Monodevelop-patches-list
mailing list