Example #1
0
        internal static void BreakLines(int iLine, int pos, TextSource ts)
        {
            Line newLine = ts.CreateLine();

            for (int i = pos; i < ts[iLine].Count; i++)
            {
                newLine.Add(ts[iLine][i]);
            }
            ts[iLine].RemoveRange(pos, ts[iLine].Count - pos);
            //
            ts.InsertLine(iLine + 1, newLine);
        }
Example #2
0
        internal static void InsertLine(TextSource ts)
        {
            var tb = ts.CurrentTB;

            if (!tb.Multiline && tb.LinesCount > 0)
            {
                return;
            }

            if (ts.Count == 0)
            {
                ts.InsertLine(0, ts.CreateLine());
            }
            else
            {
                BreakLines(tb.Selection.Start.iLine, tb.Selection.Start.iChar, ts);
            }

            tb.Selection.Start = new Place(0, tb.Selection.Start.iLine + 1);
            ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
        }