ScintillaGadget using LEXER
Posted: Sat Jan 17, 2026 6:43 pm
Hello at all,
I try to using the SciLexer embeded in PureBasic and that not works, perhaps it not exist ?
Have a good day
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