/// <summary>
/// paints the text box
/// </summary>
/// <param name="context"></param>
protected override void OnPaint(ConsoleBitmap context)
{
var toPaint = textState.CurrentValue;
var offset = 0;
if (toPaint.Length >= Width && textState.CursorPosition > Width - 1)
{
offset = (textState.CursorPosition + 1) - Width;
toPaint = toPaint.Substring(offset);
}
var bgTransformed = new List <ConsoleCharacter>();
foreach (var c in toPaint)
{
if (c.BackgroundColor == ConsoleString.DefaultBackgroundColor && Background != ConsoleString.DefaultBackgroundColor)
{
bgTransformed.Add(new ConsoleCharacter(c.Value, Foreground, Background));
}
else
{
bgTransformed.Add(c);
}
}
context.DrawString(new ConsoleString(bgTransformed), 0, 0);
if (blinkState && BlinkEnabled)
{
char blinkChar = textState.CursorPosition >= toPaint.Length ? ' ' : toPaint[textState.CursorPosition].Value;
var pen = new ConsoleCharacter(blinkChar, DefaultColors.FocusContrastColor, DefaultColors.FocusColor);
context.DrawPoint(pen, textState.CursorPosition - offset, 0);
}
}