ICSharpCode.TextEditor 配制高亮语法()

            
            string dirPath=Application.StartupPath;        
            ICSharpCode.TextEditor.Document.FileSyntaxModeProvider filePvd=new ICSharpCode.TextEditor.Document.FileSyntaxModeProvider( dirPath);
            doc.HighlightingManager.Manager.AddSyntaxModeFileProvider(filePvd);
            this.txtPad1.SetHighlighting( "LUA" );    
            
            
            this.txtPad1.Text="--int char \"123456\" " ;    
            this.textEditorControl2.Text= et01.Document.HighlightingStrategy.Name ;    
踩坑记录: FileSyntaxModeProvider 后的参数只能是"不含文件名的路径",该方法会自动加载路径下的  " .xshd" 文件,*xshd 文件模板:

<?xml version=”1.0″?><!– syntaxdefinition for C/C++ 2001 by Andrea Paatz and Mike Krueger –>

<SyntaxDefinition name = “C++.NET” extensions = “.c;.h;.cc;.C;.cpp;.hpp”> <Properties> <Property name=”LineComment” value=”//”/> </Properties> <Digits name = “Digits” bold = “false” italic = “false” color = “DarkBlue”/> <RuleSets> <RuleSet ignorecase = “false”> <Delimiters>~!%^*()-+=|\#/{}[]:;”‘&lt;&gt; , .?</Delimiters> <Span name = “PreprocessorDirectives” bold=”false” italic=”false” color=”Green” stopateol = “true”> <Begin>#</Begin> </Span> <Span name = “LineComment” bold = “false” italic = “false” color = “Green” stopateol = “true”> <Begin>//</Begin> </Span> <Span name = “BlockComment” bold = “false” italic = “false” color = “Green” stopateol = “false”> <Begin>/*</Begin> <End>*/</End> </Span> <Span name = “String” bold = “false” italic = “false” color = “Magenta” stopateol = “true” escapecharacter=”\”> <Begin>”</Begin> <End>”</End> </Span> <Span name = “Char” bold = “false” italic = “false” color = “Magenta” stopateol = “true” escapecharacter=”\”> <Begin>&apos;</Begin> <End>&apos;</End> </Span> <MarkPrevious bold = “true” italic = “false” color = “MidnightBlue”>(</MarkPrevious> <KeyWords name = “Punctuation” bold = “false” italic = “false” color = “DarkGreen”> <Key word = “?” /> <Key word = “,” /> <Key word = “.” /> <Key word = “;” /> <Key word = “(” /> <Key word = “)” /> <Key word = “[” /> <Key word = “]” /> <Key word = “{” /> <Key word = “}” /> <Key word = “+” /> <Key word = “-” /> <Key word = “/” /> <Key word = “%” /> <Key word = “*” /> <Key word = “&lt;” /> <Key word = “&gt;” /> <Key word = “^” /> <Key word = “=” /> <Key word = “~” /> <Key word = “!” /> <Key word = “|” /> <Key word = “&amp;” /> </KeyWords> <KeyWords name = “ManagedKeyWords” bold=”true” italic=”false” color=”Black”> <Key word = “__abstract” /> <Key word = “__box” /> <Key word = “__delegate” /> <Key word = “__gc” /> <Key word = “__identifier” /> <Key word = “__nogc” /> <Key word = “__pin” /> <Key word = “__property” /> <Key word = “__sealed” /> <Key word = “__try_cast” /> <Key word = “__typeof” /> <Key word = “__value” /> <Key word = “__event” /> <Key word = “__hook” /> <Key word = “__raise” /> <Key word = “__unhook” /> <Key word = “__interface” /> </KeyWords> <KeyWords name = “AccessKeywords” bold=”true” italic=”false” color=”Black”> <Key word = “this” /> </KeyWords> <KeyWords name = “OperatorKeywords” bold=”true” italic=”false” color=”DarkCyan”> <Key word = “and” /> <Key word = “and_eq” /> <Key word = “bitand” /> <Key word = “bitor” /> <Key word = “new” /> <Key word = “not” /> <Key word = “not_eq” /> <Key word = “or” /> <Key word = “or_eq” /> <Key word = “xor” /> <Key word = “xor_eq” /> </KeyWords> <KeyWords name = “NameSpaces” bold=”true” italic=”false” color=”Green”> <Key word = “using” /> <Key word = “namespace” /> </KeyWords> <KeyWords name = “Friends” bold=”false” italic=”false” color=”Brown”> <Key word = “friend” /> </KeyWords> <KeyWords name = “AccessModifiers” bold=”true” italic=”false” color=”Blue”> <Key word = “private” /> <Key word = “protected” /> <Key word = “public” /> <Key word = “const” /> <Key word = “volatile” /> <Key word = “static” /> </KeyWords> <KeyWords name = “Types” bold=”false” italic=”false” color=”Red”> <Key word = “bool” /> <Key word = “char” /> <Key word = “unsigned” /> <Key word = “union” /> <Key word = “virtual” /> <Key word = “double” /> <Key word = “float” /> <Key word = “short” /> <Key word = “signed” /> <Key word = “void” /> <Key word = “class” /> <Key word = “enum” /> <Key word = “struct” /> </KeyWords> <KeyWords name = “Literals” bold=”true” italic=”false” color=”Black”> <Key word = “false” /> <Key word = “true” /> </KeyWords> <KeyWords name = “IterationStatements” bold=”true” italic=”false” color=”Blue”> <Key word = “do” /> <Key word = “for” /> <Key word = “while” /> </KeyWords> <KeyWords name = “JumpStatements” bold=”false” italic=”false” color=”Navy”> <Key word = “break” /> <Key word = “continue” /> <Key word = “goto” /> <Key word = “return” /> </KeyWords> <KeyWords name = “ExceptionHandlingStatements” bold=”true” italic=”false” color=”Teal”> <Key word = “catch” /> <Key word = “throw” /> <Key word = “try” /> </KeyWords> <KeyWords name = “SelectionStatements” bold=”true” italic=”false” color=”Blue”> <Key word = “case” /> <Key word = “else” /> <Key word = “if” /> <Key word = “switch” /> <Key word = “default” /> </KeyWords> <KeyWords name = “KEYWORD1″ bold=”true” italic=”false” color=”Blue”> <Key word = “asm” /> <Key word = “auto” /> <Key word = “compl” /> <Key word = “mutable” /> <Key word = “typename” /> </KeyWords> </RuleSet> </RuleSets></SyntaxDefinition>

————————
            
            string dirPath=Application.StartupPath;        
            ICSharpCode.TextEditor.Document.FileSyntaxModeProvider filePvd=new ICSharpCode.TextEditor.Document.FileSyntaxModeProvider( dirPath);
            doc.HighlightingManager.Manager.AddSyntaxModeFileProvider(filePvd);
            this.txtPad1.SetHighlighting( "LUA" );    
            
            
            this.txtPad1.Text="--int char \"123456\" " ;    
            this.textEditorControl2.Text= et01.Document.HighlightingStrategy.Name ;    
踩坑记录: FileSyntaxModeProvider 后的参数只能是"不含文件名的路径",该方法会自动加载路径下的  " .xshd" 文件,*xshd 文件模板:

<?xml version=”1.0″?><!– syntaxdefinition for C/C++ 2001 by Andrea Paatz and Mike Krueger –>

<SyntaxDefinition name = “C++.NET” extensions = “.c;.h;.cc;.C;.cpp;.hpp”> <Properties> <Property name=”LineComment” value=”//”/> </Properties> <Digits name = “Digits” bold = “false” italic = “false” color = “DarkBlue”/> <RuleSets> <RuleSet ignorecase = “false”> <Delimiters>~!%^*()-+=|\#/{}[]:;”‘&lt;&gt; , .?</Delimiters> <Span name = “PreprocessorDirectives” bold=”false” italic=”false” color=”Green” stopateol = “true”> <Begin>#</Begin> </Span> <Span name = “LineComment” bold = “false” italic = “false” color = “Green” stopateol = “true”> <Begin>//</Begin> </Span> <Span name = “BlockComment” bold = “false” italic = “false” color = “Green” stopateol = “false”> <Begin>/*</Begin> <End>*/</End> </Span> <Span name = “String” bold = “false” italic = “false” color = “Magenta” stopateol = “true” escapecharacter=”\”> <Begin>”</Begin> <End>”</End> </Span> <Span name = “Char” bold = “false” italic = “false” color = “Magenta” stopateol = “true” escapecharacter=”\”> <Begin>&apos;</Begin> <End>&apos;</End> </Span> <MarkPrevious bold = “true” italic = “false” color = “MidnightBlue”>(</MarkPrevious> <KeyWords name = “Punctuation” bold = “false” italic = “false” color = “DarkGreen”> <Key word = “?” /> <Key word = “,” /> <Key word = “.” /> <Key word = “;” /> <Key word = “(” /> <Key word = “)” /> <Key word = “[” /> <Key word = “]” /> <Key word = “{” /> <Key word = “}” /> <Key word = “+” /> <Key word = “-” /> <Key word = “/” /> <Key word = “%” /> <Key word = “*” /> <Key word = “&lt;” /> <Key word = “&gt;” /> <Key word = “^” /> <Key word = “=” /> <Key word = “~” /> <Key word = “!” /> <Key word = “|” /> <Key word = “&amp;” /> </KeyWords> <KeyWords name = “ManagedKeyWords” bold=”true” italic=”false” color=”Black”> <Key word = “__abstract” /> <Key word = “__box” /> <Key word = “__delegate” /> <Key word = “__gc” /> <Key word = “__identifier” /> <Key word = “__nogc” /> <Key word = “__pin” /> <Key word = “__property” /> <Key word = “__sealed” /> <Key word = “__try_cast” /> <Key word = “__typeof” /> <Key word = “__value” /> <Key word = “__event” /> <Key word = “__hook” /> <Key word = “__raise” /> <Key word = “__unhook” /> <Key word = “__interface” /> </KeyWords> <KeyWords name = “AccessKeywords” bold=”true” italic=”false” color=”Black”> <Key word = “this” /> </KeyWords> <KeyWords name = “OperatorKeywords” bold=”true” italic=”false” color=”DarkCyan”> <Key word = “and” /> <Key word = “and_eq” /> <Key word = “bitand” /> <Key word = “bitor” /> <Key word = “new” /> <Key word = “not” /> <Key word = “not_eq” /> <Key word = “or” /> <Key word = “or_eq” /> <Key word = “xor” /> <Key word = “xor_eq” /> </KeyWords> <KeyWords name = “NameSpaces” bold=”true” italic=”false” color=”Green”> <Key word = “using” /> <Key word = “namespace” /> </KeyWords> <KeyWords name = “Friends” bold=”false” italic=”false” color=”Brown”> <Key word = “friend” /> </KeyWords> <KeyWords name = “AccessModifiers” bold=”true” italic=”false” color=”Blue”> <Key word = “private” /> <Key word = “protected” /> <Key word = “public” /> <Key word = “const” /> <Key word = “volatile” /> <Key word = “static” /> </KeyWords> <KeyWords name = “Types” bold=”false” italic=”false” color=”Red”> <Key word = “bool” /> <Key word = “char” /> <Key word = “unsigned” /> <Key word = “union” /> <Key word = “virtual” /> <Key word = “double” /> <Key word = “float” /> <Key word = “short” /> <Key word = “signed” /> <Key word = “void” /> <Key word = “class” /> <Key word = “enum” /> <Key word = “struct” /> </KeyWords> <KeyWords name = “Literals” bold=”true” italic=”false” color=”Black”> <Key word = “false” /> <Key word = “true” /> </KeyWords> <KeyWords name = “IterationStatements” bold=”true” italic=”false” color=”Blue”> <Key word = “do” /> <Key word = “for” /> <Key word = “while” /> </KeyWords> <KeyWords name = “JumpStatements” bold=”false” italic=”false” color=”Navy”> <Key word = “break” /> <Key word = “continue” /> <Key word = “goto” /> <Key word = “return” /> </KeyWords> <KeyWords name = “ExceptionHandlingStatements” bold=”true” italic=”false” color=”Teal”> <Key word = “catch” /> <Key word = “throw” /> <Key word = “try” /> </KeyWords> <KeyWords name = “SelectionStatements” bold=”true” italic=”false” color=”Blue”> <Key word = “case” /> <Key word = “else” /> <Key word = “if” /> <Key word = “switch” /> <Key word = “default” /> </KeyWords> <KeyWords name = “KEYWORD1″ bold=”true” italic=”false” color=”Blue”> <Key word = “asm” /> <Key word = “auto” /> <Key word = “compl” /> <Key word = “mutable” /> <Key word = “typename” /> </KeyWords> </RuleSet> </RuleSets></SyntaxDefinition>