Page 1 of 1

ScintillaGadget using LEXER

Posted: Sat Jan 17, 2026 6:43 pm
by Kwai chang caine
Hello at all,

I try to using the SciLexer embeded in PureBasic and that not works, perhaps it not exist ?

Code: Select all

#SCI_SETLEXER = 4001

OpenWindow(0, 0, 0, 800, 600, "Editeur Web - Scintilla", #PB_Window_SystemMenu)
IdEditor = ScintillaGadget(#PB_Any, 0, 0, 800, 600, 0)

; Set default font
ScintillaSendMessage(IdEditor, #SCI_STYLESETFONT, #STYLE_DEFAULT, @"Courier New")
ScintillaSendMessage(IdEditor, #SCI_STYLESETSIZE, #STYLE_DEFAULT, 16)
ScintillaSendMessage(IdEditor, #SCI_STYLESETBOLD, #STYLE_DEFAULT, #False)
ScintillaSendMessage(IdEditor, #SCI_STYLESETITALIC, #STYLE_DEFAULT, #False)

ScintillaSendMessage(IdEditor, #SCI_STYLECLEARALL, 0, 0)

; Set PHP style
ScintillaSendMessage(IdEditor, #SCI_STYLESETFORE, #SCLEX_PHP, RGB(255,0,0))
ScintillaSendMessage(IdEditor, #SCI_STYLESETBOLD, #SCLEX_PHP, #True)
ScintillaSendMessage(IdEditor, #SCI_STYLESETITALIC, #SCLEX_PHP, #True)

; Set JS style
ScintillaSendMessage(IdEditor, #SCI_STYLESETFORE, #SCLEX_HTML, RGB(0,255,0))
ScintillaSendMessage(IdEditor, #SCI_STYLESETBOLD, #SCLEX_HTML, #True)
ScintillaSendMessage(IdEditor, #SCI_STYLESETITALIC, #SCLEX_HTML, #True)

; Set CSS style 
ScintillaSendMessage(IdEditor, #SCI_STYLESETFORE, #SCLEX_CSS, RGB(0,0,255))
ScintillaSendMessage(IdEditor, #SCI_STYLESETBOLD, #SCLEX_CSS, #True)
ScintillaSendMessage(IdEditor, #SCI_STYLESETITALIC, #SCLEX_CSS, #True)
 
; Selecting the HTML lexer (the closest one for mixing HTML+PHP+JS)
ScintillaSendMessage(IdEditor, #SCI_SETLEXER, #SCLEX_CONTAINER, #SCLEX_HTML)

; Define PHP words
*PtrListePHP = UTF8("if else echo function return while for foreach")
ScintillaSendMessage(IdEditor, #SCI_SETKEYWORDS, #SCLEX_PHP, *PtrListePHP)
FreeMemory(*PtrListePHP)

; Define JS words
*PtrListeJS = UTF8("var let const if else function return for while")
ScintillaSendMessage(IdEditor, #SCI_SETKEYWORDS, #SCLEX_HTML, *PtrListeJS)
FreeMemory(*PtrListeJS)

; Define CSS words
*PtrListeCSS = UTF8("color background margin padding border")
ScintillaSendMessage(IdEditor, #SCI_SETKEYWORDS, #SCLEX_CSS, *PtrListeCSS)
FreeMemory(*PtrListeCSS)

; Exemple de code Web
code$ = "<html>" + #CRLF$
code$ + "<head><style>body {background-color: #fff;}</style></head>" + #CRLF$
code$ + "<body>" + #CRLF$
code$ + "<?php if($x > 0) { echo 'OK'; } ?>" + #CRLF$
code$ + "<script>if(true){console.log('Hello JS');}</script>" + #CRLF$
code$ + "</body></html>"

; Send source code
*PtrCodeSource = UTF8(code$)
ScintillaSendMessage(IdEditor, #SCI_SETTEXT, 0, *PtrCodeSource)
FreeMemory(*PtrCodeSource)

Repeat
 Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Have a good day

Re: ScintillaGadget using LEXER

Posted: Sat Jan 17, 2026 10:21 pm
by infratec
I think you need at least the SciLexer.dll

https://www.scintilla.org/SciTEDownload.html

Re: ScintillaGadget using LEXER

Posted: Sun Jan 18, 2026 2:24 am
by AZJIO

Re: ScintillaGadget using LEXER

Posted: Sun Jan 18, 2026 8:56 am
by Kwai chang caine
infratec wrote: Sat Jan 17, 2026 10:21 pm I think you need at least the SciLexer.dll
Hello INFRATEC
You have right
After read the link of AZJIO :wink: i know now Fred use personal Lexer :|
So apparently scintillagadget not have lexer
Me too, i have create my own lever, because i not knowed what is lexer when i have begining my project :oops: it works at 90% for the moment and need to be optimized, i'm mainly afffraid for the futur part, the refresh when i add or paste words
Then i wanted compare mine to official LEXER
But apparently..it is not really creating for coloring several languages together, and for the web 4 exist in the same time
I have found nice codes of MRMAT using SciLexer. dll, but not the LEXER too
And i think i'm forced to make a choice, i can't use scintillagadget and adding the scilexer functions :|
Thanks for your advice

@AZJIO
Thanks for this precious link 8)
I have not found this thread because i have search with "scilexer.dll" word, and not know lexilla word :shock:
Again a word i must learn for what it is used :shock:
I have see you have the same need than me :wink:

A good day at you two 8)