AutoHotkey Community

It is currently May 27th, 2012, 10:32 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: November 1st, 2007, 7:27 pm 
Offline

Joined: September 23rd, 2007, 4:16 pm
Posts: 140
Here is a quick and dirty "open declaration" script. Within Notepad++, upon pressing Ctrl + D, the script will obtain the function at the current caret position then proceed to find the declaration of that function within the script and all included scripts. If found, it will open that script in Notepad++ and go to the line number of the function declaration.

Some limitations:
#Include must always use the working directory of the parent script
will only find functions that begin on a new line with no tabs or spaces and also have the { NOT start on the next line.

Code:
#SingleInstance Force
#NoEnv
SendMode Input

return

#IfWinActive ahk_class Notepad++
^d::
   OpenDeclaration()
   return
   
OpenDeclaration() {
   clip := ClipboardAll
   Send, ^{Right}^+{Left}^c
   function := Clipboard
   Clipboard := clip
   regex = ^%function%\([\w\s\,\=\"]*\)\s*{
   WinGetTitle, title
   files = 1
   files1 := SubStr(title, InStr(title, " - ") + 3)
   include = ^\#Include\s+([\w\s\.\\/]+)
   Loop {
      file := files%A_Index%
      StringGetPos, index, file, \, R
      dir := SubStr(file, 1, index)
      Loop, Read, %file%
      {
         if RegExMatch(A_LoopReadLine, regex) {
            OpenFile(file, A_Index)
            return
         }
         if RegExMatch(A_LoopReadLine, include, match) {
            files++
            files%files% = %dir%\%match1%
         }
      }
      if (A_Index >= files)
         break
   }
}

OpenFile(file, index) {
   RunWait, %A_ProgramFiles%\Notepad++\notepad++.exe "%file%"
   Send, ^g
   Sleep, 20
   Send, %index%{Enter}
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 4th, 2007, 4:42 am 
Offline

Joined: September 23rd, 2007, 4:16 pm
Posts: 140
Added a little more sophistication but it is still only for Notepad++

Ctrl+D to go to the function declaration of the function at the current caret position.

Ctrl+P to list as a tooltip all the parameters of the function/command at the current caret position. Will search for functions in the script / included files as well as internal functions/commands. The function/command list compiled by dieom (I believe) is used.

Download:
http://www.autohotkey.net/~Xander/EditorHotkeys.zip

Example of showing the parameters of a user defined function:
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 4th, 2007, 6:31 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Xander wrote:
The function/command list compiled by dieom (I believe) is used.
That appears to be a subset of the function/command list in AutoHotkey\Extras\Editors\Notepad++\AHK Autohotkey.api (part of the AHK install.) As I recall, dieom posted the list with no reference to its origin.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 4th, 2007, 11:47 pm 
Offline

Joined: September 23rd, 2007, 4:16 pm
Posts: 140
lexikos wrote:
Xander wrote:
The function/command list compiled by dieom (I believe) is used.
That appears to be a subset of the function/command list in AutoHotkey\Extras\Editors\Notepad++\AHK Autohotkey.api (part of the AHK install.) As I recall, dieom posted the list with no reference to its origin.
Yes, I got it from dieom's post in the ISense thread. Thanks for clarifying the origin.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2008, 4:48 pm 
Offline

Joined: March 16th, 2006, 5:01 pm
Posts: 150
I just tried this, and it does get the args for functions in the list, but it doesn't 'teleport' to the user function definitions.

Also, is there any reason why this is Notepad++ only?

Thanks


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: specter333 and 11 guests


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

Search for:
Powered by phpBB® Forum Software © phpBB Group