Please note it is the spotSearch() procedure that does the highlights (or should).
Code: Select all
Global Output$, HelpText5
Procedure gettext()
cmd$ = "powershell.exe"
param$ = "(curl https://www.purebasic.com/documentation/reference/ide_commandline.html).Content"
exe = RunProgram(cmd$,param$,"", 2 | 4 | 8) ;
Output$ = ""
If exe
Debug "PLEASE WAIT A MOMENT ! ! !"
While ProgramRunning(exe)
s$ = ReadProgramString(exe) + Chr(13)
If Len(s$) > 2
Output$ +s$
EndIf
;Debug er$
Wend
Output$ + Chr(13) + Chr(13)
Output$ + "Exitcode: " + Str(ProgramExitCode(exe))
Output$ + " -- END --"
EndIf
EndProcedure
gettext()
;Debug Output$
#Window_5 = 0
Enumeration
#UserPick_5
#PrvUsr_5
#NxtUsr_5
#ViewPhoto_5
#F4_5
#Back_5
#Next_5
#Close_5
#HelpText_5
EndEnumeration
Structure myCHARFORMAT2 ; --> Structure for formatting EditorGadget
cbSize.i
dwMask.i
dwEffects.i
yHeight.i
yOffset.i
crTextColor.i
bCharSet.B
bPitchAndFamily.B
szFaceName.B[#LF_FACESIZE]
nullPad.W
wWeight.W
sSpacing.W
crBackColor.i
LCID.i
dwReserved.i
sStyle.W
wKerning.W
bUnderlineType.B
bAnimation.B
bRevAuthor.B
bReserved1.B
EndStructure
#CFM_BACKCOLOR = $4000000 ;FindText highlightings
Global defaultFormat.myCHARFORMAT2, editFind.FINDTEXT, helpFormat.myCHARFORMAT2, Range.CHARRANGE
Global editFormat.myCHARFORMAT2, CursorPosition.POINT,ErrorMessage$
; --> Find text from start to end of text : spotSearch(CtrlID,textToFind1$,textToFind2$,textToFind3$)
; --> Find text from start to end of text : spotSearch(CtrlID,textToFind1$,textToFind2$,textToFind3$)
editFind.FINDTEXT
editFind\chrg\cpMin = 0 ; this will change in procedure as text is found
editFind\chrg\cpMax = -1
; --> Our found text background
editFormat.myCHARFORMAT2
editFormat\cbSize = SizeOf(myCHARFORMAT2)
editFormat\dwMask = #CFM_BACKCOLOR
editFormat\crBackColor = RGB(255, 205, 225)
; --> Our default EditorGdaget background color
defaultFormat.myCHARFORMAT2
defaultFormat\cbSize = SizeOf(myCHARFORMAT2)
defaultFormat\dwMask = #CFM_BACKCOLOR
defaultFormat\crBackColor = RGB(255, 255, 255)
; --> Our default Help window gadget background color
helpFormat.myCHARFORMAT2
helpFormat\cbSize = SizeOf(myCHARFORMAT2)
helpFormat\dwMask = #CFM_BACKCOLOR
helpFormat\crBackColor = $9B9BFF
fontSan10.i = LoadFont(#PB_Default,"MS Sans Serif",10)
HWND5 = OpenWindow(#Window_5, 0,0,631,600, "TroubleShooting", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar)
If HWND5
UserPick5 = ComboBoxGadget(#UserPick_5, 31, 0, 159, 20)
ButtonGadget(#PrvUsr_5, 0, 0, 30, 20, "<< |")
ButtonGadget(#NxtUsr_5, 190, 0, 30, 20, "| >>")
ViewPhoto5 = ButtonGadget(#ViewPhoto_5, -5, 0, 225, 25, "&View Photo")
ButtonGadget(#F4_5, 220, 0, 120, 25, "[F4] CLIPBOARD")
ButtonGadget(#Back_5, 340, 0, 110, 25, "<<< &BACK ")
ButtonGadget(#Next_5, 450, 0, 100, 25, " &NEXT >>>")
ButtonGadget(#Close_5, 550, 0, 80, 25, "CLOSE")
SetGadgetFont(#PB_Default,FontID(fontSan10.i))
HelpText5 = EditorGadget(#HelpText_5, -2, 25, 625, 570)
SendMessage_(HelpText5, #EM_SETTARGETDEVICE, #Null, 0) ; 0=wrap , 1up=linewidth , $FFFFFF(effectively)=wrapoff
SendMessage_(HelpText5, #EM_SETREADONLY, 1, 0)
SendMessage_(HelpText5, #EM_SETBKGNDCOLOR, 0, RGB(255, 255, 255))
SetGadgetText(#HelpText_5, "HelpText")
HideGadget(#PrvUsr_5,1)
HideGadget(#NxtUsr_5,1)
HideGadget(#UserPick_5,1)
EndIf
SetGadgetText(#HelpText_5,Output$)
Procedure spotSearch(CtrlID,textToFind1$,textToFind2$,textToFind3$)
If textToFind1$ <> "a"
ShowWindow_(CtrlID,#SW_HIDE)
; --> Reset search to beginnng
SendMessage_(CtrlID, #EM_SETSEL, 0, 0)
; --> For resetting to default text
;SendMessage_(CtrlID, #EM_SETCHARFORMAT, #SCF_ALL, defaultFormat)
SendMessage_(CtrlID, #EM_SETCHARFORMAT, 0, defaultFormat)
PostMessage_(HelpText5, #EM_SETREADONLY, 1, 0)
; --> Split the seaarch words
spaces = CountString(textToFind1$, " ")
For i = 1 To spaces+1
editFind\chrg\cpMin = 0
thisFind$ = StringField(textToFind1$, i, " ")
editFind\lpstrText = @thisFind$
Repeat
found = SendMessage_(CtrlID, #EM_FINDTEXT, #FR_DOWN, editFind)
If found > -1
editFind\chrg\cpMin = found+1
; --> Set the selection to colorize
SendMessage_(CtrlID, #EM_SETSEL, found, found + Len(thisFind$))
; --> Colorize selection background
SendMessage_(CtrlID, #EM_SETCHARFORMAT, #SCF_SELECTION | #SCF_WORD, editFormat)
EndIf
Until found = -1 ;/ COLOR SETTINGS AT TOP OF PROGRAM LISTING
Next i
If Len(textToFind2$) ;/ See: myCHARFORMAT2
; --> Split the seaarch words
spaces = CountString(textToFind2$, " ")
For i = 1 To spaces+1
editFind\chrg\cpMin = 0
thisFind$ = StringField(textToFind2$, i, " ")
editFind\lpstrText = @thisFind$
Repeat
found = SendMessage_(CtrlID, #EM_FINDTEXT, #FR_DOWN, editFind)
If found > -1
editFind\chrg\cpMin = found+1
; --> Set the selection to colorize
SendMessage_(CtrlID, #EM_SETSEL, found, found + Len(thisFind$))
; --> Colorize selection background
SendMessage_(CtrlID, #EM_SETCHARFORMAT, #SCF_SELECTION | #SCF_WORD, editFormat)
EndIf
Until found = -1
Next i
EndIf
If Len(textToFind3$)
; --> Split the seaarch words
spaces = CountString(textToFind3$, " ")
For i = 1 To spaces+1
editFind\chrg\cpMin = 0
thisFind$ = StringField(textToFind3$, i, " ")
editFind\lpstrText = @thisFind$
Repeat
found = SendMessage_(CtrlID, #EM_FINDTEXT, #FR_DOWN, editFind)
If found > -1
editFind\chrg\cpMin = found+1
; --> Set the selection to colorize
SendMessage_(CtrlID, #EM_SETSEL, found, found + Len(thisFind$))
; --> Colorize selection background
SendMessage_(CtrlID, #EM_SETCHARFORMAT, #SCF_SELECTION | #SCF_WORD, editFormat)
EndIf
Until found = -1
Next i
EndIf
ShowWindow_(CtrlID,#SW_SHOW)
SendMessage_(CtrlID, #EM_SETSEL, 0, 0)
EndIf
EndProcedure
textToFind1$ = "the"
textToFind2$ = "or"
textToFind3$ = "is"
spotSearch(HelpText5,textToFind1$,textToFind2$,textToFind3$)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Is it an API problem? Maybe all Those APIs belong to 32 Bit OS only?