Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding keywords with Scintilla

I"m using ScintillaNET a wrapper for the Scintilla control. I want to change the keywords (for syntax highlighting) for a specific language, I am assuming I have to build my own version of SciLexer.dll for that. But I can't find a keyword file for the languages in the Scintilla project. Where are they and how can I change them?

like image 652
rayanisran Avatar asked Jan 20 '23 23:01

rayanisran


1 Answers

You don't need to build your own SciLexer.dll, ScintillaNET supports XML config files. Set the properties of the Scintilla like this:

// Relative to your running directory
scintilla1.ConfigurationManager.CustomLocation = "Config.xml"; 
//Name of the language as defined in the file
scintilla1.ConfigurationManager.Language = "MyLanguage";

Then create a config file like this one, which is based on 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>
like image 54
Migwell Avatar answered Jan 30 '23 19:01

Migwell