It is currently Sun Jan 24, 2021 10:09 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Highlight the currentl Procedure in the Procedure list
PostPosted: Tue Jun 04, 2019 1:35 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Apr 10, 2017 6:17 pm
Posts: 401
Location: Germany
It would be convenient if the procedure where the cursor is currently postioned in, would be highlighted in some way inside the procedure list. So one Look would always tell me where i am inside the IDE while editing a larger project. Currently i have to scroll up sometimes to get this info.

Example:

Image

While the cursor is inside "SetDisplayViewGadgetSize", the name inside the procedure list should be highlighted (underline, color, bold)

_________________
webpage


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Tue Jun 04, 2019 1:38 pm 
Offline
Moderator
Moderator

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1113
Location: Gernsbach (Germany)
+1 Good idea

I'll soon develop a tool for you so you don't have to wait long.

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Tue Jun 04, 2019 1:39 pm 
Offline
Moderator
Moderator

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1113
Location: Gernsbach (Germany)
Or you can use this tool by Kiffi: https://www.purebasic.fr/german/viewtop ... =8&t=28267

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Tue Jun 04, 2019 1:41 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Apr 10, 2017 6:17 pm
Posts: 401
Location: Germany
RSBasic wrote:
+1 Good idea

I'll soon develop a tool for you so you don't have to wait long.


Haha you are quick ;) nice. If you create a tool, add a little info window about the parameters while you hover over a procedure inside the list. When you are done with that, add the option to see the call hierarchy - who calls the procedure and what procedures does it call itself ;)

btw. nice work with your tools lately :)

_________________
webpage


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Tue Jun 04, 2019 3:00 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3377
Location: Boston, MA
Sorry, kiffi's tool does not work on Windows 10 Pro, PB v571b1x64.
ScintillaText = GetScintillaText() <-- returns empty string?

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Tue Jun 04, 2019 3:06 pm 
Offline
Moderator
Moderator

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1113
Location: Gernsbach (Germany)
I can't confirm.
Did you insert "%TEMPFILE" in the "Arguments" field?

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Tue Jun 04, 2019 3:24 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3377
Location: Boston, MA
DOH!
Google translator inserted spaces. :(
I thought I changed them all but missed "% TEMPFILE".
Works now, but does not update the Procedure List on the left?
Ah, I see HeXOR's code does that!!
This is super helpful. Getting closer to the Notepad++ experience. 8)

EDIT: Only thing is the TEMP folder now holds n Copies of every file browsed during Procedure hunt!
Added the following:
EDIT2: Modified the code to catch similar Procedure names.
Code:
; kiffi, https://www.purebasic.fr/german/viewtopic.php?f=8&t=28267
; GetProcedureName
; REV: 190606, skywalk
;      Modified to catch similarly named Procedures in ListBox.
;      Ex. ShowIt() and ShowIt2().
;#################################################################
; Tool arguments: "%TEMPFILE"
;#################################################################
EnableExplicit
Global.s FilePath$
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()
  ; sicro, http://www.purebasic.fr/german/viewtopic.php?p=324916#p324916
  Protected ReturnValue.s
  Protected File, BOM
  FilePath$ = ProgramParameter(0); %TEMPFILE (file also exists if code is not saved)
  File = ReadFile(#PB_Any, FilePath$, #PB_File_SharedRead)
  If IsFile(File)
    BOM = ReadStringFormat(File)  ; Skip BOM if present
    ReturnValue = ReadString(File, #PB_File_IgnoreEOL); | BOM)
    CloseFile(File)
    If FindString(FilePath$, "\Temp\", 1, #PB_String_NoCase)
      ; Only delete temp file, in case user enters wrong path in Tool options.
      DeleteFile(FilePath$)
    EndIf
  EndIf
  ProcedureReturn ReturnValue
EndProcedure
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  Procedure EnumChildProc(hWnd, *lParam)
    Protected.i Count, i, Size, searchfull
    Protected.s Buffer, Buffer2
    Protected CName.s{128}
    GetClassName_(hWnd, @CName, 128)
    If CName = "ListBox"
      Count = SendMessage_(hWnd, #LB_GETCOUNT, #Null, #Null)
      For i = Count - 1 To 0 Step -1  ; Search bottom up to help search alphabetically.
        Size   = SendMessage_(hWnd, #LB_GETTEXTLEN, i, #Null)
        Buffer = Space(Size + 64)
        If SendMessage_(hWnd, #LB_GETTEXT, i, @Buffer)
          If searchfull = 0
            ; Check if parameters are shown in listview
            If FindString(Buffer, "(")
              searchfull = 1
            Else
              searchfull = -1
            EndIf
          EndIf
          If searchfull = 1
            If PeekS(*lParam) = Buffer
              SendMessage_(hWnd, #LB_SETCURSEL, i, #Null)
              ProcedureReturn 0
            EndIf
          Else
            Buffer2 = Trim(StringField(PeekS(*lParam), 1, "("))
            ;MessageRequester("IN EnumChildProc", Buffer + " = " + Buffer2)
            If Buffer2 = Buffer
              SendMessage_(hWnd, #LB_SETCURSEL, i, #Null)
              ProcedureReturn 0
            EndIf
          EndIf
        EndIf
      Next i
    EndIf
    ProcedureReturn 1
  EndProcedure
CompilerEndIf
CompilerIf 0
  Procedure ShowIt2(Line.s)
    ; Dummy procedure with nearly same name.
    ; Cursor here did not not select correct Procedure in ListBox.
  EndProcedure
CompilerEndIf
Procedure ShowIt(Line.s)
  Protected.i hwnd, i
  Protected.s s
  CompilerSelect #PB_Compiler_OS
  CompilerCase #PB_OS_Windows
    hwnd = Val(GetEnvironmentVariable("PB_TOOL_MainWindow"))
    i    = FindString(Line, " ")
    If i = 0
      i = FindString(Line, #TAB$)
    EndIf
    Line = Mid(Line, i + 1)
    Line = RemoveLeadingWhitespaceFromString(Line)
    ;MessageRequester("SHOWIT", Line)
    EnumChildWindows_(hWnd, @EnumChildProc(), @Line)
  CompilerDefault
    ;Linux / Mac?
    MessageRequester("You are here:", Line)
  CompilerEndSelect
EndProcedure
Define ScintillaText.s
Define CursorLine = Val(StringField(GetEnvironmentVariable("PB_TOOL_Cursor"), 1, "x"))
Define Line.s
Define LineCounter
ScintillaText = GetScintillaText()
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
  #LineFeed = #CRLF$
CompilerDefault
  #LineFeed = #LF$
CompilerEndSelect
If ScintillaText <> ""
  For LineCounter = CursorLine To 1 Step - 1
    Line = RemoveLeadingWhitespaceFromString(StringField(ScintillaText, LineCounter, #LineFeed))
    ;;MessageRequester("BEFORE SHOWIT", Line)
    ; Allow EndProcedure to trigger search.
    ;If Left(LCase(Line), Len("endprocedure")) = "endprocedure"
    ;  Break
    ;EndIf
    If Left(LCase(Line), Len("procedure")) = "procedure"
      If Left(LCase(Line), Len("procedurereturn")) <> "procedurereturn"
        ShowIt(Line)
        Break
      EndIf
    EndIf
  Next LineCounter
EndIf

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Thu Jun 06, 2019 5:33 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3377
Location: Boston, MA
See bug fix above. :wink:
This feature is saving me lots of scrolling! :!:

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Fri Jun 07, 2019 3:33 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1207
skywalk, how do you make this work? I've built the exe, made it a tool, gave it the argument of "%TEMPFILE", assigned it a hotkey. Then when I press the hotkey inside a procedure, nothing happens?


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Fri Jun 07, 2019 6:21 am 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3377
Location: Boston, MA
1st, verify the tool is actually triggering. Recompile the code with any messagerequester() uncommented.
2nd, try placing the compiled exe in a white listed folder. Ex. C:\pb-tools\
Antivirus may block these tiny exe's.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Fri Jun 07, 2019 6:48 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 11, 2006 12:07 am
Posts: 587
Location: Near Hamburg
+ 100
this was requested several times. and i find it super handy. a pity that its not a native ide function after 20 years of pb developing.

Sent via mobile phone

_________________
PB 5.73 x64, OS: Windows 7 Pro x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age: 52y
"Happiness is a pet." | "Never run a changing system!"


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Fri Jun 07, 2019 7:11 am 
Offline
Moderator
Moderator

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1113
Location: Gernsbach (Germany)
The code by Kiffi is very useful. That's why I have included his code in my tool "Multicolor Procedure List". The current procedure is displayed in bold in real time. No MessageRequester, the entry in the procedure list is marked in bold: viewtopic.php?f=27&t=72884

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Fri Jun 07, 2019 7:34 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Apr 10, 2017 6:17 pm
Posts: 401
Location: Germany
Thanks, will try it this weekend :)

_________________
webpage


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Fri Jun 07, 2019 8:53 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1207
skywalk wrote:
1st, verify the tool is actually triggering. Recompile the code with any messagerequester() uncommented.
2nd, try placing the compiled exe in a white listed folder. Ex. C:\pb-tools\
Antivirus may block these tiny exe's.

Hi, no it's not that. My tools panel auto-hides, so I didn't see anything happening when pressing the hotkey. So accounting for the panel being hidden has to be taken into account (hi, RSBasic!).

But even after I disabled auto-hiding, your code doesn't work with long sources. I can scroll down a procedure at line 15000 in my source, hit the hotkey, and nothing is jumped to in the procedure browser. But it does work in a short source.


Top
 Profile  
Reply with quote  
 Post subject: Re: Highlight the currentl Procedure in the Procedure list
PostPosted: Fri Jun 07, 2019 1:32 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3377
Location: Boston, MA
I will check again. I was in line 9000 when last tested.
@RSBasic, see small bug changes to kiffi's code.

EDIT: Verified lowest line Procedure is highlighted in larger include files. ~12k and ~19k lines.
It is noticeably delayed since the file must be written to disk and scanned.
I can adapt the code to inspect the loaded process memory when I have a chance.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye