Hi Fred,
Why did you not use lexilla for the PB IDE code?
Is it easier to hardcode within the scintilla code directly?
Or it was already coded before lexilla appeared?
Initscintilla function deprecated
Re: Initscintilla function deprecated
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: Initscintilla function deprecated
We have our own parser because we need much more than just coloring/case correction
- skinkairewalker
- Addict

- Posts: 825
- Joined: Fri Dec 04, 2015 9:26 pm
Re: Initscintilla function deprecated
infratec wrote: Fri Oct 25, 2024 10:05 am Hm ... your code works here without problems.
I only changed the OpenfileRequester() part, removed InitScintilla() and modified the window stuffYou need the lexilla.dll in the same directory as your exe.Code: Select all
EnableExplicit Procedure.s ReadFileToVar(Path$) Protected id_file, Format, Text$ id_file = ReadFile(#PB_Any, Path$) If id_file Format = ReadStringFormat(id_file) Text$ = ReadString(id_file, Format | #PB_File_IgnoreEOL) CloseFile(id_file) EndIf ProcedureReturn Text$ EndProcedure Define NbLexers, *Buffer, i, k, *Text, File$, *Lexer, w, h Prototype.i CreateLexerProto(name.p - utf8) Prototype.i GetLexerCountProto() Prototype GetLexerNameProto(index.i, *BufferName, *BufferNameLength) If OpenLibrary(0, "Lexilla.dll") Define CreateLexer.CreateLexerProto = GetFunction(0, "CreateLexer") Define GetLexerCount.GetLexerCountProto = GetFunction(0, "GetLexerCount") Define GetLexerName.GetLexerNameProto = GetFunction(0, "GetLexerName") If CreateLexer = #Null Or GetLexerCount = #Null Or GetLexerName = #Null Debug "Invalid Lexilla lib" End EndIf EndIf File$ = OpenFileRequester("Choose a html file", #PB_Compiler_Home + "Examples\Sources\Data\WebView\", "HTML|*.htm;*.html", 0) If File$ If FileSize(File$) < 0 End EndIf Else End EndIf ; ; List all available lexers ; ; ; NbLexers = GetLexerCount() ; Debug "NbLexers: "+NbLexers ; ; *Buffer = AllocateMemory(128) ; If *Buffer ; For k = 0 To NbLexers - 1 ; GetLexerName(k, *Buffer, MemorySize(*Buffer)) ; Debug PeekS(*Buffer, MemorySize(*Buffer), #PB_UTF8) ; Next ; FreeMemory(*Buffer) ; EndIf ExamineDesktops() w = DesktopWidth(0) h = DesktopHeight(0) If OpenWindow(0, 0, 0, w - 40, h - 200, "ScintillaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ScintillaGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20, 0) ScintillaSendMessage(0, #SCI_STYLESETSIZE, #STYLE_DEFAULT, 12) ; font size ScintillaSendMessage(0, #SCI_STYLECLEARALL) ScintillaSendMessage(0, #SCI_STYLESETBACK, #STYLE_DEFAULT, $3f3f3f) ScintillaSendMessage(0, #SCI_SETSELBACK, 1, $a0a0a0) ; the background color of the selection ScintillaSendMessage(0, #SCI_SETSELALPHA, 100) ; transparency of the selection For i = 0 To 32 ScintillaSendMessage(0, #SCI_STYLESETBACK, i, $3f3f3f) ScintillaSendMessage(0, #SCI_STYLESETFORE, i, $999999) ; default text color Next *Lexer = CreateLexer("hypertext") ScintillaSendMessage(0, #SCI_SETILEXER, 0, *Lexer) ; HTML ScintillaSendMessage(0, #SCI_STYLESETFORE, 1, $FF9F00) ; Comments ScintillaSendMessage(0, #SCI_STYLESETFORE, 2, $9CCBEB) ; Numbers ScintillaSendMessage(0, #SCI_STYLESETFORE, 3, $8080FF) ; Keyword1 ScintillaSendMessage(0, #SCI_STYLESETFORE, 4, $999999) ; Lines ScintillaSendMessage(0, #SCI_STYLESETFORE, 6, $72ADC0) ; Operators ScintillaSendMessage(0, #SCI_STYLESETFORE, 7, $F78865) ; Keyword Identifier ScintillaSendMessage(0, #SCI_STYLESETFORE, 10, $72ADC0); Keyword2 ScintillaSendMessage(0, #SCI_STYLESETFORE, 11, $FF8000); Keyword3 ScintillaSendMessage(0, #SCI_STYLESETFORE, 12, $71AE71); Keyword4 ScintillaSendMessage(0, #SCI_STYLESETFORE, 13, $DE98D9); Constants ScintillaSendMessage(0, #SCI_STYLESETFORE, 15, $00FFFF); Label ScintillaSendMessage(0, #SCI_STYLESETFORE, 16, $8080FF); Error ScintillaSendMessage(0, #SCI_STYLESETFORE, 17, $D3D08C); Hexnumber ScintillaSendMessage(0, #SCI_STYLESETFORE, 18, $D3D08C); Binnumber ; Set the text to the ScintillaGadget *Text = UTF8(ReadFileToVar(File$)) 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
And set 'Create temporay executable in source directory' for running from the IDE
I'm trying to change the lexer to vb or lua, but apparently it didn't work, is there something I'm forgetting to do???
- Kwai chang caine
- Always Here

- Posts: 5614
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: Initscintilla function deprecated
First thanks a lot to FRED for give this amazing part of code, that i searched since two days
Thanks also to AZJIO for give to me this link and stop my researchs
I suppose native constants of PB style not exist, because FRED have not implemented a LEXER in native ScintillaGadget
For the moment i create mines,
but how FRED know the number of all the styles ?
Thanks also to AZJIO for give to me this link and stop my researchs
I suppose native constants of PB style not exist, because FRED have not implemented a LEXER in native ScintillaGadget
For the moment i create mines,
Code: Select all
#SCI_PB_STYLE_CRLF = 0
#SCI_PB_STYLE_COMMENT = 1
#SCI_PB_STYLE_NUMBER = 2
#SCI_PB_STYLE_STRING = 4FRED wrote:; Style for numbers => 2
- Kwai chang caine
- Always Here

- Posts: 5614
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: Initscintilla function deprecated
After much trial and error, I think I've found the values, but I still don't know if Fred wrote them down somewhere.
Code: Select all
#SCI_PB_STYLE_CRLF = 0
#SCI_PB_STYLE_COMMENT = 1
#SCI_PB_STYLE_NUMBER = 2
#SCI_PB_STYLE_STRING = 4
#SCI_PB_STYLE_NOTFOUND1 = 5
#SCI_PB_STYLE_SPACE = 6
#SCI_PB_STYLE_TEXT = 7
#SCI_PB_STYLE_NOTFOUND2 = 8
#SCI_PB_STYLE_NOTFOUND3 = 9
#SCI_PB_STYLE_NOTFOUND4 = 10
#SCI_PB_STYLE_NOTFOUND5 = 11
#SCI_PB_STYLE_CONSTANT = 13
#SCI_PB_STYLE_NOTFOUND6 = 14
#SCI_PB_STYLE_NOTFOUND7 = 15
#SCI_PB_STYLE_NOTFOUND8 = 16
#SCI_PB_STYLE_DOLLAR = 17
#SCI_PB_STYLE_NOTFOUND9 = 18
#SCI_PB_STYLE_NOTFOUND10 = 19
#SCI_PB_STYLE_NOTFOUND11 = 20
#SCI_PB_STYLE_NOTFOUND12 = 21
#SCI_PB_STYLE_NOTFOUND13 = 22
#SCI_PB_STYLE_NOTFOUND14 = 23
#SCI_PB_STYLE_NOTFOUND15 = 24
#SCI_PB_STYLE_NOTFOUND16 = 25
#SCI_PB_STYLE_NOTFOUND17 = 26
#SCI_PB_STYLE_NOTFOUND18 = 27
#SCI_PB_STYLE_NOTFOUND19 = 28
#SCI_PB_STYLE_NOTFOUND20 = 29
#SCI_PB_STYLE_NOTFOUND21 = 30
#SCI_PB_STYLE_NOTFOUND22 = 31
#SCI_PB_STYLE_EMPTY_CHARAC = 32
