Code: Select all
-- See https://forum.farmanager.com/viewtopic.php?p=148024#p148024
-- Based on https://forum.farmanager.com/viewtopic.php?p=146816#p146816
buildNum = ({actl.GetFarManagerVersion true})[4]
d = buildNum < 6061 and 1 or 0 -- no separate Fuzzy Search yet? Beware: these are deprecated and no longer supported.
viewerFuzzySearch = buildNum > 6077
findFileTextHexRadio = buildNum > 6081 -- note: builds 6082..6084 have issues in the dialog, see GH-592
unifiedSearchReplace = buildNum > 6095
unifiedViewerSearch = buildNum > 6098
unifiedSRTransform = unifiedSearchReplace and {1,4.3,5.3,7,10,15.1,16.1,17.1,18.1,19.4} or {1,2.3,3.3,5,7,12.1,13.1,14.1}
attributesMovedLeft = buildNum > 6311
attributesDeviceName = buildNum > 6393
DX=-6 -- 4 gives a nice 2-character gap on both sides, -8 drags the side frames just off the window
F = far.Flags
pluginVersion = (dlg)->
ownerGUID = dlg\GetDialogInfo!.Owner
plugin = far.FindPlugin F.PFM_GUID, ownerGUID
info = far.GetPluginInformation plugin
info.GInfo.Version -- table (array of 5 integers)
versionLessThan = (ver0,ver1)-> -- simplistic version comparison; each version has to be an array of 5 integers
for i = 1, 5
v0, v1 = ver0[i], ver1[i]
if v0 ~= v1 then return v0 < v1
false
transforms =
[ far.Guids.FindFileId]: findFileTextHexRadio and {1,3,6,7,17.1,18.1,19.1,20.1,22.1,25.1} or
{1,3,6,7,9,16.1-d,17.1-d,18.1-d,19.1-d,21.1-d,23.2-d,24.1-d}
[ far.Guids.CopyFilesId ]: {1,2,3}
[ far.Guids.CopyCurrentOnlyFileId ]: {1,2,3}
[ far.Guids.MoveFilesId ]: {1,2,3}
[ far.Guids.MoveCurrentOnlyFileId ]: {1,2,3}
[ far.Guids.MakeFolderId ]: {1,3,6,8}
[ far.Guids.HardSymLinkId ]: {1,2,3}
[ far.Guids.CopyProgressId ]: {1,2,4,6,7,11} -- zg's variant for Pasha_ZZZ: {1,2,4,6,7,9,10,11,13}
[ far.Guids.FileOpenCreateId ]: {1,3}
[ far.Guids.HelpSearchId ]: unifiedSRTransform
[ far.Guids.EditorSearchId ]: unifiedSRTransform
[ far.Guids.EditorReplaceId ]: unifiedSRTransform
[ far.Guids.ViewerSearchId ]: unifiedViewerSearch and unifiedSRTransform or
( viewerFuzzySearch and {1,5,11.1,12.1} or {1,3,8.1,9.1,10.1,11.1} )
[ far.Guids.FileSaveAsId ]: {1,3,6}
[ far.Guids.PluginInformationId ]: [ i for i = 1,17,2 ]
[ far.Guids.FileAttrDlgId ]: attributesDeviceName and {1,3,4,6,9,41,49} or
( attributesMovedLeft and {1,3,4,6,39,47} or {1,3,4,6,37} )
[ far.Guids.DescribeFileId ]: {1,2,3,6}
[ far.Guids.ApplyCommandId ]: {1,3,6}
[ far.Guids.EditUserMenuId ]: {1,5,8,9,10,11,12,13,14,15,16,17}
[ far.Guids.UserMenuUserInputId ]: [ i for i = 1,41,2 ] -- up to 20 !?$<history>$<title>?<init>! inputs
[ far.Guids.FileAssocModifyId ]: {1,3,5,8,10,12,14,16,18}
[ far.Guids.EditMaskGroupId ]: {1,5}
[ far.Guids.CopyOverwriteId ]: {1,3}
[ far.Guids.CopyReadOnlyId ]: {1,3}
[ far.Guids.SelectDialogId ]: {1,2}
[ far.Guids.UnSelectDialogId ]: {1,2}
[ far.Guids.FolderShortcutsDlgId ]: {1,3,5,8,10}
--{ ArcLite
['08A1229B-AD54-451B-8B53-6D5FD35BCFAA']: {1,15,19,27,31} -- Configuration
['CD57D7FA-552C-4E31-8FA8-73D9704F0666']: (dlg)-> -- two related dialogs:
if dlg\GetDlgItem 40 then {1,3,4.3,5.3,10,23} -- Create archive
else {1,8} -- (fewer than 40 items) -- Add files to archive
['97877FD0-78E6-4169-B4FB-D76746249F4D']: {1,3} -- Extract files
--['83B02899-4590-47F9-B4C1-6BC66C6CA4F9']: {1,2} -- Overwrite file: target file path is cut anyway
['761F3B4C-FC45-4A9D-A383-3F75D505A43B']: {1,2,3,4} -- Enter password
['0DCE48E5-B205-44A0-B8BF-96B28E2FD3B3']: {1,9,16,18,20,22,25,27,31,33,35,37} -- SFX options
--}
['2345D916-D5D1-4A17-800A-E44C457D4F82']: {1,3} -- TmpPanel: Save file list
--{ Colorer
['87C92249-430D-4334-AC33-05E7423286E9']: {1,5,7,9} -- Configuration: Main
['0497F43A-A8B9-4AF1-A3A4-FA568F455707']: {0.2,1,7} -- Configuration: Scheme
['3D1031EA-B67A-451C-9FC6-081320D3A139']: {1,7} -- Configuration: Logging
--}
--{ NetBox used the same GUID for many of its dialogs, thus Transfer settings, Background transfers dialogs' layouts suffered.
-- (older) Copy, Move; Make folder; (historic) Duplicate, Move to, Rename; Add link; Integration settings; Edit Session
['42E4AEB1-A230-44F4-B33C-F195BB654931']: {1,3,5,7,9, 39,63,67,81,173,152} -- before v24.3 (plugin UUID used as dialogs' UUID)
['3A32BE91-6BDF-4E90-B779-8374875390A1']: {1,3,5,7,9, 39,63,67,81,92,172,151} -- from v24.3 (at least 24.3.1 build 599)
['D5C65C2D-219A-4335-9E22-4BAC0D7426DE']: {1,3,5} -- Attributes
['B1244FD0-0C7F-4DF1-866E-AB2F630092BE']: {1,2,3} -- Duplicate, Move to, Rename
['4D9E158F-B0B7-4F93-BCD4-58625995E413']: {1,3} -- Server prompt, Transfer under different name
['4923BCD8-E1D7-4A96-906D-6CB1D72BD289']: {1,3} -- Copy, Move
['352409FB-F388-4C4F-B753-7416451C249D']: {1,3} -- Make folder
['5B19775E-DD59-43CD-9B63-35B988BE5615']: {1,3,5} -- Add link
['AF95C5A6-04FC-4979-863D-9AF4E537CEC5']: {1,3} -- Apply command
['8169A8EE-A920-4ED6-B4A8-A209FA5A71D7']: {1,3,5} -- Synchronize
['24A78A92-E48D-4E96-BE1A-BD5EAAE87B6B']: {1,3,5} -- Keep remote directory up to date
['077C86B6-3FDD-498C-9256-3ED0BA70D03D']: {1,31,32.3} -- Server and protocol information
--['A22C304F-C0CB-47FF-B752-AB1B0D887EC2']: {1,10} -- Queue - table columns don't resize to the dialog width anyway
['D3D0BC72-0473-47E2-9DF8-19B0DC2E0F0A']: (dlg)-> -- Edit session - from 24.6.0.603
if versionLessThan pluginVersion(dlg), {24,12,1,606,0} -- when the "S3" page was added
{1,28,29.3,30.3,41,65,69,83,117,118,119,144,145.3,146.3,153,155,166,167.3,168.3,174}
else {1,29,30.3,31.3,42,66,70,84,118,119,120,152,153.3,154.3,161,163,174,175.3,176.3,182}
['7D820959-80E0-4A67-98C6-F74389FF93B2']: {1,8} -- Logging settings
['5F3E08E2-B1FD-443F-A568-12ED4B997F16']: {1,3,7,9} -- Integration settings
['B5B7C807-6C25-4E7E-BA5D-D04E6ACF5FF3']: {1,8, 3.3,18.3,19.3,20.3,21.3,22.3,23.3,24.3,25.3,26.3,27.3,28.3,29.3,
30.3,31.3,32.3,33.3,34.3,35.3,36.3,37.3,38.3,41} -- Transfer settings
--}
--{ RESearch
['E506EA8F-484F-7261-FEED-9B10267753E9']: {1.0,4.0,6.0,7.3,26.3} -- Shell/Search
['9736CFC1-9F3A-D4F9-02A4-566717182E8B']: {1.0,4.0,6.0,8.0,9.3,10.3,37.3} -- Shell/Replace
['3D95792C-E25C-1CE1-EC09-DC409184EC7A']: {1.0,4.0,6.0,7.3,24.0,35.3} -- Shell/Grep
['2BA46061-20D7-96FD-0F50-9AD88DF57FA1']: {1.0,3.0,5.3,7.0,9.3,38.3} -- Shell/Search/Advanced
['AA3CA1C7-062A-67A8-3A73-80B5E9394046']: {1.0,5.0} -- Shell/SelectFiles,UnselectFiles,FlipSelection
['0AE75CCC-5872-74A7-3561-BBA1991C0395']: {1.0,4.0,6.0,8.0,28.1} -- Shell/RenameFiles
['622AAD65-B7CA-7670-6622-A267028B1A06']: {1.0,5.0,7.0,16.3} -- Shell/RenameSelectedFiles
['FF1E3A24-0B7A-0149-EFA2-1ED2309F8410']: {1.0,3.0,4.3,14.3,18.3} -- Viewer,Editor/Search (hack: [Presets] is 14 in V, 18 in E)
['411BF77E-5743-D87A-A8E7-0EFDF0C71D79']: {1.0,3.0,5.0,6.3,7.3,25.3} -- Editor/Replace
['3A6225FC-AD65-75B1-2643-5158B78D6BC4']: {1.0,3.0,4.3,14.3} -- Editor/Filter
['6938029A-B71F-09EE-D09D-9982EE2B40BC']: {1.0,3.0,4.3,15.3} -- Editor/Repeat
['DCDDDA35-A319-1B82-8410-36C04A1390B0']: {1.0,3.0,5.0,10.3} -- Editor/Transliterate
--}
['6974DF22-EF25-4803-8C52-8E80C839EB58']: {1,3} -- AltHistory: Add exclusion
['32596DDC-03ED-4EE1-884C-4AEB3F436BD6']: {1,3} -- AltHistory: Edit filter
['193AA8E6-FD4F-4915-848E-6E8D1E0C1A21']: {1,3} -- AltHistory_ViewItem
['6155F9B3-2CC4-4FF7-84B9-8F5A3A4803CF']: {1,3} -- ChDirToFolder
['84CFDB2D-416F-4E29-813C-24F96BF77533']: {1,3,5} -- %FARHOME%\Addons\Macros\Symlink.lua
['2C4EFD54-A419-47E5-99B6-C9FD2D386AEC']: {1,3,5} -- PostMacro
['E9D017C5-DB0C-441D-8E11-0AD35841AFC6']: {1,3} -- Registry: Copy (export)
['70B7A9E0-EB59-4827-B7E5-BF65AF80364A']: {1,3} -- Registry: Copy (in Registry), Move/Rename (in Registry)
['6CD79091-C9FC-4B1A-9277-037434879069']: {1,3} -- Registry: Create key
['DBF22016-D6E7-4549-B71B-BD2F1E0B0AB5']: {1,3} -- Registry: Edit value (description)
['F39EFDBF-A2E3-44F5-B4DF-519548A62BF9']: {1,2,3} -- FileUnlock: processes list
--{ XML Browser and JSON browser share their main dialog GUIDs:
['54780B3C-1ECE-41BE-8E7C-786A7F51492D']: {1,3} -- Copy (export)
['B0F0C168-3B47-41D9-826B-008F6797D5B1']: {1,3} -- Edit-view value (description)
--}
['2430BA2F-D52E-4129-9561-5E8B1C3BACDB']: {1,3} -- Observer: Extract file(s)
-- Not a custom dialog: ['7588B1C1-6D1F-4C60-BC69-2B8534CA470B']: {1,3,4,8} -- Observer: Extraction progress
['4809D144-75B8-41A8-9700-7B925665F6AD']: {1,3,8,10,12} -- Anamorphosis: custom.module: Edit association
--{ Renewal 3.23.1+, by Pasha_ZZZ, see https://forum.farmanager.com/viewtopic.php?p=172973#p172973
['FF3A8CA2-544A-4ECD-A9A2-74B01D007E60']: {1,3,5,7,9,11,13,15,17,19} -- Info
['44832B2D-406B-4071-89DD-17182E539F2F']: {1,3,5,12,16,18,21,23} -- Setup
['C6BCF2E6-CD58-4811-820C-AB72AB7F473B']: {1,8,10,12,15,17,20} -- Configuration
--}
['866927E1-60F1-4C87-A09D-D481D4189534']: [ i for i = 1,99,2 ] -- Polygon: Edit row (up to 49 columns)
['D22202DF-AB5A-4B71-97B9-FD7C07C3867E']: [ i for i = 1,2*40 ] -- NTFS File Information: File Version
['5D2D74B0-B1CC-4091-AAA2-1C5789B14E01']: {1,7} -- EnvEdit: Edit Environment Variable
--['51ECCEBF-D6F4-4B9F-9DAC-CDF69F74175F']: {1,2} -- GitShell: History - seems immune
["BE0B1498-4234-4BE1-B257-7653CAF4F091"]: -- GitShell-owned dialogs with zero Id
{1,3,5,7, unpack[ i for i = 10.5,99 ]} -- GitShell: Diff, Repository/Commit info, Rename/Create/Delete branch
transforms = { win.Uuid(k), v for k, v in pairs transforms }
consoleWidth = -> with actl.GetFarRect! return .Right - .Left + 1
Event
group:'DialogEvent'
description:'Dialog_Maximize: main'
action:(event,param)->
if event == F.DE_DLGPROCINIT and ( param.Msg == F.DN_INITDIALOG or param.Msg == F.DN_RESIZECONSOLE )
if id = param.hDlg\GetDialogInfo!
if xform = transforms[ win.Uuid'00000000-0000-0000-0000-000000000000' ~= id.Id and id.Id or id.Owner ]
if xform = ( 'function' ~= type xform ) and xform or xform param.hDlg
split = (i)->
index,opt = math.modf xform[i]
index, math.floor opt * 10 + .5
index,opt = split 1
dx = DX + ( index == 0 and opt or 0 )
cx = consoleWidth!
Left:dl,Top:dt,Right:dr,Bottom:db = param.hDlg\GetDlgRect!
diff = ( cx - dx ) - ( dr - dl + 1 )
if 0 < diff
param.hDlg\ResizeDialog 0, X:cx-dx,Y:db-dt+1
param.hDlg\MoveDialog 1, X:dx/2,Y:dt
for i = 1,#xform
index,opt = split i
if item = param.hDlg\GetDlgItem index -- prevent error message for out-of-range index (see "hack" above)
sm = (d2,d4)->
if 0 < d2 then item[2] += diff / d2
if 0 > d2 then item[2] = 5 -- skip margin and frame -- TODO check frame presence/geometry
if 0 < item[4] then item[4] += diff / d4
sm switch opt
when 0 then 0,1 -- Stretch full
when 1 then 2,2 -- Move half
when 2 then 0,2 -- Stretch half
when 3 then 1,1 -- Move full
when 4 then 2,1 -- Move half + stretch half
when 5 then -1,1 -- Stretch side to side
param.hDlg\SetDlgItem index,item
false