mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 08:37:58 +01:00
Replace util.isOS with a platform queryable util.OS object.
--HG-- extra : rebase_source : 2a00dd4e3a023c9de11818bb95d86d9901341c6a
This commit is contained in:
@@ -1223,7 +1223,7 @@ const Buffer = Module("buffer", {
|
||||
let arg = args[0];
|
||||
|
||||
// FIXME: arg handling is a bit of a mess, check for filename
|
||||
dactyl.assert(!arg || arg[0] == ">" && !util.isOS("WINNT"),
|
||||
dactyl.assert(!arg || arg[0] == ">" && !util.OS.isWindows,
|
||||
"E488: Trailing characters");
|
||||
|
||||
prefs.withContext(function () {
|
||||
|
||||
@@ -24,7 +24,7 @@ const Editor = Module("editor", {
|
||||
selectedText: function () String(Editor.getEditor(null).selection),
|
||||
|
||||
pasteClipboard: function (clipboard, toStart) {
|
||||
if (util.isOS("WINNT")) {
|
||||
if (util.OS.isWindows) {
|
||||
this.executeCommand("cmd_paste");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -511,14 +511,14 @@ const Events = Module("events", {
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=432951
|
||||
// ---
|
||||
//
|
||||
// The following fixes are only activated if util.isOS("Darwin").
|
||||
// The following fixes are only activated if util.OS.isMacOSX.
|
||||
// Technically, they prevent mappings from <C-Esc> (and
|
||||
// <C-C-]> if your fancy keyboard permits such things<?>), but
|
||||
// these <C-control> mappings are probably pathological (<C-Esc>
|
||||
// certainly is on Windows), and so it is probably
|
||||
// harmless to remove the has("Darwin") if desired.
|
||||
//
|
||||
else if (util.isOS("Darwin") && event.ctrlKey && charCode >= 27 && charCode <= 31) {
|
||||
else if (util.OS.isMacOSX && event.ctrlKey && charCode >= 27 && charCode <= 31) {
|
||||
if (charCode == 27) { // [Ctrl-Bug 1/5] the <C-[> bug
|
||||
key = "Esc";
|
||||
modifier = modifier.replace("C-", "");
|
||||
|
||||
@@ -180,7 +180,7 @@ const IO = Module("io", {
|
||||
let rcFile1 = File.joinPaths(dir, "." + config.name + "rc", this.cwd);
|
||||
let rcFile2 = File.joinPaths(dir, "_" + config.name + "rc", this.cwd);
|
||||
|
||||
if (util.isOS("WINNT"))
|
||||
if (util.OS.isWindows)
|
||||
[rcFile1, rcFile2] = [rcFile2, rcFile1];
|
||||
|
||||
if (rcFile1.exists() && rcFile1.isFile())
|
||||
@@ -230,9 +230,9 @@ const IO = Module("io", {
|
||||
if (File.isAbsolutePath(program))
|
||||
file = io.File(program, true);
|
||||
else {
|
||||
let dirs = services.get("environment").get("PATH").split(util.isOS("WINNT") ? ";" : ":");
|
||||
let dirs = services.get("environment").get("PATH").split(util.OS.isWindows ? ";" : ":");
|
||||
// Windows tries the CWD first TODO: desirable?
|
||||
if (util.isOS("WINNT"))
|
||||
if (util.OS.isWindows)
|
||||
dirs = [io.cwd].concat(dirs);
|
||||
|
||||
lookup:
|
||||
@@ -244,7 +244,7 @@ lookup:
|
||||
|
||||
// TODO: couldn't we just palm this off to the start command?
|
||||
// automatically try to add the executable path extensions on windows
|
||||
if (util.isOS("WINNT")) {
|
||||
if (util.OS.isWindows) {
|
||||
let extensions = services.get("environment").get("PATHEXT").split(";");
|
||||
for (let [, extension] in Iterator(extensions)) {
|
||||
file = File.joinPaths(dir, program + extension, io.cwd);
|
||||
@@ -407,7 +407,7 @@ lookup:
|
||||
stdin.write(input);
|
||||
|
||||
// TODO: implement 'shellredir'
|
||||
if (util.isOS("WINNT") && !/sh/.test(options["shell"])) {
|
||||
if (util.OS.isWindows && !/sh/.test(options["shell"])) {
|
||||
command = "cd /D " + this.cwd + " && " + command + " > " + stdout.path + " 2>&1" + " < " + stdin.path;
|
||||
var res = this.run(options["shell"], options["shellcmdflag"].split(/\s+/).concat(command), true);
|
||||
}
|
||||
@@ -458,7 +458,7 @@ lookup:
|
||||
const rtpvar = config.idName + "_RUNTIME";
|
||||
let rtp = services.get("environment").get(rtpvar);
|
||||
if (!rtp) {
|
||||
rtp = "~/" + (util.isOS("WINNT") ? "" : ".") + config.name;
|
||||
rtp = "~/" + (util.OS.isWindows ? "" : ".") + config.name;
|
||||
services.get("environment").set(rtpvar, rtp);
|
||||
}
|
||||
return rtp;
|
||||
@@ -641,7 +641,7 @@ lookup:
|
||||
};
|
||||
|
||||
completion.environment = function environment(context) {
|
||||
let command = util.isOS("WINNT") ? "set" : "env";
|
||||
let command = util.OS.isWindows ? "set" : "env";
|
||||
let lines = io.system(command).split("\n");
|
||||
lines.pop();
|
||||
|
||||
@@ -696,7 +696,7 @@ lookup:
|
||||
completion.shellCommand = function shellCommand(context) {
|
||||
context.title = ["Shell Command", "Path"];
|
||||
context.generate = function () {
|
||||
let dirNames = services.get("environment").get("PATH").split(util.isOS("WINNT") ? ";" : ":");
|
||||
let dirNames = services.get("environment").get("PATH").split(util.OS.isWindows ? ";" : ":");
|
||||
let commands = [];
|
||||
|
||||
for (let [, dirName] in Iterator(dirNames)) {
|
||||
@@ -726,7 +726,7 @@ lookup:
|
||||
},
|
||||
options: function () {
|
||||
var shell, shellcmdflag;
|
||||
if (util.isOS("WINNT")) {
|
||||
if (util.OS.isWindows) {
|
||||
shell = "cmd.exe";
|
||||
shellcmdflag = "/c";
|
||||
}
|
||||
@@ -766,7 +766,7 @@ lookup:
|
||||
"string", shellcmdflag,
|
||||
{
|
||||
getter: function (value) {
|
||||
if (this.hasChanged || !util.isOS("WINNT"))
|
||||
if (this.hasChanged || !util.OS.isWindows)
|
||||
return value;
|
||||
return /sh/.test(options["shell"]) ? "-c" : "/c";
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ const Tabs = Module("tabs", {
|
||||
#TabsToolbar > xul|tabs > xul|tab { -moz-binding: url(chrome://dactyl/content/bindings.xml#tab-4) !important; }
|
||||
// FIXME: better solution for themes?
|
||||
.tabbrowser-tab[busy] > .tab-icon > .tab-icon-image { list-style-image: url('chrome://global/skin/icons/loading_16.png') !important; }
|
||||
]]></>, /tab-./g, function (m) util.isOS("Darwin") ? "tab-mac" : m),
|
||||
]]></>, /tab-./g, function (m) util.OS.isMacOSX ? "tab-mac" : m),
|
||||
false, true);
|
||||
|
||||
// hide tabs initially to prevent flickering when 'stal' would hide them
|
||||
|
||||
@@ -528,16 +528,20 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
*/
|
||||
isDomainURL: function isDomainURL(url, domain) util.isSubdomain(util.getHost(url), domain),
|
||||
|
||||
/** Dactyl's notion of the current operating system platform. */
|
||||
OS: {
|
||||
_arch: services.get("runtime").OS,
|
||||
/**
|
||||
* Returns true if *os* matches Dactyl's notion of the current operating
|
||||
* system platform. This is one of "WINNT", "Darwin" or "Unix".
|
||||
*
|
||||
* @param {string} os The OS platform to test.
|
||||
* @returns {boolean}
|
||||
* @property {string} The normalised name of the OS. This is one of
|
||||
* "Windows", "Mac OS X" or "Unix".
|
||||
*/
|
||||
isOS: function isOS(os) {
|
||||
let OS = services.get("runtime").OS;
|
||||
return (OS == "WINNT" || OS == "Darwin") ? os == OS : os == "Unix";
|
||||
get name() this.isWindows ? "Windows" : this.isMacOSX ? "Mac OS X" : "Unix",
|
||||
/** @property {boolean} True if the OS is Windows. */
|
||||
get isWindows() this._arch == "WINNT",
|
||||
/** @property {boolean} True if the OS is Mac OS X. */
|
||||
get isMacOSX() this._arch == "Darwin",
|
||||
/** @property {boolean} True if the OS is some other *nix variant. */
|
||||
get isUnix() !this.isWindows && !this.isMacOSX
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user