aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/events.lua8
-rw-r--r--core/ext/key_commands.lua2
-rw-r--r--core/ext/menu.lua13
-rw-r--r--core/ext/pm/macro_browser.lua47
-rw-r--r--core/locale.conf48
-rw-r--r--init.lua1
-rw-r--r--modules/textadept/init.lua1
-rw-r--r--modules/textadept/macros.lua203
-rw-r--r--src/lua_interface.c21
9 files changed, 2 insertions, 342 deletions
diff --git a/core/events.lua b/core/events.lua
index 9deb4b86..ab664f87 100644
--- a/core/events.lua
+++ b/core/events.lua
@@ -32,10 +32,6 @@ module('textadept.events', package.seeall)
-- position: the position of the beginning of the line clicked.
-- line: the line clicked.
-- update_ui()
--- macro_record(message, wParam, lParam)
--- message: the SCI_* message.
--- wParam: wParam in SCI_*.
--- lParam: lParam in SCI_*.
-- margin_click(margin, modifiers, position)
-- margin: the margin number.
-- modifiers: mouse modifiers.
@@ -121,9 +117,6 @@ end
function update_ui()
return handle('update_ui')
end
-function macro_record(n)
- return handle('macro_record', n.message, n.wParam, n.lParam)
-end
function margin_click(n)
return handle('margin_click', n.margin, n.modifiers, n.position)
end
@@ -148,7 +141,6 @@ local scnnotifications = {
[c.SCN_SAVEPOINTLEFT] = save_point_left,
[c.SCN_DOUBLECLICK] = double_click,
[c.SCN_UPDATEUI] = update_ui,
- [c.SCN_MACRORECORD] = macro_record,
[c.SCN_MARGINCLICK] = margin_click,
[c.SCN_USERLISTSELECTION] = user_list_selection,
[c.SCN_URIDROPPED] = uri_dropped,
diff --git a/core/ext/key_commands.lua b/core/ext/key_commands.lua
index 4a40ea5a..9f449679 100644
--- a/core/ext/key_commands.lua
+++ b/core/ext/key_commands.lua
@@ -173,7 +173,6 @@ if not MAC then
c = { pm_activate, 'ctags' },
b = { pm_activate, 'buffers' },
f = { pm_activate, '/' },
- -- TODO: { pm_activate, 'macros' }
m = { pm_activate, 'modules' },
}
@@ -361,7 +360,6 @@ else
c = { pm_activate, 'ctags' },
b = { pm_activate, 'buffers' },
f = { pm_activate, '/' },
- -- TODO: { pm_activate, 'macros' }
m = { pm_activate, 'modules' },
}
diff --git a/core/ext/menu.lua b/core/ext/menu.lua
index 963967ab..81e9f473 100644
--- a/core/ext/menu.lua
+++ b/core/ext/menu.lua
@@ -97,9 +97,6 @@ local ID = {
CLEAR_BOOKMARKS = 417,
GOTO_NEXT_BOOKMARK = 418,
GOTO_PREV_BOOKMARK = 419,
- START_RECORDING_MACRO = 413,
- STOP_RECORDING_MACRO = 414,
- PLAY_MACRO = 415,
-- Buffer
NEXT_BUFFER = 501,
PREV_BUFFER = 502,
@@ -244,11 +241,6 @@ local menubar = {
{ l.MENU_TOOLS_BM_NEXT, ID.GOTO_NEXT_BOOKMARK },
{ l.MENU_TOOLS_BM_PREV, ID.GOTO_PREV_BOOKMARK },
},
- { title = l.MENU_TOOLS_MACROS_TITLE,
- { l.MENU_TOOLS_MACROS_START, ID.START_RECORDING_MACRO },
- { l.MENU_TOOLS_MACROS_STOP, ID.STOP_RECORDING_MACRO },
- { l.MENU_TOOLS_MACROS_PLAY, ID.PLAY_MACRO },
- },
},
gtkmenu {
title = l.MENU_BUF_TITLE,
@@ -306,7 +298,6 @@ local m_snippets = _m.textadept.lsnippets
local m_editing = _m.textadept.editing
local m_mlines = _m.textadept.mlines
local m_bookmarks = _m.textadept.bookmarks
-local m_macros = _m.textadept.macros
local m_run = _m.textadept.run
local function set_encoding(encoding)
@@ -428,10 +419,6 @@ local actions = {
[ID.CLEAR_BOOKMARKS] = { m_bookmarks.clear },
[ID.GOTO_NEXT_BOOKMARK] = { m_bookmarks.goto_next },
[ID.GOTO_PREV_BOOKMARK] = { m_bookmarks.goto_prev },
- -- Tools -> Macros
- [ID.START_RECORDING_MACRO] = { m_macros.start_recording },
- [ID.STOP_RECORDING_MACRO] = { m_macros.stop_recording },
- [ID.PLAY_MACRO] = { m_macros.play },
-- Buffer
[ID.NEXT_BUFFER] = { 'goto_buffer', v, 1, false },
[ID.PREV_BUFFER] = { 'goto_buffer', v, -1, false },
diff --git a/core/ext/pm/macro_browser.lua b/core/ext/pm/macro_browser.lua
deleted file mode 100644
index d7cde6bd..00000000
--- a/core/ext/pm/macro_browser.lua
+++ /dev/null
@@ -1,47 +0,0 @@
--- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
-
-local textadept = _G.textadept
-local locale = _G.locale
-
----
--- 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)
-
-if not RESETTING then textadept.pm.add_browser('macros') end
-
-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
-
-local ID = { DELETE = 1 }
-
-function get_context_menu(selected_item)
- return { { locale.PM_BROWSER_MACRO_DELETE, ID.DELETE } }
-end
-
-function perform_menu_action(menu_id, selected_item)
- local m_macros = _m.textadept.macros
- if menu_id == ID.DELETE then
- m_macros.delete(selected_item[2])
- end
- textadept.pm.activate()
-end
-
-local function update_view()
- if matches(textadept.pm.entry_text) then textadept.pm.activate() end
-end
-textadept.events.add_handler('macro_saved', update_view)
-textadept.events.add_handler('macro_deleted', update_view)
diff --git a/core/locale.conf b/core/locale.conf
index 4004e4ff..5edabdaa 100644
--- a/core/locale.conf
+++ b/core/locale.conf
@@ -512,22 +512,6 @@ MENU_TOOLS_BM_NEXT "_Next"
MENU_TOOLS_BM_PREV "_Previous"
% core/ext/menu.lua
-% "M_acros"
-MENU_TOOLS_MACROS_TITLE "M_acros"
-
-% core/ext/menu.lua
-% "_Start Recording"
-MENU_TOOLS_MACROS_START "_Start Recording"
-
-% core/ext/menu.lua
-% "S_top Recording"
-MENU_TOOLS_MACROS_STOP "S_top Recording"
-
-% core/ext/menu.lua
-% "_Play Macro"
-MENU_TOOLS_MACROS_PLAY "_Play Macro"
-
-% core/ext/menu.lua
% "_Buffer"
MENU_BUF_TITLE "_Buffer"
@@ -703,10 +687,6 @@ PM_BROWSER_FILE_INFO_OK "OK"
% "Show Dot Files"
PM_BROWSER_FILE_SHOW_DOT_FILES "Show _Dot Files"
-% core/ext/pm/macro_browser.lua
-% "_Delete"
-PM_BROWSER_MACRO_DELETE "_Delete"
-
% core/ext/pm/modules_browser.lua
% "_New Module"
PM_BROWSER_MODULE_NEW "_New Module"
@@ -767,34 +747,6 @@ M_TEXTADEPT_EDITING_GOTO_TITLE "Go To"
% "Line Number:"
M_TEXTADEPT_EDITING_GOTO_TEXT "Line Number:"
-% modules/textadept/macros.lua
-% "Macro recording"
-M_TEXTADEPT_MACRO_RECORDING "Macro recording"
-
-% modules/textadept/macros.lua
-% "Macro name?"
-M_TEXTADEPT_MACRO_SAVE_TITLE "Macro name?"
-
-% modules/textadept/macros.lua
-% "Macro name"
-M_TEXTADEPT_MACRO_SAVE_TEXT "Macro name"
-
-% modules/textadept/macros.lua
-% "Macro saved"
-M_TEXTADEPT_MACRO_SAVED "Macro saved"
-
-% modules/textadept/macros.lua
-% "Macro not saved"
-M_TEXTADEPT_MACRO_NOT_SAVED "Macro not saved"
-
-% modules/textadept/macros.lua
-% "Select a Macro"
-M_TEXTADEPT_MACRO_SELECT_TITLE "Select a Macro"
-
-% modules/textadept/macros.lua
-% "Macro name:"
-M_TEXTADEPT_MACRO_SELECT_TEXT "Macro name:"
-
% modules/textadept/run.lua
% "The file "%s" does not exist."
M_TEXTADEPT_RUN_FILE_DOES_NOT_EXIST "The file "%s" does not exist."
diff --git a/init.lua b/init.lua
index aafdb41a..8c99b41b 100644
--- a/init.lua
+++ b/init.lua
@@ -25,7 +25,6 @@ require 'ext/pm' -- provides the dynamic browser (side pane) functionality
require 'ext/pm.buffer_browser' -- buffer browser
require 'ext/pm.file_browser' -- file browser
require 'ext/pm.modules_browser' -- modules browser
-require 'ext/pm.macro_browser' -- macro browser
if not WIN32 then
require 'ext/pm.ctags_browser' -- ctags browser
end
diff --git a/modules/textadept/init.lua b/modules/textadept/init.lua
index 4a4b279a..535f0089 100644
--- a/modules/textadept/init.lua
+++ b/modules/textadept/init.lua
@@ -8,6 +8,5 @@ module('_m.textadept', package.seeall)
require 'textadept.bookmarks'
require 'textadept.editing'
require 'textadept.lsnippets'
-require 'textadept.macros'
require 'textadept.mlines'
require 'textadept.run'
diff --git a/modules/textadept/macros.lua b/modules/textadept/macros.lua
deleted file mode 100644
index f45e1fa2..00000000
--- a/modules/textadept/macros.lua
+++ /dev/null
@@ -1,203 +0,0 @@
--- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
-
-local textadept = _G.textadept
-local locale = _G.locale
-
----
--- Support for recording, saving, and playing macros for the textadept module.
---
--- Events:
--- macro_saved()
--- macro_deleted()
-module('_m.textadept.macros', package.seeall)
-
-local MACRO_FILE = _HOME..'/saved_macros'
-
----
--- The list of available macros.
--- Each key is the macro name, and the value is a numerically indexed table of
--- commands. Each command is a table with a structure as follows:
--- { command, wParam, lParam }
--- where command is the buffer function and wParam and lParam are the arguments
--- for it.
--- @class table
--- @name list
-list = {}
-
----
--- [Local table] The currently recording macro.
--- It is a numerically indexed table of commands with each command having the
--- same structure as described in list.
--- @class table
--- @name current
--- @see list
-local current = {}
-
-local recording = false
-
----
--- [Local function] Handles a Scintilla macro notification.
--- If a macro is being recorded, add this command to 'current'.
--- @param msg The Scintilla message ID.
-local function macro_notification(msg, wParam, lParam)
- if recording then
- current[#current + 1] = { msg, wParam or 0, lParam or 0 }
- textadept.statusbar_text = locale.M_TEXTADEPT_MACRO_RECORDING
- end
-end
-textadept.events.add_handler('macro_record', macro_notification)
-
----
--- Starts recording a macro.
-function start_recording()
- if recording then return end
- buffer:start_record()
- current = {}
- recording = true
- textadept.statusbar_text = 'Macro recording'
-end
-
----
--- Stops recording a macro.
--- Each command's msg in the recorded macro is changed to the name of the
--- message Then the user is prompted for a macro name and the macro is saved to
--- the current macro list and macro file.
-function stop_recording()
- if not recording then return end
- buffer:stop_record()
- recording = false
- local ret, macro_name =
- cocoa_dialog('standard-inputbox', {
- ['informative-text'] = locale.M_TEXTADEPT_MACRO_SAVE_TITLE,
- text = locale.M_TEXTADEPT_MACRO_SAVE_TEXT,
- ['no-newline'] = true
- }):match('^(%d)\n([^\n]+)$')
-
- if ret == '1' and macro_name and #macro_name > 0 then
- for _, command in ipairs(current) do
- local msg = command[1]
- for f, t in pairs(textadept.buffer_functions) do
- if t[1] == msg then command[1] = f break end
- end
- end
- list[macro_name] = current
- save()
- textadept.statusbar_text = locale.M_TEXTADEPT_MACRO_SAVED
- textadept.events.handle('macro_saved')
- else
- textadept.statusbar_text = locale.M_TEXTADEPT_MACRO_NOT_SAVED
- end
-end
-
----
--- Toggles between recording a macro and not recording one.
-function toggle_record()
- (not recording and start_recording or stop_recording)()
-end
-
----
--- Plays a specified macro.
--- @param macro_name The name of the macro to play. If none specified, the user
--- is prompted to choose one from a list of available macros.
-function play(macro_name)
- if not macro_name then
- local macros = {}
- for name, _ in pairs(list) do macros[#macros + 1] = name end
- if #macros > 0 then
- local ret
- ret, macro_name =
- cocoa_dialog('standard-dropdown', {
- title = locale.M_TEXTADEPT_MACRO_SELECT_TITLE,
- text = locale.M_TEXTADEPT_MACRO_SELECT_TEXT,
- items = '"'..table.concat(macros, '" "')..'"',
- ['string-output'] = true,
- ['no-newline'] = true
- }):match('^([^\n]+)\n([^\n]+)$')
- if ret == 'Cancel' then return end
- end
- end
- local macro = list[macro_name]
- if not macro then return end
- local buffer = buffer
- local bf = textadept.buffer_functions
- for _, command in ipairs(macro) do
- local cmd, wParam, lParam = unpack(command)
- local _, _, p1_type, p2_type = unpack(bf[cmd])
- if p2_type == 7 and p1_type == 0 or p1_type == 2 then -- single string param
- buffer[cmd](buffer, lParam)
- else
- buffer[cmd](buffer, wParam, lParam)
- end
- end
-end
-
----
--- Deletes a specified macro.
--- @param macro_name The name of the macro to delete.
-function delete(macro_name)
- if list[macro_name] then
- list[macro_name] = nil
- save()
- textadept.events.handle('macro_deleted')
- end
-end
-
----
--- Saves the current list of macros to a specified file.
--- @param filename The absolute path to the file to save the macros to.
-function save(filename)
- if not filename then filename = MACRO_FILE end
- local f = assert(io.open(filename, 'wb'))
- for name, macro in pairs(list) do
- f:write(name, '\n')
- for _, command in ipairs(macro) do
- local msg, wParam, lParam = unpack(command)
- if type(lParam) == 'string' then
- lParam =
- lParam:gsub('[\t\n\r\f]',
- { ['\t'] = '\\t', ['\n'] = '\\n', ['\r'] = '\\r',
- ['\f'] = '\\f' })
- end
- f:write(("%s\t%s\t%s\n"):format(msg, wParam, lParam))
- end
- f:write('\n')
- end
- f:close()
-end
-
----
--- Loads macros from a specified file.
--- @param filename The absolute path to the file to load the macros from.
-function load(filename)
- if not filename then filename = MACRO_FILE end
- local f = io.open(filename, 'rb')
- if not f then return end
- local name, current_macro
- for line in f:lines() do
- if not name then -- new macro
- name = line
- current_macro = {}
- else
- if line == '' then -- finished; save current macro
- list[name] = current_macro
- name = nil
- else
- local cmd, wParam, lParam = line:match('^([^\t]+)\t([^\t]+)\t(.*)$')
- if cmd and wParam and lParam then
- lParam =
- lParam:gsub('\\[tnrf]',
- { ['\\t'] = '\t', ['\\n'] = '\n', ['\\r'] = '\r',
- ['\\f'] = '\f' })
- local num = wParam:match('^-?%d+$')
- if num then wParam = tonumber(num) end
- num = lParam:match('^-?%d+$')
- if num then lParam = tonumber(num) end
- local command = { cmd, wParam, lParam }
- current_macro[#current_macro + 1] = command
- end
- end
- end
- end
-end
-
-load() -- load saved macros on startup
diff --git a/src/lua_interface.c b/src/lua_interface.c
index 3a7e5e38..180ad60d 100644
--- a/src/lua_interface.c
+++ b/src/lua_interface.c
@@ -726,25 +726,8 @@ void l_handle_scnnotification(SCNotification *n) {
l_pushscninteger(n->length, "length");
l_pushscninteger(n->linesAdded, "lines_added");
l_pushscninteger(n->message, "message");
- if (n->nmhdr.code == SCN_MACRORECORD) {
- lua_getfield(lua, LUA_REGISTRYINDEX, "buffer_functions");
- lua_pushnil(lua);
- while (lua_next(lua, -2))
- if (l_rawgeti_int(lua, -1, 1) == n->message) {
- if (l_rawgeti_int(lua, -1, 3) == tSTRING) {
- l_pushscnstring(reinterpret_cast<char*>(n->wParam), "wParam");
- } else l_pushscninteger(static_cast<int>(n->wParam), "wParam");
- if (l_rawgeti_int(lua, -1, 4) == tSTRING) {
- l_pushscnstring(reinterpret_cast<char*>(n->lParam), "lParam");
- } else l_pushscninteger(static_cast<int>(n->lParam), "lParam");
- lua_pop(lua, 2); // key and value
- break;
- } else lua_pop(lua, 1); // value
- lua_pop(lua, 1); // ta_buffer_functions
- } else {
- l_pushscninteger(static_cast<int>(n->wParam), "wParam");
- l_pushscninteger(static_cast<int>(n->lParam), "lParam");
- }
+ l_pushscninteger(static_cast<int>(n->wParam), "wParam");
+ l_pushscninteger(static_cast<int>(n->lParam), "lParam");
l_pushscninteger(n->line, "line");
l_pushscninteger(n->foldLevelNow, "fold_level_now");
l_pushscninteger(n->foldLevelPrev, "fold_level_prev");