Debug Output options

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BarryG
Addict
Addict
Posts: 4135
Joined: Thu Apr 18, 2019 8:17 am

Debug Output options

Post by BarryG »

Some (easy) Debug Output window requests:

(1) A Pause button for the Debug Output window, so it won't show anything unless unpaused. Reason: Sometimes a lot of debug output goes there and you don't want to scroll back through a long list to find the needle in the haystack, especially if the output is still updating while you're trying to scroll. So this would let us pause it until we're ready to start/continue the output again.

(2) A text field for a filter, so that only outputs containing that text from that point on will be output. A blank field means show all text for new outputs.

Both these items could be added in front of the current "Copy all", "Save", and "Clear" buttons.

And speaking of copying/saving, request (3): An option to only copy or save the selected items, instead of all items.

Here's a quick mock-up of what I mean, and thanks for considering!

Code: Select all

Global output,outputpaused,outputfilter$,outputfilterold$

Procedure OutputTest(null)
  Repeat
    Sleep_(25)
    If outputpaused=0
      t$=""
      For a=1 To 10
        Select Random(2)
          Case 0 : t$+Chr(Random(9)+48)  ; 0-9
          Case 1 : t$+Chr(Random(25)+97) ; a-z
          Case 2 : t$+Chr(Random(25)+65) ; A-Z
        EndSelect
      Next
      If outputfilter$="" Or FindString(t$,outputfilter$)
        AddGadgetItem(2,-1,t$)
        SendMessage_(output,#EM_SETSEL,-1,0)
      EndIf
    EndIf
  ForEver
EndProcedure

OpenWindow(0,500,200,330,250,"Debug Output",#PB_Window_SystemMenu)
pause=ButtonGadget(0,10,10,100,25,"Pause",#PB_Button_Toggle)
filter=StringGadget(1,120,10,200,25,"")
output=EditorGadget(2,10,40,310,200)

CreateThread(@OutputTest(),0)

Repeat
  ev=WaitWindowEvent()
  If ev=#PB_Event_Gadget
    Select EventGadget()
      Case 0
        outputpaused=GetGadgetState(0)
      Case 1
        outputfilter$=GetGadgetText(1)
        If outputfilter$<>outputfilterold$
          outputfilterold$=outputfilter$
        EndIf
    EndSelect
  EndIf
Until ev=#PB_Event_CloseWindow
Last edited by BarryG on Fri Jan 06, 2023 4:12 am, edited 3 times in total.
Axolotl
Addict
Addict
Posts: 802
Joined: Wed Dec 31, 2008 3:36 pm

Re: Debug Output options

Post by Axolotl »

I find your requests interesting.

to (1)
If I understand your request correctly, it could be done like this:
When adding a new debug line, the update of the visible last line could be disabled. (Behavior as for the "Find in files - Results").
Turning on/off this function would be great though.

to (2)
Should the Data be updated, when you change the filter text later on.
Which means the data would have to be held in a separate list....

to (3)
You know that you can select areas and copy them to the clipboard with Crtl+C ?
So a button would be missing for that, so at least for the copy process?
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
BarryG
Addict
Addict
Posts: 4135
Joined: Thu Apr 18, 2019 8:17 am

Re: Debug Output options

Post by BarryG »

For (1): Automatic pausing shouldn't be done after the last output. Only when the user clicks the button.

For (2): Previous data shouldn't be updated, no. Only new output, taking into account when the filter field was last changed.

For (3): I actually didn't know that. Thanks! I assumed the output was a listview or listicon.

Basically, (1) and (2) would be like ProcessMon from SysInternals, to make finding data in the output a heck of a lot easier. Sometimes we don't just debug one or two things, but have a constant fast stream of data being output. It would be easy to code in a pause and filter (under 30 mins).

First post edited to demonstrate what I mean. Took me all of 10 minutes to code.
Post Reply