------------------------------------------------------------------------------------------------------------------------
-- CtrlAltShiftQ - полезная информация об элементе под курсором (панели, диалоги, меню, пр.)
-- CtrlAltShiftA - все элементы диалога
------------------------------------------------------------------------------------------------------------------------
local F = far.Flags
local MaxLen = 80 -- максимальная длина для обрезки длинных значений
------------------------------------------------------------------------------------------------------------------------
-- Поиск гуида в таблице far.Guids
_G.FindGuid = function(guid)
if guid and guid:len()==16 then guid=win.Uuid(guid) end
guid = guid and guid:upper() or ""
for n,v in pairs(far.Guids) do
if v == guid then
return n
end
end
return nil
end
-- Поиск флага в far.Flags
_G.FindFlag = function(flag,prefix)
prefix = prefix and "^"..prefix or ".+"
for n,v in pairs(far.Flags) do
if flag==v and n:find(prefix) then
return n
end
end
return nil
end
------------------------------------------------------------------------------------------------------------------------
Macro {
description="Info";
area="Common";
key="CtrlAltShiftQ";
action=function()
local a = Area.Current
local t = "Area: " .. Area.Current
local info = far.AdvControl(F.ACTL_GETWINDOWINFO)
local object_id, owner_id
if Area.Menu then
a = "Menu"
local menu_id = Menu.Id
local menu_guid = FindGuid(menu_id)
menu_guid = menu_guid and (" ("..menu_guid..")") or ""
t = "Area: " .. Area.Current
.."\n".."ID: " .. menu_id
.."\n".."Title: " .. (Object.Title or ""):sub(1,MaxLen)
.."\n".."ItemStatus: " .. (Menu.ItemStatus() or "")
.."\n".."Value: " .. (Menu.Value or ""):sub(1,MaxLen)
.."\n".."Type: " .. info.TypeName
.."\n".."Name: " .. info.Name
elseif Area.MainMenu then
a = "Menu"
local guid = Menu.Id
local guid_name = FindGuid(guid)
guid_name = guid_name and (" ("..guid_name..")") or ""
t = "Area: " .. Area.Current
.."\n".."ID: " .. (guid or "")
.."\n".."Title: " .. (Object.Title or ""):sub(1,MaxLen)
.."\n".."ItemStatus: " .. (Menu.ItemStatus() or "")
.."\n".."Value: " .. (Menu.Value or ""):sub(1,MaxLen)
.."\n".."Type: " .. info.TypeName
.."\n".."Name: " .. info.Name
elseif Area.UserMenu then
a = "UserMenu"
local guid = Menu.Id
local guid_name = FindGuid(guid)
guid_name = guid_name and (" ("..guid_name..")") or ""
t = "Area: " .. Area.Current
.."\n".."ID: " .. guid
.."\n".."Title: " .. (Object.Title or ""):sub(1,MaxLen)
.."\n".."ItemStatus: " .. (Menu.ItemStatus() or "")
.."\n".."Value: " .. (Menu.Value or ""):sub(1,MaxLen)
elseif Area.Dialog then
a = "Dialog"
local dlg_h = info.Id
local coord = dlg_h:send(F.DM_GETDLGRECT,0,0)
local focus = dlg_h:send(F.DM_GETFOCUS)
local item = dlg_h:send(F.DM_GETDLGITEM,focus)
local item_type = FindFlag(item[1],"DI_")
local dlg_guid = Dlg.Id
local dlg_owner = Dlg.Owner
local dlg_guid_name = FindGuid(dlg_guid)
local dlg_owner_name = FindGuid(dlg_owner)
local dlg_title = Object.Title
t = "Area: " .. Area.Current
.."\n".."ID: " .. dlg_guid .. (dlg_guid_name and (" ("..dlg_guid_name..")") or "")
.."\n".."Owner: " .. dlg_owner .. (dlg_owner_name and (" ("..dlg_owner_name..")") or "")
.."\n".."Title: " .. (dlg_title or ""):sub(1,MaxLen)
.."\n".."Coord: " .. ("X1=%i Y1=%i X2=%i Y2=%i"):format(coord.Left,coord.Top,coord.Right,coord.Bottom)
.."\n".."Size: " .. ("Width=%i Height=%i"):format(coord.Right-coord.Left+1,coord.Bottom-coord.Top+1)
.."\n".."Type: " .. info.TypeName
.."\n".."Name: " .. info.Name
.."\n"
.."\n".."Focus: " .. focus
.."\n".."ItemType: " .. item[1] .. (item_type and " ("..item_type..")" or "")
.."\n".."Value: " .. item[10]:sub(1,MaxLen)
.."\n".."Coord: " .. ("X1=%i Y1=%i X2=%i Y2=%i"):format(item[2],item[3],item[4],item[5])
.."\n".."Size: " .. ("Width=%i Height=%i"):format(item[4]-item[2]+1,item[5]-item[3]+1)
elseif Area.Dialog then
a = "Dialog"
local dlg_h = info.Id
local coord = dlg_h:send(F.DM_GETDLGRECT,0,0)
local focus = dlg_h:send(F.DM_GETFOCUS)
local item = dlg_h:send(F.DM_GETDLGITEM,focus)
local item_type = FindFlag(item[1],"DI_")
local dlg_info = dlg_h:send(F.DM_GETDIALOGINFO,0)
local dlg_guid = win.Uuid(dlg_info.Id):upper()
local dlg_owner = win.Uuid(dlg_info.Owner):upper()
local dlg_guid_name = FindGuidS(dlg_guid)
local dlg_owner_name = FindGuidS(dlg_owner)
local dlg_title = dlg_h:send(F.DM_GETDIALOGTITLE,0)
local menu_value = Menu.Value
t = "Area: " .. Area.Current
.."\n".."ID: " .. dlg_guid .. (dlg_guid_name and (" ("..dlg_guid_name..")") or "")
.."\n".."Owner: " .. dlg_owner .. (dlg_owner_name and (" ("..dlg_owner_name..")") or "")
.."\n".."Title: " .. (dlg_title or ""):sub(1,MaxLen)
.."\n".."Coord: " .. ("X1=%i Y1=%i X2=%i Y2=%i"):format(coord.Left,coord.Top,coord.Right,coord.Bottom)
.."\n".."Size: " .. ("Width=%i Height=%i"):format(coord.Right-coord.Left+1,coord.Bottom-coord.Top+1)
.."\n".."Type: " .. info.TypeName
.."\n".."Name: " .. info.Name
.."\n"
.."\n".."Focus: " .. focus
.."\n".."ItemType: " .. item[1] .. (item_type and " ("..item_type..")" or "")
.."\n".."Value: " .. item[10]:sub(1,MaxLen)
.."\n".."Coord: " .. ("X1=%i Y1=%i X2=%i Y2=%i"):format(item[2],item[3],item[4],item[5])
.."\n".."Size: " .. ("Width=%i Height=%i"):format(item[4]-item[2]+1,item[5]-item[3]+1)
.."\n".."MenuValue: " .. (menu_value or "")
elseif Area.Search then
a = "Search"
t = "Area: " .. Area.Current
.."\n".."Title: " .. (Object.Title or "")
.."\n".."Focus: " .. Dlg.SetFocus()
.."\n".."Value: " .. Dlg.GetValue(-1,0):sub(1,MaxLen)
.."\n".."ItemType: " .. Dlg.ItemType
--.."\n"..win.Uuid(id)
elseif Area.Shell then
local dir = panel.GetPanelDirectory(nil,1)
a = "Shell"
t = "Area: " .. Area.Current
.."\n".."Name: " .. dir.Name
.."\n".."Param: " .. dir.Param
.."\n".."PluginId: " .. string.upper(win.Uuid(dir.PluginId))
.."\n".."File: " .. dir.File
.."\n".."Type: " .. info.TypeName
--.."\n".."Name: " .. info.Name
elseif Area.Disks then
a = "Disks"
t = "Area: " .. Area.Current
.."\n".."Title: " .. (Object.Title or ""):sub(1,MaxLen)
.."\n".."Type: " .. info.TypeName
.."\n".."Name: " .. info.Name
.."\n"
.."\n".."Value: " .. (Menu.Value or ""):sub(1,MaxLen)
else
a = "Unknown"
t = "Area: " .. Area.Current
.."\n".."Title: " .. (Object.Title or ""):sub(1,MaxLen)
.."\n".."ID: " .. Dlg.Id
.."\n".."ID: " .. Menu.Id
.."\n".."Type: " .. info.TypeName
.."\n".."Name: " .. info.Name
end
msgbox(a.." info", t, 8)
end;
}
------------------------------------------------------------------------------------------------------------------------
local AllItemsListId = "6FC32E48-2857-4487-8B46-B658C1C8B585"
local AllItemsViewId = "98B202E2-EB02-4B42-8375-59876F2A5367"
Macro {
description="Info: All dialog items";
area="Dialog";
key="CtrlAltShiftA";
action=function()
local t = ""
local info = far.AdvControl(F.ACTL_GETWINDOWINFO,nil)
local dlg = info.Id
local focus = dlg:send("DM_GETFOCUS")
local item, itemtype
local items = {}
local hotkeys = { {BreakKey="F3"} }
local current = 0
local itemnum = 0
while true do
itemnum = itemnum+1
item = dlg:send(F.DM_GETDLGITEM,itemnum)
if item==nil then break end
itemtype = FindFlag(item[1],"DI_")
items[#items+1] = {
text="Item "..tostring(itemnum).."; Type: "..tostring(item[1])..(itemtype and " ("..itemtype..")" or ""),
}
if itemnum == focus then
current = #items
items[#items].checked = true
end
items[#items+1] = {
text=" "..item[10],
grayed=true,
}
items[#items+1] = {
text=" "..("X1=%i Y1=%i X2=%i Y2=%i W=%i H=%i"):format(item[2],item[3],item[4],item[5],item[4]-item[2]+1,item[5]-item[3]+1),
grayed=true,
}
end
far.Menu(
{
Title="Dialog: "..info.Name,
Bottom="F3: View",
SelectIndex=current,
Id=win.Uuid(AllItemsListId),
Flags=bor(F.FMENU_SHOWAMPERSAND,F.FMENU_WRAPMODE),
MaxHeight=21,
},
items, hotkeys
)
end;
}
------------------------------------------------------------------------------------------------------------------------