diff options
author | Peter Dennis Bartok <pbartok@mono-cvs.ximian.com> | 2006-02-28 05:14:39 +0300 |
---|---|---|
committer | Peter Dennis Bartok <pbartok@mono-cvs.ximian.com> | 2006-02-28 05:14:39 +0300 |
commit | 5295cd8a570b7ca0f8ae6468cd444434f6be2696 (patch) | |
tree | 3848d4f4fbb4a2862e08a4fa8aee312c6804c0f2 /mcs | |
parent | e06fd0b53d69263f0568b0ff73c31637f76525c5 (diff) |
2006-02-27 Peter Dennis Bartok <pbartok@novell.com>
* TextControl.cs:
- InsertRTFFromStream: Added 'number of characters inserted' argument
- set_SelectedRTF: Now using the number of characters to calculate
the new location for the selection and cursor (x/y cannot be used
due to potentially already wrapped text)
svn path=/trunk/mcs/; revision=57367
Diffstat (limited to 'mcs')
-rw-r--r-- | mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog | 8 | ||||
-rw-r--r-- | mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs | 23 |
2 files changed, 25 insertions, 6 deletions
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 9e7f3a5d6ba..8a3faaaaded 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,11 @@ +2006-02-27 Peter Dennis Bartok <pbartok@novell.com> + + * TextControl.cs: + - InsertRTFFromStream: Added 'number of characters inserted' argument + - set_SelectedRTF: Now using the number of characters to calculate + the new location for the selection and cursor (x/y cannot be used + due to potentially already wrapped text) + 2006-02-27 Peter Dennis Bartok <pbartok@novell.com> * TextControl.cs: Added property and implemented means to allow diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs index 1fc221f6bc4..f4e18289edd 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs @@ -57,6 +57,7 @@ namespace System.Windows.Forms { private HorizontalAlignment rtf_rtfalign; private int rtf_cursor_x; private int rtf_cursor_y; + private int rtf_chars; #endregion // Local Variables #region Public Constructors @@ -305,19 +306,24 @@ namespace System.Windows.Forms { MemoryStream data; int x; int y; + int sel_start; + int chars; Line line; + LineTag tag; if (document.selection_visible) { document.ReplaceSelection(""); } + sel_start = document.LineTagToCharIndex(document.selection_start.line, document.selection_start.pos); + data = new MemoryStream(Encoding.ASCII.GetBytes(value), false); - InsertRTFFromStream(data, document.selection_start.pos, document.selection_start.line.line_no, out x, out y); + InsertRTFFromStream(data, document.selection_start.pos, document.selection_start.line.line_no, out x, out y, out chars); data.Close(); - line = document.GetLine(y); - document.SetSelection(document.GetLine(y), x); - document.PositionCaret(line, x); + document.CharIndexToLineTag(sel_start + chars + (y - document.selection_start.line.line_no) * 2, out line, out tag, out sel_start); + document.SetSelection(line, sel_start); + document.PositionCaret(line, sel_start); document.DisplayCaret(); OnTextChanged(EventArgs.Empty); @@ -1299,6 +1305,8 @@ namespace System.Windows.Forms { } } + rtf_chars += rtf_line.Length; + if (rtf_cursor_x == 0) { document.Add(rtf_cursor_y, rtf_line.ToString(), rtf_rtfalign, font, rtf_color); } else { @@ -1324,11 +1332,12 @@ namespace System.Windows.Forms { private void InsertRTFFromStream(Stream data, int cursor_x, int cursor_y) { int x; int y; + int chars; - InsertRTFFromStream(data, cursor_x, cursor_y, out x, out y); + InsertRTFFromStream(data, cursor_x, cursor_y, out x, out y, out chars); } - private void InsertRTFFromStream(Stream data, int cursor_x, int cursor_y, out int to_x, out int to_y) { + private void InsertRTFFromStream(Stream data, int cursor_x, int cursor_y, out int to_x, out int to_y, out int chars) { RTF.RTF rtf; rtf = new RTF.RTF(data); @@ -1347,6 +1356,7 @@ namespace System.Windows.Forms { rtf_rtffont = null; rtf_cursor_x = cursor_x; rtf_cursor_y = cursor_y; + rtf_chars = 0; rtf.DefaultFont(this.Font.Name); rtf_text_map = new RTF.TextMap(); @@ -1366,6 +1376,7 @@ namespace System.Windows.Forms { to_x = rtf_cursor_x; to_y = rtf_cursor_y; + chars = rtf_chars; document.RecalculateDocument(CreateGraphics(), cursor_y, document.Lines, false); document.NoRecalc = false; |