1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 01:47:58 +01:00

Add PrivateMode autocommand. Add -js flag to :au

This commit is contained in:
Kris Maglione
2009-06-28 15:14:23 -04:00
parent 7c7710b23d
commit c4e9e414be
5 changed files with 24 additions and 12 deletions

View File

@@ -87,6 +87,8 @@ function AutoCommands() //{{{
{
if (args.bang)
autocommands.remove(event, regex);
if (args["-javascript"])
cmd = eval("(function(args) { with(args) {" + cmd + "} })");
autocommands.add(events, regex, cmd);
}
else
@@ -107,7 +109,8 @@ function AutoCommands() //{{{
{
bang: true,
completer: function (context) completion.autocmdEvent(context),
literal: 2
literal: 2,
options: [[["-javascript", "-js"], commands.OPTION_NOARG]]
});
// TODO: expand target to all buffers

View File

@@ -13,7 +13,9 @@
{ arg: true, count: true, motion: true, route: true });
* IMPORTANT: shifted key notation now matches Vim's behaviour. E.g. <C-a>
and <C-A> are equivalent, to map the uppercase character use <C-S-A>. - Is this still true, or going to be true? --djk
* add 'private' - enter private browsing mode
* add '-javascript' flag to :autocommand
* add 'private' - enter private browsing mode, matching 'PrivateMode'
autocommand
* add -description option to :command
* command-line options are now supported via the host application's
-liberator option

View File

@@ -55,6 +55,7 @@ const config = { //{{{
["LocationChange", "Triggered when changing tabs or when navigation to a new location"],
["PageLoadPre", "Triggered after a page load is initiated"],
["PageLoad", "Triggered when a page gets (re)loaded/opened"],
["PrivateMode", "Triggered private mode is activated or deactivated"],
["ShellCmdPost", "Triggered after executing a shell command with :!cmd"],
["VimperatorEnter", "Triggered after Firefox starts"],
["VimperatorLeavePre", "Triggered before exiting Firefox, just before destroying each module"],
@@ -485,17 +486,11 @@ const config = { //{{{
"Set the 'private browsing' option",
"boolean", false,
{
setter: function (value)
{
return services.get("privateBrowsing").privateBrowsingEnabled = value;
},
getter: function ()
{
return services.get("privateBrowsing").privateBrowsingEnabled;
}
setter: function (value) services.get("privateBrowsing").privateBrowsingEnabled = value,
getter: function () services.get("privateBrowsing").privateBrowsingEnabled,
});
let services = modules.services; // Storage objects are global to all windows, 'modules' isn't.
storage.newObject("private-mode-observer", function () {
storage.newObject("private-mode", function () {
({
init: function () {
services.get("observer").addObserver(this, "private-browsing", false);
@@ -508,6 +503,7 @@ const config = { //{{{
storage.privateMode = true;
else if (data == "exit")
storage.privateMode = false;
storage.fireEvent("private-mode", "change", storage.privateMode);
} else if (topic == "quit-application") {
services.get("observer").removeObserver(this, "quit-application");
services.get("observer").removeObserver(this, "private-browsing");
@@ -515,6 +511,10 @@ const config = { //{{{
},
}).init();
}, false);
storage.addObserver("private-mode",
function (key, event, value) {
autocommands.trigger("PrivateMode", { state: value });
}, window);
}
// TODO: merge with Vimperator version and add Muttator version

View File

@@ -10,6 +10,9 @@ Execute commands automatically on events.
[c]:au[tocmd][c] {event} {pat} {cmd}
If the *-javascript* (short name *-js*) option is specified, {cmd} is executed
as JavaScript code, with any supplied arguments available as variables.
Add {cmd} to the list of commands Vimperator will execute on {event} for a URL matching {pat}:
* [c]:autocmd[!][c] {events} {pat}: list/remove autocommands filtered by {events} and {pat}
@@ -28,6 +31,7 @@ Available {events}:
*LocationChange* Triggered when changing tabs or when navigating to a new location
*PageLoadPre* Triggered after a page load is initiated
*PageLoad* Triggered when a page gets (re)loaded/opened
*PrivateMode* Triggered private mode is activated or deactivated
*ShellCmdPost* Triggered after executing a shell command with [c]:![c]#{cmd}
*VimperatorEnter* Triggered after Firefox starts
*VimperatorLeavePre* Triggered before exiting Firefox, just before destroying each module
@@ -49,7 +53,7 @@ The following keywords are available where relevant:
*<icon>* The icon associated with <url>. Only for *BookmarkAdd*.
*<size>* The size of a downloaded file. Only for *DownloadPost*.
*<file>* The target destination of a download. Only for *DownloadPost*.
*<state>* The new fullscreen state. Only for *Fullscreen*.
*<state>* The new state. Only for *Fullscreen* and *PrivateMode*.
*<name>* The color scheme name. Only for *ColorScheme*.
--------------------------------------------------------------

View File

@@ -12,6 +12,9 @@ Execute commands automatically on events.
Add {cmd} to the list of commands Xulmus will execute on {event} for a URL matching {pat}:
If the *-javascript* (short name *-js*) option is specified, {cmd} is executed
as JavaScript code, with any supplied arguments available as variables.
* [c]:autocmd[!][c] {events} {pat}: list/remove autocommands filtered by {events} and {pat}
* [c]:autocmd[!][c] {events}: list/remove autocommands matching {events}
* [c]:autocmd[!][c] * {pat}: list/remove autocommands matching {pat}