Change "TAB" behaviour only when the command line is not empty

Here you can discuss any topic concerning Far macro commands.
mrfyx
Posts: 10
Joined: Fri 10 Apr, 2015 14:04

Change "TAB" behaviour only when the command line is not empty

Postby mrfyx » Tue 16 Feb, 2016 14:59

Hi, I want to change "TAB" behavior in the bottom prompt.
I am used to "TAB" in command line for the auto-completion. I want the same behavoir in Far manager.

I can remap the "TAB" key to "Down" but I just want to apply this macro when the command line is not empty.

Is it possible ?

Shmuel
Posts: 4906
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 10 times
Been thanked: 118 times

Change "TAB" behaviour only when the command line is not empty

Postby Shmuel » Tue 16 Feb, 2016 15:24

mrfyx wrote:Source of the post but I just want to apply this macro when the command line is not empty

Specify flags="NotEmptyCommandLine"; in your macro definition.

mrfyx
Posts: 10
Joined: Fri 10 Apr, 2015 14:04

Change "TAB" behaviour only when the command line is not empty

Postby mrfyx » Wed 17 Feb, 2016 09:21

I try but it does'nt work.

Code: Select all

Macro {
  description="auto-complete in command line";
  area="Shell"; key="Tab";
  flags="NoSendKeysToPlugins NotEmptyCommandLine";
  code="Keys(\"Down\")";
}

When i push "tab", i lose the focus in the prompt, and the cursor goes down in the active panel :(

2useven10
Posts: 2833
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 2 times
Been thanked: 72 times

Change "TAB" behaviour only when the command line is not empty

Postby 2useven10 » Wed 17 Feb, 2016 09:48

Code: Select all

Macro {
  description="auto-complete in command line";
  area="Shell"; key="Tab";
  flags="NoSendKeysToPlugins NotEmptyCommandLine";
  action = function()
    Keys("CtrlSpace")
  end;
}

mrfyx
Posts: 10
Joined: Fri 10 Apr, 2015 14:04

Change "TAB" behaviour only when the command line is not empty

Postby mrfyx » Wed 17 Feb, 2016 10:29

Thanks, but it doesn't work either.

I don't lose the focus but the cursor doesn't go down on each possible choice.

2useven10
Posts: 2833
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 2 times
Been thanked: 72 times

Change "TAB" behaviour only when the command line is not empty

Postby 2useven10 » Wed 17 Feb, 2016 11:55

Code: Select all

Macro {
  description="auto-complete in command line";
  area="ShellAutoCompletion"; key="Tab";
  flags="NoSendKeysToPlugins NotEmptyCommandLine";
  action = function()
    Keys("Down")
  end;
}

And probably NotEmptyCommandLine is not required.
Updated: area fixed.
Last edited by 2useven10 on Wed 17 Feb, 2016 12:23, edited 1 time in total.

Shmuel
Posts: 4906
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 10 times
Been thanked: 118 times

Change "TAB" behaviour only when the command line is not empty

Postby Shmuel » Wed 17 Feb, 2016 12:06

2useven10, I did not try the macro but the area is spelled incorrectly (should be ShellAutoCompletion).

2useven10
Posts: 2833
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 2 times
Been thanked: 72 times

Change "TAB" behaviour only when the command line is not empty

Postby 2useven10 » Wed 17 Feb, 2016 12:24

Shmuel
Sure ShellAutoCompletion

mrfyx
Posts: 10
Joined: Fri 10 Apr, 2015 14:04

Change "TAB" behaviour only when the command line is not empty

Postby mrfyx » Wed 17 Feb, 2016 14:31

Thank you for your help however it doesn't work :'(
Even if I saw the history/autocompletion screen when I press "Tab" It change the actif panel.
I try to put back CtrlSpace but I obtain the same result.

2useven10
Posts: 2833
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 2 times
Been thanked: 72 times

Change "TAB" behaviour only when the command line is not empty

Postby 2useven10 » Wed 17 Feb, 2016 15:11

Did you correct area="ShellAutoCompletion" ?

2useven10
Posts: 2833
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 2 times
Been thanked: 72 times

Change "TAB" behaviour only when the command line is not empty

Postby 2useven10 » Wed 17 Feb, 2016 15:54

Code: Select all

Macro {
  description="auto-complete start"; area="Shell"; key="Tab"; flags="NoSendKeysToPlugins NotEmptyCommandLine";
  action = function() Keys("CtrlSpace") end;
}
Macro {
  description="auto-complete navigation"; area="ShellAutoCompletion"; key="Tab"; flags="NoSendKeysToPlugins";
  action = function() Keys("Down") end;
}

User avatar
sToLp
Posts: 691
Joined: Thu 23 Jul, 2009 10:16
Has thanked: 31 times
Been thanked: 5 times

Change "TAB" behaviour only when the command line is not empty

Postby sToLp » Wed 17 Feb, 2016 21:30

And then surely we need one more macro:

Code: Select all

Macro {
  description="auto-complete navigation"; area="ShellAutoCompletion"; key="ShiftTab"; flags="NoSendKeysToPlugins";
  action = function() Keys("Up") end;
}

mrfyx
Posts: 10
Joined: Fri 10 Apr, 2015 14:04

Change "TAB" behaviour only when the command line is not empty

Postby mrfyx » Thu 18 Feb, 2016 08:58

The macro doesn't work. Tab do nothing.

2useven10
Posts: 2833
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 2 times
Been thanked: 72 times

Change "TAB" behaviour only when the command line is not empty

Postby 2useven10 » Thu 18 Feb, 2016 10:28

The macro works fine for me.
It should be your environment specific.
Can you test it in clean environment?
1) Extract far archive (x64 or x86, last nightly or stable) to separate direcory (C:\Test_Far\ for example).
2) Rename C:\Test_Far\far.exe.example.ini to C:\Test_Far\far.exe.ini
3) Uncomment and correct line:
UseSystemProfiles=0
4) Write my macro content to C:\Test_Far\Profile\Macros\scripts\TabAutoComplete.lua
5) Run C:\Test_Far\Far.exe

PS: Tab does nothing when entered commandline text can't be auto-completed.
Attachments
TabAutoComplete.lua
(501 Bytes) Downloaded 29 times

mrfyx
Posts: 10
Joined: Fri 10 Apr, 2015 14:04

Change "TAB" behaviour only when the command line is not empty

Postby mrfyx » Thu 18 Feb, 2016 15:19

Sorry, It doesn't work for me because I copy the script in ...\Far Manager\Profile\Macros\internal with my other scripts.
When I change the directory to ..\Far Manager\Profile\Macros\scripts, it works. Thank you and sorry again.

Shmuel
Posts: 4906
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 10 times
Been thanked: 118 times

Change "TAB" behaviour only when the command line is not empty

Postby Shmuel » Thu 18 Feb, 2016 21:26

mrfyx, you may want to read %FARHOME%\Encyclopedia\macroapi_manual.en.chm.


Return to “Macro Commands Discussions”

Who is online

Users browsing this forum: No registered users and 1 guest