Procedure Window Line Number Display, "Jump to"

A view option to display procedure line numbers while editing would be quite useful to me, especially when interpreting unified diffs.

Similarly, a "jump to line" editor shortcut would be invaluable in my day-to-day Igor programming. (e.g. Emacs: M-g g)
kravlor wrote:
A view option to display procedure line numbers while editing would be quite useful to me, especially when interpreting unified diffs.

If you click the paper icon at the lower left corner of a procedure window, the information in the dialog that comes up will show you the line number. That's obviously not what you're asking for, but it's the closest Igor comes to it for now.

On overhaul of procedure windows is on the to do list, probably for Igor 7. That will still be a while from now, unfortunately.

kravlor wrote:
Similarly, a "jump to line" editor shortcut would be invaluable in my day-to-day Igor programming. (e.g. Emacs: M-g g)

Without having an easy way to display the line numbers, this is probably not all that useful, but if you're using the latest beta version of Igor 6.2, the following command should work:
DisplayProcedure/W=Procedure/L=5        // Shows Line 5 (the sixth line)


The /L flag is undocumented, but takes a line number in the procedure file. If you don't also use the /W flag to specify which procedure window, the results aren't likely to be very useful to you. Don't provide the functionOrMacroNameStr parameter when you use the /L flag, as it's not allowed.

You can write a simple menu item that allows you to execute this using a keyboard shortcut. Here is an example:
Menu "Procedure"
    "Go to line.../F12",/Q,GoToProcedureLine()
End

Function GoToProcedureLine([lineNum])
    Variable lineNum
   
    // Get the name of the top procedure window.
    String topProcWinName = WinName(0, 128)
   
    // If topProcWinName is a null string or empty
    // string, don't do anything.
    if (numtype(strlen(topProcWinName)) == 0 && strlen(topProcWinName) > 0)
        // Prompt the user for the line number if it's
        // not provided as the optional parameter.
        if (ParamIsDefault(lineNum))
            Prompt lineNum, "Line to go to:"
            DoPrompt "Go to line...", lineNum
            if (V_flag == 1)
                // Don't do anything if cancel button was pressed.
                return 0
            endif
        endif
       
        // Check that lineNum is an actual number and is positive.
        if (numtype(lineNum) == 0 && lineNum > 0)
            DisplayProcedure/W=$(topProcWinName)/L=(lineNum)
        endif
    endif
End


Using this example, if a procedure window is the top window and you hit F12, a dialog will pop up asking you to type a line number, and then that line number in the top procedure window will be highlighted. If you want the keyboard shortcut to work when a procedure window is not on top, you'll need to put it in a Menu that is always available, such as the Misc menu or a new top level menu item that you create.
aclight wrote:
If you click the paper icon at the lower left corner of a procedure window, the information in the dialog that comes up will show you the line number. That's obviously not what you're asking for, but it's the closest Igor comes to it for now.

On overhaul of procedure windows is on the to do list, probably for Igor 7. That will still be a while from now, unfortunately.


This is good to know that the paper icon's display is the only way to view line numbers to date. I thought this was the case. Thanks for the quick response/acknowledgement and update on this "to-do" for IP 7.

Also, thanks for the heads-up to the undocumented feature of DisplayProcedure in the IP 6.2 beta and the clean wrapper in your reply. It's exactly what I would have done if armed with the knowledge of the /L flag! And, it solves the problem of navigating to particular specified lines from diffs very neatly. As such, it is now in our group's set of swiss-army-knife code snippets for our IP 6.2 beta users.