Code: Select all
local function InsertMacro()
local F=far.Flags
local Items =
{
--[[01]] {F.DI_DOUBLEBOX,3,1,69,18,0,0,0,0,"Macro settings"},
--[[02]] {F.DI_TEXT,5,2,0,2,0,0,0,0,"Description:"},
--[[03]] {F.DI_EDIT,5,3,67,3,0,"MacroDescription",0,F.DIF_HISTORY,""},
--[[04]] {F.DI_TEXT,-1,4,0,4,0,0,0,F.DIF_SEPARATOR,""},
--[[05]] {F.DI_CHECKBOX,5,5,0,5,0,0,0,0,"Allo&w screen output while executing macro"},
--[[06]] {F.DI_CHECKBOX,5,6,0,6,0,0,0,0,"Execute after FAR &start"},
--[[07]] {F.DI_CHECKBOX,5,7,0,7,0,0,0,0,"Do not send &keys to plugins"},
--[[08]] {F.DI_TEXT,-1,8,0,8,0,0,0,F.DIF_SEPARATOR,""},
--[[09]] {F.DI_CHECKBOX,5,9,0,9,0,0,0,0,"&ActivePanel"},
--[[10]] {F.DI_CHECKBOX,7,10,0,10,2,0,0,{DIF_3STATE=1,DIF_DISABLE=1},"P&luginPanel"},
--[[11]] {F.DI_CHECKBOX,7,11,0,11,2,0,0,{DIF_3STATE=1,DIF_DISABLE=1},"Execute for &folders"},
--[[12]] {F.DI_CHECKBOX,7,12,0,12,2,0,0,{DIF_3STATE=1,DIF_DISABLE=1},"Se&lection present"},
--[[13]] {F.DI_CHECKBOX,37,9,0,9,0,0,0,0,"&PassivePanel"},
--[[14]] {F.DI_CHECKBOX,39,10,0,10,2,0,0,{DIF_3STATE=1,DIF_DISABLE=1},"P&luginPanel"},
--[[15]] {F.DI_CHECKBOX,39,11,0,11,2,0,0,{DIF_3STATE=1,DIF_DISABLE=1},"Execute for &folders"},
--[[16]] {F.DI_CHECKBOX,39,12,0,12,2,0,0,{DIF_3STATE=1,DIF_DISABLE=1},"Se&lection present"},
--[[17]] {F.DI_TEXT,-1,13,0,13,0,0,0,F.DIF_SEPARATOR,""},
--[[18]] {F.DI_CHECKBOX,5,14,0,14,2,0,0,F.DIF_3STATE,"Empty &command line"},
--[[19]] {F.DI_CHECKBOX,5,15,0,15,2,0,0,F.DIF_3STATE,"Selection &block present"},
--[[20]] {F.DI_TEXT,-1,16,0,16,0,0,0,F.DIF_SEPARATOR,""},
--[[21]] {F.DI_BUTTON,0,17,0,17,0,0,0,{DIF_DEFAULTBUTTON=1,DIF_CENTERGROUP=1},"OK"},
--[[22]] {F.DI_BUTTON,0,17,0,17,0,0,0,F.DIF_CENTERGROUP,"Cancel"},
}
local function DlgProc (hDlg,Msg,Param1,Param2)
if Msg == F.DN_BTNCLICK then
if Param1==9 or Param1==13 then
local enable = far.SendDlgMessage(hDlg,"DM_GETCHECK",Param1)
far.SendDlgMessage(hDlg,"DM_ENABLE",Param1+1,enable)
far.SendDlgMessage(hDlg,"DM_ENABLE",Param1+2,enable)
far.SendDlgMessage(hDlg,"DM_ENABLE",Param1+3,enable)
end
end
end
local guid = win.Uuid("7feed31e-ce59-4f94-9dd9-7da619b4ef00")
if far.Dialog (guid,-1,-1,73,20,nil,Items,nil,DlgProc) ~= 21 then return end
local tFlags = {}
if Items[5][6]==1 then tFlags[#tFlags+1]="EnableOutput" end
if Items[6][6]==1 then tFlags[#tFlags+1]="RunAfterFARStart" end
if Items[7][6]==1 then tFlags[#tFlags+1]="NoSendKeysToPlugins" end
if Items[9][6]==1 then
if Items[10][6]==0 then tFlags[#tFlags+1]="NoPluginPanels"
elseif Items[10][6]==1 then tFlags[#tFlags+1]="NoFilePanels"
end
if Items[11][6]==0 then tFlags[#tFlags+1]="NoFolders"
elseif Items[11][6]==1 then tFlags[#tFlags+1]="NoFiles"
end
if Items[12][6]==0 then tFlags[#tFlags+1]="NoSelection"
elseif Items[12][6]==1 then tFlags[#tFlags+1]="Selection"
end
end
if Items[13][6]==1 then
if Items[14][6]==0 then tFlags[#tFlags+1]="NoPluginPPanels"
elseif Items[14][6]==1 then tFlags[#tFlags+1]="NoFilePPanels"
end
if Items[15][6]==0 then tFlags[#tFlags+1]="NoPFolders"
elseif Items[15][6]==1 then tFlags[#tFlags+1]="NoPFiles"
end
if Items[16][6]==0 then tFlags[#tFlags+1]="NoPSelection"
elseif Items[16][6]==1 then tFlags[#tFlags+1]="PSelection"
end
end
if Items[18][6]==0 then tFlags[#tFlags+1]="NotEmptyCommandLine"
elseif Items[18][6]==1 then tFlags[#tFlags+1]="EmptyCommandLine"
end
if Items[19][6]==0 then tFlags[#tFlags+1]="NoEVSelection"
elseif Items[19][6]==1 then tFlags[#tFlags+1]="EVSelection"
end
local tResult = ([[
Macro {
description=%q;
area=""; key="";
flags=%q;
id=%q;
-- priority=50; condition=function(key) end;
action=function()
end;
}
]]) : format(Items[3][10], table.concat(tFlags," "), win.Uuid(win.Uuid()):upper())
print(tResult)
end
Macro {
description="New Macro";
area="Editor"; key="CtrlF11";
action=InsertMacro;
}