iar

For IAR embedded workbench, is there a shortcut key to quickly find and open a file within your project


I'm currently using IAR Embedded Workbench V8.30.2.

The project I'm on has about 1500 source files, and it's a pain in the neck to manually browse for the desired file in the 'Workspace' pane and double-click on it.

I'd much rather some shortcut key that opens a 'finder' window, that lets me type in a few letters of the file and it then automatically locates the file for me and opens it.

For now, I've managed to cobble together a poor-man's workaround by using AHK (autohotkey) for windows.

But still wanted to put this Q out there, in-case there is a better way.


Solution

  • For now, I will share my poor man's autohotkey solution under windows.

    #Include c:\src\gurce_ahk\ExtListView.ahk
    
    ;CapsLock+F = IAR locate desired file
    CapsLock & f::
    
    ; 1) Get current path of project
    Send,^o 
    Sleep,300
    ControlGetText, txt, ToolbarWindow323, ahk_exe IarIdePm.exe
    dir := SubStr(txt, 10)
    Send,{Escape}
    
    ; 2) find source files within dir
    RunWait, cmd /c type *_Source.ewp | grep "<name>$PROJ_DIR$/.." | \cygwin0005\bin\sed "s@</name>@@" | \cygwin0005\bin\sed "s@.*/@@" | \windows\system32\sort.exe | clip , %dir%, Hide
    files := StrSplit(Clipboard, "`r`n")
    
    ; 3) Show dialog prompt
    InputBox, filename, Enter filename to open... (can be partial)
    
    ; 4) Find request in my local list
    for idx in files
    {
      ff := files[idx]
      IfInString, ff, %filename%
        break
    }
    
    ; 5) Select the desired row
    objLV := ExtListView_Initialize(ahk_exe IarIdePm.exe)
    ExtListView_ToggleSelection(objLV, 0, -1) ; deselect all
    ExtListView_ToggleFocusAndSelection(objLV, 1, 2 + idx)
    ExtListView_EnsureVisible(objLV, 2 + idx)
    ExtListView_DeInitialize(objLV)
    Send,{Enter}
    
    return
    

    Some notes on the thought process that went into this: