[Vimperator] autocommands and :macros
calmar
mac at calmar.ws
Sat Jan 19 17:53:03 PST 2008
Needs your review Martin :)
e.g. listMacro does not sound 'thaaat' good, since it just returns
a reference to macros...
etc..
(alternatively: http://www.calmar.ws/tmp/dd.diff )
Cheers
marco
just in case, the plugin i'm going to use:
http://www.calmar.ws/tmp/macro_dump.js
--
(o_ It rocks: LINUX + Command-Line-Interface
//\
V_/_ http://www.calmar.ws
-------------- next part --------------
? dd.diff
Index: commands.js
===================================================================
RCS file: /cvs/vimperator/src/content/commands.js,v
retrieving revision 1.110
diff -u -r1.110 commands.js
--- commands.js 15 Jan 2008 15:53:48 -0000 1.110
+++ commands.js 20 Jan 2008 01:48:33 -0000
@@ -1439,6 +1439,24 @@
completer: function (filter) { return vimperator.completion.autocommands(filter); }
}
));
+ commandManager.add(new vimperator.Command(["mac[ros]"],
+ function ()
+ {
+ var str = "<table>";
+ var macroRef = vimperator.events.listMacro();
+ for (var item in macroRef)
+ str += "<tr><td>\"" + item + " </td><td>" +
+ vimperator.util.escapeHTML(macroRef[item]) + "</td></tr>";
+
+ str += "</table>";
+
+ vimperator.echo(str, vimperator.commandline.FORCE_MULTILINE);
+ },
+ {
+ shortHelp: "List all macros"
+ }
+ ));
+
// 0 args -> list all maps
// 1 arg -> list the maps starting with args
// 2 args -> map arg1 to arg*
Index: completion.js
===================================================================
RCS file: /cvs/vimperator/src/content/completion.js,v
retrieving revision 1.41
diff -u -r1.41 completion.js
--- completion.js 14 Jan 2008 15:50:02 -0000 1.41
+++ completion.js 20 Jan 2008 01:48:34 -0000
@@ -133,6 +133,8 @@
{
substrings = [];
var nodes = [
+ ["BrowserExit", "when firefox exits"],
+ ["BrowserReload", "when firefox restarts"],
["PageLoad", "when a page gets (re)loaded/opened"]
];
Index: events.js
===================================================================
RCS file: /cvs/vimperator/src/content/events.js,v
retrieving revision 1.56
diff -u -r1.56 events.js
--- events.js 19 Jan 2008 12:53:59 -0000 1.56
+++ events.js 20 Jan 2008 01:48:35 -0000
@@ -539,6 +539,11 @@
vimperator.echoerr("Register " + lastMacro + " not set");
},
+ listMacro: function ()
+ {
+ return macros;
+ },
+
// 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
Index: vimperator.js
===================================================================
RCS file: /cvs/vimperator/src/content/vimperator.js,v
retrieving revision 1.55
diff -u -r1.55 vimperator.js
--- vimperator.js 5 Jan 2008 23:31:07 -0000 1.55
+++ vimperator.js 20 Jan 2008 01:48:36 -0000
@@ -374,6 +374,8 @@
// 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 @@
restart: function ()
{
+ vimperator.autocommands.trigger("BrowserRestart", "");
+
const nsIAppStartup = Components.interfaces.nsIAppStartup;
// notify all windows that an application quit has been requested.
More information about the Vimperator
mailing list