Author: jackson
Date: 2006-11-27 09:40:32 -0500 (Mon, 27 Nov 2006)
New Revision: 68514
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
Log:
* TextControl.cs: new param for ReplaceSelection which
determines
whether we select the new selection, or set the cursor to the
end
of the new selection.
* TextBoxBase.cs: Use new param for ReplaceSelection. When
pasting, select the new text.
* RichTextBox.cs: Use new param for ReplaceSelection.
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
2006-11-27 14:14:13 UTC (rev 68513)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
2006-11-27 14:40:32 UTC (rev 68514)
@@ -316,7 +316,7 @@
LineTag tag;
if (document.selection_visible) {
- document.ReplaceSelection("");
+ document.ReplaceSelection("", false);
}
sel_start =
document.LineTagToCharIndex(document.selection_start.line,
document.selection_start.pos);
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
2006-11-27 14:14:13 UTC (rev 68513)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
2006-11-27 14:40:32 UTC (rev 68514)
@@ -436,8 +436,8 @@
set {
if (!read_only) {
-
document.ReplaceSelection(CaseAdjust(value));
- document.PositionCaret
(document.selection_end.line, document.selection_end.pos);
+
document.ReplaceSelection(CaseAdjust(value), true);
+ // document.PositionCaret
(document.selection_end.line, document.selection_end.pos);
ScrollToCaret();
OnTextChanged(EventArgs.Empty);
}
@@ -680,7 +680,7 @@
o.SetData(DataFormats.Rtf,
((RichTextBox)this).SelectedRtf);
}
Clipboard.SetDataObject(o);
- document.ReplaceSelection("");
+ document.ReplaceSelection("", false);
}
public void Paste() {
@@ -995,7 +995,7 @@
Line line;
if (document.selection_visible)
{
-
document.ReplaceSelection("");
+
document.ReplaceSelection("", false);
}
line = document.CaretLine;
@@ -1015,7 +1015,7 @@
if (!read_only && accepts_tab &&
multiline) {
document.InsertChar(document.CaretLine, document.CaretPosition, '\t');
if (document.selection_visible)
{
-
document.ReplaceSelection("");
+
document.ReplaceSelection("", false);
}
document.SetSelectionToCaret(true);
@@ -1070,7 +1070,7 @@
}
if (document.selection_visible) {
- document.ReplaceSelection("");
+ document.ReplaceSelection("",
false);
} else {
// DeleteChar only deletes on
the line, doesn't do the combine
if (document.CaretPosition ==
document.CaretLine.Text.Length) {
@@ -1130,7 +1130,7 @@
// delete only deletes on the line, doesn't do the
combine
if (document.selection_visible) {
- document.ReplaceSelection("");
+ document.ReplaceSelection("", false);
fire_changed = true;
}
document.SetSelectionToCaret(true);
@@ -1220,7 +1220,7 @@
HandleBackspace(true);
} else if (ch >= 32) {
if (document.selection_visible)
{
-
document.ReplaceSelection("");
+
document.ReplaceSelection("", false);
}
char c = (char)m.WParam;
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
2006-11-27 14:14:13 UTC (rev 68513)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
2006-11-27 14:40:32 UTC (rev 68514)
@@ -3295,7 +3295,7 @@
}
}
- internal void ReplaceSelection(string s) {
+ internal void ReplaceSelection(string s, bool select_new) {
int i;
int selection_start_pos = LineTagToCharIndex
(selection_start.line, selection_start.pos);
@@ -3338,20 +3338,33 @@
}
}
-
Insert(selection_start.line, null, selection_start.pos,
true, s);
- CharIndexToLineTag(selection_start_pos + s.Length + 1,
out selection_start.line,
- out selection_start.tag, out
selection_start.pos);
-
- selection_end.line = selection_start.line;
- selection_end.pos = selection_start.pos;
- selection_end.tag = selection_start.tag;
- selection_anchor.line = selection_start.line;
- selection_anchor.pos = selection_start.pos;
- selection_anchor.tag = selection_start.tag;
-
- SetSelectionVisible (false);
+ if (!select_new) {
+ CharIndexToLineTag(selection_start_pos +
s.Length, out selection_start.line,
+ out selection_start.tag, out
selection_start.pos);
+
+ selection_end.line = selection_start.line;
+ selection_end.pos = selection_start.pos;
+ selection_end.tag = selection_start.tag;
+ selection_anchor.line = selection_start.line;
+ selection_anchor.pos = selection_start.pos;
+ selection_anchor.tag = selection_start.tag;
+
+ SetSelectionVisible (false);
+ } else {
+ CharIndexToLineTag(selection_start_pos, out
selection_start.line,
+ out selection_start.tag, out
selection_start.pos);
+
+ CharIndexToLineTag(selection_start_pos +
s.Length, out selection_end.line,
+ out selection_end.tag, out
selection_end.pos);
+
+ selection_anchor.line = selection_start.line;
+ selection_anchor.pos = selection_start.pos;
+ selection_anchor.tag = selection_start.tag;
+
+ SetSelectionVisible (true);
+ }
}
internal void CharIndexToLineTag(int index, out Line line_out,
out LineTag tag_out, out int pos) {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches