Add a new line to the command line "silently" (i.e., without printing to history)

These functions create a button that can be clicked to add a new line to the command history without also printing to history. I use this to compile in the command line multiple commands from history.

I would prefer to have a hotkey that inserts a new line (e.g., return with the control key down), but I am unaware of a way to make a new hotkey that executes a function but does not also print to the command line. Printing to the command line is undesirable because one's location in the command window could change as a result. (If there was a built-in function like getCommandHistoryPosition() and setCommandHistoryPosition(), that location change could be dealt with, but I don't believe such a built-in function is available.)

//To use, run this function, newCommandLineLine_panel(). It will make a new window (which may be resized and moved as desired).
//A button with the label "nl" is created in the window. It will insert a new line into the command line when pressed
//(by calling the second function, newCommandLineLine)
function newCommandLineLine_panel()
    newpanel/N=commandLineLinePanel/K=1/W=(50,50,200,100);doupdate;
    Button btn0 title="nl", proc=newCommandLineLine
end

//function called on button click
function newCommandLineLine(s) : ButtonControl
    STRUCT WMButtonAction &s
   
    if (s.eventcode == 1)
            toCommandLine "\r"
    endif
end


Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More