Windows 32bit or 64bit
Thanks to Danilo for the code.
1. shighlighter.exe to pb dir or where ever you want, scintilla.dll replaces \compilers\scintilla.dll.
2. add as tool no params, shortcut (i use) Left Ctrl+`, quick easy to access with one hand
1. highlight word to search for, press shortcut to highlight all
2. cursor on whitespace, press shortcut to un-highlight all
MD5 923ffa611e0db75823a534ad3adda85f
http://goo.gl/NIM9t
works great and a must have saves so much time on larger codebase

Zebuddi.

http://www.purebasic.fr/english/viewtop ... 13&t=49986
Code: Select all
CompilerIf #PB_Compiler_Unicode = 0
CompilerError "Compile with Unicode mode enabled"
CompilerEndIf
#INDIC_STRAIGHTBOX = 8
#INDIC_DASH = 9
#INDIC_DOTS = 10
#INDIC_SQUIGGLELOW = 11
#INDIC_DOTBOX = 12
#SCI_INDICSETALPHA = 2523
#SCI_INDICSETOUTLINEALPHA = 2558
;-----------------------------------
; SETUP
; #INDIC_PLAIN ; Underlined With a single, straight line.
; #INDIC_SQUIGGLE ; A squiggly underline. Requires 3 pixels of descender space.
; #INDIC_TT ; A line of small T shapes.
; #INDIC_DIAGONAL ; Diagonal hatching.
; #INDIC_STRIKE ; Strike out.
; #INDIC_HIDDEN ; An indicator With no visual effect.
; #INDIC_BOX ; A rectangle around the text.
;
; - the following styles don't work with Scintilla used by PB 4.60
; - maybe useful for future versions
;
; #INDIC_ROUNDBOX ; A rectangle with rounded corners around the text using translucent drawing
; ; with the interior usually more transparent than the border.
; ; You can use SCI_INDICSETALPHA And SCI_INDICSETOUTLINEALPHA to control the alpha transparency values.
; ; The default alpha values are 30 for fill colour and 50 for outline colour.
; #INDIC_STRAIGHTBOX ; A rectangle around the text using translucent drawing With the interior
; ; usually more transparent than the border.
; ; You can use SCI_INDICSETALPHA And SCI_INDICSETOUTLINEALPHA to control the alpha transparency values.
; ; The default alpha values are 30 for fill colour and 50 for outline colour.
; #INDIC_DASH ; A dashed underline.
; #INDIC_DOTS ; A dotted underline.
; #INDIC_SQUIGGLELOW ; Similar To INDIC_SQUIGGLE but only using 2 vertical pixels so will fit under small fonts.
; #INDIC_DOTBOX ; A dotted rectangle around the text using translucent drawing.
; ; Translucency alternates between the alpha and outline alpha settings with the top-left pixel
; ; using the alpha setting.
; ; SCI_INDICSETALPHA And SCI_INDICSETOUTLINEALPHA control the alpha transparency values.
; ; The default values are 30 For alpha And 50 For outline alpha.
; ; To avoid excessive memory allocation the maximum width of a dotted box is 4000 pixels.
; ; Not available For OS X Carbon.
style = #INDIC_STRAIGHTBOX
color = RGB($00,$FF,$FF)
InnerAlpha = 50
BorderAlpha = 200
#IGNORE_CASE = #True
;-----------------------------------
NewList positions.i()
NewList source.s()
Global Scintilla = Val( GetEnvironmentVariable("PB_TOOL_Scintilla") )
Global numBytes, utf8Buffer
If Scintilla
SendMessageTimeout_(Scintilla,#SCI_GETSELECTIONSTART,0,0,#SMTO_ABORTIFHUNG,2000,@selectionStart)
SendMessageTimeout_(Scintilla,#SCI_GETSELECTIONEND ,0,0,#SMTO_ABORTIFHUNG,2000,@selectionEnd)
If selectionStart <> selectionEnd
word$=""
For i = selectionStart To selectionEnd-1
SendMessageTimeout_(Scintilla,#SCI_GETCHARAT,i,0,#SMTO_ABORTIFHUNG,2000,@result)
word$ + Chr(result)
Next i
Else
word$ = GetEnvironmentVariable("PB_TOOL_Word")
EndIf
SendMessageTimeout_(Scintilla,#SCI_SETINDICATORCURRENT ,9, 0 ,#SMTO_ABORTIFHUNG,2000,@result)
SendMessageTimeout_(Scintilla,#SCI_INDICSETSTYLE ,9, style ,#SMTO_ABORTIFHUNG,2000,@result)
SendMessageTimeout_(Scintilla,#SCI_INDICSETFORE ,9, color ,#SMTO_ABORTIFHUNG,2000,@result)
SendMessageTimeout_(Scintilla,#SCI_INDICSETALPHA ,9, InnerAlpha ,#SMTO_ABORTIFHUNG,2000,@result)
SendMessageTimeout_(Scintilla,#SCI_INDICSETOUTLINEALPHA ,9, BorderAlpha,#SMTO_ABORTIFHUNG,2000,@result)
SendMessageTimeout_(Scintilla,#SCI_INDICSETUNDER ,9, #False ,#SMTO_ABORTIFHUNG,2000,@result)
If word$
wordlen = Len(word$)
CompilerIf #IGNORE_CASE
word$ = LCase(word$)
CompilerEndIf
#SCI_GETCHARACTERPOINTER = 2520
SendMessageTimeout_(Scintilla,#SCI_SETREADONLY,1,0,#SMTO_ABORTIFHUNG,2000,@result)
SendMessageTimeout_(Scintilla,#SCI_GETCHARACTERPOINTER,0,0,#SMTO_ABORTIFHUNG,2000,@result)
If result
SendMessageTimeout_(Scintilla,#SCI_GETTEXTLENGTH,0,0,#SMTO_ABORTIFHUNG,2000,@length)
memory = AllocateMemory(length+2)
If Not memory
SendMessageTimeout_(Scintilla,#SCI_SETREADONLY,0,0,#SMTO_ABORTIFHUNG,2000,@result)
End
EndIf
GetWindowThreadProcessId_(Scintilla, @processId)
hProcess = OpenProcess_(#PROCESS_ALL_ACCESS, #False, processId)
ReadProcessMemory_(hProcess,result,memory,length,0)
*p.Ascii = memory
length = memory + length
While *p < length And *p\a
If *p\a = 10 ; remove chr(10) + chr(13)
*p+1
If *p\a = 13 : *p+1 : EndIf
ElseIf *p\a = 13 ; remove chr(13) + chr(10)
*p+1
If *p\a = 10 : *p+1 : EndIf
line+1
Else ; read line
offset = *p - memory
text$ = ""
While *p\a And *p\a <> 10 And *p\a <> 13
text$ + Chr(*p\a)
*p+1
Wend
If text$
CompilerIf #IGNORE_CASE
text$ = LCase(text$)
CompilerEndIf
pos = 1
Repeat
pos = FindString(text$,word$,pos)
If pos
If AddElement(positions())
positions() = offset + pos - 1
EndIf
pos + wordlen
EndIf
Until pos = 0
line + 1
EndIf
EndIf
Wend
EndIf
SendMessageTimeout_(Scintilla,#SCI_SETREADONLY,0,0,#SMTO_ABORTIFHUNG,2000,@result)
SendMessageTimeout_(Scintilla,#SCI_GETTEXTLENGTH ,0,0,#SMTO_ABORTIFHUNG,2000,@length)
PostMessage_(Scintilla,#SCI_INDICATORCLEARRANGE,0,length)
ForEach positions()
PostMessage_(Scintilla,#SCI_INDICATORFILLRANGE,positions(),wordlen)
Next
Else
SendMessageTimeout_(Scintilla,#SCI_GETTEXTLENGTH ,0,0,#SMTO_ABORTIFHUNG,2000,@length)
PostMessage_(Scintilla,#SCI_INDICATORCLEARRANGE,0,length)
EndIf
EndIf