diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/textadept/keys.lua | 5 | ||||
-rw-r--r-- | modules/textadept/macros.lua | 34 | ||||
-rw-r--r-- | modules/textadept/menu.lua | 4 |
3 files changed, 18 insertions, 25 deletions
diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua index e2968ab6..d3cc7350 100644 --- a/modules/textadept/keys.lua +++ b/modules/textadept/keys.lua @@ -398,9 +398,8 @@ keys.f2 = m_bookmark[_L['_Next Bookmark']][2] keys[GUI and 'sf2' or 'f3'] = m_bookmark[_L['_Previous Bookmark']][2] keys[GUI and 'af2' or 'f4'] = textadept.bookmarks.goto_mark -- Macros. -keys.f9 = textadept.macros.start_recording -keys[GUI and 'sf9' or 'f10'] = textadept.macros.stop_recording -keys[GUI and 'af9' or 'f12'] = textadept.macros.play +keys.f9 = textadept.macros.record +keys[GUI and 'sf9' or 'f10'] = textadept.macros.play -- Quick Open. local m_quick_open = m_tools[_L['Quick _Open']] keys[not OSX and 'cu' or 'mu'] = m_quick_open[_L['Quickly Open _User Home']][2] diff --git a/modules/textadept/macros.lua b/modules/textadept/macros.lua index 2d44c54a..476a6b44 100644 --- a/modules/textadept/macros.lua +++ b/modules/textadept/macros.lua @@ -15,10 +15,12 @@ local recording, macro -- ultimately executed will be recorded in some form. local ignore events.connect(events.INITIALIZED, function() + local m_tools = textadept.menu.menubar[_L['_Tools']] ignore = { textadept.menu.menubar[_L['_Search']][_L['_Find']][2], ui.find.find_incremental, - textadept.menu.menubar[_L['_Tools']][_L['Select Co_mmand']][2], + m_tools[_L['Select Co_mmand']][2], + m_tools[_L['_Macros']][_L['Start/Stop _Recording']][2] } end) @@ -47,24 +49,18 @@ local event_recorders = { } --- --- Begins recording a macro. --- @name start_recording -function M.start_recording() - if recording then return end - macro = {} - for event, f in pairs(event_recorders) do events.connect(event, f, 1) end - recording = true - ui.statusbar_text = _L['Macro recording'] -end - ---- --- Stops recording a macro. --- @name stop_recording -function M.stop_recording() - if not recording then return end - for event, f in pairs(event_recorders) do events.disconnect(event, f) end - recording = false - ui.statusbar_text = _L['Macro stopped recording'] +-- Toggles between starting and stopping macro recording. +-- @name record +function M.record() + if not recording then + macro = {} + for event, f in pairs(event_recorders) do events.connect(event, f, 1) end + ui.statusbar_text = _L['Macro recording'] + else + for event, f in pairs(event_recorders) do events.disconnect(event, f) end + ui.statusbar_text = _L['Macro stopped recording'] + end + recording = not recording end --- diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua index 9b4cb9a4..059af354 100644 --- a/modules/textadept/menu.lua +++ b/modules/textadept/menu.lua @@ -216,9 +216,7 @@ local default_menubar = { }, { title = _L['_Macros'], - {_L['_Start Recording'], textadept.macros.start_recording}, - {_L['Sto_p Recording'], textadept.macros.stop_recording}, - SEPARATOR, + {_L['Start/Stop _Recording'], textadept.macros.record}, {_L['_Play'], textadept.macros.play}, SEPARATOR, {_L['Sa_ve...'], textadept.macros.save}, |