Author: mkrueger
Date: 2008-02-15 14:47:32 -0500 (Fri, 15 Feb 2008)
New Revision: 95805
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/DefaultEditActions.cs
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/Document.cs
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs
Log:
Some refactorings.
Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-15
19:44:48 UTC (rev 95804)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-15
19:47:32 UTC (rev 95805)
@@ -1,5 +1,9 @@
2008-02-15 Mike Krüger <[EMAIL PROTECTED]>
+
+
+2008-02-15 Mike Krüger <[EMAIL PROTECTED]>
+
* Mono.TextEditor/DefaultEditActions.cs, Mono.TextEditor/Document.cs,
Mono.TextEditor/IBuffer.cs, Mono.TextEditor/GapBuffer.cs,
Mono.TextEditor/GutterMargin.cs: Fixed gutter bug & refactored.
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/DefaultEditActions.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/DefaultEditActions.cs
2008-02-15 19:44:48 UTC (rev 95804)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/DefaultEditActions.cs
2008-02-15 19:47:32 UTC (rev 95805)
@@ -574,7 +574,7 @@
endLineNr = data.Document.LineCount;
data.Document.BeginAtomicUndo ();
foreach (LineSegment line in data.SelectedLines) {
- data.Document.Insert (line.Offset, new
StringBuilder(TextEditorOptions.Options.IndentationString));
+ data.Document.Insert (line.Offset,
TextEditorOptions.Options.IndentationString);
}
if (data.IsSomethingSelected)
data.SelectionStart.Column++;
@@ -601,7 +601,7 @@
data.DeleteSelectedText ();
}
- data.Document.Insert (data.Caret.Offset, new
StringBuilder (TextEditorOptions.Options.IndentationString));
+ data.Document.Insert (data.Caret.Offset,
TextEditorOptions.Options.IndentationString);
data.Caret.Column ++;
}
}
@@ -610,9 +610,6 @@
{
public override void Run (TextEditorData data)
{
- StringBuilder newLine = new StringBuilder
(data.Document.EolMarker);
-
-
/* if (TextEditorOptions.Options.AutoIndent) {
LineSegment line = data.Document.GetLine
(data.Caret.Line);
for (int i = 0; i < line.EditableLength; i++) {
@@ -622,7 +619,7 @@
newLine.Append (ch);
}
}*/
- data.Document.Insert (data.Caret.Offset, newLine);
+ data.Document.Insert (data.Caret.Offset,
data.Document.EolMarker);
data.Document.CommitLineToEndUpdate (data.Caret.Line);
data.Caret.Column = 0;
data.Caret.Line++;
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-15 19:44:48 UTC (rev 95804)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/Document.cs
2008-02-15 19:47:32 UTC (rev 95805)
@@ -252,7 +252,7 @@
if (args.Value != null && args.Value.Length > 0)
doc.Remove (args.Offset,
args.Value.Length);
if (!String.IsNullOrEmpty (text))
- doc.Insert (args.Offset, new
StringBuilder (text));
+ doc.Insert (args.Offset, text);
}
public virtual void Redo (Document doc)
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs
2008-02-15 19:44:48 UTC (rev 95804)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs
2008-02-15 19:47:32 UTC (rev 95805)
@@ -272,15 +272,7 @@
this.RedrawLines (System.Math.Min (from, to),
System.Math.Max (from, to));
};
- Document.DocumentUpdated += delegate {
- try {
- foreach (DocumentUpdateRequest request
in Document.UpdateRequests) {
- request.Update (this);
- }
- } catch (Exception e) {
- System.Console.WriteLine (e);
- }
- };
+ Document.DocumentUpdated += DocumentUpdatedHandler;
TextEditorOptions.Changed += OptionsChanged;
@@ -292,6 +284,13 @@
};
}
+ void DocumentUpdatedHandler (object sender, EventArgs args)
+ {
+ foreach (DocumentUpdateRequest request in
Document.UpdateRequests) {
+ request.Update (this);
+ }
+ }
+
protected virtual void OptionsChanged (object sender, EventArgs
args)
{
this.TextEditorData.ColorStyle =
TextEditorOptions.Options.GetColorStyle (this);
@@ -321,6 +320,8 @@
if (isDisposed)
return;
this.isDisposed = true;
+
+ Document.DocumentUpdated -= DocumentUpdatedHandler;
TextEditorOptions.Changed -= OptionsChanged;
foreach (IMargin margin in this.margins) {
@@ -396,9 +397,9 @@
if (!char.IsControl (ch)) {
LineSegment line = Document.GetLine
(Caret.Line);
if (Caret.IsInInsertMode
|| Caret.Column >= line.EditableLength) {
- Document.Insert (Caret.Offset,
new StringBuilder (ch.ToString()));
+ Document.Insert (Caret.Offset,
ch.ToString());
} else {
- Document.Replace (Caret.Offset,
1, new StringBuilder (ch.ToString()));
+ Document.Replace (Caret.Offset,
1, ch.ToString());
}
bool autoScroll =
Caret.AutoScrollToCaret;
Caret.Column++;
@@ -508,14 +509,13 @@
protected override void OnDragDataReceived (DragContext
context, int x, int y, SelectionData selection_data, uint info, uint time_)
{
if (selection_data.Length > 0 && selection_data.Format
== 8) {
- StringBuilder builder = new StringBuilder
(selection_data.Text);
Caret.Location = dragCaretPos;
int offset = Caret.Offset;
if (selection != null && selection.Offset >=
offset)
- selection.Offset += builder.Length;
- Document.Insert (offset, builder);
- Caret.Offset = offset + builder.Length;
- this.TextEditorData.SelectionRange = new
Segment (offset, builder.Length);
+ selection.Offset +=
selection_data.Text.Length;
+ Document.Insert (offset, selection_data.Text);
+ Caret.Offset = offset +
selection_data.Text.Length;
+ this.TextEditorData.SelectionRange = new
Segment (offset, selection_data.Text.Length);
dragOver = false;
context = null;
}
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs
2008-02-15 19:44:48 UTC (rev 95804)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs
2008-02-15 19:47:32 UTC (rev 95805)
@@ -37,7 +37,7 @@
Adjustment vadjustment = new Adjustment (0, 0, 0, 0, 0, 0);
Document document;
Caret caret;
-
+
public TextEditorData ()
{
Document = new Document ();
@@ -56,7 +56,7 @@
};
}
}
-
+
public Mono.TextEditor.Caret Caret {
get {
return caret;
@@ -151,7 +151,7 @@
hadjustment = value;
}
}
-
+
public Adjustment VAdjustment {
get {
return vadjustment;
@@ -160,7 +160,7 @@
vadjustment = value;
}
}
-
+
public SelectionMarker SelectionStart {
get {
return selectionStart;
@@ -170,7 +170,7 @@
OnSelectionChanged (EventArgs.Empty);
}
}
-
+
public SelectionMarker SelectionEnd {
get {
return selectionEnd;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches