【问题标题】:Adding keywords with Scintilla使用 Scintilla 添加关键字
【发布时间】:2011-05-20 02:35:50
【问题描述】:

我正在使用 ScintillaNET 作为 Scintilla 控件的包装器。我想更改特定语言的关键字(用于语法突出显示),我假设我必须为此构建自己的 SciLexer.dll 版本。但我找不到 Scintilla 项目中语言的关键字文件。它们在哪里?如何更改它们?

【问题讨论】:

    标签: c# syntax-highlighting keyword scintilla


    【解决方案1】:

    您不需要构建自己的 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-25
      • 1970-01-01
      • 2011-07-20
      • 1970-01-01
      • 2017-04-13
      • 2012-12-18
      相关资源
      最近更新 更多