ScintillaGadget best event for hightlighting same words selected [Resolved]
Posted: Tue Jul 30, 2024 6:45 pm
Hello at all
Thanks to Danilo/Zebuddhi, I was able to adapt (I don't know by what miracle
) an external PB tool code for highlighting identical words, to code for the same function, but for an internal SyntillaGadget
But after...i don't know where i must put this code ?
on what event ?
After several try, i have put it in the #SCN_Painted of the SyntillaCallback()
That works, bit did i do well? or as usual, i'm way off base ?
Have a good day
Thanks to Danilo/Zebuddhi, I was able to adapt (I don't know by what miracle
But after...i don't know where i must put this code ?
After several try, i have put it in the #SCN_Painted of the SyntillaCallback()
That works, bit did i do well? or as usual, i'm way off base ?
Code: Select all
; Code de départ de Zebuddhi pour outil IDE externe en EXE => https://www.purebasic.fr/english/viewtopic.php?p=381547#p381547
; Modifié par KCC pour ScintillaGadget interne le 30/7/2024
#INDIC_STRAIGHTBOX = 8
#SCI_INDICSETALPHA = 2523
#SCI_INDICSETOUTLINEALPHA = 2558
Procedure ScintillaCallBack(ScintillaGadget.l, *scinotify.SCNotification)
Static MemSelectionTexte.s
Select *scinotify\nmhdr\code
Case #SCN_PAINTED
; Détection du texte sélectionné
SelectionStart = ScintillaSendMessage(ScintillaGadget,#SCI_GETSELECTIONSTART,0,0)
SelectionEnd = ScintillaSendMessage(ScintillaGadget,#SCI_GETSELECTIONEND ,0, 0)
buffer$ = Space(LongueurSelection)
ScintillaSendMessage(ScintillaGadget, #SCI_GETSELTEXT, LongueurSelection, @buffer$)
SelectionTexte$ = PeekS(@buffer$, -1, #PB_UTF8)
If SelectionTexte$ <> MemSelectionTexte
MemSelectionTexte = SelectionTexte$
Length = ScintillaSendMessage(ScintillaGadget,#SCI_GETTEXTLENGTH , 0, 0)
ScintillaSendMessage(ScintillaGadget,#SCI_INDICATORCLEARRANGE, 0, length)
wordlen = Len(SelectionTexte$)
; Retourner tout le texte
MaxTexte = ScintillaSendMessage(ScintillaGadget, #SCI_GETLENGTH) + 1
buffer$ = Space(MaxTexte)
ScintillaSendMessage(ScintillaGadget, #SCI_GETTEXT, MaxTexte, @buffer$)
Texte$ = PeekS(@buffer$, -1, #PB_UTF8)
If Texte$ <> ""
pos = 1
Repeat
Pos = FindString(LCase(Texte$), LCase(SelectionTexte$), pos)
If Pos
ScintillaSendMessage(ScintillaGadget,#SCI_INDICATORFILLRANGE, Pos - 1, wordlen)
Pos + wordlen
EndIf
Until pos = 0
EndIf
EndIf
EndSelect
EndProcedure
style = #INDIC_STRAIGHTBOX
color = RGB($00,$FF,$FF)
InnerAlpha = 50
BorderAlpha = 200
InitScintilla("Scintilla.dll")
OpenWindow(0,10,150,650,500,"Test",#PB_Window_SystemMenu)
Scintilla = ScintillaGadget(#PB_Any, 0, 0, 650, 500, @ScintillaCallBack())
Text$ = "Hello Hello !!! i'm KCC and KCC say the best Hello" + #CRLF$ + "of all the Hello of the world"
*PtrText = UTF8(Text$)
ScintillaSendMessage(Scintilla, #SCI_SETTEXT, 0, *PtrText)
FreeMemory(*PtrText)
RedrawWindow_(GadgetID(Scintilla), 0, 0, #RDW_INVALIDATE|#RDW_UPDATENOW)
ScintillaSendMessage(Scintilla,#SCI_SETINDICATORCURRENT ,9, 0 )
ScintillaSendMessage(Scintilla,#SCI_INDICSETSTYLE ,9, style )
ScintillaSendMessage(Scintilla,#SCI_INDICSETFORE ,9, color )
ScintillaSendMessage(Scintilla,#SCI_INDICSETALPHA ,9, InnerAlpha )
ScintillaSendMessage(Scintilla,#SCI_INDICSETOUTLINEALPHA ,9, BorderAlpha)
ScintillaSendMessage(Scintilla,#SCI_INDICSETUNDER ,9, #False )
Repeat
Evenement = WaitWindowEvent()
Until Evenement = #PB_Event_CloseWindow
