internal static void ClearSelected(TextSource ts)
{
var tb = ts.CurrentTB;
tb.Selection.Normalize();
Place start = tb.Selection.Start;
Place end = tb.Selection.End;
int fromLine = Math.Min(end.iLine, start.iLine);
int toLine = Math.Max(end.iLine, start.iLine);
int fromChar = tb.Selection.FromX;
int toChar = tb.Selection.ToX;
if (fromLine < 0) return;
//
if (fromLine == toLine)
ts[fromLine].RemoveRange(fromChar, toChar - fromChar);
else
{
ts[fromLine].RemoveRange(fromChar, ts[fromLine].Count - fromChar);
ts[toLine].RemoveRange(0, toChar);
ts.RemoveLine(fromLine + 1, toLine - fromLine - 1);
InsertCharCommand.MergeLines(fromLine, ts);
}
}