From 84a40c95280504d6ad2d95f84b205ec22f6b99c5 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Thu, 12 Feb 2009 22:42:10 -0500 Subject: Load dropped directories into the PM file browser; core/ext/pm/file_browser.lua --- core/ext/pm/file_browser.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'core') diff --git a/core/ext/pm/file_browser.lua b/core/ext/pm/file_browser.lua index 45c1db4c..17723c70 100644 --- a/core/ext/pm/file_browser.lua +++ b/core/ext/pm/file_browser.lua @@ -79,3 +79,21 @@ function perform_menu_action(menu_id, selected_item) }) end end + +-- load the dropped directory (if any) into the file browser; events.lua's +-- "uri_dropped" handler already opens dropped files +textadept.events.add_handler('uri_dropped', + function(uris) + for uri in uris:gmatch('[^\r\n\f]+') do + if uri:find('^file://') then + uri = uri:match('^file://([^\r\n\f]+)') + uri = uri:gsub('%%20', ' ') -- sub back for spaces + if WIN32 then uri = uri:sub(2, -1) end -- ignore leading '/' + if lfs.attributes(uri).mode == 'directory' then + textadept.pm.entry_text = uri + textadept.pm.activate() + return + end + end + end + end) -- cgit v1.2.3