Page 1 of 1
Scintilla: auto-indent: how to?
Posted: Sun Jul 28, 2024 7:31 am
by morosh
Hello:
I'm searching for auto-indent feature for Scintilla, with no luck.
did someone developed that and like to share?
Thanks in advance
Re: Scintilla: auto-indent: how to?
Posted: Sun Jul 28, 2024 8:23 am
by TassyJim
My method which is unlikely to be the "correct" way is:
I intercept the CR key and do a number if things when the line ends.
Because the CR was intercepted, the first thing is to insert the end-of-line character(s)
Then I copy the line indentation from the last line to the new line.
Look in the scintilla help for #SCI_GETLINEINDENTATION and #SCI_SETLINEINDENTATION.
You might want to work out if the new line needs a different indentation based on the text of the previous line.
It works for me...
Re: Scintilla: auto-indent: how to?
Posted: Sun Jul 28, 2024 7:55 pm
by morosh
Thank you, I'll try.
Meanwhile, I still searching for a readymade solution
Re: Scintilla: auto-indent: how to?
Posted: Mon Jul 29, 2024 1:28 pm
by firace
Perhaps you can take a look at the PB IDE source code, which uses Scintilla:
https://www.purebasic.fr/english/viewtopic.php?t=74151
(Procedure UpdateIndent and Procedure AutoIndent)
Re: Scintilla: auto-indent: how to?
Posted: Mon Jul 29, 2024 3:17 pm
by Tenaja
morosh wrote: Sun Jul 28, 2024 7:31 am
Hello:
I'm searching for auto-indent feature for Scintilla, with no luck.
did someone developed that and like to share?
Thanks in advance
Look for GoScintilla on the forum. It's a full featured library that takes care of almost all of the regularly used features of an IDE, including this. At the least, you can copy the procs needed.
Re: Scintilla: auto-indent: how to?
Posted: Mon Jul 29, 2024 3:41 pm
by skywalk
I was considering migrating from rich editor to scintilla for easier syntax highlighting and indenting.
I started to browse the IDE code but globals are in another area and it is slightly difficult to follow.
Does GoScintilla support syntax highlighting?
I read Lexilla is now a separate lib.
Does anyone have code snippet calling the lexer directly?
Is it less or more work to recreate the lexer commands for a single language?
Re: Scintilla: auto-indent: how to?
Posted: Mon Jul 29, 2024 5:32 pm
by morosh
Thank you all!!!
yes GoScintilla is really excellent, finally my callback looks like that (if anyone is also looking for, like me):
Code: Select all
Procedure ScintillaCallBack(Gadget, *scinotify.SCNotification)
Protected nPos, startLine, level
Select *scinotify\nmhdr\code
Case #SCN_CHARADDED
If *scinotify\ch=10
nPos = ScintillaSendMessage(Gadget, #SCI_GETCURRENTPOS)
startLine = ScintillaSendMessage(Gadget, #SCI_LINEFROMPOSITION, nPos)-1
level = ScintillaSendMessage(Gadget, #SCI_GETLINEINDENTATION, startLine)
If level > 0
startLine+1
ScintillaSendMessage(Gadget, #SCI_SETLINEINDENTATION, startLine, level)
nPos = ScintillaSendMessage(Gadget, #SCI_GETLINEINDENTPOSITION, startLine)
ScintillaSendMessage(Gadget, #SCI_GOTOPOS, nPos)
EndIf
EndIf
Case #SCN_STYLENEEDED
Highlight(Gadget, *scinotify\position)
EndSelect
EndProcedure
Re: Scintilla: auto-indent: how to?
Posted: Wed Jul 31, 2024 5:13 am
by Tenaja
Does GoScintilla support syntax highlighting?
gosci is a full featured customizable lexer that supports almost everything.
Re: Scintilla: auto-indent: how to?
Posted: Fri Aug 02, 2024 4:47 pm
by skywalk
Where is the latest gosci lib/module?
I found a module from 2019.
Re: Scintilla: auto-indent: how to?
Posted: Fri Aug 02, 2024 6:29 pm
by Tenaja
skywalk wrote: Fri Aug 02, 2024 4:47 pm
Where is the latest gosci lib/module?
I found a module from 2019.
That module is probably the latest. I have not been using it lately, so I have not updated it myself. With srod being inactive since 2020, he has not been updating it. However, in 2017, he posted:
current version of GoScintilla (2.7) seems to work fine with PB 5.51 x86
Any updates that are required should be minimal. It is an excellent, thorough, and consistent library, and would be worth your time if you want to do anything more than one or two features. The examples that he provided were also quite helpful, and well rounded.
Re: Scintilla: auto-indent: how to?
Posted: Fri Aug 02, 2024 6:37 pm
by skywalk
I found it here:
v301
Yes, it is an excellent library. I was writing too much code already available in these fine libs.
Re: Scintilla: auto-indent: how to?
Posted: Fri Aug 02, 2024 10:38 pm
by TassyJim
GoScintilla works well with PB6.11 x64. Windows and Linux.
There are a few places where .l needs changing to .i
I also had to change the size allocated to some string buffers at some stage. My notes are not very informative.
My main project uses a mixture of goScintilla and direct ScintillaSendMessage calls.
Re: Scintilla: auto-indent: how to?
Posted: Fri Aug 02, 2024 11:14 pm
by skywalk
Dang it!
I'm crashing the calltip demo's when compiling threadsafe.
Without creating a thread!
Meaning, I'm just running the example code with/without threadsafe.
Just hitting backspace or enter?
And the lib does not support UTF8 characters?
I might have to go back and rewrite just what I need.
