mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 10:37:59 +01:00
Use self as the returned object from all creation functions.
This commit is contained in:
@@ -307,7 +307,7 @@ function Commands() //{{{
|
|||||||
completion.setFunctionCompleter(commands.get, [function () ([c.name, c.description] for (c in commands))]);
|
completion.setFunctionCompleter(commands.get, [function () ([c.name, c.description] for (c in commands))]);
|
||||||
});
|
});
|
||||||
|
|
||||||
var commandManager = {
|
const self = {
|
||||||
|
|
||||||
// FIXME: remove later, when our option handler is better
|
// FIXME: remove later, when our option handler is better
|
||||||
OPTION_ANY: 0, // can be given no argument or an argument of any type,
|
OPTION_ANY: 0, // can be given no argument or an argument of any type,
|
||||||
@@ -796,7 +796,7 @@ function Commands() //{{{
|
|||||||
|
|
||||||
// TODO: Vim allows commands to be defined without {rep} if there are {attr}s
|
// TODO: Vim allows commands to be defined without {rep} if there are {attr}s
|
||||||
// specified - useful?
|
// specified - useful?
|
||||||
commandManager.add(["com[mand]"],
|
self.add(["com[mand]"],
|
||||||
"List and define commands",
|
"List and define commands",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
@@ -903,11 +903,11 @@ function Commands() //{{{
|
|||||||
bang: true,
|
bang: true,
|
||||||
completer: function (context) completion.userCommand(context),
|
completer: function (context) completion.userCommand(context),
|
||||||
options: [
|
options: [
|
||||||
[["-nargs"], commandManager.OPTION_STRING,
|
[["-nargs"], self.OPTION_STRING,
|
||||||
function (arg) /^[01*?+]$/.test(arg), ["0", "1", "*", "?", "+"]],
|
function (arg) /^[01*?+]$/.test(arg), ["0", "1", "*", "?", "+"]],
|
||||||
[["-bang"], commandManager.OPTION_NOARG],
|
[["-bang"], self.OPTION_NOARG],
|
||||||
[["-count"], commandManager.OPTION_NOARG],
|
[["-count"], self.OPTION_NOARG],
|
||||||
[["-complete"], commandManager.OPTION_STRING,
|
[["-complete"], self.OPTION_STRING,
|
||||||
function (arg) arg in completeOptionMap || /custom,\w+/.test(arg),
|
function (arg) arg in completeOptionMap || /custom,\w+/.test(arg),
|
||||||
function (context) [[k, ""] for ([k, v] in Iterator(completeOptionMap))]]
|
function (context) [[k, ""] for ([k, v] in Iterator(completeOptionMap))]]
|
||||||
],
|
],
|
||||||
@@ -930,7 +930,7 @@ function Commands() //{{{
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
commandManager.add(["comc[lear]"],
|
self.add(["comc[lear]"],
|
||||||
"Delete all user-defined commands",
|
"Delete all user-defined commands",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
@@ -938,7 +938,7 @@ function Commands() //{{{
|
|||||||
},
|
},
|
||||||
{ argCount: "0" });
|
{ argCount: "0" });
|
||||||
|
|
||||||
commandManager.add(["delc[ommand]"],
|
self.add(["delc[ommand]"],
|
||||||
"Delete the specified user-defined command",
|
"Delete the specified user-defined command",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
@@ -956,7 +956,7 @@ function Commands() //{{{
|
|||||||
|
|
||||||
//}}}
|
//}}}
|
||||||
|
|
||||||
return commandManager;
|
return self;
|
||||||
|
|
||||||
}; //}}}
|
}; //}}}
|
||||||
|
|
||||||
|
|||||||
@@ -1265,7 +1265,7 @@ function Completion() //{{{
|
|||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
let self = {
|
const self = {
|
||||||
|
|
||||||
setFunctionCompleter: function setFunctionCompleter(funcs, completers)
|
setFunctionCompleter: function setFunctionCompleter(funcs, completers)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -612,7 +612,7 @@ function Events() //{{{
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
eventManager[method](event);
|
self[method](event);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
@@ -758,7 +758,7 @@ function Events() //{{{
|
|||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
var eventManager = {
|
const self = {
|
||||||
|
|
||||||
feedingKeys: false,
|
feedingKeys: false,
|
||||||
|
|
||||||
@@ -1723,7 +1723,7 @@ function Events() //{{{
|
|||||||
}
|
}
|
||||||
}; //}}}
|
}; //}}}
|
||||||
|
|
||||||
window.XULBrowserWindow = eventManager.progressListener;
|
window.XULBrowserWindow = self.progressListener;
|
||||||
window.QueryInterface(Ci.nsIInterfaceRequestor)
|
window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
.getInterface(Ci.nsIWebNavigation)
|
.getInterface(Ci.nsIWebNavigation)
|
||||||
.QueryInterface(Ci.nsIDocShellTreeItem).treeOwner
|
.QueryInterface(Ci.nsIDocShellTreeItem).treeOwner
|
||||||
@@ -1732,21 +1732,21 @@ function Events() //{{{
|
|||||||
.XULBrowserWindow = window.XULBrowserWindow;
|
.XULBrowserWindow = window.XULBrowserWindow;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getBrowser().addProgressListener(eventManager.progressListener, Ci.nsIWebProgress.NOTIFY_ALL);
|
getBrowser().addProgressListener(self.progressListener, Ci.nsIWebProgress.NOTIFY_ALL);
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
|
||||||
eventManager.prefObserver.register();
|
self.prefObserver.register();
|
||||||
liberator.registerObserver("shutdown", function () {
|
liberator.registerObserver("shutdown", function () {
|
||||||
eventManager.destroy();
|
self.destroy();
|
||||||
eventManager.prefObserver.unregister();
|
self.prefObserver.unregister();
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener("keypress", wrapListener("onKeyPress"), true);
|
window.addEventListener("keypress", wrapListener("onKeyPress"), true);
|
||||||
window.addEventListener("keydown", wrapListener("onKeyUpOrDown"), true);
|
window.addEventListener("keydown", wrapListener("onKeyUpOrDown"), true);
|
||||||
window.addEventListener("keyup", wrapListener("onKeyUpOrDown"), true);
|
window.addEventListener("keyup", wrapListener("onKeyUpOrDown"), true);
|
||||||
|
|
||||||
return eventManager;
|
return self;
|
||||||
|
|
||||||
}; //}}}
|
}; //}}}
|
||||||
|
|
||||||
|
|||||||
@@ -114,10 +114,10 @@ function IO() //{{{
|
|||||||
|
|
||||||
function joinPaths(head, tail)
|
function joinPaths(head, tail)
|
||||||
{
|
{
|
||||||
let path = ioManager.getFile(head);
|
let path = self.getFile(head);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
path.appendRelativePath(ioManager.expandPath(tail, true)); // FIXME: should only expand env vars and normalise path separators
|
path.appendRelativePath(self.expandPath(tail, true)); // FIXME: should only expand env vars and normalise path separators
|
||||||
if (path.exists() && path.normalize)
|
if (path.exists() && path.normalize)
|
||||||
path.normalize();
|
path.normalize();
|
||||||
}
|
}
|
||||||
@@ -385,14 +385,14 @@ function IO() //{{{
|
|||||||
|
|
||||||
liberator.registerObserver("load_completion", function ()
|
liberator.registerObserver("load_completion", function ()
|
||||||
{
|
{
|
||||||
completion.setFunctionCompleter([ioManager.getFile, ioManager.expandPath],
|
completion.setFunctionCompleter([self.getFile, self.expandPath],
|
||||||
[function (context, obj, args) {
|
[function (context, obj, args) {
|
||||||
context.quote[2] = "";
|
context.quote[2] = "";
|
||||||
completion.file(context, true);
|
completion.file(context, true);
|
||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
var ioManager = {
|
const self = {
|
||||||
|
|
||||||
MODE_RDONLY: 0x01,
|
MODE_RDONLY: 0x01,
|
||||||
MODE_WRONLY: 0x02,
|
MODE_WRONLY: 0x02,
|
||||||
@@ -413,7 +413,7 @@ function IO() //{{{
|
|||||||
// Firefox's CWD - see // https://bugzilla.mozilla.org/show_bug.cgi?id=280953
|
// Firefox's CWD - see // https://bugzilla.mozilla.org/show_bug.cgi?id=280953
|
||||||
getCurrentDirectory: function ()
|
getCurrentDirectory: function ()
|
||||||
{
|
{
|
||||||
let dir = ioManager.getFile(cwd.path);
|
let dir = self.getFile(cwd.path);
|
||||||
|
|
||||||
// NOTE: the directory could have been deleted underneath us so
|
// NOTE: the directory could have been deleted underneath us so
|
||||||
// fallback to Firefox's CWD
|
// fallback to Firefox's CWD
|
||||||
@@ -433,7 +433,7 @@ function IO() //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
let dir = ioManager.getFile(newdir);
|
let dir = self.getFile(newdir);
|
||||||
|
|
||||||
if (!dir.exists() || !dir.isDirectory())
|
if (!dir.exists() || !dir.isDirectory())
|
||||||
{
|
{
|
||||||
@@ -444,7 +444,7 @@ function IO() //{{{
|
|||||||
[cwd, oldcwd] = [dir, this.getCurrentDirectory()];
|
[cwd, oldcwd] = [dir, this.getCurrentDirectory()];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ioManager.getCurrentDirectory();
|
return self.getCurrentDirectory();
|
||||||
},
|
},
|
||||||
|
|
||||||
getRuntimeDirectories: function (specialDirectory)
|
getRuntimeDirectories: function (specialDirectory)
|
||||||
@@ -489,10 +489,10 @@ function IO() //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
let expandedPath = ioManager.expandPath(path);
|
let expandedPath = self.expandPath(path);
|
||||||
|
|
||||||
if (!isAbsolutePath(expandedPath) && !noCheckPWD)
|
if (!isAbsolutePath(expandedPath) && !noCheckPWD)
|
||||||
file = joinPaths(ioManager.getCurrentDirectory().path, expandedPath);
|
file = joinPaths(self.getCurrentDirectory().path, expandedPath);
|
||||||
else
|
else
|
||||||
file.initWithPath(expandedPath);
|
file.initWithPath(expandedPath);
|
||||||
}
|
}
|
||||||
@@ -536,7 +536,7 @@ function IO() //{{{
|
|||||||
readDirectory: function (file, sort)
|
readDirectory: function (file, sort)
|
||||||
{
|
{
|
||||||
if (typeof file == "string")
|
if (typeof file == "string")
|
||||||
file = ioManager.getFile(file);
|
file = self.getFile(file);
|
||||||
else if (!(file instanceof Ci.nsILocalFile))
|
else if (!(file instanceof Ci.nsILocalFile))
|
||||||
throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined
|
throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined
|
||||||
|
|
||||||
@@ -567,7 +567,7 @@ function IO() //{{{
|
|||||||
|
|
||||||
let toCharset = "UTF-8";
|
let toCharset = "UTF-8";
|
||||||
if (typeof file == "string")
|
if (typeof file == "string")
|
||||||
file = ioManager.getFile(file);
|
file = self.getFile(file);
|
||||||
else if (!(file instanceof Ci.nsILocalFile))
|
else if (!(file instanceof Ci.nsILocalFile))
|
||||||
throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined
|
throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined
|
||||||
|
|
||||||
@@ -595,14 +595,14 @@ function IO() //{{{
|
|||||||
|
|
||||||
let charset = "UTF-8"; // Can be any character encoding name that Mozilla supports
|
let charset = "UTF-8"; // Can be any character encoding name that Mozilla supports
|
||||||
if (typeof file == "string")
|
if (typeof file == "string")
|
||||||
file = ioManager.getFile(file);
|
file = self.getFile(file);
|
||||||
else if (!(file instanceof Ci.nsILocalFile))
|
else if (!(file instanceof Ci.nsILocalFile))
|
||||||
throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined
|
throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined
|
||||||
|
|
||||||
if (mode == ">>")
|
if (mode == ">>")
|
||||||
mode = ioManager.MODE_WRONLY | ioManager.MODE_CREATE | ioManager.MODE_APPEND;
|
mode = self.MODE_WRONLY | self.MODE_CREATE | self.MODE_APPEND;
|
||||||
else if (!mode || mode == ">")
|
else if (!mode || mode == ">")
|
||||||
mode = ioManager.MODE_WRONLY | ioManager.MODE_CREATE | ioManager.MODE_TRUNCATE;
|
mode = self.MODE_WRONLY | self.MODE_CREATE | self.MODE_TRUNCATE;
|
||||||
|
|
||||||
if (!perms)
|
if (!perms)
|
||||||
perms = 0644;
|
perms = 0644;
|
||||||
@@ -624,7 +624,7 @@ function IO() //{{{
|
|||||||
|
|
||||||
if (isAbsolutePath(program))
|
if (isAbsolutePath(program))
|
||||||
{
|
{
|
||||||
file = ioManager.getFile(program, true);
|
file = self.getFile(program, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -701,9 +701,9 @@ lookup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (res > 0) // FIXME: Is this really right? Shouldn't we always show both?
|
if (res > 0) // FIXME: Is this really right? Shouldn't we always show both?
|
||||||
var output = ioManager.readFile(stderr) + "\nshell returned " + res;
|
var output = self.readFile(stderr) + "\nshell returned " + res;
|
||||||
else
|
else
|
||||||
output = ioManager.readFile(stdout);
|
output = self.readFile(stdout);
|
||||||
|
|
||||||
// if there is only one \n at the end, chop it off
|
// if there is only one \n at the end, chop it off
|
||||||
if (output && output.indexOf("\n") == output.length - 1)
|
if (output && output.indexOf("\n") == output.length - 1)
|
||||||
@@ -752,11 +752,11 @@ lookup:
|
|||||||
// no need (actually forbidden) to add: js <<EOF ... EOF around those files
|
// no need (actually forbidden) to add: js <<EOF ... EOF around those files
|
||||||
source: function (filename, silent)
|
source: function (filename, silent)
|
||||||
{
|
{
|
||||||
let wasSourcing = ioManager.sourcing;
|
let wasSourcing = self.sourcing;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var file = ioManager.getFile(filename);
|
var file = self.getFile(filename);
|
||||||
ioManager.sourcing = {
|
self.sourcing = {
|
||||||
file: file.path,
|
file: file.path,
|
||||||
line: 0
|
line: 0
|
||||||
};
|
};
|
||||||
@@ -778,7 +778,7 @@ lookup:
|
|||||||
|
|
||||||
liberator.echomsg("sourcing " + filename.quote(), 2);
|
liberator.echomsg("sourcing " + filename.quote(), 2);
|
||||||
|
|
||||||
let str = ioManager.readFile(file);
|
let str = self.readFile(file);
|
||||||
let uri = ioService.newFileURI(file);
|
let uri = ioService.newFileURI(file);
|
||||||
|
|
||||||
// handle pure JavaScript files specially
|
// handle pure JavaScript files specially
|
||||||
@@ -824,7 +824,7 @@ lookup:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ioManager.sourcing.line = i + 1;
|
self.sourcing.line = i + 1;
|
||||||
// skip line comments and blank lines
|
// skip line comments and blank lines
|
||||||
line = line.replace(/\r$/, "");
|
line = line.replace(/\r$/, "");
|
||||||
|
|
||||||
@@ -899,7 +899,7 @@ lookup:
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
ioManager.sourcing = wasSourcing;
|
self.sourcing = wasSourcing;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -919,7 +919,7 @@ lookup:
|
|||||||
}
|
}
|
||||||
}; //}}}
|
}; //}}}
|
||||||
|
|
||||||
return ioManager;
|
return self;
|
||||||
|
|
||||||
}; //}}}
|
}; //}}}
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ const modes = (function () //{{{
|
|||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
var self = {
|
const self = {
|
||||||
|
|
||||||
NONE: 0,
|
NONE: 0,
|
||||||
|
|
||||||
__iterator__: function () util.Array.iterator(this.all),
|
__iterator__: function () util.Array.iterator(this.all),
|
||||||
|
|||||||
Reference in New Issue
Block a user