mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 09:17:59 +01:00
Add PrivateMode autocommand. Add -js flag to :au
This commit is contained in:
@@ -87,6 +87,8 @@ function AutoCommands() //{{{
|
|||||||
{
|
{
|
||||||
if (args.bang)
|
if (args.bang)
|
||||||
autocommands.remove(event, regex);
|
autocommands.remove(event, regex);
|
||||||
|
if (args["-javascript"])
|
||||||
|
cmd = eval("(function(args) { with(args) {" + cmd + "} })");
|
||||||
autocommands.add(events, regex, cmd);
|
autocommands.add(events, regex, cmd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -107,7 +109,8 @@ function AutoCommands() //{{{
|
|||||||
{
|
{
|
||||||
bang: true,
|
bang: true,
|
||||||
completer: function (context) completion.autocmdEvent(context),
|
completer: function (context) completion.autocmdEvent(context),
|
||||||
literal: 2
|
literal: 2,
|
||||||
|
options: [[["-javascript", "-js"], commands.OPTION_NOARG]]
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: expand target to all buffers
|
// TODO: expand target to all buffers
|
||||||
|
|||||||
@@ -13,7 +13,9 @@
|
|||||||
{ arg: true, count: true, motion: true, route: true });
|
{ arg: true, count: true, motion: true, route: true });
|
||||||
* IMPORTANT: shifted key notation now matches Vim's behaviour. E.g. <C-a>
|
* 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
|
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
|
* add -description option to :command
|
||||||
* command-line options are now supported via the host application's
|
* command-line options are now supported via the host application's
|
||||||
-liberator option
|
-liberator option
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ const config = { //{{{
|
|||||||
["LocationChange", "Triggered when changing tabs or when navigation to a new location"],
|
["LocationChange", "Triggered when changing tabs or when navigation to a new location"],
|
||||||
["PageLoadPre", "Triggered after a page load is initiated"],
|
["PageLoadPre", "Triggered after a page load is initiated"],
|
||||||
["PageLoad", "Triggered when a page gets (re)loaded/opened"],
|
["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"],
|
["ShellCmdPost", "Triggered after executing a shell command with :!cmd"],
|
||||||
["VimperatorEnter", "Triggered after Firefox starts"],
|
["VimperatorEnter", "Triggered after Firefox starts"],
|
||||||
["VimperatorLeavePre", "Triggered before exiting Firefox, just before destroying each module"],
|
["VimperatorLeavePre", "Triggered before exiting Firefox, just before destroying each module"],
|
||||||
@@ -485,17 +486,11 @@ const config = { //{{{
|
|||||||
"Set the 'private browsing' option",
|
"Set the 'private browsing' option",
|
||||||
"boolean", false,
|
"boolean", false,
|
||||||
{
|
{
|
||||||
setter: function (value)
|
setter: function (value) services.get("privateBrowsing").privateBrowsingEnabled = value,
|
||||||
{
|
getter: function () services.get("privateBrowsing").privateBrowsingEnabled,
|
||||||
return services.get("privateBrowsing").privateBrowsingEnabled = value;
|
|
||||||
},
|
|
||||||
getter: function ()
|
|
||||||
{
|
|
||||||
return services.get("privateBrowsing").privateBrowsingEnabled;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
let services = modules.services; // Storage objects are global to all windows, 'modules' isn't.
|
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 () {
|
init: function () {
|
||||||
services.get("observer").addObserver(this, "private-browsing", false);
|
services.get("observer").addObserver(this, "private-browsing", false);
|
||||||
@@ -508,6 +503,7 @@ const config = { //{{{
|
|||||||
storage.privateMode = true;
|
storage.privateMode = true;
|
||||||
else if (data == "exit")
|
else if (data == "exit")
|
||||||
storage.privateMode = false;
|
storage.privateMode = false;
|
||||||
|
storage.fireEvent("private-mode", "change", storage.privateMode);
|
||||||
} else if (topic == "quit-application") {
|
} else if (topic == "quit-application") {
|
||||||
services.get("observer").removeObserver(this, "quit-application");
|
services.get("observer").removeObserver(this, "quit-application");
|
||||||
services.get("observer").removeObserver(this, "private-browsing");
|
services.get("observer").removeObserver(this, "private-browsing");
|
||||||
@@ -515,6 +511,10 @@ const config = { //{{{
|
|||||||
},
|
},
|
||||||
}).init();
|
}).init();
|
||||||
}, false);
|
}, false);
|
||||||
|
storage.addObserver("private-mode",
|
||||||
|
function (key, event, value) {
|
||||||
|
autocommands.trigger("PrivateMode", { state: value });
|
||||||
|
}, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: merge with Vimperator version and add Muttator version
|
// TODO: merge with Vimperator version and add Muttator version
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ Execute commands automatically on events.
|
|||||||
|
|
||||||
[c]:au[tocmd][c] {event} {pat} {cmd}
|
[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}:
|
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}
|
* [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
|
*LocationChange* Triggered when changing tabs or when navigating to a new location
|
||||||
*PageLoadPre* Triggered after a page load is initiated
|
*PageLoadPre* Triggered after a page load is initiated
|
||||||
*PageLoad* Triggered when a page gets (re)loaded/opened
|
*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}
|
*ShellCmdPost* Triggered after executing a shell command with [c]:![c]#{cmd}
|
||||||
*VimperatorEnter* Triggered after Firefox starts
|
*VimperatorEnter* Triggered after Firefox starts
|
||||||
*VimperatorLeavePre* Triggered before exiting Firefox, just before destroying each module
|
*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*.
|
*<icon>* The icon associated with <url>. Only for *BookmarkAdd*.
|
||||||
*<size>* The size of a downloaded file. Only for *DownloadPost*.
|
*<size>* The size of a downloaded file. Only for *DownloadPost*.
|
||||||
*<file>* The target destination of a download. 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*.
|
*<name>* The color scheme name. Only for *ColorScheme*.
|
||||||
--------------------------------------------------------------
|
--------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -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}:
|
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} {pat}: list/remove autocommands filtered by {events} and {pat}
|
||||||
* [c]:autocmd[!][c] {events}: list/remove autocommands matching {events}
|
* [c]:autocmd[!][c] {events}: list/remove autocommands matching {events}
|
||||||
* [c]:autocmd[!][c] * {pat}: list/remove autocommands matching {pat}
|
* [c]:autocmd[!][c] * {pat}: list/remove autocommands matching {pat}
|
||||||
|
|||||||
Reference in New Issue
Block a user