Code: Select all
local function stepDirect( key, count )
Keys( 'CtrlF5 ' .. ( count or 1 ) .. '*' .. ( key or 'AKey' ) .. ' Enter' )
end
Macro {
description = "Snap the dialog to the left window edge";
area = 'Dialog'; key = 'CtrlNum4'; -- Use Self.X1 below
action = function() stepDirect( 'Left', Dlg.GetValue( 0, 2 ) ) end
}
Macro {
description = "Snap the dialog to the bottom-left window corner";
area = 'Dialog'; key = 'CtrlNum1';
action = function()
stepDirect( 'Down', Far.Height - Dlg.GetValue( 0, 5 ) - 1 ) -- Use Self.Y2
stepDirect( 'Left', Dlg.GetValue( 0, 2 ) ) -- Use Self.X1
end
}
Macro {
description = "Snap the dialog to the right window edge";
area = 'Dialog'; key = 'CtrlNum6'; -- Use Self.X2 below
action = function() stepDirect( 'Right', Far.Width - Dlg.GetValue( 0, 4 ) - 1 ) end
}
Macro {
description = "Snap the dialog to the top-right window corner";
area = 'Dialog'; key = 'CtrlNum9';
action = function()
stepDirect( 'Right', Far.Width - Dlg.GetValue( 0, 4 ) - 1 ) -- Use Self.X2
stepDirect( 'Up' , Dlg.GetValue( 0, 3 ) ) -- Use Self.Y1
end
}
Macro {
description = "Snap the dialog to the top window edge";
area = 'Dialog'; key = 'CtrlNum8'; -- Use Self.Y1 below
action = function() stepDirect( 'Up', Dlg.GetValue( 0, 3 ) ) end
}
Macro {
description = "Snap the dialog to the top-left window corner";
area = 'Dialog'; key = 'CtrlNum7';
action = function()
stepDirect( 'Left', Dlg.GetValue( 0, 2 ) ) -- Use Self.X1
stepDirect( 'Up' , Dlg.GetValue( 0, 3 ) ) -- Use Self.Y1
end
}
Macro {
description = "Snap the dialog to the bottom window edge";
area = 'Dialog'; key = 'CtrlNum2'; -- Use Self.Y2 below
action = function() stepDirect( 'Down', Far.Height - Dlg.GetValue( 0, 5 ) - 1 ) end
}
Macro {
description = "Snap the dialog to the bottom-right window corner";
area = 'Dialog'; key = 'CtrlNum3';
action = function()
stepDirect( 'Down' , Far.Height - Dlg.GetValue( 0, 5 ) - 1 ) -- Use Self.Y2
stepDirect( 'Right', Far.Width - Dlg.GetValue( 0, 4 ) - 1 ) -- Use Self.X2
end
}
Macro {
description = "Center the dialog in the window";
area = 'Dialog'; key = 'CtrlClear CtrlNum5'; -- Use Self.Y2 below
action = function()
local offX = ( Far.Width - ( Dlg.GetValue( 0, 2 ) + Dlg.GetValue( 0, 4 ) ) ) / 2
local offY = ( Far.Height - ( Dlg.GetValue( 0, 3 ) + Dlg.GetValue( 0, 5 ) ) ) / 2
-- -0.5 chosen for the "Edit", "Find", "Select" dialogs to stay in their initial positions
stepDirect( offX > 0 and 'Right' or 'Left', math.abs( math.floor( offX - 0.5 ) ) )
stepDirect( offY > 0 and 'Down' or 'Up' , math.abs( math.floor( offY - 0.5 ) ) )
end
}