Example #1
0
        /// <summary>
        /// Highlights PHP code
        /// </summary>
        /// <param name="range"></param>
        public void PHPSyntaxHighlight(Range range)
        {
            range.tb.CommentPrefix = "//";
            range.tb.LeftBracket = '(';
            range.tb.RightBracket = ')';
            range.tb.LeftBracket2 = '{';
            range.tb.RightBracket2 = '}';
            range.tb.BracketsHighlightStrategy = BracketsHighlightStrategy.Strategy2;
            //clear style of changed range
            range.ClearStyle(StringStyle, CommentStyle, NumberStyle, VariableStyle, KeywordStyle, KeywordStyle2,
                             KeywordStyle3);

            range.tb.AutoIndentCharsPatterns = @"^\s*\$[\w\.\[\]\'\""]+\s*(?<range>=)\s*(?<range>[^;]+);";

            //
            if (PHPStringRegex == null) InitPHPRegex();
            range.SetStyle(NumberStyle, PHPNumberRegex);
            range.SetStyle(VariableStyle, PHPVarRegex);
            range.SetStyle(KeywordStyle , PHPKeywordRegex1); //
            range.SetStyle(KeywordStyle2, PHPKeywordRegex2);
            range.SetStyle(KeywordStyle3, PHPKeywordRegex3);
            range.SetStylesStringsAndComments(PHPStringRegex, StringStyle, CommentStyle); // By WendyH

            //clear folding markers
            range.ClearFoldingMarkers();
            //set folding markers
            range.SetFoldingMarkers("{", "}"); //allow to collapse brackets block
            range.SetFoldingMarkers(@"/\*", @"\*/"); //allow to collapse comment block
        }
Example #2
0
        /// <summary>
        /// Highlights JavaScript code
        /// </summary>
        /// <param name="range"></param>
        public void JScriptSyntaxHighlight(Range range)
        {
            range.tb.CommentPrefix = "//";
            range.tb.LeftBracket   = '(';
            range.tb.RightBracket  = ')';
            range.tb.LeftBracket2  = '{';
            range.tb.RightBracket2 = '}';
            range.tb.BracketsHighlightStrategy = BracketsHighlightStrategy.Strategy2;
            range.tb.AutoIndentCharsPatterns = @"^\s*[\w\.]+(\s\w+)?\s*(?<range>=)\s*(?<range>[^;]+);";

            range.ClearStyle(StringStyle, CommentStyle, NumberStyle, KeywordStyle);
            if (JScriptStringRegex == null) InitJScriptRegex();
            range.SetStyle(NumberStyle, JScriptNumberRegex);
            range.SetStyle(KeywordStyle, JScriptKeywordRegex);
            range.SetStylesStringsAndComments(JScriptStringRegex, StringStyle, CommentStyle);
            range.ClearFoldingMarkers();
            range.SetFoldingMarkers("{", "}"); //allow to collapse brackets block
            range.SetFoldingMarkers(@"/\*", @"\*/"); //allow to collapse comment block
        }
Example #3
0
        /// <summary>
        /// Highlights PascalScript code
        /// </summary>
        /// <param name="range"></param>
        public void PascalScriptSyntaxHighlight(Range range)
        {
            range.tb.CommentPrefix = "//";
            range.tb.LeftBracket   = '(';
            range.tb.RightBracket  = ')';
            range.tb.LeftBracket2  = '\x0';
            range.tb.RightBracket2 = '\x0';

            range.tb.BracketsHighlightStrategy = BracketsHighlightStrategy.Strategy1;
            range.tb.AutoIndentCharsPatterns = @"^\s*[\w\.]+(\s\w+)?\s*(?<range>=)\s*(?<range>[^;]+);^\s*(case|default)\s*[^:]*(?<range>:)\s*(?<range>[^;]+);";

            range.ClearStyle(StringStyle, CommentStyle, NumberStyle, KeywordStyle, BoldStyle, BoldStyle2, FunctionsStyle, VariableStyle, ConstantsStyle);
            if (PascalScriptStringRegex == null) InitPascalScriptRegex();
            range.SetStyle(NumberStyle      , PascalScriptNumberRegex  );
            range.SetStyle(KeywordStyle     , PascalScriptKeywordRegex1);
            range.SetStyle(ClassNameStyle   , PascalScriptClassNameRegex);
            range.SetStyle(AltPascalKeywordsHighlight ? BoldStyle2 : BoldStyle, PascalScriptKeywordRegex2);
            range.SetStyle(FunctionsStyle   , HMS.RegexHmsFunctions);
            range.SetStyle(VariableStyle    , HMS.RegexHmsVariables);
            range.SetStyle(ConstantsStyle   , HMS.RegexHmsConstants);
            range.SetStyle(DeclFunctionStyle, regexDeclFunctionPAS);
            range.SetStylesStringsAndComments(PascalScriptStringRegex, StringStyle, CommentStyle);
            range.ClearFoldingMarkers();
            range.SetFoldingMarkers(@"\b(begin|try)\b", @"\b(end)\b", RegexCompiledOption | RegexOptions.IgnoreCase); //allow to collapse brackets block
        }
Example #4
0
 /// <summary>
 /// Highlights C++Script code
 /// </summary>
 /// <param name="range"></param>
 public void CPPScriptSyntaxHighlight(Range range)
 {
     range.tb.CommentPrefix = "//";
     range.tb.LeftBracket   = '(';
     range.tb.RightBracket  = ')';
     range.tb.LeftBracket2  = '{';
     range.tb.RightBracket2 = '}';
     range.tb.BracketsHighlightStrategy = BracketsHighlightStrategy.Strategy2;
     range.tb.AutoIndentCharsPatterns = @"^\s*[\w\.]+(\s\w+)?\s*(?<range>=)\s*(?<range>[^;]+);^\s*(case|default)\s*[^:]*(?<range>:)\s*(?<range>[^;]+);";
     range.ClearStyle(StringStyle, CommentStyle, NumberStyle, AttributeStyle, ClassNameStyle, KeywordStyle, FunctionsStyle, DeclFunctionStyle, VariableStyle, ConstantsStyle);
     if (CSharpStringRegex     == null) InitCSharpRegex();
     if (CPPScriptKeywordRegex == null) InitCPPScriptRegex();
     range.SetStyle(NumberStyle   , CSharpNumberRegex);
     range.SetStyle(AttributeStyle, CSharpAttributeRegex);
     range.SetStyle(ClassNameStyle, CPPClassNameRegex);
     range.SetStyle(FunctionsStyle, HMS.RegexHmsFunctions);
     range.SetStyle(VariableStyle , HMS.RegexHmsVariables);
     range.SetStyle(ConstantsStyle, HMS.RegexHmsConstants);
     range.SetStyle(DeclFunctionStyle, regexDeclFunctionCPP);
     range.SetStyle(KeywordStyle  , CPPScriptKeywordRegex);
     range.SetStylesStringsAndComments(CSharpStringAndCommentsRegex, StringStyle, CommentStyle);
     range.ClearFoldingMarkers();
     range.SetFoldingMarkers("{", "}");       //allow to collapse brackets block
 }
Example #5
0
        /// <summary>
        /// Highlights C# code
        /// </summary>
        /// <param name="range"></param>
        public void CSharpSyntaxHighlight(Range range)
        {
            range.tb.CommentPrefix = "//";
            range.tb.LeftBracket = '(';
            range.tb.RightBracket = ')';
            range.tb.LeftBracket2 = '{';
            range.tb.RightBracket2 = '}';
            range.tb.BracketsHighlightStrategy = BracketsHighlightStrategy.Strategy2;

            range.tb.AutoIndentCharsPatterns = @"^\s*[\w\.]+(\s\w+)?\s*(?<range>=)\s*(?<range>[^;]+);^\s*(case|default)\s*[^:]*(?<range>:)\s*(?<range>[^;]+);";
            range.ClearStyle(StringStyle, CommentStyle, NumberStyle, AttributeStyle, ClassNameStyle, KeywordStyle);
            if (CSharpStringRegex == null) InitCSharpRegex();
            range.SetStyle(NumberStyle, CSharpNumberRegex);
            range.SetStyle(AttributeStyle, CSharpAttributeRegex);
            range.SetStyle(ClassNameStyle, CSharpClassNameRegex);
            range.SetStyle(KeywordStyle, CSharpKeywordRegex);
            range.SetStylesStringsAndComments(CSharpStringAndCommentsRegex, StringStyle, CommentStyle); // By WendyH

            //find document comments
            foreach (Range r in range.GetRanges(@"^\s*///.*$", RegexOptions.Multiline)) {
                //remove C# highlighting from this fragment
                r.ClearStyle(StyleIndex.All);
                //do XML highlighting
                if (HTMLTagRegex == null)
                    InitHTMLRegex();
                //
                r.SetStyle(CommentStyle);
                //tags
                foreach (Range rr in r.GetRanges(HTMLTagContentRegex)) {
                    rr.ClearStyle(StyleIndex.All);
                    rr.SetStyle(CommentTagStyle);
                }
                //prefix '///'
                foreach (Range rr in r.GetRanges(@"^\s*///", RegexOptions.Multiline)) {
                    rr.ClearStyle(StyleIndex.All);
                    rr.SetStyle(CommentTagStyle);
                }
            }

            //clear folding markers
            range.ClearFoldingMarkers();
            //set folding markers
            range.SetFoldingMarkers("{", "}"); //allow to collapse brackets block
            range.SetFoldingMarkers(@"#region\b", @"#endregion\b"); //allow to collapse #region blocks
            range.SetFoldingMarkers(@"/\*", @"\*/"); //allow to collapse comment block
        }
Example #6
0
 /// <summary>
 /// Highlights BasicScript code
 /// </summary>
 /// <param name="range"></param>
 public void BasicSyntaxHighlight(Range range)
 {
     range.tb.CommentPrefix = "'";
     range.tb.LeftBracket   = '(';
     range.tb.RightBracket  = ')';
     range.tb.LeftBracket2  = '\x0';
     range.tb.RightBracket2 = '\x0';
     range.tb.AutoIndentCharsPatterns = @"^\s*[\w\.\(\)]+\s*(?<range>=)\s*(?<range>.+)";
     range.ClearStyle(StringStyle, CommentStyle, NumberStyle, ClassNameStyle, KeywordStyle, FunctionsStyle, VariableStyle, ConstantsStyle);
     if (VBStringRegex == null) InitVBRegex();
     if (BasicScriptKeywordRegex1 == null) InitBasicScriptRegex();
     range.SetStyle(NumberStyle   , VBNumberRegex);
     range.SetStyle(ClassNameStyle, VBClassNameRegex);
     range.SetStyle(KeywordStyle  , BasicScriptKeywordRegex1);
     range.SetStyle(BlueBoldStyle , BasicScriptKeywordRegex2);
     range.SetStyle(FunctionsStyle, HMS.RegexHmsFunctions);
     range.SetStyle(VariableStyle , HMS.RegexHmsVariables);
     range.SetStyle(ConstantsStyle, HMS.RegexHmsConstants);
     range.SetStyle(DeclFunctionStyle, regexDeclFunctionBAS);
     range.SetStylesStringsAndComments(VBStringRegex, StringStyle, CommentStyle, false);
     range.ClearFoldingMarkers();
     range.SetFoldingMarkers(@"#Region\b", @"#End\s+Region\b", RegexOptions.IgnoreCase);
     range.SetFoldingMarkers(@"\b(Class|Property|Enum|Structure|Interface)[ \t]+\S+", @"\bEnd (Class|Property|Enum|Structure|Interface)\b", RegexOptions.IgnoreCase);
     range.SetFoldingMarkers(@"^\s*(?<range>While)[ \t]+\S+", @"^\s*(?<range>End While)\b", RegexOptions.Multiline | RegexOptions.IgnoreCase);
     range.SetFoldingMarkers(@"\b(Sub|Function)[ \t]+[^\s']+", @"\bEnd (Sub|Function)\b"  , RegexOptions.IgnoreCase);
     //this declared separately because Sub and Function can be unclosed
     //range.SetFoldingMarkers(@"(\r|\n|^)[ \t]*(?<range>Get|Set)[ \t]*(\r|\n|$)", @"\bEnd (Get|Set)\b", RegexOptions.IgnoreCase);
     //range.SetFoldingMarkers(@"^\s*(?<range>For|For\s+Each)\b", @"^\s*(?<range>Next)\b", RegexOptions.Multiline | RegexOptions.IgnoreCase);
     //range.SetFoldingMarkers(@"^\s*(?<range>Do)\b", @"^\s*(?<range>Loop)\b", RegexOptions.Multiline | RegexOptions.IgnoreCase);
 }
Example #7
0
 /// <summary>
 /// Highlights YAML code
 /// </summary>
 /// <param name="range"></param>
 public void YAMLSyntaxHighlight(Range range)
 {
     range.tb.CommentPrefix = "#";
     range.tb.LeftBracket   = '(';
     range.tb.RightBracket  = ')';
     range.tb.LeftBracket2  = '\x0';
     range.tb.RightBracket2 = '\x0';
     range.ClearStyle(StringStyle, CommentStyle, NumberStyle, KeywordStyle, ClassNameStyle, TagBracketStyle, VariableStyle, ConstantsStyle);
     if (YAMLStringRegex == null) InitYAMLRegex();
     range.SetStyle(NumberStyle, YAMLNumberRegex);
     range.SetStyle(ClassNameStyle , YAMLObjectNameRegex);
     range.SetStyle(VariableStyle  , HMS.RegexHmsVariables);
     range.SetStyle(ConstantsStyle , HMS.RegexHmsConstants);
     range.SetStyle(TagBracketStyle, YAMLBreaketsRegex);
     range.SetStyle(KeywordStyle   , YAMLKeywordRegex);
     range.SetStylesStringsAndComments(YAMLStringRegex, StringStyle, CommentStyle);
     range.ClearFoldingMarkers();
     range.SetFoldingMarkers(@"^[\s-]*?\w+\s*?:", "[IDENT]", RegexOptions.Multiline); // Allow to collapse block
 }
        // By WendyH > -------------------------------------------------------
        /// <summary>
        /// Highlights JScript code
        /// </summary>
        /// <param name="range"></param>
        public void HmsJScriptSyntaxHighlight(Range range)
        {
            range.tb.CommentPrefix = "//";
            range.tb.LeftBracket   = '(';
            range.tb.RightBracket  = ')';
            range.tb.LeftBracket2  = '{';
            range.tb.RightBracket2 = '}';
            range.tb.BracketsHighlightStrategy = BracketsHighlightStrategy.Strategy1;
            range.tb.AutoIndentCharsPatterns   = @"^\s*[\w\.]+(\s\w+)?\s*(?<range>=)\s*(?<range>[^;]+);";
            if (JScriptNumberRegex     == null) InitJScriptRegex();
            if (HmsJScriptKeywordRegex == null) InitHmsJScriptRegex();
            if (CPPClassNameRegex      == null) InitCPPScriptRegex();
            bool bigText = range.Text.Length > MaxLenght4FastWork;

            range.ClearStyleAndFuncBegin(StringStyle, CommentStyle, NumberStyle, DeclFunctionStyle, FunctionsStyle, VariableStyle, ConstantsStyle, PunctuationSyle, KeywordStyle, ClassNameStyle);
            range.SetStylesStringsAndComments(CPPStringAndCommentsRegex, StringStyle, CommentStyle);
            range.SetStyle(NumberStyle      , JScriptNumberRegex  );
            range.SetFunct(DeclFunctionStyle, regexDeclFunctionCPP);

            range.ClearFoldingMarkers();
            range.SetFoldingMarkers("{", "}"); //allow to collapse brackets block

            if (bigText && !Worker4BigText.IsBusy) {
                Worker4BigText.RunWorkerAsync(new Syntax2StepArgs(currentLanguage, range));
            } else {
                HmsJScriptSyntaxHighlight2(range);
            }
        }
        /// <summary>
        /// Highlights BasicScript code
        /// </summary>
        /// <param name="range"></param>
        public void BasicSyntaxHighlight(Range range)
        {
            range.tb.CommentPrefix = "'";
            range.tb.LeftBracket   = '(';
            range.tb.RightBracket  = ')';
            range.tb.LeftBracket2  = '[';
            range.tb.RightBracket2 = ']';
            range.tb.AutoIndentCharsPatterns = @"^\s*[\w\.\(\)]+\s*(?<range>=)\s*(?<range>.+)";
            if (VBStringRegex            == null) InitVBRegex();
            if (BasicScriptKeywordRegex1 == null) InitBasicScriptRegex();
            if (CPPClassNameRegex        == null) InitCPPScriptRegex();
            bool bigText = range.Text.Length > MaxLenght4FastWork;

            range.ClearStyleAndFuncBegin(StringStyle, CommentStyle, NumberStyle, DeclFunctionStyle, ClassNameStyle, KeywordStyle, FunctionsStyle, VariableStyle, ConstantsStyle, PunctuationSyle, TypesStyle);
            range.SetStylesStringsAndComments(VBStringRegex, StringStyle, CommentStyle, false);
            range.SetStyle(NumberStyle      , VBNumberRegex);
            range.SetFunct(DeclFunctionStyle, regexDeclFunctionBAS);

            range.ClearFoldingMarkers();
            range.SetFoldingMarkers(@"#Region\b"                                           , @"#End\s+Region\b"                                  , RegexOptions.IgnoreCase);
            range.SetFoldingMarkers(@"\b(Class|Property|Enum|Structure|Interface)[ \t]+\S+", @"\bEnd (Class|Property|Enum|Structure|Interface)\b", RegexOptions.IgnoreCase);
            range.SetFoldingMarkers(@"^\s*(?<range>While)[ \t]+\S+"                        , @"^\s*(?<range>End While)\b"                        , RegexOptions.IgnoreCase | RegexOptions.Multiline);
            //this declared separately because Sub and Function can be unclosed
            range.SetFoldingMarkers(@"\b(Sub|Function)[ \t]+[^\s']+"                       , @"\bEnd (Sub|Function)\b"                           , RegexOptions.IgnoreCase);
            range.SetFoldingMarkers(@"\bIF[ \t][^\n]+THEN\s*?$"                            , @"\bEND IF\b"                                       , RegexOptions.IgnoreCase | RegexOptions.Multiline);
            range.SetFoldingMarkers(@"(\r|\n|^)[ \t]*(?<range>Get|Set)[ \t]*(\r|\n|$)"     , @"\bEnd (Get|Set)\b"                                , RegexOptions.IgnoreCase);
            range.SetFoldingMarkers(@"^\s*(?<range>For|For\s+Each)\b"                      , @"^\s*(?<range>Next)\b"                             , RegexOptions.IgnoreCase | RegexOptions.Multiline);
            range.SetFoldingMarkers(@"^\s*(?<range>Do)\b"                                  , @"^\s*(?<range>Loop)\b"                             , RegexOptions.IgnoreCase | RegexOptions.Multiline);

            if (bigText && !Worker4BigText.IsBusy) {
                Worker4BigText.RunWorkerAsync(new Syntax2StepArgs(currentLanguage, range));
            } else {
                BasicSyntaxHighlight2(range);
            }
        }
        /// <summary>
        /// Highlights PascalScript code
        /// </summary>
        /// <param name="range"></param>
        public void PascalScriptSyntaxHighlight(Range range)
        {
            range.tb.CommentPrefix = "//";
            range.tb.LeftBracket   = '(';
            range.tb.RightBracket  = ')';
            range.tb.LeftBracket2  = '[';
            range.tb.RightBracket2 = ']';
            range.tb.BracketsHighlightStrategy = BracketsHighlightStrategy.Strategy1;
            range.tb.AutoIndentCharsPatterns   = @"^\s*[\w\.]+(\s\w+)?\s*(?<range>=)\s*(?<range>[^;]+);^\s*(case|default)\s*[^:]*(?<range>:)\s*(?<range>[^;]+);";
            if (PascalScriptStringRegex == null) InitPascalScriptRegex();
            bool bigText = range.Text.Length > MaxLenght4FastWork;

            range.ClearStyleAndFuncBegin(StringStyle, CommentStyle, NumberStyle, DeclFunctionStyle, ClassNameStyle, KeywordStyle, FunctionsStyle, VariableStyle, ConstantsStyle, TypesStyle, PunctuationSyle);
            range.SetStylesStringsAndComments(PascalScriptStringRegex, StringStyle, CommentStyle);
            range.SetStyle(NumberStyle      , PascalScriptNumberRegex);
            range.SetFunct(DeclFunctionStyle, regexDeclFunctionPAS   );

            range.ClearFoldingMarkers();
            range.SetFoldingMarkers(@"\b(repeat)\b"   , @"\b(until)\b", RegexCompiledOption | RegexOptions.IgnoreCase); //allow to collapse brackets block
            range.SetFoldingMarkers(@"\b(begin|try)\b", @"\b(end)\b"  , RegexCompiledOption | RegexOptions.IgnoreCase); //allow to collapse brackets block

            if (bigText && !Worker4BigText.IsBusy) {
                Worker4BigText.RunWorkerAsync(new Syntax2StepArgs(currentLanguage, range));
            } else {
                PascalScriptSyntaxHighlight2(range);
            }
        }