mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-06 09:54:12 +01:00
Merge branch 'master' into vimperator-2.1
Conflicts: common/content/io.js common/content/style.js
This commit is contained in:
@@ -66,7 +66,7 @@ function IO() //{{{
|
||||
const WINDOWS = liberator.has("Win32");
|
||||
const EXTENSION_NAME = config.name.toLowerCase(); // "vimperator" or "muttator"
|
||||
|
||||
const downloadManager = Cc["@mozilla.org/download-manager;1"].createInstance(Ci.nsIDownloadManager);
|
||||
const downloadManager = Cc["@mozilla.org/download-manager;1"].createInstance(Ci.nsIDownloadManager);
|
||||
|
||||
var processDir = services.get("directory").get("CurWorkD", Ci.nsIFile);
|
||||
var cwd = processDir;
|
||||
@@ -108,10 +108,10 @@ function IO() //{{{
|
||||
|
||||
function joinPaths(head, tail)
|
||||
{
|
||||
let path = ioManager.getFile(head);
|
||||
let path = self.getFile(head);
|
||||
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)
|
||||
path.normalize();
|
||||
}
|
||||
@@ -379,14 +379,14 @@ function IO() //{{{
|
||||
|
||||
liberator.registerObserver("load_completion", function ()
|
||||
{
|
||||
completion.setFunctionCompleter([ioManager.getFile, ioManager.expandPath],
|
||||
completion.setFunctionCompleter([self.getFile, self.expandPath],
|
||||
[function (context, obj, args) {
|
||||
context.quote[2] = "";
|
||||
completion.file(context, true);
|
||||
}]);
|
||||
});
|
||||
|
||||
var ioManager = {
|
||||
const self = {
|
||||
|
||||
MODE_RDONLY: 0x01,
|
||||
MODE_WRONLY: 0x02,
|
||||
@@ -405,7 +405,7 @@ function IO() //{{{
|
||||
// Firefox's CWD - see // https://bugzilla.mozilla.org/show_bug.cgi?id=280953
|
||||
getCurrentDirectory: function ()
|
||||
{
|
||||
let dir = ioManager.getFile(cwd.path);
|
||||
let dir = self.getFile(cwd.path);
|
||||
|
||||
// NOTE: the directory could have been deleted underneath us so
|
||||
// fallback to Firefox's CWD
|
||||
@@ -425,7 +425,7 @@ function IO() //{{{
|
||||
}
|
||||
else
|
||||
{
|
||||
let dir = ioManager.getFile(newdir);
|
||||
let dir = self.getFile(newdir);
|
||||
|
||||
if (!dir.exists() || !dir.isDirectory())
|
||||
{
|
||||
@@ -436,7 +436,7 @@ function IO() //{{{
|
||||
[cwd, oldcwd] = [dir, this.getCurrentDirectory()];
|
||||
}
|
||||
|
||||
return ioManager.getCurrentDirectory();
|
||||
return self.getCurrentDirectory();
|
||||
},
|
||||
|
||||
getRuntimeDirectories: function (specialDirectory)
|
||||
@@ -482,10 +482,10 @@ function IO() //{{{
|
||||
}
|
||||
else
|
||||
{
|
||||
let expandedPath = ioManager.expandPath(path);
|
||||
let expandedPath = self.expandPath(path);
|
||||
|
||||
if (!isAbsolutePath(expandedPath) && !noCheckPWD)
|
||||
file = joinPaths(ioManager.getCurrentDirectory().path, expandedPath);
|
||||
file = joinPaths(self.getCurrentDirectory().path, expandedPath);
|
||||
else
|
||||
file.initWithPath(expandedPath);
|
||||
}
|
||||
@@ -502,7 +502,7 @@ function IO() //{{{
|
||||
switch (EXTENSION_NAME)
|
||||
{
|
||||
case "muttator":
|
||||
tmpName = "mutt-ator-mail"; // to allow vim to :set ft=mail automatically
|
||||
tmpName = "mutt-ator-mail"; // to allow Vim to :set ft=mail automatically
|
||||
break;
|
||||
case "vimperator":
|
||||
try
|
||||
@@ -529,7 +529,7 @@ function IO() //{{{
|
||||
readDirectory: function (file, sort)
|
||||
{
|
||||
if (typeof file == "string")
|
||||
file = ioManager.getFile(file);
|
||||
file = self.getFile(file);
|
||||
else if (!(file instanceof Ci.nsILocalFile))
|
||||
throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined
|
||||
|
||||
@@ -543,11 +543,12 @@ function IO() //{{{
|
||||
array.push(entry.QueryInterface(Ci.nsIFile));
|
||||
}
|
||||
if (sort)
|
||||
return array.sort(function (a, b) b.isDirectory() - a.isDirectory() || String.localeCompare(a.path, b.path));
|
||||
array.sort(function (a, b) b.isDirectory() - a.isDirectory() || String.localeCompare(a.path, b.path));
|
||||
return array;
|
||||
}
|
||||
else
|
||||
return []; // XXX: or should it throw an error, probably yes?
|
||||
// Yes --djk
|
||||
},
|
||||
|
||||
// file is either a full pathname or an instance of file instanceof nsILocalFile
|
||||
@@ -559,7 +560,7 @@ function IO() //{{{
|
||||
|
||||
let toCharset = "UTF-8";
|
||||
if (typeof file == "string")
|
||||
file = ioManager.getFile(file);
|
||||
file = self.getFile(file);
|
||||
else if (!(file instanceof Ci.nsILocalFile))
|
||||
throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined
|
||||
|
||||
@@ -587,14 +588,14 @@ function IO() //{{{
|
||||
|
||||
let charset = "UTF-8"; // Can be any character encoding name that Mozilla supports
|
||||
if (typeof file == "string")
|
||||
file = ioManager.getFile(file);
|
||||
file = self.getFile(file);
|
||||
else if (!(file instanceof Ci.nsILocalFile))
|
||||
throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined
|
||||
|
||||
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 == ">")
|
||||
mode = ioManager.MODE_WRONLY | ioManager.MODE_CREATE | ioManager.MODE_TRUNCATE;
|
||||
mode = self.MODE_WRONLY | self.MODE_CREATE | self.MODE_TRUNCATE;
|
||||
|
||||
if (!perms)
|
||||
perms = 0644;
|
||||
@@ -616,12 +617,12 @@ function IO() //{{{
|
||||
|
||||
if (isAbsolutePath(program))
|
||||
{
|
||||
file = ioManager.getFile(program, true);
|
||||
file = self.getFile(program, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
let dirs = services.get("environment").get("PATH").split(WINDOWS ? ";" : ":");
|
||||
// Windows tries the cwd first TODO: desirable?
|
||||
// Windows tries the CWD first TODO: desirable?
|
||||
if (WINDOWS)
|
||||
dirs = [io.getCurrentDirectory().path].concat(dirs);
|
||||
|
||||
@@ -693,9 +694,9 @@ lookup:
|
||||
}
|
||||
|
||||
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
|
||||
output = ioManager.readFile(stdout);
|
||||
output = self.readFile(stdout);
|
||||
|
||||
// if there is only one \n at the end, chop it off
|
||||
if (output && output.indexOf("\n") == output.length - 1)
|
||||
@@ -740,15 +741,15 @@ lookup:
|
||||
return found;
|
||||
},
|
||||
|
||||
// files which end in .js are sourced as pure javascript files,
|
||||
// files which end in .js are sourced as pure JavaScript files,
|
||||
// no need (actually forbidden) to add: js <<EOF ... EOF around those files
|
||||
source: function (filename, silent)
|
||||
{
|
||||
let wasSourcing = ioManager.sourcing;
|
||||
let wasSourcing = self.sourcing;
|
||||
try
|
||||
{
|
||||
var file = ioManager.getFile(filename);
|
||||
ioManager.sourcing = {
|
||||
var file = self.getFile(filename);
|
||||
self.sourcing = {
|
||||
file: file.path,
|
||||
line: 0
|
||||
};
|
||||
@@ -770,10 +771,10 @@ lookup:
|
||||
|
||||
liberator.echomsg("sourcing " + filename.quote(), 2);
|
||||
|
||||
let str = ioManager.readFile(file);
|
||||
let str = self.readFile(file);
|
||||
let uri = ioService.newFileURI(file);
|
||||
|
||||
// handle pure javascript files specially
|
||||
// handle pure JavaScript files specially
|
||||
if (/\.js$/.test(filename))
|
||||
{
|
||||
try
|
||||
@@ -797,7 +798,7 @@ lookup:
|
||||
{
|
||||
let heredoc = "";
|
||||
let heredocEnd = null; // the string which ends the heredoc
|
||||
let lines = str.split("\n");
|
||||
let lines = str.split(/\r\n|[\r\n]/);
|
||||
|
||||
for (let [i, line] in Iterator(lines))
|
||||
{
|
||||
@@ -816,7 +817,7 @@ lookup:
|
||||
}
|
||||
else
|
||||
{
|
||||
ioManager.sourcing.line = i + 1;
|
||||
self.sourcing.line = i + 1;
|
||||
// skip line comments and blank lines
|
||||
line = line.replace(/\r$/, "");
|
||||
|
||||
@@ -891,7 +892,7 @@ lookup:
|
||||
}
|
||||
finally
|
||||
{
|
||||
ioManager.sourcing = wasSourcing;
|
||||
self.sourcing = wasSourcing;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -911,7 +912,7 @@ lookup:
|
||||
}
|
||||
}; //}}}
|
||||
|
||||
return ioManager;
|
||||
return self;
|
||||
|
||||
}; //}}}
|
||||
|
||||
@@ -921,8 +922,16 @@ IO.PATH_SEP = (function () {
|
||||
return file.path[0];
|
||||
})();
|
||||
|
||||
IO.__defineGetter__("runtimePath", function () services.get("environment").get(config.name.toUpperCase() + "_RUNTIME") ||
|
||||
"~/" + (liberator.has("Win32") ? "" : ".") + config.name.toLowerCase());
|
||||
IO.__defineGetter__("runtimePath", function () {
|
||||
const rtpvar = config.name.toUpperCase() + "_RUNTIME";
|
||||
let rtp = services.get("environment").get(rtpvar);
|
||||
if (!rtp)
|
||||
{
|
||||
rtp = "~/" + (liberator.has("Win32") ? "" : ".") + config.name.toLowerCase();
|
||||
services.get("environment").set(rtpvar, rtp);
|
||||
}
|
||||
return rtp;
|
||||
});
|
||||
|
||||
IO.expandPath = function (path, relative)
|
||||
{
|
||||
@@ -947,7 +956,7 @@ IO.expandPath = function (path, relative)
|
||||
// Try $HOME first, on all systems
|
||||
let home = services.get("environment").get("HOME");
|
||||
|
||||
// Windows has its own ideosyncratic $HOME variables.
|
||||
// Windows has its own idiosyncratic $HOME variables.
|
||||
if (!home && WINDOWS)
|
||||
home = services.get("environment").get("USERPROFILE") ||
|
||||
services.get("environment").get("HOMEDRIVE") + services.get("environment").get("HOMEPATH");
|
||||
|
||||
Reference in New Issue
Block a user