ShellExecute inserts newline in Far interface

Here you can discuss any topic concerning Far macro commands.
Post Reply
rattle
Posts: 6
Joined: Sat 02 Sep, 2017 18:58

ShellExecute inserts newline in Far interface

Post by rattle » Wed 11 Oct, 2017 11:21

Hey all, I created the following command shortcut:

Code: Select all

CommandLine {
  prefixes = "vsc";
  action = function(prefix, filename) 
    win.ShellExecute(nil, "VSCode", filename, nil, panel.GetPanelDirectory(nil, 1).Name)
  end;
}
which will open the argument in Visual Studio Code. The problem I have is that this command always inserts a newline character in Far, messing up the interface. It only happens with this particular shell exectue handler, if you replace it by

Code: Select all

    win.ShellExecute(nil, "open", "notepad", filename, panel.GetPanelDirectory(nil, 1).Name)
it works without problem. Does anyone know what is causing this and how to avoid it?

User avatar
DrKnS
Posts: 4644
Joined: Thu 04 Aug, 2005 06:44
Location: Kyiv
Has thanked: 4 times
Been thanked: 125 times
Contact:

ShellExecute inserts newline in Far interface

Post by DrKnS » Wed 11 Oct, 2017 12:12

Perhaps the underlying implementation writes something to stdout.
Adding getuserscreen before your call and setuserscreen after it might help.

rattle
Posts: 6
Joined: Sat 02 Sep, 2017 18:58

ShellExecute inserts newline in Far interface

Post by rattle » Wed 11 Oct, 2017 17:27

Hey man, thanks again, that helped.

Post Reply

Return to “Macro Commands Discussions”