// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+// Copyright (c) 2005-2006 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Peter Bartok <pbartok@novell.com>
private HorizontalAlignment rtf_rtfalign;
private int rtf_cursor_x;
private int rtf_cursor_y;
+ private int rtf_chars;
#endregion // Local Variables
#region Public Constructors
ForeColor = ThemeEngine.Current.ColorWindowText;
base.HScrolled += new EventHandler(RichTextBox_HScrolled);
base.VScrolled += new EventHandler(RichTextBox_VScrolled);
+
+#if NET_2_0
+ SetStyle (ControlStyles.StandardDoubleClick, false);
+#endif
}
#endregion // Public Constructors
get {
Line start_line;
Line end_line;
- int current;
- int total;
start_line = document.GetLine(1);
end_line = document.GetLine(document.Lines);
InsertRTFFromStream(data, 0, 1);
data.Close();
+
+ Invalidate();
}
}
MemoryStream data;
int x;
int y;
+ int sel_start;
+ int chars;
Line line;
+ LineTag tag;
if (document.selection_visible) {
- document.ReplaceSelection("");
+ document.ReplaceSelection("", false);
}
+ 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();
-
+ ScrollToCaret();
OnTextChanged(EventArgs.Empty);
}
}
}
}
+ [Browsable(false)]
+ [DefaultValue(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [MonoTODO]
+ public bool SelectionBullet {
+ get {
+ return false;
+ }
+
+ set {
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue(0)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [MonoTODO]
+ public int SelectionCharOffset {
+ get {
+ return 0;
+ }
+
+ set {
+ }
+ }
+
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Color SelectionColor {
}
set {
- int sel_start;
- int sel_end;
+ FontDefinition attributes;
+ int sel_start;
+ int sel_end;
+
+ attributes = new FontDefinition();
+ attributes.color = value;
sel_start = document.LineTagToCharIndex(document.selection_start.line, document.selection_start.pos);
sel_end = document.LineTagToCharIndex(document.selection_end.line, document.selection_end.pos);
-Console.WriteLine("FIXME - SelectionColor should not alter font");
- document.FormatText(document.selection_start.line, document.selection_start.pos + 1, document.selection_end.line, document.selection_end.pos, document.selection_start.tag.font, new SolidBrush(value));
+
+ document.FormatText(document.selection_start.line, document.selection_start.pos + 1, document.selection_end.line, document.selection_end.pos + 1, attributes);
document.CharIndexToLineTag(sel_start, out document.selection_start.line, out document.selection_start.tag, out document.selection_start.pos);
document.CharIndexToLineTag(sel_end, out document.selection_end.line, out document.selection_end.tag, out document.selection_end.pos);
}
set {
- int sel_start;
- int sel_end;
+ FontDefinition attributes;
+ int sel_start;
+ int sel_end;
+
+ attributes = new FontDefinition();
+ attributes.font_obj = value;
sel_start = document.LineTagToCharIndex(document.selection_start.line, document.selection_start.pos);
sel_end = document.LineTagToCharIndex(document.selection_end.line, document.selection_end.pos);
- document.FormatText(document.selection_start.line, document.selection_start.pos + 1, document.selection_end.line, document.selection_end.pos, value, document.selection_start.tag.color);
+ document.FormatText(document.selection_start.line, document.selection_start.pos + 1, document.selection_end.line, document.selection_end.pos + 1, attributes);
document.CharIndexToLineTag(sel_start, out document.selection_start.line, out document.selection_start.tag, out document.selection_start.pos);
document.CharIndexToLineTag(sel_end, out document.selection_end.line, out document.selection_end.tag, out document.selection_end.pos);
document.UpdateView(document.selection_start.line, 0);
document.AlignCaret();
-
+
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue(0)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [MonoTODO]
+ public int SelectionHangingIndent {
+ get {
+ return 0;
+ }
+
+ set {
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue(0)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [MonoTODO]
+ public int SelectionIndent {
+ get {
+ return 0;
+ }
+
+ set {
}
}
}
}
+ [Browsable(false)]
+ [DefaultValue(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [MonoTODO]
+ public bool SelectionProtected {
+ get {
+ return false;
+ }
+
+ set {
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue(0)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [MonoTODO]
+ public int SelectionRightIndent {
+ get {
+ return 0;
+ }
+
+ set {
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [MonoTODO]
+ public int[] SelectionTabs {
+ get {
+ return new int[0];
+ }
+
+ set {
+ }
+ }
+
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public RichTextBoxSelectionTypes SelectionType {
}
}
+ [DefaultValue(false)]
+ [MonoTODO]
+ public bool ShowSelectionMargin {
+ get {
+ return false;
+ }
+
+ set {
+ }
+ }
+
[Localizable(true)]
public override string Text {
get {
}
public void LoadFile(System.IO.Stream data, RichTextBoxStreamType fileType) {
- RTF.RTF rtf; // Not 'using SWF.RTF' to avoid ambiguities with font and color
-
document.Empty();
// FIXME - ignoring unicode
}
public void Paste(DataFormats.Format clipFormat) {
- base.Paste(clipFormat, false);
+ base.Paste(Clipboard.GetDataObject(), clipFormat, false);
}
[MonoTODO()]
#endregion // Events
#region Private Methods
+
+ internal override void SelectWord ()
+ {
+ document.ExpandSelection(CaretSelection.Word, false);
+ }
+
private void HandleControl(RTF.RTF rtf) {
+// Console.WriteLine ("HANDLING MAJOR: {0} MINOR: {1}", rtf.Major, rtf.Minor);
switch(rtf.Major) {
case RTF.Major.Unicode: {
switch(rtf.Minor) {
}
case RTF.Major.Destination: {
- Console.Write("[Got Destination control {0}]", rtf.Minor);
+// Console.Write("[Got Destination control {0}]", rtf.Minor);
rtf.SkipGroup();
break;
}
if (rtf.Param == RTF.RTF.NoParam) {
rtf_rtfstyle |= FontStyle.Underline;
} else {
- rtf_rtfstyle &= ~FontStyle.Underline;
+ rtf_rtfstyle = rtf_rtfstyle & ~FontStyle.Underline;
}
break;
}
}
case RTF.Major.SpecialChar: {
- Console.Write("[Got SpecialChar control {0}]", rtf.Minor);
+ //Console.Write("[Got SpecialChar control {0}]", rtf.Minor);
SpecialChar(rtf);
break;
}
}
case Minor.Tab: {
- Console.Write("\t");
+ rtf_line.Append ("\t");
+// FlushText (rtf, false);
break;
}
+ case Minor.NoReqHyphen:
case Minor.NoBrkHyphen: {
- Console.Write("-");
+ rtf_line.Append ("-");
+// FlushText (rtf, false);
break;
}
case Minor.Bullet: {
- Console.Write("*");
+ Console.WriteLine("*");
break;
}
+ case Minor.WidowCtrl:
+ break;
+
case Minor.EmDash: {
- Console.Write("\97");
+ rtf_line.Append ("\u2014");
break;
}
case Minor.EnDash: {
- Console.Write("\96");
+ rtf_line.Append ("\u2013");
break;
}
-
+/*
case Minor.LQuote: {
- Console.Write("\91");
+ Console.Write("\u2018");
break;
}
case Minor.RQuote: {
- Console.Write("\92");
+ Console.Write("\u2019");
break;
}
case Minor.LDblQuote: {
- Console.Write("\93");
+ Console.Write("\u201C");
break;
}
case Minor.RDblQuote: {
- Console.Write("\94");
+ Console.Write("\u201D");
break;
}
-
+*/
default: {
- rtf.SkipGroup();
+// Console.WriteLine ("skipped special char: {0}", rtf.Minor);
+// rtf.SkipGroup();
break;
}
}
Font font;
length = rtf_line.Length;
- if (length == 0) {
+ if (!newline && (length == 0)) {
return;
}
}
}
+ rtf_chars += rtf_line.Length;
+
if (rtf_cursor_x == 0) {
document.Add(rtf_cursor_y, rtf_line.ToString(), rtf_rtfalign, font, rtf_color);
} else {
Line line;
line = document.GetLine(rtf_cursor_y);
- document.InsertString(line, rtf_cursor_x, rtf_line.ToString());
- document.FormatText(line, rtf_cursor_x + 1, line, rtf_cursor_x + 1 + length, font, rtf_color); // FormatText is 1-based
+ if (rtf_line.Length > 0) {
+ document.InsertString(line, rtf_cursor_x, rtf_line.ToString());
+ document.FormatText(line, rtf_cursor_x + 1, line, rtf_cursor_x + 1 + length, font, rtf_color); // FormatText is 1-based
+ }
+ if (newline) {
+ document.Split(line, rtf_cursor_x + length);
+ }
}
if (newline) {
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);
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();
RTF.TextMap.SetupStandardTable(rtf_text_map.Table);
+ document.NoRecalc = true;
+
try {
rtf.Read(); // That's it
FlushText(rtf, false);
}
- catch (RTF.RTFException) {
- // Seems to be plain text...
-
+ catch (RTF.RTFException e) {
+ // Seems to be plain text or broken RTF
+ Console.WriteLine("RTF Parsing failure: {0}", e.Message);
}
to_x = rtf_cursor_x;
to_y = rtf_cursor_y;
+ chars = rtf_chars;
+
+ document.RecalculateDocument(CreateGraphicsInternal(), cursor_y, document.Lines, false);
+ document.NoRecalc = false;
- document.RecalculateDocument(CreateGraphics(), cursor_y, document.Lines, false);
document.Invalidate(document.GetLine(cursor_y), 0, document.GetLine(document.Lines), -1);
}