local F = far.Flags local ffi = require'ffi' Macro { description="* Select Duplicates FileName in Branch panel"; name="SDFN"; area="Shell"; action=function() local pBL=ffi.cast("BOOL*",1) local pc=ffi.cast("struct PluginStartupInfo*",far.CPluginStartupInfo()).PanelControl local pin=panel.GetPanelInfo(nil,1) if bit.band(pin.Flags,F.PFLAGS_SELECTEDFIRST)>0 then Keys("ShiftF12") end if pin.SortMode~=F.SM_NAME then panel.SetSortMode(nil,1,F.SM_NAME) end local j,fn0,fn1,t0 = 0,"","",far.FarClock() pc(PANEL_ACTIVE,"FCTL_BEGINSELECTION",0,nil) for i=1,pin.ItemsNumber do fn0,fn1 = fn1,string.gsub(panel.GetPanelItem(nil,1,i).FileName,"^.+\\","") if fn1==fn0 then if i>j then pc(PANEL_ACTIVE,"FCTL_SETSELECTION",i-2,pBL) end pc(PANEL_ACTIVE,"FCTL_SETSELECTION",i-1,pBL) j=i+1 end end pc(PANEL_ACTIVE,"FCTL_ENDSELECTION",0,nil) pc(PANEL_ACTIVE,"FCTL_REDRAWPANEL",0,nil) Keys("ShiftF12") msgbox("SDFN","mcs: "..far.FarClock()-t0.."\n\nUse ShiftF12 for sort") end; } |