mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 04:07:59 +01:00
Replace dactyl.has(OS) with util.isOS.
This commit is contained in:
@@ -1216,7 +1216,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] == ">" && !dactyl.has("WINNT"),
|
||||
dactyl.assert(!arg || arg[0] == ">" && !util.isOS("WINNT"),
|
||||
"E488: Trailing characters");
|
||||
|
||||
prefs.withContext(function () {
|
||||
|
||||
@@ -1112,12 +1112,6 @@ const Dactyl = Module("dactyl", {
|
||||
dactyl.help(tag);
|
||||
}
|
||||
}, {
|
||||
config: function () {
|
||||
// TODO: is the OS really a config feature? I think not. --djk
|
||||
let os = services.get("runtime").OS;
|
||||
config.features.push(os == "WINNT" || os == "Darwin" ? os : "Unix");
|
||||
},
|
||||
|
||||
// Only general options are added here, which are valid for all Dactyl extensions
|
||||
options: function () {
|
||||
options.add(["errorbells", "eb"],
|
||||
|
||||
@@ -60,7 +60,7 @@ const Editor = Module("editor", {
|
||||
},
|
||||
|
||||
pasteClipboard: function (clipboard, toStart) {
|
||||
if (dactyl.has("WINNT")) {
|
||||
if (util.isOS("WINNT")) {
|
||||
this.executeCommand("cmd_paste");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -484,14 +484,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 dactyl.has("Darwin").
|
||||
// The following fixes are only activated if util.isOS("Darwin").
|
||||
// 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 (dactyl.has("Darwin") && event.ctrlKey && charCode >= 27 && charCode <= 31) {
|
||||
else if (util.isOS("Darwin") && 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 (dactyl.has("WINNT"))
|
||||
if (util.isOS("WINNT"))
|
||||
[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(dactyl.has("WINNT") ? ";" : ":");
|
||||
let dirs = services.get("environment").get("PATH").split(util.isOS("WINNT") ? ";" : ":");
|
||||
// Windows tries the CWD first TODO: desirable?
|
||||
if (dactyl.has("WINNT"))
|
||||
if (util.isOS("WINNT"))
|
||||
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 (dactyl.has("WINNT")) {
|
||||
if (util.isOS("WINNT")) {
|
||||
let extensions = services.get("environment").get("PATHEXT").split(";");
|
||||
for (let [, extension] in Iterator(extensions)) {
|
||||
file = File.joinPaths(dir, program + extension, io.cwd);
|
||||
@@ -398,7 +398,7 @@ lookup:
|
||||
stdin.write(input);
|
||||
|
||||
// TODO: implement 'shellredir'
|
||||
if (dactyl.has("WINNT")) {
|
||||
if (util.isOS("WINNT")) {
|
||||
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);
|
||||
}
|
||||
@@ -452,7 +452,7 @@ lookup:
|
||||
const rtpvar = config.idName + "_RUNTIME";
|
||||
let rtp = services.get("environment").get(rtpvar);
|
||||
if (!rtp) {
|
||||
rtp = "~/" + (dactyl.has("WINNT") ? "" : ".") + config.name;
|
||||
rtp = "~/" + (util.isOS("WINNT") ? "" : ".") + config.name;
|
||||
services.get("environment").set(rtpvar, rtp);
|
||||
}
|
||||
return rtp;
|
||||
@@ -634,7 +634,7 @@ lookup:
|
||||
};
|
||||
|
||||
completion.environment = function environment(context) {
|
||||
let command = dactyl.has("WINNT") ? "set" : "env";
|
||||
let command = util.isOS("WINNT") ? "set" : "env";
|
||||
let lines = io.system(command).split("\n");
|
||||
lines.pop();
|
||||
|
||||
@@ -689,7 +689,7 @@ lookup:
|
||||
completion.shellCommand = function shellCommand(context) {
|
||||
context.title = ["Shell Command", "Path"];
|
||||
context.generate = function () {
|
||||
let dirNames = services.get("environment").get("PATH").split(dactyl.has("WINNT") ? ";" : ":");
|
||||
let dirNames = services.get("environment").get("PATH").split(util.isOS("WINNT") ? ";" : ":");
|
||||
let commands = [];
|
||||
|
||||
for (let [, dirName] in Iterator(dirNames)) {
|
||||
@@ -719,7 +719,7 @@ lookup:
|
||||
},
|
||||
options: function () {
|
||||
var shell, shellcmdflag;
|
||||
if (dactyl.has("WINNT")) {
|
||||
if (util.isOS("WINNT")) {
|
||||
shell = "cmd.exe";
|
||||
// TODO: setting 'shell' to "something containing sh" updates
|
||||
// 'shellcmdflag' appropriately at startup on Windows in Vim
|
||||
|
||||
@@ -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) dactyl.has("Darwin") ? "tab-mac" : m),
|
||||
]]></>, /tab-./g, function (m) util.isOS("Darwin") ? "tab-mac" : m),
|
||||
false, true);
|
||||
|
||||
// hide tabs initially to prevent flickering when 'stal' would hide them
|
||||
|
||||
@@ -526,6 +526,18 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
*/
|
||||
isDomainURL: function isDomainURL(url, domain) util.isSubdomain(util.getHost(url), domain),
|
||||
|
||||
/**
|
||||
* 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}
|
||||
*/
|
||||
isOS: function isOS(os) {
|
||||
let OS = services.get("runtime").OS;
|
||||
return (OS == "WINNT" || OS == "Darwin") ? os == OS : os == "Unix";
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true if 'host' is a subdomain of 'domain'.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user