Initscintilla function deprecated
Initscintilla function deprecated
The function Initscintilla is deprecated with PB 6.10... and dont load any scintilla DLL...
The warning say Initscintilla2() deprecated.
I can't use specific scintilla DLL (scilexer.dll)... for my application.
How to use the predefined lexers in scilexer.dll (ie HTML...) ?
Any help appreciated.
// Not a bug, but intentional. Moved from "Bugs - Windows" to "Coding Questions" (Kiffi)
The warning say Initscintilla2() deprecated.
I can't use specific scintilla DLL (scilexer.dll)... for my application.
How to use the predefined lexers in scilexer.dll (ie HTML...) ?
Any help appreciated.
// Not a bug, but intentional. Moved from "Bugs - Windows" to "Coding Questions" (Kiffi)
Re: Initscintilla function deprecated
https://www.purebasic.fr/english/viewtopic.php?t=83486
Looks like you should open a feature request.
Looks like you should open a feature request.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: Initscintilla function deprecated
Its regrettable that regularly, update broke compatibility with old code...
Nothing to say, nobody listen...
Here is code for use scintilla dll (ie scilexer.dll) with PB 6.10 on WINDOWS.
With standard lexer and full fonctionnal inbuild popup menu.
All my application is to rewrite. Cool.
Nothing to say, nobody listen...
Here is code for use scintilla dll (ie scilexer.dll) with PB 6.10 on WINDOWS.
With standard lexer and full fonctionnal inbuild popup menu.
All my application is to rewrite. Cool.
Code: Select all
EnableExplicit
Enumeration window
#window_new
EndEnumeration
;
Global sci
Procedure WinCallback(hWnd, uMsg, WParam, LParam)
; Windows fills the parameter automatically, which we will use in the callback...
Protected *scinotify.SCNotification
If uMsg=#WM_NOTIFY
*scinotify=LParam
If *scinotify\nmhdr\code=#SCN_UPDATEUI
Debug "notify"
EndIf
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Procedure openwin()
Protected lStyle,*text,text$
;
CompilerIf #PB_Compiler_64Bit
If OpenLibrary(0,"scilexer_x64.dll")
CompilerElse
If OpenLibrary(0,"scilexer_x86.dll")
CompilerEndIf
OpenWindow(#window_new,#PB_Ignore,#PB_Ignore,613,358,"window",#PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
SetWindowCallback(@WinCallback(),#window_new)
;
lStyle = #WS_CHILD | #WS_VISIBLE | #WS_TABSTOP | #WS_CLIPCHILDREN
sci = CreateWindowEx_(0, "Scintilla", #Null, lStyle, 10, 10, 400, 200, WindowID(#window_new), 0, GetModuleHandle_(0), 0)
;
; Output set to red color
SendMessage_(sci, #SCI_STYLESETFORE, 0, RGB(255, 0, 0))
; Set the initial text to the ScintillaGadget
*Text=UTF8("This is a simple ScintillaGadget with text...")
SendMessage_(sci, #SCI_SETTEXT, 0, *Text)
FreeMemory(*Text) ; The buffer made by UTF8() has to be freed, to avoid memory leak
; Adding a second line of text with linebreak before
Text$ = Chr(10) + "Second line"
*Text=UTF8(Text$)
SendMessage_(sci, #SCI_APPENDTEXT, Len(Text$), *Text)
FreeMemory(*Text)
EndIf
EndProcedure
Openwin()
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
CloseWindow(#window_new)
CloseLibrary(0)
Break
EndSelect
ForEver
Re: Initscintilla function deprecated
I don't agree with this. We do what we can to avoid broken changes but computer science is always evolving so do PureBasic. In this case, Scintilla 5 changed the way to handle lexers: https://www.scintilla.org/Scintilla5Migration.htmldrgolf wrote: Sat Feb 17, 2024 11:14 am Its regrettable that regularly, update broke compatibility with old code...
Nothing to say, nobody listen...
Here is code for use scintilla dll (ie scilexer.dll) with PB 6.10 on WINDOWS.
With standard lexer and full fonctionnal inbuild popup menu.
All my application is to rewrite. Cool.
As you are using undocumented features of PureBasic (using 'scilexer.dll' instead of the regular 'scintilla.dll' wasn't documented nor supported) you should be able to understand how to migrate to the new component without complaining and pointing the issue to us.
Here is a quick and dirty example to show how to integrate Lexilla (you need the Lexilla.dll). The style for all languages can be found here https://github.com/ScintillaOrg/lexilla ... SciLexer.h
Code: Select all
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
Re: Initscintilla function deprecated
Hello Fred,
Your help is very appreciated. Big Thank.
Have a good day !
(en Français : merci beaucoup de la part d'un utilisateur de longue date...)
Your help is very appreciated. Big Thank.
Have a good day !
(en Français : merci beaucoup de la part d'un utilisateur de longue date...)
Re: Initscintilla function deprecated
Made a facepalm about this and wrote my own Scintilla_RegisterClasses().
Really bad move to force static Scintilla on everyone.
Really bad move to force static Scintilla on everyone.
Re: Initscintilla function deprecated
Is the static load only if you use a scintilla gadget?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: Initscintilla function deprecated
as a (rather) newbe regarding pb scintilla things I didn't even know about those undocumented features.
Trying to learn from the examples shown in this thread, but don't have libs like scilexer.dll or lexilla.dll. Can someone please point me to where to get them?
Thanks!

Trying to learn from the examples shown in this thread, but don't have libs like scilexer.dll or lexilla.dll. Can someone please point me to where to get them?
Thanks!
Re: Initscintilla function deprecated
Official site: https://www.scintilla.org/micha-b wrote: Can someone please point me to where to get them?
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Except on this sentence...
Re: Initscintilla function deprecated
How to enable HTML code highlighting? Previously there was a constant SCI_SETLEXERLANGUAGE, but now it is gone.
I tried different ways, but it doesn't work.
The documentation states that I should use ILexer5. Is this a structure?
I tried different ways, but it doesn't work.
Code: Select all
PokeS(*Buffer, "hypertext", -1, #PB_UTF8)
ScintillaSendMessage(0, #SCI_SETILEXER, 0, *Buffer) ; the program crashes
; 53=hypertext
ScintillaSendMessage(0, #SCI_SETILEXER, 0, 53)
PokeI(*Buffer, 53)
ScintillaSendMessage(0, #SCI_SETILEXER, 0, *Buffer) ; the program crashes
Code: Select all
ILexer5
class ILexer5 : public ILexer4 {
public:
virtual const char * SCI_METHOD GetName() = 0;
virtual int SCI_METHOD GetIdentifier() = 0;
virtual const char * SCI_METHOD PropertyGet(const char *key) = 0;
};
Re: Initscintilla function deprecated
You need CreateLexer()
Use the example from Fred.
You need the Lexilla.dll which is inside of:
https://www.scintilla.org/wscite32_553.zip x86
or
https://www.scintilla.org/wscite553.zip x64
All is available at:
https://www.scintilla.org/SciTEDownload.html
Use the example from Fred.
You need the Lexilla.dll which is inside of:
https://www.scintilla.org/wscite32_553.zip x86
or
https://www.scintilla.org/wscite553.zip x64
All is available at:
https://www.scintilla.org/SciTEDownload.html
Code: Select all
*iLexer5 = CreateLexer("hypertext")
ScintillaSendMessage(0, #SCI_SETILEXER, 0, *iLexer5)
Re: Initscintilla function deprecated
This line shows that lexers have already been created. Should I create it again? Or it will initialize an existing lexer.
I, of course, used the above example, but it is intended for the programming language being added. This is how keywords are indicated. Should I specify keywords for html?
It seemed to me that if I use a DLL with a built-in engine for several dozen programming languages, then I only have to associate the file extension with the lexer.
Code: Select all
Debug PeekS(*Buffer, MemorySize(*Buffer), #PB_UTF8)
It seemed to me that if I use a DLL with a built-in engine for several dozen programming languages, then I only have to associate the file extension with the lexer.
Re: Initscintilla function deprecated
You are not showing your code.
So I can not tell you why it is not working.
The above example from Fred works.
I can change "purebasic" to "hypertext" and inject a html code.
So I can not tell you why it is not working.
The above example from Fred works.
I can change "purebasic" to "hypertext" and inject a html code.
Re: Initscintilla function deprecated
I don't understand why I should create a lexer. If I don’t understand, then even if it’s easy to do, I won’t be able to do it, because I don’t think it’s necessary to create a lexer if it exists. If it works this way, then this order of things will have to be accepted.
Code: Select all
EnableExplicit
Define NbLexers, *Buffer, i, k, *Text, File$, PureBasicLexer, w, h
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
File$ = OpenFileRequester("OpenFileRequester", GetCurrentDirectory(), "*.htm|*.htm|*.pb|*.pb;*.pbi", 0)
If Asc(File$)
; If Not (Right(File$, 3) = ".pb" Or Right(File$, 4) = ".pbi")
; File$ + ".pb"
; EndIf
If FileSize(File$) < 0
End
EndIf
Else
End
EndIf
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 = 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)
; If PeekS(*Buffer, MemorySize(*Buffer), #PB_UTF8) = "hypertext"
; Debug k
; EndIf
Next
FreeMemory(*Buffer)
ExamineDesktops()
w = DesktopWidth(0)
h = DesktopHeight(0)
If OpenWindow(0, 0, 0, w, h - 40, "ScintillaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If Not InitScintilla()
End
EndIf
ScintillaGadget(0, 10, 10, w - 20, h - 60, 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
PureBasicLexer = CreateLexer("hypertext")
ScintillaSendMessage(0, #SCI_SETILEXER, 0, PureBasicLexer)
; 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
; PureBasic
; ScintillaSendMessage(0, #SCI_STYLESETFORE, 1, $71AE71) ; Comments
; ScintillaSendMessage(0, #SCI_STYLESETFORE, 2, $9CCBEB) ; Numbers
; ScintillaSendMessage(0, #SCI_STYLESETFORE, 3, $FF9F00) ; Keyword1
; ScintillaSendMessage(0, #SCI_STYLESETFORE, 4, $999999) ; Lines
; ScintillaSendMessage(0, #SCI_STYLESETFORE, 6, $8080FF) ; Operators
; ScintillaSendMessage(0, #SCI_STYLESETFORE, 7, $72ADC0) ; Keyword Identifier
; ScintillaSendMessage(0, #SCI_STYLESETFORE, 10, $FF9F00); Keyword2
; ScintillaSendMessage(0, #SCI_STYLESETFORE, 11, $FF8000); Keyword3
; ScintillaSendMessage(0, #SCI_STYLESETFORE, 12, $F78865); 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
Re: Initscintilla function deprecated
Hm ... your code works here without problems.
I only changed the OpenfileRequester() part, removed InitScintilla() and modified the window stuff
You need the lexilla.dll in the same directory as your exe.
And set 'Create temporay executable in source directory' for running from the IDE
I only changed the OpenfileRequester() part, removed InitScintilla() and modified the window stuff
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