aboutsummaryrefslogtreecommitdiff
path: root/core/ext/pm
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2007-08-10 17:12:50 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2007-08-10 17:12:50 -0400
commit6362d808eab3b9a7adf591d306687b439ba85031 (patch)
tree3934c3e539d0bfd5902bb09e013bf7216b4bee2f /core/ext/pm
parent473c7c0973a3f0760efac0e54c68b420695baff9 (diff)
downloadtextadept-6362d808eab3b9a7adf591d306687b439ba85031.tar.gz
textadept-6362d808eab3b9a7adf591d306687b439ba85031.zip
Macros can now be recorded, saved, played, browsed, etc.
Diffstat (limited to 'core/ext/pm')
-rw-r--r--core/ext/pm/macro_browser.lua43
1 files changed, 43 insertions, 0 deletions
diff --git a/core/ext/pm/macro_browser.lua b/core/ext/pm/macro_browser.lua
new file mode 100644
index 00000000..237aa9fb
--- /dev/null
+++ b/core/ext/pm/macro_browser.lua
@@ -0,0 +1,43 @@
+-- Copyright 2007 Mitchell mitchell<att>caladbolg.net. See LICENSE.
+
+---
+-- Macro browser for the Textadept project manager.
+-- It is enabled with the prefix 'macros' in the project manager entry field.
+module('textadept.pm.browsers.macro', package.seeall)
+
+local textadept = textadept
+
+function matches(entry_text)
+ return entry_text:sub(1, 7) == 'macros'
+end
+
+function get_contents_for()
+ local m_macros = _m.textadept.macros
+ local contents = {}
+ for name in pairs(m_macros.list) do contents[name] = { text = name } end
+ return contents
+end
+
+function perform_action(selected_item)
+ _m.textadept.macros.play( selected_item[2] )
+ view:focus()
+end
+
+function get_context_menu(selected_item)
+ return { '_Delete' }
+end
+
+function perform_menu_action(menu_item, selected_item)
+ local m_macros = _m.textadept.macros
+ if menu_item == 'Delete' then
+ m_macros.delete( selected_item[2] )
+ end
+ textadept.pm.activate()
+end
+
+local add_function_to_handler = textadept.handlers.add_function_to_handler
+local function update_view()
+ if matches(textadept.pm.entry_text) then textadept.pm.activate() end
+end
+add_function_to_handler('macro_saved', update_view)
+add_function_to_handler('macro_deleted', update_view)