InsertChar() static private method

static private InsertChar ( char c, char &deletedChar, TextSource ts ) : void
c char
deletedChar char
ts TextSource
return void
示例#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);
                foreach (char c in insertedText)
                {
                    InsertCharCommand.InsertChar(c, ref cc, ts);
                }
                ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
            }
            finally
            {
                tb.Selection.EndUpdate();
            }
        }
示例#2
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();
            }
        }
示例#3
0
 internal static void InsertText(string insertedText, FastColoredTextBox tb)
 {
     try
     {
         tb.Selection.BeginUpdate();
         char cc = '\x0';
         if (tb.LinesCount == 0)
         {
             InsertCharCommand.InsertLine(tb);
         }
         tb.ExpandBlock(tb.Selection.Start.iLine);
         foreach (char c in insertedText)
         {
             InsertCharCommand.InsertChar(c, ref cc, tb);
         }
         tb.needRecalc = true;
     }
     finally {
         tb.Selection.EndUpdate();
     }
 }