Cannot load a lexer

42 views
Skip to first unread message

Roger Tunnicliffe

unread,
Dec 11, 2025, 11:05:20 PM (4 days ago) Dec 11
to scintilla-interest
I am using Linux, FreeBasic, GTK3, Scintilla and lexilla.

Scintilla and Lexilla are both statically linked.

The following code returns pLexer but SETILEXER always returns a 0. 
I have spent so long on this. Can anyone help 

Dim pLexer As Any Ptr = CreateLexer("freebasic")
Dim result As ULong = scintilla_send_message(sci, SCI_GETLEXER, 0, pLexer)
CONST SCI_SETILEXER As UInteger = 2187
result = scintilla_send_message(sci, SCI_SETILEXER, 0, pLexer)

Neil Hodgson

unread,
Dec 11, 2025, 11:29:24 PM (4 days ago) Dec 11
to scintilla...@googlegroups.com
Roger Tunnicliffe:

> The following code returns pLexer but SETILEXER always returns a 0.

SCI_SETILEXER does not return anything. There aren't even any checks
on that call, Scintilla just stores the value given.

https://scintilla.org/ScintillaDoc.html#SCI_SETILEXER

> Dim pLexer As Any Ptr = CreateLexer("freebasic")

Good. Check for NULL.

> Dim result As ULong = scintilla_send_message(sci, SCI_GETLEXER, 0, pLexer)

SCI_GETLEXER doesn't take any arguments. At this point it will likely
return something boring like 0.

> CONST SCI_SETILEXER As UInteger = 2187

From Scintilla.h:
#define SCI_SETILEXER 4033

2187 is not associated with lexing:
#define SCI_GETOVERTYPE 2187

Neil
Message has been deleted

Roger Tunnicliffe

unread,
Dec 12, 2025, 10:05:55 PM (3 days ago) Dec 12
to scintilla-interest

Roger Tunnicliffe
8:
Thx for the reply Neil.

Correcting SCI_SETILEXER did not provide any Highlighting in Scintilla at all.

I have been struggling with this for days and days and the snippet I posted was just a cut down of all those efforts.
The doco page for Lexilla suggest that the posted code is all I need but I keep reading that I have to provide keywords as well.
I have tried that but still get no highlighting. In fact there probably isn't anything I haven't tried (except the right thing I suppose)

As an aside, I have spent days with all those dumb$#@ AI's who can only explain why their idiotic code does not even compile (Mostly they tell you that you are frustrated and that they lied)
God knows why there's been a trillion dollars spent on these things.

All that aside I wonder if you or anyone else here could guide me thru this as I  just don't believe it should be that hard.

edit:- 
Dim pLexer As Any Ptr = CreateLexer("freebasic")
CONST SCI_SETILEXER As UInteger = 4033
VAR result = scintilla_send_message(sci, SCI_SETILEXER, 0, pLexer)
Dim tmp As string
scintilla_send_message(sci, SCI_GETLEXERLANGUAGE, 0, strptr(tmp))

SCI_GETLEXERLANGUAGE returns nothing

Thanking you in advance
Roger

Roger Tunnicliffe

unread,
Dec 12, 2025, 11:33:29 PM (3 days ago) Dec 12
to scintilla-interest
Sorry but I cant see how to edit a post.

The following though

dim R as integer = scintilla_send_message(sci, SCI_GETLEXER, NULL, pLexer)

returns a value of 75

Neil Hodgson

unread,
Dec 13, 2025, 2:23:09 AM (3 days ago) Dec 13
to scintilla...@googlegroups.com
Roger Tunnicliffe:

> Dim pLexer As Any Ptr = CreateLexer("freebasic")
...
> dim R as integer = scintilla_send_message(sci, SCI_GETLEXER, NULL, pLexer)
>
> returns a value of 75

That looks good since that is the right ID for freebasic.
#define SCLEX_FREEBASIC 75

> Correcting SCI_SETILEXER did not provide any Highlighting in Scintilla at all.

Have you defined appearances for the lexical classes?
SCI_STYLESETFORE and related.
https://scintilla.org/ScintillaDoc.html#SCI_STYLESETFORE

Neil

Roger Tunnicliffe

unread,
Dec 13, 2025, 3:44:52 PM (2 days ago) Dec 13
to scintilla-interest
Yes Neil, I have the following code which appears to be working...

VAR sci = scintilla_new()
scintilla_send_message(sci, SCI_STYLESETBACK, STYLE_DEFAULT, mRGB(33,37,43)) ' Background Dark
scintilla_send_message(sci, SCI_STYLESETFORE, STYLE_DEFAULT, mRGB(0,255,255)) ' Foreground Cyan
scintilla_send_message(sci, SCI_STYLESETFONT, STYLE_DEFAULT, strptr("Consolas")) ' Font style
scintilla_send_message(sci, SCI_STYLESETSIZE, STYLE_DEFAULT, 9) ' Font size
scintilla_send_message(sci, SCI_SETTABWIDTH, STYLE_DEFAULT, 2) ' Tab width
scintilla_send_message(sci, SCI_SETSELBACK, STYLE_DEFAULT, mRGB(38,79,120)) ' Selected Text BGR color BLUISH
scintilla_send_message(sci, SCI_SETSELFORE, STYLE_DEFAULT, &hffffff) ' Selected Text FOR color WHITE
scintilla_send_message(sci, SCI_SETCARETFORE,mRGB(255,255,255),0) ' Caret Colour
' Propergate thru all styles
scintilla_send_message(sci, SCI_STYLECLEARALL, 0, 0)

' line-number text + background style
scintilla_send_message(sci, SCI_SETMARGINTYPEN, 1, SC_MARGIN_NUMBER)
scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 1, 45)
scintilla_send_message(sci, SCI_STYLESETFORE, STYLE_LINENUMBER, mRGB(86,133,229))
scintilla_send_message(sci, SCI_STYLESETBACK, STYLE_LINENUMBER, mRGB(56,56,56))

Roger Tunnicliffe

unread,
Dec 13, 2025, 8:50:35 PM (2 days ago) Dec 13
to scintilla-interest
Further to the above Neil..
You have led me to an epiphany.. So I have the following which works

CONST SCI_SETILEXER As UInteger = 4033

CONST SCE_B_COMMENT = 1
CONST SCE_B_NUMBER = 2
CONST SCE_B_KEYWORD = 3
CONST SCE_B_STRING = 4
CONST SCE_B_PREPROCESSOR = 5
CONST SCE_B_OPERATOR = 6
CONST SCE_B_IDENTIFIER = 7
CONST SCE_B_DATE = 8
CONST SCE_B_STRINGEOL = 9
CONST SCE_B_KEYWORD2 = 10
CONST SCE_B_KEYWORD3 = 11
CONST SCE_B_KEYWORD4 = 12
CONST SCE_B_CONSTANT = 13
CONST SCE_B_ASM = 14
CONST SCE_B_LABEL = 15
CONST SCE_B_ERROR = 16
CONST SCE_B_HEXNUMBER = 17
CONST SCE_B_BINNUMBER = 18
CONST SCE_B_COMMENTBLOCK = 19
CONST SCE_B_DOCLINE = 20
CONST SCE_B_DOCBLOCK = 21
CONST SCE_B_DOCKEYWORD = 22

Dim pLexer As Any Ptr = CreateLexer("freebasic")
scintilla_send_message(sci, SCI_SETILEXER, 0, pLexer)

scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_COMMENT, mRGB(90,90,90))
scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_NUMBER, mRGB(255,255,0))
scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_STRING, mRGB(224,176,255))
scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_OPERATOR, mRGB(255,255,255))

and this that doesn't
scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_CONSTANT, mRGB(0,255,255))
scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_ASM, mRGB(0,255,255))
scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_LABEL, mRGB(0,255,255))
dim one_keyword as string = "dim" & &h00
scintilla_send_message(sci, SCI_SETKEYWORDS, 1, strptr(one_keyword))
scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_KEYWORD, mRGB(0,255,255))


from the doc it says.
SCI_SETKEYWORDS(int keyWordSet, const char *keyWords)
You can set up to 9 lists of keywords for use by the current lexer. keyWordSet can be 0 to 8 (actually 0 to KEYWORDSET_MAX) and selects which keyword list to replace

If this is to replace keywords it tells us that they already exist so I am not sure why I would have to add any..
Regardless..
I have the constants from SciLexer.h and am selecting keywords set 1 because LexBasic.cxx says:-

static const char * const freebasicWordListDesc[] = {
"FreeBasic Keywords",
"FreeBasic PreProcessor Keywords",
"user defined 1",
"user defined 2",
0
};

I have tried other keyword lists (0,2,3, etc) but to no avail.
Can you spot what I am doing wrong ???

Cheers
Roger
Reply all
Reply to author
Forward
0 new messages