FastColoredTextBoxNS.InsertCharCommand.InsertLine C# (CSharp) Method

InsertLine() static private method

static private InsertLine ( TextSource ts ) : void
ts TextSource
return void
        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));
        }

Usage Example

示例#1
0
        internal static void InsertText(string insertedText, TextSource ts)
        {
            var tb = ts.CurrentTB;

            try
            {
                tb.Selection.BeginUpdate();
                char cc = '\x0';

                if (ts.Count == 0)
                {
                    InsertCharCommand.InsertLine(ts);
                    tb.Selection.Start = Place.Empty;
                }
                tb.ExpandBlock(tb.Selection.Start.iLine);
                var len = insertedText.Length;
                for (int i = 0; i < len; i++)
                {
                    var c = insertedText[i];
                    if (c == '\r' && (i >= len - 1 || insertedText[i + 1] != '\n'))
                    {
                        InsertCharCommand.InsertChar('\n', ref cc, ts);
                    }
                    else
                    {
                        InsertCharCommand.InsertChar(c, ref cc, ts);
                    }
                }
                ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
            }
            finally {
                tb.Selection.EndUpdate();
            }
        }
All Usage Examples Of FastColoredTextBoxNS.InsertCharCommand::InsertLine