Please add a tab to the variable viewer for listing constants.
Thanks.
Variable Viewer: Please add Constants tab
Re: Variable Viewer: Please add Constants tab
If someone is working on variables viewer, could it be possible to right click on a variable and to...
... launch the search function with the variable name prefilled
or
... display all lines where the variable appear in the file
A better things is to have the variable viewer in the tabs with 'project', 'form', 'Explorer'...
Thanks
... launch the search function with the variable name prefilled
or
... display all lines where the variable appear in the file
A better things is to have the variable viewer in the tabs with 'project', 'form', 'Explorer'...
Thanks
- Zebuddi123
- Enthusiast
- Posts: 796
- Joined: Wed Feb 01, 2012 3:30 pm
- Location: Nottinghamshire UK
- Contact:
Re: Variable Viewer: Please add Constants tab
Hi Golfy. Try Kiffi`s tool, variable viewer
just set as a tool, no arguments required. I use LCtrl+`as shortcut.
Zebuddi.
http://forums.purebasic.com/german/view ... w=previous
just set as a tool, no arguments required. I use LCtrl+`as shortcut.
Zebuddi.

http://forums.purebasic.com/german/view ... w=previous
Code: Select all
; FindAllReferences
EnableExplicit
Enumeration ; Windows
#frmMain
EndEnumeration
Enumeration ; Gadgets
#frmMain_References
EndEnumeration
Enumeration ; Menu-/Toolbaritems
#frmMain_Shortcut_Escape_Event
EndEnumeration
Global PbIdeHandle = Val(GetEnvironmentVariable("PB_TOOL_MainWindow"))
If PbIdeHandle = 0 : End : EndIf
Global ScintillaHandle = Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))
If ScintillaHandle = 0 : End : EndIf
Procedure.s RemoveLeadingWhitespaceFromString(InString.s)
While Left(InString, 1) = Chr(32) Or Left(InString, 1) = Chr(9)
InString = LTrim(InString, Chr(32))
InString = LTrim(InString, Chr(9))
Wend
ProcedureReturn InString
EndProcedure
Procedure.s GetScintillaText()
Protected ReturnValue.s
Protected length
Protected buffer
Protected processId
Protected hProcess
Protected result
length = SendMessage_(ScintillaHandle, #SCI_GETLENGTH, 0, 0)
If length
length + 2
buffer = AllocateMemory(length)
If buffer
SendMessageTimeout_(ScintillaHandle, #SCI_GETCHARACTERPOINTER, 0, 0, #SMTO_ABORTIFHUNG, 2000, @result)
If result
GetWindowThreadProcessId_(ScintillaHandle, @processId)
hProcess = OpenProcess_(#PROCESS_ALL_ACCESS, #False, processId)
If hProcess
ReadProcessMemory_(hProcess, result, buffer, length, 0)
ReturnValue = PeekS(buffer, -1, #PB_UTF8)
; MessageRequester("",PeekS(buffer))
EndIf
EndIf
EndIf
FreeMemory(buffer)
EndIf
ProcedureReturn ReturnValue
EndProcedure
Procedure frmMain_SizeWindow_Event()
ResizeGadget(#frmMain_References, #PB_Ignore, #PB_Ignore, WindowWidth(#frmMain) - 20, WindowHeight(#frmMain) - 20)
EndProcedure
Procedure frmMain_References_Event()
Protected SelectedLine
SelectedLine = Val(GetGadgetItemText(#frmMain_References, GetGadgetState(#frmMain_References), 0))
If SelectedLine > 0
SendMessage_(ScintillaHandle, #SCI_GOTOLINE, SelectedLine - 1, 0)
SendMessage_(ScintillaHandle, #SCI_ENSUREVISIBLE, SelectedLine - 1, 0)
SetForegroundWindow_(PbIdeHandle)
SetActiveWindow_(PbIdeHandle)
EndIf
EndProcedure
Define SelectedWord.s = GetEnvironmentVariable("PB_TOOL_Word")
If SelectedWord = "" : End : EndIf
Define ScintillaText.s = GetScintillaText()
If ScintillaText = "" : End : EndIf
Define Line.s
Define CountLines, LineCounter
Define CountTokens, TokenCounter
Define WWE
Define RegexLines, PbRegexTokens
Structure sFoundReference
LineNo.i
Reference.s
EndStructure
NewList FoundReference.sFoundReference()
Dim Tokens.s(0)
;------- debug
;http://www.purebasic.fr/english/viewtopic.php?f=12&t=37823
RegexLines = CreateRegularExpression(#PB_Any , ".*\r\n")
PbRegexTokens = CreateRegularExpression(#PB_Any, #DOUBLEQUOTE$ + "[^" + #DOUBLEQUOTE$ + "]*" + #DOUBLEQUOTE$ + "|[\*]?[a-zA-Z_]+[\w]*[\x24]?|#[a-zA-Z_]+[\w]*[\x24]?|[\[\]\(\)\{\}]|[-+]?[0-9]*\.?[0-9]+|;.*|\.|\+|-|[&@!\\\/\*,\|]|::|:|\|<>|>>|<<|=>{1}|>={1}|<={1}|=<{1}|={1}|<{1}|>{1}|\x24+[0-9a-fA-F]+|\%[0-1]*|%|'")
CountLines = CountString(ScintillaText, #CRLF$)
Dim Lines.s(0)
CountLines = ExtractRegularExpression(RegexLines, ScintillaText, Lines())
SelectedWord = LCase(SelectedWord) ; word passed from the scintilla gadget in the ide to match
For LineCounter = 0 To CountLines - 1
Line = Lines(LineCounter)
CountTokens = ExtractRegularExpression(PbRegexTokens, Line, Tokens())
For TokenCounter = 0 To CountTokens - 1
PrintN(SelectedWord)
PrintN(Chr(9)+SelectedWord+Chr(10))
If SelectedWord = LCase(Tokens(TokenCounter))
AddElement(FoundReference())
FoundReference()\LineNo = LineCounter + 1
FoundReference()\Reference = Line
EndIf
Next
Next
;--------------------------------------
If ListSize(FoundReference()) = 0 : End : EndIf
OpenWindow(#frmMain,
#PB_Ignore,
#PB_Ignore,
600,
300,
"All references for: '" + SelectedWord + "'",
#PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered);End_OpenWindow
StickyWindow(#frmMain, #True)
ListIconGadget(#frmMain_References,
10,
10,
WindowWidth(#frmMain) - 20,
WindowHeight(#frmMain) - 20,
"LineNo.",
50,
#PB_ListIcon_FullRowSelect |
#PB_ListIcon_GridLines |
#PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(#frmMain_References, 1, "Reference", 4000)
SetWindowColor(#frmMain, $98FAFF)
SetGadgetColor(#frmMain_References,#PB_Gadget_BackColor ,$BEFCFF)
ForEach FoundReference()
AddGadgetItem(#frmMain_References, -1, Str(FoundReference()\LineNo) + #LF$ + Trim(FoundReference()\Reference))
Next
AddKeyboardShortcut(#frmMain, #PB_Shortcut_Escape, #frmMain_Shortcut_Escape_Event)
BindEvent(#PB_Event_SizeWindow, @frmMain_SizeWindow_Event(), #frmMain)
BindGadgetEvent(#frmMain_References, @frmMain_References_Event())
SetActiveGadget(#frmMain_References)
Repeat
WWE = WaitWindowEvent()
If (WWE = #PB_Event_Menu And EventMenu() = #frmMain_Shortcut_Escape_Event) Or (WWE = #PB_Event_CloseWindow)
Break
EndIf
ForEver
malleo, caput, bang. Ego, comprehendunt in tempore
- majikeyric
- Enthusiast
- Posts: 187
- Joined: Mon Oct 21, 2013 5:21 pm
- Location: France
- Contact:
Re: Variable Viewer: Please add Constants tab
Yes, very nice, but we really need TOOL_VAR's to span all open files. This only works in current file.
Like the File - Edit - Find in Files utility ...
Like the File - Edit - Find in Files utility ...
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: Variable Viewer: Please add Constants tab
Though I'd +1 the feature request, CodeCaddy actually looks for variable declarations in current and related ('included') files.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )