Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Lua lexer? #23

Closed
nagblock opened this issue Jun 7, 2015 · 2 comments
Closed

Lua lexer? #23

nagblock opened this issue Jun 7, 2015 · 2 comments

Comments

@nagblock
Copy link

nagblock commented Jun 7, 2015

Hi,

As you said you've been implementing lexers on an "as needed basis" I wonder if you would consider adding lua (http://www.lua.org/) to the list? Is this only possible by extending the library itself? I see that there is a custom recipe for python but it uses the Lexer.Python enum for setting everything up. How would one add support for lua without a dedicated lua enum value? Is there a viable option apart from handling StyleNeeded and doing all the lexing manually?

best regards, nagblock

jacobslusser added a commit that referenced this issue Jun 7, 2015
@jacobslusser
Copy link
Owner

I added Lua for you in commit 202759c.

Lexers and styles in ScintillaNET are just integer constants. I get them from the SciLexer.h header file in the native Scintilla project. I include them in ScintillaNET to make it easier for developers, but strictly speaking there is nothing special about it. You could do the same for any lexer not officially in the project like this:

// Obtained from SciLexer.h
const int SCLEX_LUA = 15;
const int SCE_LUA_DEFAULT = 0;
const int SCE_LUA_COMMENT = 1;
const int SCE_LUA_COMMENTLINE = 2;
const int SCE_LUA_COMMENTDOC = 3;
const int SCE_LUA_NUMBER = 4;
const int SCE_LUA_WORD = 5;
const int SCE_LUA_STRING = 6;
const int SCE_LUA_CHARACTER = 7;
const int SCE_LUA_LITERALSTRING = 8;
const int SCE_LUA_PREPROCESSOR = 9;
const int SCE_LUA_OPERATOR = 10;
const int SCE_LUA_IDENTIFIER = 11;
const int SCE_LUA_STRINGEOL = 12;
const int SCE_LUA_WORD2 = 13;
const int SCE_LUA_WORD3 = 14;
const int SCE_LUA_WORD4 = 15;
const int SCE_LUA_WORD5 = 16;
const int SCE_LUA_WORD6 = 17;
const int SCE_LUA_WORD7 = 18;
const int SCE_LUA_WORD8 = 19;
const int SCE_LUA_LABEL = 20;

scintilla.Lexer = (Lexer)SCLEX_LUA;
scintilla.Styles[SCE_LUA_DEFAULT].ForeColor = Color.Black;
scintilla.Styles[SCE_LUA_COMMENT].ForeColor = Color.Green;
// etc..

@nagblock
Copy link
Author

nagblock commented Jun 7, 2015

thanks, that's just what I needed! :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants