예제 #1
0
 private void FastColoredTextBox1OnPasting(object sender, TextChangingEventArgs args)
 {
     LogLine("Pasting " + args.InsertingText);
     Console.WriteLine("Pasting " + args.InsertingText);
 }
예제 #2
0
        private void FastColoredTextBox1OnTextChanging(object sender, TextChangingEventArgs args)
        {
            LogLine("TextChanging " + args.InsertingText);
            Console.WriteLine("TextChanging " + args.InsertingText);

            if (args.InsertingText != null && args.InsertingText.Length == 1)
            {
                char c = args.InsertingText[0];
                if (c == '{')
                {
                    lastCharIsOpenBracket = true; // TODO: Ignore when we are inside a string
                    doCompletionOnEnter = false;
                }
                else if (c == '\n' && lastCharIsOpenBracket)
                {
                    if (this.hasPosition && this.caretPosition == this.fastColoredTextBox1.Selection.Start)
                    {
                        // only do bracket completion on enter when the caret position is the same
                        lastCharIsOpenBracket = false; // don't trigger again
                        doCompletionOnEnter = true;
                    }
                    this.hasPosition = false;
                    this.caretPosition = Place.Empty;

                    // do stuff, but do it in the Changed
                    /*
                    args.InsertingText += "\n}";

                    lastCharIsOpenBracket = false; // don't trigger again

                    // because we added more text the caret will be placed at the end of that, make sure we put the caret position back
                    resetPosition = true;
                    caretPosition = this.fastColoredTextBox1.Selection.Start;
                    */

                }
                else
                {
                    lastCharIsOpenBracket = false;
                    doCompletionOnEnter = false;
                }
            }
        }