Code: Select all
; ProSeeker Tool V1.0 by Michael Vogel
; -------------------------------------
; Commandline: %COMPILEFILE\..\..\Pure\Tools\Tool ProSeeker.exe
; Arguments: "%TEMPFILE"
; Shortcut: Ctrl+Shift+P
; Define
EnableExplicit
#CharByteShift= #PB_Compiler_Unicode
#CharByte= 1<<#CharByteShift
#LenMacro= 5
#LenProcedure= 9
Structure NameList
Name.s
Info.s
Line.i
EndStructure
Structure ComboboxInfo
cbSize.l
rcItem.RECT
rcButton.RECT
stateButton.l
hwndCombo.i
hwndItem.i
hwndList.i
EndStructure
Structure ComboType
pbnr.i
pbid.i
proc.i
info.ComboboxInfo
EndStructure
Enumeration
#StateIdle
#StateAbort
#StateExit
EndEnumeration
Enumeration
#Window
#Combo
#Info
EndEnumeration
Enumeration
#ModeProcedure
#ModeMacro
EndEnumeration
Global *Combo.ComboType
Global NewList Names.NameList()
Global Line
Global State
; EndDefine
Procedure GetName(*String.Character,Mode)
Protected n,z
Protected *Start
Protected s.s
Enumeration
#Z_Idle
#Z_Name
#Z_Parameter
EndEnumeration
Repeat
Select *String\c
Case ' ',#TAB
z=#True
If n=0
*Start=*String+#CharByte
EndIf
Case '('
z<<1
Break
Case #Null,';','='
Break
Default
If z : n+1 : EndIf
EndSelect
*String+#CharByte
ForEver
If z
AddElement(Names())
With Names()
\Name=PeekS(*Start,n)
\Line=Line
\Info=" ["+Mid("ProcedureMacro",Mode*9+1,9)+"]"
If z=#Z_Parameter
s=StringField(PeekS(*String+#CharByte),1,")")
If s
\Info=Left(\Info,5)+"]: "+s
EndIf
EndIf
\Info+", "+Str(Line)
; Debug Str(\Line)+": "+\Name+" - "+\Parameter
EndWith
EndIf
EndProcedure
Procedure ScanProcedures(file.s)
Protected z.i
Protected s.s
If ReadFile(0,file,#PB_File_SharedRead)
While Eof(0)=0
line+1
s=ReadString(0)
If s
z=FindString(s,"procedure",1,#PB_String_NoCase)
If z
If (z<4 Or LCase(Mid(s,z-3,3))<>"end") And (LCase(Mid(s,z+#LenProcedure,1))<>"r")
GetName(@s+(#LenProcedure+z-1)<<#CharByteShift,#ModeProcedure)
EndIf
EndIf
z=FindString(s,"macro",1,#PB_String_NoCase)
If z
If (z<4 Or LCase(Mid(s,z-3,3))<>"end")
GetName(@s+(#LenMacro+z-1)<<#CharByteShift,#ModeMacro)
;Debug Str(line)+": "+s
EndIf
EndIf
EndIf
Wend
CloseFile(0)
If ListSize(Names())
SortStructuredList(Names(),#PB_Sort_NoCase|#PB_Sort_Ascending,OffsetOf(NameList\Name),TypeOf(NameList\Name))
; ResetList(Names())
; While NextElement(Names())
; With Names()
; Debug Str(\Line)+": "+\Name+" - "+\Parameter
; EndWith
; Wend
ProcedureReturn #True
EndIf
EndIf
ProcedureReturn #Null
EndProcedure
Procedure.i ComboBoxEvents(hwnd,msg,wParam,lParam)
Protected startpos,endpos
Protected found
Protected s.s
If msg=#WM_CHAR
Select wParam
Case #CR
State=#StateExit
ProcedureReturn 0
Case #ESC
State=#StateAbort
ProcedureReturn 0
Default
SendMessage_(hwnd,#EM_GETSEL,@startpos,0)
s=Left(GetGadgetText(*Combo\pbnr),startpos)+Chr(wParam)
found=SendMessage_(*Combo\pbid,#CB_FINDSTRING,-1,@s)
If found>=#Null
SetGadgetState(*Combo\pbnr,found)
SendMessage_(hwnd,#EM_SETSEL,startpos+1,-1)
SelectElement(Names(),found)
SetGadgetText(#Info,Names()\Info)
ProcedureReturn 0
EndIf
EndSelect
EndIf
ProcedureReturn CallWindowProc_(*Combo\proc,hwnd,msg,wParam,lParam)
EndProcedure
Procedure init()
Protected id
LoadFont(#Null,"Segoe UI",10)
SetGadgetFont(#PB_Default, FontID(#Null))
OpenWindow(#Window,210,210,320,50,"Procedure Seeker",#PB_Window_Invisible|#PB_Window_BorderLess);#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowColor(#Window,#Black)
id=ComboBoxGadget(#Combo,1,23,318,26,#PB_ComboBox_Editable);|#CBS_SORT)
;SendMessage_(id,#CB_SETCUEBANNER,0,@"Enter procedure name...")
TextGadget(#Info,1,1,318,21," Search for procedures...")
SetActiveGadget(#Combo)
*Combo=AllocateMemory(SizeOf(ComboType))
SendMessage_(id,#CB_SETMINVISIBLE, 15, 0) ;ab 15 Einträge Scrollbalken
With *Combo
\info\cbSize=SizeOf(ComboboxInfo)
GetComboBoxInfo_(id,\info)
\pbid=id
\pbnr=#Combo
\proc=SetWindowLongPtr_(\info\hwndItem,#GWL_WNDPROC,@ComboBoxEvents())
EndWith
ResetList(Names())
While NextElement(Names())
SendMessage_(id,#CB_ADDSTRING,0,@Names()\Name)
Wend
StickyWindow(#Window,#True)
HideWindow(#Window,#Null)
EndProcedure
: CompilerIf #PB_Compiler_Debugger :
: If ScanProcedures("C:\Program Files\System\Connect IQ\Information\Pure\Screeny.pb") :
: CompilerElse :
If CountProgramParameters()=1 And ScanProcedures(ProgramParameter())
: CompilerEndIf :
init()
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
State=#StateAbort
Case #PB_Event_Gadget,#PB_Event_Menu
If EventType()=#PB_EventType_Change
Line=GetGadgetState(#Combo)
If Line>=#Null
SelectElement(Names(),Line)
With Names()
SetGadgetText(#Info,\Info)
EndWith
EndIf
EndIf
EndSelect
Until State
If State=#StateExit
Line=GetGadgetState(#Combo)
If Line>=#Null
SelectElement(Names(),Line)
; MessageRequester("Goto","Line "+Str(Names()\Line))
Line=Val(GetEnvironmentVariable("PB_Tool_Scintilla"))
If Line
SendMessageTimeout_(Line,#SCI_GOTOLINE,Names()\Line-1,0,#SMTO_NORMAL,500,#Null)
EndIf
EndIf
EndIf
EndIf