static private MergeLines ( int i, TextSource ts ) : void | ||
i | int | |
ts | TextSource | |
return | void |
internal static void MergeLines(int i, TextSource ts)
{
var tb = ts.CurrentTB;
if (i + 1 >= ts.Count)
return;
tb.ExpandBlock(i);
tb.ExpandBlock(i + 1);
int pos = ts[i].Count;
//
/*
if(ts[i].Count == 0)
ts.RemoveLine(i);
else*/
if (ts[i + 1].Count == 0)
ts.RemoveLine(i + 1);
else
{
ts[i].AddRange(ts[i + 1]);
ts.RemoveLine(i + 1);
}
tb.Selection.Start = new Place(pos, i);
ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
}
internal static void ClearSelected(FastColoredTextBox tb) { 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) { tb[fromLine].RemoveRange(fromChar, toChar - fromChar); } else { tb[fromLine].RemoveRange(fromChar, tb[fromLine].Count - fromChar); tb[toLine].RemoveRange(0, toChar); tb.RemoveLine(fromLine + 1, toLine - fromLine - 1); InsertCharCommand.MergeLines(fromLine, tb); } // tb.Selection.Start = new Place(fromChar, fromLine); // tb.needRecalc = true; }