diff --git a/content/commands.js b/content/commands.js index f47a8445..69578f88 100644 --- a/content/commands.js +++ b/content/commands.js @@ -1439,6 +1439,24 @@ vimperator.Commands = function () //{{{ completer: function (filter) { return vimperator.completion.autocommands(filter); } } )); + commandManager.add(new vimperator.Command(["mac[ros]"], + function (arg) + { + var str = ""; + var macroRef = vimperator.events.getMacros(arg); + for (var item in macroRef) + str += ""; + + str += "
\"" + item + "   " + + vimperator.util.escapeHTML(macroRef[item]) + "
"; + + vimperator.echo(str, vimperator.commandline.FORCE_MULTILINE); + }, + { + shortHelp: "List macros matching the argument; or all macros if no argument is given." + } + )); + // 0 args -> list all maps // 1 arg -> list the maps starting with args // 2 args -> map arg1 to arg* diff --git a/content/completion.js b/content/completion.js index 60f4ef63..cc1d7edc 100644 --- a/content/completion.js +++ b/content/completion.js @@ -133,6 +133,8 @@ vimperator.Completion = function () //{{{ { substrings = []; var nodes = [ + ["BrowserExit", "when firefox exits"], + ["BrowserRestart", "when firefox restarts"], ["PageLoad", "when a page gets (re)loaded/opened"] ]; diff --git a/content/events.js b/content/events.js index d3f34951..a0588ba7 100644 --- a/content/events.js +++ b/content/events.js @@ -539,6 +539,17 @@ vimperator.Events = function () //{{{ vimperator.echoerr("Register " + lastMacro + " not set"); }, + getMacros: function (filter) + { + var mfiltered = {}; + for (var item in macros) + { + if (filter == null || item.indexOf(filter) != -1) + mfiltered[item] = macros[item]; + } + return mfiltered; //XXX: returns a real copy, since this is only a 'var ..'? + }, + // This method pushes keys into the event queue from vimperator // it is similar to vim's feedkeys() method, but cannot cope with // 2 partially feeded strings, you have to feed one parsable string diff --git a/content/vimperator.js b/content/vimperator.js index c05d24f3..775b7d61 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -374,6 +374,8 @@ const vimperator = (function () //{{{ // quit vimperator, no matter how many tabs/windows are open quit: function (saveSession) { + vimperator.autocommands.trigger("BrowserExit", ""); + if (saveSession) vimperator.options.setFirefoxPref("browser.startup.page", 3); // start with saved session else @@ -384,6 +386,8 @@ const vimperator = (function () //{{{ restart: function () { + vimperator.autocommands.trigger("BrowserRestart", ""); + const nsIAppStartup = Components.interfaces.nsIAppStartup; // notify all windows that an application quit has been requested.