Ejemplo n.º 1
0
        internal static void BreakLines(int iLine, int pos, TextSource ts)
        {
            var newLine = ts.CreateLine();

            for (var 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);
        }
Ejemplo n.º 2
0
        internal static void InsertLine(TextSource ts)
        {
            var tb = ts.CurrentTextBox;

            if (!tb.Multiline && tb.LinesCount > 0)
            {
                return;
            }
            if (ts.Count == 0)
            {
                ts.InsertLine(0, ts.CreateLine());
            }
            else
            {
                BreakLines(tb.Selection.Start.Line, tb.Selection.Start.Char, ts);
            }
            tb.Selection.Start = new Place(0, tb.Selection.Start.Line + 1);
            ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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);
 }
        /// <summary>
        /// Chop an existing line into two lines.
        /// This means that this method is also called when pressing enter on the start of a line.
        /// </summary>
        /// <param name="iLine"></param>
        /// <param name="pos"></param>
        /// <param name="ts"></param>
        internal static void BreakLines(int iLine, int pos, TextSource ts)
        {
            Line newLine = ts.CreateLine();

            EolFormat format = EolFormat.None;
            if (iLine < ts.Count - 1)
            {
                // breaking in the middle of an existing line
                format = ts[iLine].EolFormat;
            }
            newLine.EolFormat = format;

            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);
        }