[Update: working snippet is at a few post below]
1.) Ctrl-U swaps panels well even if they contains plugin content. But it swaps whole panels with their _dimensions_ too (width, height) which is not good for me (I using asymmetric panels because of good reasons)
2.) I made a script which swaps panel _paths_, but of course it can't handle plugin contents.
I like to swap any (even plugin) panel's _content_ without change of layout. My theory is that I call Ctrl-U then You smart LUA-gods drop a few lines of LUA script to me to restore panel's dimension to the original
Maybe the solution will be something different, I don't know. Notice that even the built-in 'Same folder' not handles plugin-panels - it's a shame
Sidenote: I using ConEmu - it can display picture thumbnails but Ctrl-U leaves thumbnails view on the original side - I feel I need to consult with ConEmu's author right?
I much appreciate any technical details - thank You!
Correct 'swap panels' with LUA (solved)
-
- Posts: 23
- Joined: Mon 12 Aug, 2013 14:03
- Has thanked: 6 times
Correct 'swap panels' with LUA (solved)
Last edited by galaxy_far_FAR_away on Thu 15 Oct, 2015 05:35, edited 2 times in total.
- HaRT
- Moderator
- Posts: 10862
- Joined: Tue 30 Aug, 2005 17:21
- Has thanked: 221 times
- Been thanked: 358 times
Correct swap panels with LUA
galaxy_far_FAR_away, I suggest that you write a simple Lua script that memorizes the panel widths, then swaps panels (
[b]CtrlU[/b]
), then adjusts the widths ([b]CtrlLeft[/b]
/[b]CtrlRight[/b]
).Фар есть инструмент, а не нянька. © 2009 DrKnS
-
- Posts: 23
- Joined: Mon 12 Aug, 2013 14:03
- Has thanked: 6 times
Correct swap panels with LUA
Thanks HaRT, I wrote the same idea just with other words
So, I not as experimented as You may think - I dug in the documentations of LUA/FAR plugins (quite) some time ago and I not really found where I can figure out panel's dimensions (?)
So, I not as experimented as You may think - I dug in the documentations of LUA/FAR plugins (quite) some time ago and I not really found where I can figure out panel's dimensions (?)
- HaRT
- Moderator
- Posts: 10862
- Joined: Tue 30 Aug, 2005 17:21
- Has thanked: 221 times
- Been thanked: 358 times
Correct swap panels with LUA
Фар есть инструмент, а не нянька. © 2009 DrKnS
-
- Posts: 6834
- Joined: Thu 23 Mar, 2006 21:36
- Location: Israel
- Has thanked: 41 times
- Been thanked: 530 times
Correct swap panels with LUA
It is slow but seems to work.
Code: Select all
Macro {
area="Shell"; key="F1";
action=function()
local F = far.Flags
local apanel = panel.GetPanelInfo(nil,1)
local ppanel = panel.GetPanelInfo(nil,0)
local aleft = bit64.band(apanel.Flags, F.PFLAGS_PANELLEFT) ~= 0
local awidth = apanel.PanelRect.right - apanel.PanelRect.left + 1
local pwidth = ppanel.PanelRect.right - ppanel.PanelRect.left + 1
local key1 = aleft and (awidth > pwidth) and "CtrlRight" or
not aleft and (pwidth > awidth) and "CtrlRight" or "CtrlLeft"
Keys("CtrlU")
for k=1, math.abs(awidth-pwidth) do Keys(key1) end
end;
}
-
- Posts: 23
- Joined: Mon 12 Aug, 2013 14:03
- Has thanked: 6 times
Correct swap panels with LUA
Nice - Shmuel You done Your answer before I could send mine (a short one)
OK, I did tested this key-emulation technique and it is not flashing, it is real-time. I will implement height adjustment too (and fix a minor bug because 'divider' moves a bit at every swap if total width is odd).
Many thanks for your super great LUA support!
OK, I did tested this key-emulation technique and it is not flashing, it is real-time. I will implement height adjustment too (and fix a minor bug because 'divider' moves a bit at every swap if total width is odd).
Many thanks for your super great LUA support!
-
- Posts: 6834
- Joined: Thu 23 Mar, 2006 21:36
- Location: Israel
- Has thanked: 41 times
- Been thanked: 530 times
Correct swap panels with LUA
The fix for a minor bug you mentioned.
Code: Select all
Macro {
area="Shell"; key="F1";
action=function()
local awidth, aleft = APanel.Width, APanel.Left
Keys("CtrlU")
local pwidth = PPanel.Width
local key1 = aleft == (awidth > pwidth) and "CtrlRight" or "CtrlLeft"
for k=1, math.abs(awidth-pwidth) do Keys(key1) end
end;
}
-
- Posts: 23
- Joined: Mon 12 Aug, 2013 14:03
- Has thanked: 6 times
Correct swap panels with LUA
Ahh, the fixed code also much cleaner Thanks to you guys, here is the final snippet for everybody (I using Shift-Tab to swap panels):
Code: Select all
Macro
{
key = 'ShiftTab';
area = 'Shell';
flags = '';
description= 'Panel: Swap panels';
action = function()
local awidth, aleft = APanel.Width, APanel.Left
Keys("CtrlU")
local pwidth = PPanel.Width
local key1 = aleft == (awidth > pwidth) and "CtrlRight" or "CtrlLeft"
for k=1, math.abs(awidth-pwidth) do Keys(key1) end
local dif = APanel.Height - PPanel.Height;
key1 = (dif>0) and "CtrlShiftUp" or "CtrlShiftDown"
local key0 = (dif<0) and "CtrlShiftUp" or "CtrlShiftDown"
dif = math.abs(dif);
for k=1, dif do Keys(key1) end
Keys ("Tab");
for k=1, dif do Keys(key0) end
Keys ("Tab");
end;
}