AmandaInterface.FileEditorTab._TextChanged C# (CSharp) Method

_TextChanged() private method

private _TextChanged ( object sender, TextChangedEventArgs e ) : void
sender object
e TextChangedEventArgs
return void
        private void _TextChanged(object sender, TextChangedEventArgs e)
        {
            AmandaTagParser parser = new AmandaTagParser();
            parser.Parse(textBox.Text);

            // Set isEdited to true so the we can ask the user to save the file when he closes the program.
            //
            if (!IsEdited) IsEdited = true;

            e.ChangedRange.ClearStyle(KeywordStyle, CommentStyle, ConstantStyle, FunctionStyle);

            e.ChangedRange.SetStyle(KeywordStyle, @"\b(where|if|else|True|False|otherwise)\b");
            e.ChangedRange.SetStyle(CommentStyle, @"\|\|.*");                          //comments ||...
            e.ChangedRange.SetStyle(ConstantStyle, @"\b(\B-)?[0-9]+\b");                  //numbers 123, -123, to be removed?
            e.ChangedRange.SetStyle(ConstantStyle, @"""[^""\\]*(?:\\.[^""\\]*)*""?");   //string "", source: stackoverflow
            e.ChangedRange.SetStyle(ConstantStyle, @"'[^'\\]*(?:\\.[^'\\]*)*'?");       //char ''

            foreach(string functionName in parser.AmandaTags.Select(q => q.Name))
            {
                e.ChangedRange.SetStyle(FunctionStyle, @"\b" + functionName + @"\b" );
            }
        }