diff options
author | 2009-07-08 19:14:33 -0400 | |
---|---|---|
committer | 2009-07-08 19:14:33 -0400 | |
commit | 9827462bc8ac4ecc6009f2285c2397bf6ff64777 (patch) | |
tree | cc2d9b16d23a904d1107b111bf19f39ced993db1 /core/ext/pm.lua | |
parent | bfef6fc70792fe002df7f8c0bfc82749fcd08152 (diff) | |
download | textadept-9827462bc8ac4ecc6009f2285c2397bf6ff64777.tar.gz textadept-9827462bc8ac4ecc6009f2285c2397bf6ff64777.zip |
Extended the event system to include project manager, find, command entry, etc.
Diffstat (limited to 'core/ext/pm.lua')
-rw-r--r-- | core/ext/pm.lua | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/core/ext/pm.lua b/core/ext/pm.lua index 67cbbbfb..8838582c 100644 --- a/core/ext/pm.lua +++ b/core/ext/pm.lua @@ -8,37 +8,36 @@ local current_browser = nil local last_browser_text = nil local browser_cursors = {} --- LuaDoc is in core/.browser.lua. -function pm.get_contents_for(full_path, expanding) - for _, browser in pairs(pm.browsers) do - if browser.matches(full_path[1]) then - current_browser = browser - if last_browser_text and last_browser_text ~= pm.entry_text then - -- Switching browsers, save the current one's cursor. - -- Don't reset last_browser_text here though, we still need to detect - -- the switch when the 'pm_view_filled' event is called so as to restore - -- the cursor to the new browser. - browser_cursors[last_browser_text] = pm.cursor +textadept.events.add_handler('pm_contents_request', + function(full_path, expanding) + for _, browser in pairs(pm.browsers) do + if browser.matches(full_path[1]) then + current_browser = browser + if last_browser_text and last_browser_text ~= pm.entry_text then + -- Switching browsers, save the current one's cursor. + -- Don't reset last_browser_text here though, we still need to detect + -- the switch when the 'pm_view_filled' event is called so as to restore + -- the cursor to the new browser. + browser_cursors[last_browser_text] = pm.cursor + end + pm.fill(browser.get_contents_for(full_path, expanding), expanding) + textadept.events.handle('pm_view_filled') end - return browser.get_contents_for(full_path, expanding) end - end -end + end) --- LuaDoc is in core/.browser.lua. -function pm.perform_action(selected_item) - current_browser.perform_action(selected_item) -end +textadept.events.add_handler('pm_item_selected', + function(selected_item) current_browser.perform_action(selected_item) end) --- LuaDoc is in core/.browser.lua. -function pm.get_context_menu(selected_item) - return current_browser.get_context_menu(selected_item) -end +textadept.events.add_handler('pm_context_menu_request', + function(selected_item, event) + pm.show_context_menu(current_browser.get_context_menu(selected_item), event) + end) --- LuaDoc is in core/.browser.lua. -function pm.perform_menu_action(menu_id, selected_item) - current_browser.perform_menu_action(menu_id, selected_item) -end +textadept.events.add_handler('pm_menu_clicked', + function(menu_id, selected_item) + current_browser.perform_menu_action(menu_id, selected_item) + end) -- LuaDoc is in core/.browser.lua. function pm.toggle_visible() @@ -51,7 +50,7 @@ function pm.toggle_visible() end textadept.events.add_handler('pm_view_filled', - function() -- tries to restore the cursor for a previous browser + function() -- try to restore previous browser cursor if last_browser_text ~= pm.entry_text then last_browser_text = pm.entry_text local previous_cursor = browser_cursors[pm.entry_text] |