Описание функции
SCI_SETILEXER
Устанавливает лексер
Возвращаемое значение
Ничего. Для проверки успеха использовать SCI_GETLEXER |
Примечания
Чтобы найти имя встроенного лексера нужно скачать исходники, в папке "lexilla\lexers\" открыть соответствующий файл Lex???.cxx, найти в нём конструктор LexerModule (в конце файла) и в нём 3-й параметр в кавычках это имя лексера. Например для HTML это hypertext.См. также
SCI_STYLEПример
; Fred
; https://www.purebasic.fr/english/viewtopic.php?p=616117#p616117
Prototype.i CreateLexerProto(name.p-utf8)
Prototype.i GetLexerCountProto()
Prototype GetLexerNameProto(index.i, *BufferName, *BufferNameLength)
If OpenLibrary(0, "Lexilla.dll")
CreateLexer.CreateLexerProto = GetFunction(0, "CreateLexer")
GetLexerCount.GetLexerCountProto = GetFunction(0, "GetLexerCount")
GetLexerName.GetLexerNameProto = GetFunction(0, "GetLexerName")
If CreateLexer = 0 Or GetLexerCount = 0 Or GetLexerName = 0
Debug "Invalid Lexilla lib"
End
EndIf
EndIf
; List all available lexers
;
NbLexers = GetLexerCount()
Debug "NbLexers: " + NbLexers
*Buffer = AllocateMemory(128)
For k = 0 To NbLexers - 1
GetLexerName(k, *Buffer, MemorySize(*Buffer))
Debug PeekS(*Buffer, MemorySize(*Buffer), #PB_UTF8)
Next
If OpenWindow(0, 0, 0, 330, 90, "ScintillaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ScintillaGadget(0, 10, 10, 320, 70, 0)
Debug "Current lexer ID: " + ScintillaSendMessage(0, #SCI_GETLEXER)
PureBasicLexer = CreateLexer("purebasic")
ScintillaSendMessage(0, #SCI_SETILEXER, 0, PureBasicLexer)
Debug "New Lexer ID: " + ScintillaSendMessage(0, #SCI_GETLEXER)
; Style for numbers
ScintillaSendMessage(0, #SCI_STYLESETFORE, 2, RGB(255, 0, 0))
; Style for strings
ScintillaSendMessage(0, #SCI_STYLESETFORE, 4, RGB(0, 0, 255))
; Set the text to the ScintillaGadget
*Text = UTF8(~"If a = 0\n MessageRequester(\"Hello\", \"World\")\nEndIf")
ScintillaSendMessage(0, #SCI_SETTEXT, 0, *Text)
FreeMemory(*Text) ; The buffer made by UTF8() has to be freed, to avoid memory leak
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf