gpt4 book ai didi

c# - 使用 Scintilla 添加关键字

转载 作者:太空狗 更新时间:2023-10-30 00:27:59 24 4
gpt4 key购买 nike

我正在使用 ScintillaNET 作为 Scintilla 控件的包装器。我想更改特定语言的关键字(用于语法高亮显示),我假设我必须为此构建我自己的 SciLexer.dll 版本。但是我在 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>

关于c# - 使用 Scintilla 添加关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4351871/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com