Author: jpobst
Date: 2007-10-17 16:30:31 -0400 (Wed, 17 Oct 2007)
New Revision: 87707
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Line.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
Log:
2007-10-17 Jonathan Pobst <[EMAIL PROTECTED]>
* Line.cs: Move the InsertString function to here.
* TextControl.cs: Cleanup some duplicate code, move some InsertString
functionality to Line.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-10-17 19:39:26 UTC (rev 87706)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-10-17 20:30:31 UTC (rev 87707)
@@ -1,3 +1,9 @@
+2007-10-17 Jonathan Pobst <[EMAIL PROTECTED]>
+
+ * Line.cs: Move the InsertString function to here.
+ * TextControl.cs: Cleanup some duplicate code, move some InsertString
+ functionality to Line.
+
2007-10-17 Geoff Norton <[EMAIL PROTECTED]>
* ComboBox.cs: Destroy the popup after hiding it. Fixes #322582
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Line.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Line.cs
2007-10-17 19:39:26 UTC (rev 87706)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Line.cs
2007-10-17 20:30:31 UTC (rev 87707)
@@ -302,6 +302,30 @@
}
}
+ // Inserts a string at the given position
+ public void InsertString (int pos, string s)
+ {
+ LineTag tag = FindTag (pos);
+ int len = s.Length;
+
+ // Insert the text into the StringBuilder
+ text.Insert (pos, s);
+
+ // Update the start position of every tag after this one
+ tag = tag.Next;
+
+ while (tag != null) {
+ tag.Start += len;
+ tag = tag.Next;
+ }
+
+ // Make sure we have room in the widths array
+ Grow (len);
+
+ // This line needs to be recalculated
+ recalc = true;
+ }
+
/// <summary>
/// Go through all tags on a line and recalculate all
size-related values;
/// returns true if lineheight changed
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
2007-10-17 19:39:26 UTC (rev 87706)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
2007-10-17 20:30:31 UTC (rev 87707)
@@ -1281,7 +1281,7 @@
LineTag tag;
int index;
- tag = FindTag(0, viewport_y +
viewport_height, out index, false);
+ tag = FindCursor (0, viewport_y +
viewport_height, out index);
if (tag.Line.line_no > 1) {
line = GetLine(tag.Line.line_no
- 1);
} else {
@@ -1632,54 +1632,17 @@
}
}
- // Inserts a character at the given position
- internal void InsertString(Line line, int pos, string s) {
- InsertString(line.FindTag(pos), pos, s);
- }
-
// Inserts a string at the given position
- internal void InsertString(LineTag tag, int pos, string s) {
- Line line;
- int len;
+ internal void InsertString (Line line, int pos, string s)
+ {
+ // Update our character count
+ CharCount += s.Length;
- len = s.Length;
-
- CharCount += len;
-
- line = tag.Line;
- line.text.Insert(pos, s);
-
- tag = tag.Next;
- while (tag != null) {
- tag.Start += len;
- tag = tag.Next;
- }
- line.Grow(len);
- line.recalc = true;
-
- UpdateView(line, pos);
+ // Insert the text into the Line
+ line.InsertString (pos, s);
}
- // Inserts a string at the caret position
- internal void InsertStringAtCaret(string s, bool move_caret) {
-
- InsertString (caret.tag, caret.pos, s);
-
- UpdateView(caret.line, caret.pos);
- if (move_caret) {
- caret.pos += s.Length;
- UpdateCaret();
- }
- }
-
-
-
// Inserts a character at the given position
- internal void InsertChar(Line line, int pos, char ch) {
- InsertChar(line.FindTag(pos), pos, ch);
- }
-
- // Inserts a character at the given position
internal void InsertChar(LineTag tag, int pos, char ch) {
Line line;
@@ -3217,51 +3180,7 @@
return last;
}
- // Give it x/y pixel coordinates and it returns the Tag at that
position; optionally the char position is returned in index
- internal LineTag FindTag(int x, int y, out int index, bool
exact) {
- Line line;
- LineTag tag;
-
- line = GetLineByPixel(y, exact);
- if (line == null) {
- index = 0;
- return null;
- }
- tag = line.tags;
-
- // Alignment adjustment
- x += line.X;
-
- while (true) {
- if (x >= tag.X && x < (tag.X+tag.Width)) {
- int end;
-
- end = tag.Start + tag.Length - 1;
-
- for (int pos = tag.Start; pos < end;
pos++) {
- if (x < line.widths[pos]) {
- index = pos;
- return
LineTag.GetFinalTag (tag);
- }
- }
- index=end;
- return LineTag.GetFinalTag (tag);
- }
- if (tag.Next != null) {
- tag = tag.Next;
- } else {
- if (exact) {
- index = 0;
- return null;
- }
-
- index = line.text.Length;
- return LineTag.GetFinalTag (tag);
- }
- }
- }
-
- // Give it x/y pixel coordinates and it returns the Tag at that
position; optionally the char position is returned in index
+ // Give it x/y pixel coordinates and it returns the Tag at that
position
internal LineTag FindCursor (int x, int y, out int index)
{
Line line;
@@ -3269,7 +3188,7 @@
line = GetLineByPixel (multiline ? y : x, false);
LineTag tag = line.GetTag (x);
-
+
if (tag.Length == 0)
index = 0;
else
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches