diff --git a/addons/find.lua b/addons/find.lua index 35fa588..d2f56ff 100644 --- a/addons/find.lua +++ b/addons/find.lua @@ -12,10 +12,11 @@ local msg = require "mp.msg" local fb = require "file-browser" -local input = require "user-input-module" +local input_loaded, input = pcall(require, "mp.input") +local user_input_loaded, user_input = pcall(require, "user-input-module") local find = { - version = "1.3.0" + version = "1.4.0" } local latest_coroutine = nil local global_fb_state = getmetatable(fb.get_state()).__original @@ -35,9 +36,21 @@ local function main(key, state, co) if key.name == "find/find" then text = "Find: enter search string" else text = "Find: enter advanced search string" end - local query, error = coroutine.yield( - input.get_user_input( fb.coroutine.callback(), { text = text, id = "find", replace = true } ) - ) + local query, error = nil, nil + if input_loaded then + query = coroutine.yield( + input.get({ + prompt = text .. "\n>", + id = "find", + submit = fb.coroutine.callback(), + }) + ) + input.terminate() + elseif user_input_loaded then + query, error = coroutine.yield( + user_input.get_user_input( fb.coroutine.callback(), { text = text, id = "find", replace = true } ) + ) + end if not query then return msg.debug(error) end diff --git a/main.lua b/main.lua index 38a6656..6080a88 100644 --- a/main.lua +++ b/main.lua @@ -20,7 +20,9 @@ local script_messages = require 'modules.script-messages' -- setting the package paths package.path = mp.command_native({"expand-path", o.module_directory}).."/?.lua;"..package.path -local user_input_loaded, input = pcall(require, "user-input-module") +local input_loaded, input = pcall(require, "mp.input") +local user_input_loaded, user_input = pcall(require, "user-input-module") + -- root and addon setup setup.root() @@ -51,8 +53,18 @@ mp.register_script_message("get-directory-contents", script_messages.get_directo mp.add_key_binding('MENU','browse-files', controls.toggle) mp.add_key_binding('Ctrl+o','open-browser', controls.open) -if user_input_loaded then +if input_loaded then + mp.add_key_binding("Alt+o", "browse-directory/get-user-input", function() + input.get({ + prompt = "open directory:", + submit = function(text) + controls.browse_directory(text) + input.terminate() + end + }) + end) +elseif user_input_loaded then mp.add_key_binding("Alt+o", "browse-directory/get-user-input", function() - input.get_user_input(controls.browse_directory, {request_text = "open directory:"}) + user_input.get_user_input(controls.browse_directory, {request_text = "open directory:"}) end) end