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

Post by mrfyx »

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: 6167
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 31 times
Been thanked: 330 times

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

Post by Shmuel »

mrfyx wrote: 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

Post by mrfyx »

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: 4072
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 5 times
Been thanked: 189 times

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

Post by 2useven10 »

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

Post by mrfyx »

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: 4072
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 5 times
Been thanked: 189 times

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

Post by 2useven10 »

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.
Shmuel
Posts: 6167
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 31 times
Been thanked: 330 times

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

Post by Shmuel »

2useven10, I did not try the macro but the area is spelled incorrectly (should be ShellAutoCompletion).
2useven10
Posts: 4072
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 5 times
Been thanked: 189 times

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

Post by 2useven10 »

Shmuel
Sure ShellAutoCompletion
mrfyx
Posts: 10
Joined: Fri 10 Apr, 2015 14:04

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

Post by mrfyx »

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: 4072
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 5 times
Been thanked: 189 times

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

Post by 2useven10 »

Did you correct area="ShellAutoCompletion" ?
2useven10
Posts: 4072
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 5 times
Been thanked: 189 times

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

Post by 2useven10 »

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: 938
Joined: Thu 23 Jul, 2009 10:16
Has thanked: 107 times
Been thanked: 12 times

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

Post by sToLp »

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

Post by mrfyx »

The macro doesn't work. Tab do nothing.
2useven10
Posts: 4072
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 5 times
Been thanked: 189 times

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

Post by 2useven10 »

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 128 times
mrfyx
Posts: 10
Joined: Fri 10 Apr, 2015 14:04

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

Post by mrfyx »

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.
Post Reply

Return to “Macro Commands Discussions”