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; }
internal static void ClearSelected(TextSource ts) { var tb = ts.CurrentTB; 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); } // tb.Selection.Start = new Place(fromChar, fromLine); // ts.NeedRecalc(new TextSource.TextChangedEventArgs(fromLine, toLine)); }
internal static void ClearSelected(TextSource ts) { var tb = ts.CurrentTb; tb.Selection.Normalize(); var start = tb.Selection.Start; var end = tb.Selection.End; var fromLine = Math.Min(end.ILine, start.ILine); var toLine = Math.Max(end.ILine, start.ILine); var fromChar = tb.Selection.FromX; var 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); } }