File Filter Control

LuaFAR 3

File Filter Control


File filter control is implemented as bindings of Far API function FileFilterControl. LuaFAR API is chosen to be different from Far API (in fact, it is much simpler).

The API consists of 1 function (far.CreateFileFilter) that creates an instance of file filter object, the latter has 4 methods: FreeFileFilter, OpenFiltersMenu, StartingToFilter and IsFileInFilter.

Example

  -- create a filter for the "active panel" area
  local AFilter = far.CreateFileFilter(1, "FFT_PANEL")
  if AFilter then
    -- update the "current time" parameter
    AFilter:StartingToFilter()

    -- manipulate panel elements
    local pInfo = panel.GetPanelInfo(nil, 1)
    for i=1, pInfo.ItemsNumber do
      -- apply the filter...
      local item = panel.GetPanelItem(nil, 1, i)
      if AFilter:IsFileInFilter(item) then
        -- the element matches filter conditions;
        -- process the element...
      end
    end

    -- free memory
    AFilter:FreeFileFilter()
  end