使用Scintilla添加关键字
问题描述:
我使用ScintillaNET作为Scintilla控件的封装,我想更改特定语言的关键字(用于语法高亮显示),我假设我必须构建自己的SciLexer.dll版本但是我找不到Scintilla项目中的语言关键字文件,它们在哪里以及如何更改它们?使用Scintilla添加关键字
答
您不需要构建自己的SciLexer.dll,ScintillaNET支持XML配置。文件中设置的Scintilla的的性质是这样的:
// Relative to your running directory
scintilla1.ConfigurationManager.CustomLocation = "Config.xml";
//Name of the language as defined in the file
scintilla1.ConfigurationManager.Language = "MyLanguage";
然后建立这样一个,它是基于LUA的配置文件:
<?xml version="1.0" encoding="utf-8"?>
<ScintillaNET>
<!--This is what you set the Language property to-->
<Language Name="lua">
<!--These are characters after which autocomplete will open-->
<AutoComplete FillUpCharacters=".([" SingleLineAccept="True" IsCaseSensitive="False">
<List>
<!--Insert autocomplete keywords here-->
and break do else elseif end false for function
if in local nil not or repeat return then true until while
</List>
</AutoComplete>
<!--Indentation width and indentation type-->
<Indentation TabWidth="4" SmartIndentType="cpp" />
<!--Comment characters and the lexer to use-->
<Lexer LexerName="lua" LineCommentPrefix="--" StreamCommentPrefix="--[[ " StreamCommentSuffix=" ]]" >
<Keywords List="0" Inherit="False">
<!--Insert highlighted keywords here-->
and break do else elseif end false for function
if in local nil not or repeat return then true until while
</Keywords>
</Lexer>
</Language>
</ScintillaNET>
太棒了。谢谢 :) – david 2010-12-04 06:07:09