Angel_Ka
Full Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Macro { area="Shell"; key="AltF8"; description="AltF8 История команд НАТИВНО "; action=function() Keys("AltF8") end; } ------------------------------------------------------------------------------- -- cyberwolf » Ср 17 апр, 2013 08:55 http://forum.farmanager.com/viewtopic.php?p=108079#p108079 ------------------------------------------------------------------------------- -- Shortcuts for More History plugin. -- plugin: © 2013 Maxim Rusov -- http:/ /code.google.com/p/far-plugins/wiki/MoreHistory -- macro : v 0.02 © CyberWolf ------------------------------------------------------------------------------- -- Settings : ------------------------------------------------------------------------------- -- keyboard shortcuts local KEY_Folders = "AltF12" -- Folders local KEY_EdtView = "AltF11" -- Editor/viewer history local KEY_Cmds = "AltF8" -- Command history local KEY_NextCmd = "CtrlE" -- Show next command local KEY_PrevCmd = "CtrlShiftE" -- Show previous command local KEY_FAR_Folders = "AltShiftF12" -- Original FAR history : Folders local KEY_FAR_EdtView = "AltShiftF11" -- Original FAR history : Editor/viewer history local KEY_FAR_Cmd = "AltShiftF10" -- Original FAR history : Command history -- "AltShiftF8" ------------------------------------------------------------------------------- -- Code : do not modify (unless you know what you're doing) ------------------------------------------------------------------------------- local GUID_MoreHistory = "0AB780BC-36CA-4FDA-B321-70520D875CDE" local GUID_DlgEdtView = "EF4E9F0A-56EA-4510-92D9-FC361FE1FA9A" local GUID_DlgCmds = "433B0FAD-56A5-46E1-BCFB-462DEAAE35C9" local GUID_DlgFolders = "DDA833F3-3EA1-4B96-B867-590CE29AE6E0" local CMD_FolderHist = 1 local CMD_EditorHist = 2 local CMD_ModifyHist = 3 local CMD_CommandHist = 4 local CMD_PrevCmd = 5 local CMD_NextCmd = 6 local CMD_Options = 7 local AREA_History = "Shell Info QView Editor Viewer Search" local PlgExist_MoreHistory = function () return Plugin.Exist(GUID_MoreHistory) end local PlgExist_MoreHistory_DlgEdtView = function () return Plugin.Exist(GUID_MoreHistory) and Dlg.Id == GUID_DlgEdtView end local PlgExist_MoreHistory_DlgCmds = function () return Plugin.Exist(GUID_MoreHistory) and Dlg.Id == GUID_DlgCmds end local PlgExist_MoreHistory_DlgFolders = function () return Plugin.Exist(GUID_MoreHistory) and Dlg.Id == GUID_DlgFolders end Macro { area=AREA_History; key=KEY_Cmds; condition=PlgExist_MoreHistory; description="&MoreHist: история команд (CyberWolf)"; --- description="MoreHist: Commands history"; action = function() Plugin.Call(GUID_MoreHistory, CMD_CommandHist) end; } -- MoreHist: Commands history - Filter for current folder Macro { area="Dialog"; key=KEY_Cmds; condition=PlgExist_MoreHistory_DlgCmds; description="MoreHist: Commands history - Filter for current folder"; action = function() -- open the filter dialog Keys("CtrlF") -- if there's no text in the filter then add the current folder as a filter if Object.Empty then Keys("CtrlShift[ Enter Tab") -- if there's already a filter delete it else Keys("ShiftHome Del Enter Home Enter") end end; } -- MoreHist: Next command Macro { area="Shell"; key=KEY_NextCmd; condition=PlgExist_MoreHistory_DlgCmds; description="MoreHist: Next command"; action = function() Plugin.Call(GUID_MoreHistory, CMD_NextCmd) end; } -- MoreHist: Prev command Macro { area="Shell"; key=KEY_PrevCmd; condition=PlgExist_MoreHistory_DlgCmds; description="MoreHist: Prev command"; action = function() Plugin.Call(GUID_MoreHistory, CMD_PrevCmd) end; } -- Original FAR commands; Macro { area=AREA_History; key=KEY_FAR_Folders; condition=PlgExist_MoreHistory; description="MoreHist: Standard History: Folders"; action = function() Keys("AltF12") end; } Macro { area=AREA_History; key=KEY_FAR_EdtView; condition=PlgExist_MoreHistory; description="MoreHist: Standard History: Edit/View"; action = function() Keys("AltF11") end; } Macro { area=AREA_History; key=KEY_FAR_Cmd; condition=PlgExist_MoreHistory; description="MoreHist: Standard History: Command"; action = function() Keys("AltF8") end; } ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- local LFHistory = "a745761d-42b5-4e67-83da-f07af367ae86" local function LFH_exist() return Plugin.Exist(LFHistory) end local function LFH_run(key) Plugin.Menu(LFHistory) Keys(key) end Macro { description="&LuaFAR History: история команд (Shmuel)"; area="Shell"; key="AltF8"; condition=LFH_exist; action=function() LFH_run"1" end; } ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- Shmuel Сб 16 фев, 2013 10:21 http://forum.farmanager.com/viewtopic.php?p=104084#p104084 local ALT_HISTORY="FF8FC1AE-0F35-4134-9BAB-56D71B1D47B9" --local cfmCommandHistory = 1 --local cfmViewHistory = 2 --local cfmFolderHistory = 3 --local cfmFilteredCommandHistory = 4 --local cfmPrevCommand = 5 --local cfmNextCommand = 6 --local cfmXLat = 255 -- Macros for replace with AltHistory standard history --1 Macro { description="&AltHistory: история команд (Shmuel)"; -- description="Alternative commands history"; area="Shell Viewer Editor Info Qview Tree Dialog"; key="AltF8"; flags="DisableOutput"; condition=function() return Plugin.Exist(ALT_HISTORY) end; action=function() Plugin.Call(ALT_HISTORY, 1) end; } ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- fml2 Mon 06 Jan, 2014 23:48 http://forum.farmanager.com/viewtopic.php?p=113808#p113808 -- fml2 Wed 22 Jan, 2014 13:40 http://forum.farmanager.com/viewtopic.php?p=113808#p113808 -- -- Изначально комады сортируются по убыванию по дате запуска, т.е. последние запущенные команды находятся сверху. -- Во время отображения списка команд действуют следующие клавиши: -- Ctrl+F1: показать список возможных действий и соответствующих кнопкосочетаний -- Ctrl+F3: сортировать список по команде (повторное нажатие сортирует в обратном порядке). Индикатор в левом верхнем углу: "C". -- Ctrl+F4: сортировать список по дате запуска (повторное нажатие сортирует в обратном порядке). Индикатор в левом верхнем углу: "T". -- (Для сортировки по дате я вначале хотел использовать Ctrl+F5, но Far перехватывает это сочетание и обрабатывает его сам) -- Enter: запустить выбранную команду -- Ctrl+Enter: поместить выбранную команду в командную строку, но не запускать ее -- Shift+Enter: запустить выбранную команду в отдельном окне -- Del: удалить выбранную команду из истории -- Esc: погасить список и ничего не делать -- -- Изначально комады сортируются по возрастанию по дате запуска, т.е. последние запущенные команды находятся снизу. -- -- Displays the commands (from the command history) that have been launched -- from the current directory. -- "Enter" executes the command again -- "Shift+Enter" executes the command in a separate window -- "Ctrl+Enter" copies the command to the command line but does not execute it -- local function sortTableByField(pMenuItems, fieldName, sortAscending) table.sort(pMenuItems, function(a,b) local v1, v2 = a[fieldName], b[fieldName] if type(v1) == "string" then v1, v2 = v1:lower(), v2:lower() end if sortAscending then return v1 < v2 else return v1 > v2 end end) end -- Re-sorts the menu by the given field. Returns the index of the current entry -- after re-sorting local function resortMenuByField(pMenuItems, curIndex, fieldName, sortState) local curText = pMenuItems[curIndex].text if sortState.sortField == fieldName then -- Toggle the order sortState[fieldName] = not sortState[fieldName] else -- Switch the field, retain the order sortState.sortField = fieldName end sortTableByField(pMenuItems, sortState.sortField, sortState[fieldName]) local newIndex for i = 1, #pMenuItems do if pMenuItems[ш].text == curText then newIndex = i break end end return newIndex end local function getShortcutsDescription(breakKeys) sortTableByField(breakKeys, "BreakKey", true) local result = "" for i = 1, #breakKeys do if breakKeys[ш].descr then if result ~= "" then result = result.."\n" end result = result..breakKeys[ш].shortcutName.." -- "..breakKeys[ш].descr end end return result end local function getSortingDescription(sortState) local fieldToLetterMap = { execTime = "T", command = "C" } local sortLetter = fieldToLetterMap[sortState.sortField] local sortOrderLetter if sortLetter ~= nil then sortOrderLetter = sortState[sortState.sortField] and "↑" or "↓" else sortOrderLetter = "" end return sortLetter..sortOrderLetter end local function trim(str) return str:gsub("^%s*(.-)%s*$", "%1") end -- Removes the specified command from the Far's command history. -- Returns true iff the command was found and removed local function removeCommandFromHistory(commandToRemove) -- There is no plugin API for removing entries from a history. -- Hence we do it by simulating key presses. Keys("AltF8") -- Call the inbuilt command history dialog. The cursor is positioned at the last entry. local trimmedCmd = trim(commandToRemove) -- The command may contain spaces at the end local itemPos = Menu.Select(trimmedCmd) -- Try to select the item to be deleted local found = (itemPos > 0) if found then Keys("ShiftDel") -- Delete the current item end Keys("Esc") -- Hide the history return found end -- Removes the currently selected command from the Far's command history -- and from our menu. Returns the index of the item that should be active -- after removal. local function removeCurrentCommandFromHistory(pMenuItems, curIndex) local curItem = pMenuItems[curIndex] local curCmd = curItem.command local removed = removeCommandFromHistory(curCmd) if removed then -- Remove the command from our menu as well table.remove(pMenuItems, curIndex) end return #pMenuItems < curIndex and #pMenuItems or curIndex end local function showMenuAndExecCommand(menuItems, menuTitle) local sortState = { sortField = "execTime", command = true, execTime = false } -- true local menuProps = { Bottom = "Ctrl+F1 - Помощь по макросу", -- Bottom = "Ctrl+F1 - Display help", SelectIndex = #menuItems -- SelectIndex = 1 } resortMenuByField(menuItems, menuProps.SelectIndex, sortState.sortField, sortState) local execCommand = true local useSeparateWindow = false local breakKeys = { { BreakKey = "RETURN", leave = true, shortcutName = "Enter", descr = "Выполнить выбранную команду" }, -- descr = "Execute the selected command" { BreakKey = "S+RETURN", action = function() useSeparateWindow = true; return menuProps.SelectIndex end, leave = true, shortcutName = "Shift+Enter", descr = "Выполнить выбранную команду в отдельном окне" }, -- descr = "Execute the selected command in a separate window" { BreakKey = "C+RETURN", action = function() execCommand = false; return menuProps.SelectIndex end, leave = true, shortcutName = "Ctrl+Enter", descr = "Поставить выбранную команду в комстроку (но не выполнять её)" }, -- descr = "Put the selected command to the command line (but do not execute it)" { BreakKey = "C+F3", action = function() return resortMenuByField(menuItems, menuProps.SelectIndex, "command", sortState) end, shortcutName = "Ctrl+F3", descr = "Сортировать список по команде (повторно - в обратном порядке). Индикатор: 'C'" }, -- descr = "Sort entries by the command text" { BreakKey = "C+F4", action = function() return resortMenuByField(menuItems, menuProps.SelectIndex, "execTime", sortState) end, shortcutName = "Ctrl+F4", descr = "Сортировать список по дате запуска (повторно - в обратном порядке). Индикатор: 'T'" }, -- descr = "Sort entries by the command execution time" { BreakKey = "DELETE", action = function() return removeCurrentCommandFromHistory(menuItems, menuProps.SelectIndex) end, shortcutName = "Del", descr = "Удалить выбранную команду из истории" }, -- descr = "Remove the selected command from history" } local helpText = getShortcutsDescription(breakKeys) table.insert(breakKeys, { BreakKey = "C+F1", action = function() far.Message(helpText, "Возможные действия и соответствующие кнопкосочетания", nil, "l") end }) -- far.Message(helpText, "Keyboard reference", nil, "l") local selectedItem repeat local sortDescr = getSortingDescription(sortState) menuProps.Title = "[ "..getSortingDescription(sortState).." ] "..menuTitle selectedItem, menuProps.SelectIndex = far.Menu(menuProps, menuItems, breakKeys) if selectedItem then if selectedItem.action then menuProps.SelectIndex = selectedItem:action() end end until not selectedItem or selectedItem.leave if selectedItem then print(menuItems[menuProps.SelectIndex].command) if execCommand then local execKey = useSeparateWindow and "ShiftEnter" or "Enter" Keys(execKey) -- The selection was made by Enter (not Ctrl+Enter) --> launch the command end end end local function commandHistoryFromCurDir() local settings = far.CreateSettings("far") local historyItems = settings:Enum("FSSF_HISTORY_CMD") settings:Free() local curDir = far.GetCurrentDirectory() -- Create an array of items. Each item represents a command -- that has been launched from the current directory. local menuItems = {} local menuItemCnt = 0 for historyItemIdx = 1, #historyItems do local historyItem = historyItems[historyItemIdx] local param = historyItem["Param"] if param == curDir then local cmd = historyItem["Name"] local menuItem = {text = cmd, command = cmd, execTime = historyItem["Time"], id = historyItem["Id"]} menuItemCnt = menuItemCnt + 1 menuItems[menuItemCnt] = menuItem end end if menuItemCnt > 0 then -- There are commands found --> display the menu showMenuAndExecCommand(menuItems, "Команды, запускавшиеся из папки "..curDir) -- showMenuAndExecCommand(menuItems, "Commands launched from "..curDir) else far.Message("Запускавшихся из папки '"..curDir.."' команд в истории не найдено") -- far.Message("No commands launched from '"..curDir.."' have been found in the history") end end Macro { description = "&5 История команд, запущенных из текущей папки (fml2) AltShiftF8"; -- description = "Display commands that have been launched from the current directory"; area = "Shell"; key = "AltF8"; action = commandHistoryFromCurDir; } ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- John Doe Wed 01 Jan, 2014 20:46 http://forum.farmanager.com/viewtopic.php?p=115713#p115713 -- делать режим фильтра сразу активным при отображении истории -- т.е. чтобы при вводе каких-то букв эти буквы интерпретировались как фильтр (CtrlAltF) для истории local allShell = "Shell QView Tree Info Search " local allScreens = allShell.."Editor Viewer " local allMenu = "Menu MainMenu UserMenu Disks " local Completion = "ShellAutoCompletion DialogAutoCompletion " local allDlgs = "Dialog "..allMenu..Completion local set,lock,notempty = 0,1,2 -- auto-turn filter on (in defined menus) -- Macro { description="&6 Нативное History Menu сразу с CtrlAltF-фильтром (JD)"; -- [filter on] - area=allShell; key="AltF8"; action=function() Keys("AKey") Menu.Filter(set,1) end; } |