internal Line left; // Line with smaller line number\r
internal Line right; // Line with higher line number\r
internal LineColor color; // We're doing a black/red tree. this is the node color\r
- internal int DEFAULT_TEXT_LEN; // \r
+ static int DEFAULT_TEXT_LEN = 0; // \r
internal bool recalc; // Line changed\r
#endregion // Local Variables\r
\r
\r
tags = new LineTag(this, 1);\r
tags.Font = font;\r
- tags.Color = color; \r
+ tags.Color = color;\r
}\r
\r
internal Line (Document document, int LineNo, string Text, HorizontalAlignment align, Font font, Color color, LineEnding ending) : this(document, ending)\r
#endregion // Internal Properties\r
\r
#region Internal Methods\r
- public void DeleteCharacters (int pos, int count)\r
+\r
+ /// <summary>\r
+ /// Builds a simple code to record which tags are links and how many tags\r
+ /// used to compare lines before and after to see if the scan for links\r
+ /// process has changed anything.\r
+ /// </summary>\r
+ internal void LinkRecord (StringBuilder linkRecord)\r
+ {\r
+ LineTag tag = tags;\r
+\r
+ while (tag != null) {\r
+ if (tag.IsLink)\r
+ linkRecord.Append ("L");\r
+ else\r
+ linkRecord.Append ("N");\r
+\r
+ tag = tag.Next;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Clears all link properties from tags\r
+ /// </summary>\r
+ internal void ClearLinks ()\r
+ {\r
+ LineTag tag = tags;\r
+\r
+ while (tag != null) {\r
+ tag.IsLink = false;\r
+ tag = tag.Next;\r
+ }\r
+ }\r
+\r
+ public void DeleteCharacters(int pos, int count)\r
{\r
LineTag tag;\r
bool streamline = false;\r
return;\r
\r
// Find the first tag that we are deleting from\r
- tag = FindTag (pos);\r
+ tag = FindTag (pos + 1);\r
\r
// Remove the characters from the line\r
text.Remove (pos, count);\r
break;\r
}\r
\r
- TextBoxTextRenderer.DrawText (dc, end_str, last.Font, last.Color, X + widths [TextLengthWithoutEnding ()] - document.viewport_x, y, true);\r
+ TextBoxTextRenderer.DrawText (dc, end_str, last.Font, last.Color, X + widths [TextLengthWithoutEnding ()] - document.viewport_x + document.OffsetX, y, true);\r
}\r
\r
/// <summary> Find the tag on a line based on the character position, pos is 0-based</summary>\r
pos = text.Length - 1;\r
\r
while (tag != null) {\r
- if (((tag.Start - 1) <= pos) && (pos < (tag.Start + tag.Length - 1)))\r
+ if (((tag.Start - 1) <= pos) && (pos <= (tag.Start + tag.Length - 1)))\r
return LineTag.GetFinalTag (tag);\r
\r
tag = tag.Next;\r
widths = new_widths;\r
}\r
}\r
+ public void InsertString (int pos, string s)\r
+ {\r
+ InsertString (pos, s, FindTag (pos));\r
+ }\r
\r
// Inserts a string at the given position\r
- public void InsertString (int pos, string s)\r
+ public void InsertString (int pos, string s, LineTag tag)\r
{\r
- LineTag tag = FindTag (pos);\r
int len = s.Length;\r
\r
// Insert the text into the StringBuilder\r
bool wrapped;\r
Line line;\r
int wrap_pos;\r
+ int prev_height;\r
+ int prev_ascent;\r
\r
pos = 0;\r
len = this.text.Length;\r
tag = this.tags;\r
prev_offset = this.offset; // For drawing optimization calculations\r
+ prev_height = this.height;\r
+ prev_ascent = this.ascent;\r
this.height = 0; // Reset line height\r
this.ascent = 0; // Reset the ascent for the line\r
tag.Shift = 0;\r
wrap_pos = 0;\r
\r
while (pos < len) {\r
+\r
while (tag.Length == 0) { // We should always have tags after a tag.length==0 unless len==0\r
//tag.Ascent = 0;\r
- tag.Shift = 0;\r
+ tag.Shift = tag.Line.ascent - tag.Ascent;\r
tag = tag.Next;\r
}\r
\r
}\r
}\r
\r
+ while (tag != null) { \r
+ tag.Shift = tag.Line.ascent - tag.Ascent;\r
+ tag = tag.Next;\r
+ }\r
+\r
if (this.height == 0) {\r
this.height = tags.Font.Height;\r
- tag.Height = this.height;\r
+ tags.Height = this.height;\r
+ tags.Shift = 0;\r
}\r
\r
- if (prev_offset != offset)\r
+ if (prev_offset != offset || prev_height != this.height || prev_ascent != this.ascent)\r
retval = true;\r
\r
return retval;\r