Browse Source

2006-08-02 Peter Dennis Bartok <[email protected]>

	* TextControl.cs:
	  - UpdateCaret: Added sanity check in case caret isn't defined yet
	  - Line.Delete: Now updating selection and caret markers if we're
	    transfering a node (Properly fixes #78323)
	  - SetSelectionEnd: Added sanity check
	* TextBoxBase.cs: Removed broken attempt to fix #78323


svn path=/trunk/mcs/; revision=63256
Peter Dennis Bartok 19 years ago
parent
commit
40b4e10786

+ 9 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog

@@ -1,3 +1,12 @@
+2006-08-02  Peter Dennis Bartok  <[email protected]>
+
+	* TextControl.cs:
+	  - UpdateCaret: Added sanity check in case caret isn't defined yet
+	  - Line.Delete: Now updating selection and caret markers if we're
+	    transfering a node (Properly fixes #78323)
+	  - SetSelectionEnd: Added sanity check
+	* TextBoxBase.cs: Removed broken attempt to fix #78323
+
 2006-08-01  Chris Toshok  <[email protected]>
 
 	* PrintPreviewDialog.cs: the CancelEventArgs stuff surrounding the

+ 0 - 12
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs

@@ -1145,14 +1145,6 @@ namespace System.Windows.Forms {
 		}
 
 		protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
-			int	sel_start;
-			int	sel_length;
-			int	lines;
-
-			sel_start = SelectionStart;
-			sel_length = SelectionLength;
-			lines = document.selection_start.line.line_no;
-
 			// Make sure we don't get sized bigger than we want to be
 			if (!richtext) {
 				if (!multiline) {
@@ -1168,10 +1160,6 @@ namespace System.Windows.Forms {
 
 			TextBoxBase_SizeChanged(this, EventArgs.Empty);
 			CalculateDocument();
-
-			// don't use SelectionStart directly (NRE in Document.Caret)
-			document.SetSelectionStart(sel_start);
-			SelectionLength = sel_length;
 		}
 
 		protected override void WndProc(ref Message m) {

+ 33 - 5
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs

@@ -1005,7 +1005,7 @@ namespace System.Windows.Forms {
 
 			total = 1;
 
-			Console.Write("Line {0}, Y: {1} Text {2}", line.line_no, line.Y, line.text != null ? line.text.ToString() : "undefined");
+			Console.Write("Line {0} [# {1}], Y: {1} Text {2}", line.line_no, line.GetHashCode(), line.Y, line.text != null ? line.text.ToString() : "undefined");
 
 			if (line.left == sentinel) {
 				Console.Write(", left = sentinel");
@@ -1460,7 +1460,7 @@ namespace System.Windows.Forms {
 		}
 
 		internal void UpdateCaret() {
-			if (!owner.IsHandleCreated) {
+			if (!owner.IsHandleCreated || caret.tag == null) {
 				return;
 			}
 
@@ -2459,7 +2459,6 @@ if (owner.backcolor_set || (owner.Enabled && !owner.read_only)) {
 
 				Console.WriteLine("Post-delete Y of first line: {0}, second line: {1}", check_first.Y, check_second.Y);
 			#endif
-
 		}
 
 		// Split the line at the position into two
@@ -2743,16 +2742,37 @@ if (owner.backcolor_set || (owner.Enabled && !owner.read_only)) {
 			if (line3 != line1) {
 				LineTag	tag;
 
+				if (selection_start.line == line3) {
+					selection_start.line = line1;
+				}
+
+				if (selection_end.line == line3) {
+					selection_end.line = line1;
+				}
+
+				if (selection_anchor.line == line3) {
+					selection_anchor.line = line1;
+				}
+
+				if (caret.line == line3) {
+					caret.line = line1;
+				}
+
+
+				line1.alignment = line3.alignment;
 				line1.ascent = line3.ascent;
+				line1.hanging_indent = line3.hanging_indent;
 				line1.height = line3.height;
+				line1.indent = line3.indent;
 				line1.line_no = line3.line_no;
 				line1.recalc = line3.recalc;
+				line1.right_indent = line3.right_indent;
+				line1.soft_break = line3.soft_break;
 				line1.space = line3.space;
 				line1.tags = line3.tags;
 				line1.text = line3.text;
 				line1.widths = line3.widths;
 				line1.Y = line3.Y;
-				line1.soft_break = line3.soft_break;
 
 				tag = line1.tags;
 				while (tag != null) {
@@ -3140,6 +3160,10 @@ if (owner.backcolor_set || (owner.Enabled && !owner.read_only)) {
 			LineTag	tag;
 			int	pos;
 
+			if (character_index < 0) {
+				return;
+			}
+
 			CharIndexToLineTag(character_index, out line, out tag, out pos);
 			SetSelectionStart(line, pos);
 		}
@@ -3178,6 +3202,10 @@ if (owner.backcolor_set || (owner.Enabled && !owner.read_only)) {
 			LineTag	tag;
 			int	pos;
 
+			if (character_index < 0) {
+				return;
+			}
+
 			CharIndexToLineTag(character_index, out line, out tag, out pos);
 			SetSelectionEnd(line, pos);
 		}
@@ -3765,7 +3793,7 @@ if (owner.backcolor_set || (owner.Enabled && !owner.read_only)) {
 					HeightChanged(this, null);
 				}
 			}
-
+			UpdateCaret();
 			return changed;
 		}