Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support path prefixes for the files menu #32

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions memo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ local palette = false
local search_words = nil
local search_query = nil
local dir_menu = false
local dir_menu_prefixes = nil
local path_prefixes = nil

local data_protocols = {
edl = true,
Expand Down Expand Up @@ -759,6 +759,12 @@ function show_history(entries, next_page, prev_page, update, return_items)
return
end

if not dir_menu and path_prefixes then
if not find_path_prefix(display_path, path_prefixes) then
return
end
end

if search_words and not options.use_titles then
for _, word in ipairs(search_words) do
if display_path:lower():find(word, 1, true) == nil then
Expand All @@ -778,7 +784,7 @@ function show_history(entries, next_page, prev_page, update, return_items)
if dirname == "." then return end
local unix_dirname = dirname:gsub("\\", "/")
local parent, _ = mp.utils.split_path(unix_dirname:sub(1, -2))
local start, stop = find_path_prefix(parent, dir_menu_prefixes)
local start, stop = find_path_prefix(parent, path_prefixes)
if not start then
return
end
Expand Down Expand Up @@ -1137,22 +1143,27 @@ mp.add_key_binding(nil, "memo-search", function()
end
mp.commandv("script-message-to", "console", "type", "script-message memo-search: ")
end)
mp.add_key_binding("h", "memo-history", function()
mp.register_script_message("memo-history", function(custom_path_prefixes)
if event_loop_exhausted then return end
last_state = nil
search_words = nil
dir_menu = false
if custom_path_prefixes then
path_prefixes = parse_path_prefixes(custom_path_prefixes)
else
path_prefixes = nil
end
show_history(options.entries, false)
end)
mp.register_script_message("memo-dirs", function(path_prefixes)
mp.register_script_message("memo-dirs", function(custom_path_prefixes)
if event_loop_exhausted then return end
last_state = nil
search_words = nil
dir_menu = true
if path_prefixes then
dir_menu_prefixes = parse_path_prefixes(path_prefixes)
if custom_path_prefixes then
path_prefixes = parse_path_prefixes(custom_path_prefixes)
else
dir_menu_prefixes = options.path_prefixes
path_prefixes = options.path_prefixes
end
show_history(options.entries, false)
end)
Expand Down