MBS; DesktopScintillaControlMBS; InitializeLexer;

Win10 | Xojo 2021r3.1 | MBS22.1pre1 | DesktopScintillaControlMBS

me.SciSQL.InitializeLexer("sql")
Is this initializing enough to get styled SQL?
Or need libraries to be loaded?

Problem is source entered in control is not styled…

Any idea?
Thanks a lot in advance!

Well, that initializes the lexer. You still need to set keywords and define styles.

See sql.properties for Scite:

See my blog post for HTML today: Configure Scintilla Control for HTML

So you grab the keyword lists and put them into the Keywords() property for the control.

And here are the SQL style constants:

const SCE_SQL_DEFAULT = 0
const SCE_SQL_COMMENT = 1
const SCE_SQL_COMMENTLINE = 2
const SCE_SQL_COMMENTDOC = 3
const SCE_SQL_NUMBER = 4
const SCE_SQL_WORD = 5
const SCE_SQL_STRING = 6
const SCE_SQL_CHARACTER = 7
const SCE_SQL_SQLPLUS = 8
const SCE_SQL_SQLPLUS_PROMPT = 9
const SCE_SQL_OPERATOR = 10
const SCE_SQL_IDENTIFIER = 11
const SCE_SQL_SQLPLUS_COMMENT = 13
const SCE_SQL_COMMENTLINEDOC = 15
const SCE_SQL_WORD2 = 16
const SCE_SQL_COMMENTDOCKEYWORD = 17
const SCE_SQL_COMMENTDOCKEYWORDERROR = 18
const SCE_SQL_USER1 = 19
const SCE_SQL_USER2 = 20
const SCE_SQL_USER3 = 21
const SCE_SQL_USER4 = 22
const SCE_SQL_QUOTEDIDENTIFIER = 23
const SCE_SQL_QOPERATOR = 24

And finally you may translate the style definitions or make your own.
e.g.

c.Style(SCE_SQL_DEFAULT).foreColor = &c00000
c.Style(SCE_SQL_COMMENT).foreColor = &cFF80FF

similar to our MySQL example in the sample project.

Styling did work!

Thanks a lot for the examples!