Page 18 of 20
Re: GoScintilla - 2.6 (Purebasic 4.5 onwards)
Posted: Mon Jul 02, 2012 12:22 pm
by ts-soft
Here my simple search version without regex:
Code: Select all
Procedure GoSCI_Search(id, search.s, direction, flags)
Protected *mem, pos, result
Protected selstart, selend
If search
*mem = AllocateMemory(StringByteLength(search, #PB_UTF8) + 1)
If *mem
PokeS(*mem, search, -1, #PB_UTF8)
If direction = 0
pos = ScintillaSendMessage(id, #SCI_GETSELECTIONSTART) - 1
Else
pos = ScintillaSendMessage(id, #SCI_GETSELECTIONEND) + 1
EndIf
ScintillaSendMessage(id, #SCI_SETSEL, pos, pos)
ScintillaSendMessage(id, #SCI_SEARCHANCHOR)
If direction
result = ScintillaSendMessage(id, #SCI_SEARCHNEXT, flags, *mem)
Else
result = ScintillaSendMessage(id, #SCI_SEARCHPREV, flags, *mem)
EndIf
If result <> -1
selstart = ScintillaSendMessage(id, #SCI_GETSELECTIONSTART)
selend = ScintillaSendMessage(id, #SCI_GETSELECTIONEND)
GOSCI_SetState(id, #GOSCI_CURRENTLINE, ScintillaSendMessage(id, #SCI_LINEFROMPOSITION, result))
ScintillaSendMessage(id, #SCI_SETSELECTIONSTART, selstart)
ScintillaSendMessage(id, #SCI_SETSELECTIONEND, selend)
ScintillaSendMessage(id, #SCI_SCROLLCARET)
EndIf
FreeMemory(*mem)
EndIf
ProcedureReturn result
EndIf
EndProcedure
Re: GoScintilla - 2.6 (Purebasic 4.5 onwards)
Posted: Mon Jul 02, 2012 2:10 pm
by srod
The problem with that method Thomas is that the control can be scrolled even when no match is found because you are using the #SCI_SETSEL message regardless.
You're best off, inmo, using a targeted search.
Here's my version which I will add to the next update of GoScintilla.
Code: Select all
Procedure GOSCI_Search(id, search.s, direction=#GOSCI_SEARCHFORWARDS, flags=0)
Protected result, *mem, pos, numBytes, byteLen
Protected selstart, selend
If IsGadget(id) And GadgetType(id) = #PB_GadgetType_Scintilla And search
numBytes = ScintillaSendMessage(id, #SCI_GETLENGTH)
If numBytes
byteLen = StringByteLength(search, #PB_UTF8)
*mem = AllocateMemory(byteLen+1)
If *mem
PokeS(*mem, search, -1, #PB_UTF8)
ScintillaSendMessage(id, #SCI_SETSEARCHFLAGS, flags)
If direction = #GOSCI_SEARCHBACKWARDS
pos = ScintillaSendMessage(id, #SCI_GETSELECTIONSTART)
ScintillaSendMessage(id, #SCI_SETTARGETSTART, pos)
ScintillaSendMessage(id, #SCI_SETTARGETEND, 0)
result = ScintillaSendMessage(id, #SCI_SEARCHINTARGET, byteLen, *mem)
If result <> -1
ScintillaSendMessage(id, #SCI_SETSEL, ScintillaSendMessage(id, #SCI_GETTARGETSTART), ScintillaSendMessage(id, #SCI_GETTARGETEND))
EndIf
Else
pos = ScintillaSendMessage(id, #SCI_GETSELECTIONEND)
ScintillaSendMessage(id, #SCI_SETTARGETSTART, pos)
ScintillaSendMessage(id, #SCI_SETTARGETEND, numBytes)
result = ScintillaSendMessage(id, #SCI_SEARCHINTARGET, byteLen, *mem)
If result <> -1
ScintillaSendMessage(id, #SCI_SETSEL, ScintillaSendMessage(id, #SCI_GETTARGETSTART), ScintillaSendMessage(id, #SCI_GETTARGETEND))
EndIf
EndIf
FreeMemory(*mem)
EndIf
EndIf
ProcedureReturn result
EndIf
EndProcedure
You will need to add the following to the header file :
Code: Select all
;Search direction.
Enumeration
#GOSCI_SEARCHBACKWARDS
#GOSCI_SEARCHFORWARDS
EndEnumeration
Re: GoScintilla - 2.6 (Purebasic 4.5 onwards)
Posted: Mon Jul 02, 2012 2:27 pm
by ts-soft
Hello Stephen,
byteLen doesn't include place for the stringterminator, i think it is better to add a byte for this.
Have you made a test with purifier?
Re: GoScintilla - 2.6 (Purebasic 4.5 onwards)
Posted: Mon Jul 02, 2012 2:29 pm
by srod
The null terminator is not required for the #SCI_SEARCHINTARGET message.
**EDIT : ah yes, for the PokeS()!
I shall edit the code. Thanks.
Why would I run the purifier?
Re: GoScintilla - 2.6 (Purebasic 4.5 onwards)
Posted: Mon Jul 02, 2012 2:36 pm
by ts-soft
srod wrote:Why would I run the purifier?
The should say you, there is to small memory allocation for PokeS
I have not tested your code with purifier, i am to lazy to write a example,
but i test most time my allocations with purifier!
Re: GoScintilla - 2.6 (Purebasic 4.5 onwards)
Posted: Mon Jul 02, 2012 3:23 pm
by srod
Not required as I see it. The memory allocation is now correct.
Re: GoScintilla - 2.6 (Purebasic 4.5 onwards)
Posted: Sat Aug 11, 2012 1:02 pm
by srod
GoScintilla 2.7 - 11th Aug 2012
GoScintilla 2.7 adds a targeted search facility as well as a facility for highlighting error lines (typically those which generate compiler errors etc).
The history.txt file lists the detailed changes as of course does the .chm help manual.
In terms of error markers; GoScintilla can highlight any lines deemed to contain errors in much the same way that the PB IDE highlights lines which generate compiler errors.
Please note that error markers are implemented by means of a suitable Scintilla marker and share the same margin as GoScintilla bookmarks. For this reason, it is very important that you read the relevant parts of the GoScintilla user manual if using both bookmarks and error markers with the same document etc.
There is a demo showing the error markers in use.
Please see the nxSoftware site for the download.
Re: GoScintilla - 2.6 (Purebasic 4.5 onwards)
Posted: Sat Aug 11, 2012 1:08 pm
by ts-soft

for the update
Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)
Posted: Sat Feb 23, 2013 5:45 pm
by LCD
Update to 5.10 final made GoSci not working anymore because of "disallow native type for pointers"... (because beginners were "confused" by this). I'm confused by this.
Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)
Posted: Sat Feb 23, 2013 5:52 pm
by srod
Just remove the .i or .q etc. from which ever statements cause the compiler to fail.
On beta 4 (haven't upgraded to the final version yet) I only had to alter 1 such line.
Change
to
Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)
Posted: Sun Feb 24, 2013 1:10 am
by LCD
srod wrote:Just remove the .i or .q etc. from which ever statements cause the compiler to fail.
On beta 4 (haven't upgraded to the final version yet) I only had to alter 1 such line.
Change
to
Thanks, this works now...
Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)
Posted: Tue Mar 12, 2013 12:08 pm
by venom27
Hello,
Thank you for this superb LIB.
I do not speak much English, but can change the background color?
Sorry if the question was already asked.
EDIT :
I found my answer
Code: Select all
GOSCI_SetColor(id, #GOSCI_BACKCOLOR, Color)
@++
Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)
Posted: Sun Mar 24, 2013 8:51 pm
by uwekel
Hi,
i wasn't able to change the line number back and fore colors. I wanted to change them to black background and white text color.
Example:
Code: Select all
GOSCI_SetColor(1, #GOSCI_LINENUMBERBACKCOLOR, $000000)
GOSCI_SetColor(1, #GOSCI_LINENUMBERFORECOLOR, $FFFFFF)
This has no effect

Any ideas?
Btw, line 40 and 41 of the header file seems to have a bug, the letter "O" is missing:
Code: Select all
#GSCI_CALLTIPBACKCOLOR ;Get/Set.
#GSCI_CALLTIPFORECOLOR ;Get/Set.
Best regards
Uwe
Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)
Posted: Sun Mar 24, 2013 9:11 pm
by srod
GOSCI_SetFont() and GOSCI_SETCOLOR() with #GOSCI_BACKCOLOR or #GOSCI_FORECOLOR resets the various styles.
Hence, you should place all line-number color changes after any of these statements.
Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)
Posted: Sun Mar 24, 2013 10:09 pm
by uwekel
srod wrote:GOSCI_SetFont() ... resets the various styles.
That's it

Thx a lot, srod!