Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Программы » FAR Manager (часть 5)

Модерирует : gyra, Maz

Maz (15-01-2020 17:38): FAR Manager (часть 6)  Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

   

Alexyz21



Silver Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

Код:
 
-- started: 2014-03-09
 
local ThisScriptId = "A84D789F-C101-4055-BFDA-E1594CB489DE"
 
local F = far.Flags
 
local menuIds = {"937F0B1C-7690-4F85-8469-AA935517F202", -- Plugin commands
                 "B4C242E7-AA8E-4449-B0C3-BD8D9FA11AED", -- Plugins configuration
                 "A204FF09-07FA-478C-98C9-E56F61377BDE", -- far:config
                 "F6D2437C-FEDC-4075-AA56-275666FC8979", -- File associations
                 "D0422DF0-AAF5-46E0-B98B-1776B427E70D", -- Files highlighting
                 "5B87B32E-494A-4982-AF55-DAFFCD251383"  -- Filters menu
                }
 
for k,v in pairs(menuIds) do menuIds[k]=win.Uuid(v) end
 
local Positions = mf.mload(ThisScriptId, "FarMenuPositions") or {}
local LastArea = "Shell"
--[=[
-- Since Plugins menu can be called from various areas and it has the same GUID
-- but different contents depending on the area it called from, in order to
-- distinguish between those menus, this macro stores the area name prior to
-- calling Plugins menu.
автоперевод:
Поскольку меню плагинов можно вызывать из разных областей, и у него есть тот же идентификатор GUID,
но различное содержимое в зависимости от области, из которой он вызван, чтобы различать эти меню,
этот макрос сохраняет имя области до вызова меню плагинов.
]=]--
Macro {
  description="Call Plugins menu";
  area="Common"; key="F11 ShiftF11";
  action=function()
    local a = Area.Current
    LastArea = (a=="Search" or a=="Tree" or a=="Info") and "Shell" or a
    Keys("F11")
    -- Execute the menu item
    if akey(1,1)=="ShiftF11" then Keys("Enter") end
  end;
}
--[=[
-- Get the key for accessing the Positions table.
-- NOTE: when adding new keys, their values must differ from any name of Far
--       macro areas (numeric values are OK).
автоперевод:
Получение ключа для доступа к таблице Positions.
ПРИМЕЧАНИЕ.
При добавлении новых ключей их значения должны отличаться от любого имени областей Far macro (числовые значения нормальны).
]=]--
local function GetKey (hDlg)
  local info = hDlg:send("DM_GETDIALOGINFO")
  local res
  if info then
    if info.Id==menuIds[1]
    then res=LastArea
    else for i=2,#menuIds do if info.Id==menuIds[i] then res=i-1 break end end
    end
  end
  return res
end
 
local function EvHandler (Event, FarDialogEvent)
  --if Event == F.DE_DLGPROCINIT then --> crashes when opening RESearch plugin's search or replace dialogs.
                                        --сбой при открытии диалога поиска или замены диалогового окна RESearch.
  if Event == F.DE_DLGPROCEND then
    local hDlg, Msg = FarDialogEvent.hDlg, FarDialogEvent.Msg
    if Msg == F.DN_INITDIALOG then
      -- Set position in the menu --Задать позицию в меню
      local key = GetKey(hDlg)
      if key and Positions[key] then
        hDlg:send("DM_LISTSETCURPOS", 1, {SelectPos=Positions[key]})
      end
    elseif Msg == F.DN_CLOSE then
      -- Get menu position --Получить позицию меню
      local key = GetKey(hDlg)
      if key then
        local t = hDlg:send("DM_LISTGETCURPOS", 1)
        if t then
          Positions[key] = t.SelectPos
        end
        LastArea = "Shell"
      end
    end
  end
end
 
Event {
  description="Сохранение и восстановление позиций в меню (shmuz) Event";
  --description="Store and restore menu positions";
  group="DialogEvent"; action=EvHandler;
}
 
Event {
  description="Сохранить позиции в меню (shmuz) Event";
  --description="Save menu positions";
  group="ExitFAR";
  action=function() mf.msave(ThisScriptId, "FarMenuPositions", Positions) end;
}
--[=[
shmuz 19:42 12-09-2018
http://forum.ru-board.com/topic.cgi?forum=5&topic=49572&start=1018&limit=1&m=1#1
 
http://forum.ru-board.com/topic.cgi?forum=5&topic=49572&start=1000#20
 
shmuz 18:22 12-09-2018
http://forum.ru-board.com/topic.cgi?forum=5&topic=49572&start=1000#18
 
Автовыделение последнего выполненного пункта - этим я пользуюсь для:
меню плагинов, меню настроек плагинов и far:config (естественно, позиции запоминаются и восстанавливаются отдельно).
]=]--
 

Всего записей: 3484 | Зарегистр. 16-06-2007 | Отправлено: 10:30 17-09-2018 | Исправлено: Alexyz21, 10:34 17-09-2018
   

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Программы » FAR Manager (часть 5)
Maz (15-01-2020 17:38): FAR Manager (часть 6)


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru