private void RenderSelectedText(int RowIndex, int XOffset, Word StartWord)
{
GDISurface bbuff = GFX.SelectionBuffer;
bbuff.Font = GFX.FontNormal;
bbuff.FontTransparent = true;
if (RowIndex <= Control.Document.Count - 1)
{
bbuff.TextForeColor = Control.ContainsFocus ? Control.SelectionForeColor : Control.InactiveSelectionForeColor;
Row xtr = Control.Document[RowIndex];
//if (xtr.startSpan != null)
// bbuff.DrawTabbedString (xtr.startSpan.GetHashCode ().ToString (System.Globalization.CultureInfo.InvariantCulture),100,0,0,0);
//bbuff.TextForeColor = Color.Black;
//bbuff.DrawTabbedString (xtr.Text,(int)(Control.View.TextMargin -Control.View.ClientAreaStart),1,-Control.View.FirstVisibleColumn*Control.View.CharWidth+Control.View.TextMargin,Control.PixelTabSize);
int xpos = Control.View.TextMargin - Control.View.ClientAreaStart + XOffset;
int wdh = 0;
int taborig = -Control.View.FirstVisibleColumn*Control.View.CharWidth + Control.View.TextMargin;
bool ws = Control.ShowWhitespace;
bool StartDraw = false;
if (StartWord == null)
StartDraw = true;
xtr.Expansion_StartChar = 0;
xtr.Expansion_EndChar = 0;
bool HasExpansion = false;
foreach (Word w in xtr.FormattedWords)
{
if (StartDraw)
{
if (w.Span == xtr.expansion_StartSpan && xtr.expansion_StartSpan != null)
if (xtr.expansion_StartSpan.Expanded == false)
{
RenderCollapsedSelectedText(RowIndex, xpos);
HasExpansion = true;
break;
}
if (w.Type == WordType.Word || ws == false)
{
if (w.Style != null)
{
SetFont(w.Style.Bold, w.Style.Italic, w.Style.Underline, bbuff);
}
else
{
bbuff.Font = GFX.FontNormal;
}
wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width;
//render errors
if (w.HasError)
{
//bbuff.FillRect (Color.Red,xpos,Control.View.RowHeight-2,wdh,2);
int ey = Control.View.RowHeight - 1;
Color c = w.ErrorColor;
for (int x = 0; x < wdh + 3; x += 4)
{
bbuff.DrawLine(c, new Point(xpos + x, ey), new Point(xpos + x + 2, ey - 2));
bbuff.DrawLine(c, new Point(xpos + x + 2, ey - 2), new Point(xpos + x + 4, ey));
}
}
}
else if (w.Type == WordType.Space)
{
bbuff.Font = GFX.FontNormal;
bbuff.DrawTabbedString("·", xpos, 0, taborig, Control.PixelTabSize);
wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width;
}
else if (w.Type == WordType.Tab)
{
bbuff.Font = GFX.FontNormal;
bbuff.DrawTabbedString("»", xpos, 0, taborig, Control.PixelTabSize);
wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width;
}
if (w.Pattern != null)
if (w.Pattern.IsSeparator)
{
bbuff.FillRect(Control.SeparatorColor, Control.View.TextMargin - 4, Control.View.RowHeight - 1, Control.View.ClientAreaWidth, 1);
}
xpos += wdh;
}
if (!StartDraw)
xtr.Expansion_StartChar += w.Text.Length;
if (w == StartWord)
StartDraw = true;
xtr.Expansion_EndChar += w.Text.Length;
}
if (xtr.IsCollapsed) {}
else if (xtr.endSpan != null && xtr.endSpan.spanDefinition != null && xtr.endSpan.spanDefinition.Style != null)
{
GFX.BackBuffer.FillRect(xtr.endSpan.spanDefinition.Style.BackColor, xpos, 0, Control.Width - xpos, Control.View.RowHeight);
}
if (Control._SyntaxBox.ShowEOLMarker && !HasExpansion)
{
bbuff.Font = GFX.FontNormal;
bbuff.TextForeColor = Control.SelectionForeColor;
bbuff.FontTransparent = true;
bbuff.DrawTabbedString("¶", xpos, 0, taborig, Control.PixelTabSize);
}
}
}