mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 10:37:59 +01:00
Fix Windows platform detection.
--HG-- extra : rebase_source : 22fa7cb45e3571c2fd4fe527121c50ceac249b25
This commit is contained in:
@@ -1143,7 +1143,7 @@ const Buffer = Module("buffer", {
|
|||||||
let arg = args[0];
|
let arg = args[0];
|
||||||
|
|
||||||
// FIXME: arg handling is a bit of a mess, check for filename
|
// FIXME: arg handling is a bit of a mess, check for filename
|
||||||
dactyl.assert(!arg || arg[0] == ">" && !dactyl.has("Win32"),
|
dactyl.assert(!arg || arg[0] == ">" && !dactyl.has("WINNT"),
|
||||||
"E488: Trailing characters");
|
"E488: Trailing characters");
|
||||||
|
|
||||||
options.withContext(function () {
|
options.withContext(function () {
|
||||||
|
|||||||
@@ -1155,12 +1155,6 @@ const Dactyl = Module("dactyl", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// return the platform normalized to Vim values
|
|
||||||
getPlatformFeature: function () {
|
|
||||||
let platform = services.get("runtime").OS;
|
|
||||||
return /^Mac/.test(platform) ? "MacUnix" : platform == "Win32" ? "Win32" : "Unix";
|
|
||||||
},
|
|
||||||
|
|
||||||
// TODO: move this
|
// TODO: move this
|
||||||
getMenuItems: function () {
|
getMenuItems: function () {
|
||||||
function addChildren(node, parent) {
|
function addChildren(node, parent) {
|
||||||
@@ -1193,7 +1187,9 @@ const Dactyl = Module("dactyl", {
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
config: function () {
|
config: function () {
|
||||||
config.features.push(Dactyl.getPlatformFeature());
|
// 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
|
// Only general options are added here, which are valid for all Dactyl extensions
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ const Editor = Module("editor", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
pasteClipboard: function () {
|
pasteClipboard: function () {
|
||||||
if (dactyl.has("Win32")) {
|
if (dactyl.has("WINNT")) {
|
||||||
this.executeCommand("cmd_paste");
|
this.executeCommand("cmd_paste");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -524,14 +524,14 @@ const Events = Module("events", {
|
|||||||
// https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=432951
|
// 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("MacUnix").
|
// The following fixes are only activated if dactyl.has("Darwin").
|
||||||
// Technically, they prevent mappings from <C-Esc> (and
|
// Technically, they prevent mappings from <C-Esc> (and
|
||||||
// <C-C-]> if your fancy keyboard permits such things<?>), but
|
// <C-C-]> if your fancy keyboard permits such things<?>), but
|
||||||
// these <C-control> mappings are probably pathological (<C-Esc>
|
// these <C-control> mappings are probably pathological (<C-Esc>
|
||||||
// certainly is on Windows), and so it is probably
|
// certainly is on Windows), and so it is probably
|
||||||
// harmless to remove the has("MacUnix") if desired.
|
// harmless to remove the has("Darwin") if desired.
|
||||||
//
|
//
|
||||||
else if (dactyl.has("MacUnix") && event.ctrlKey && charCode >= 27 && charCode <= 31) {
|
else if (dactyl.has("Darwin") && event.ctrlKey && charCode >= 27 && charCode <= 31) {
|
||||||
if (charCode == 27) { // [Ctrl-Bug 1/5] the <C-[> bug
|
if (charCode == 27) { // [Ctrl-Bug 1/5] the <C-[> bug
|
||||||
key = "Esc";
|
key = "Esc";
|
||||||
modifier = modifier.replace("C-", "");
|
modifier = modifier.replace("C-", "");
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ const IO = Module("io", {
|
|||||||
let rcFile1 = File.joinPaths(dir, "." + config.name + "rc");
|
let rcFile1 = File.joinPaths(dir, "." + config.name + "rc");
|
||||||
let rcFile2 = File.joinPaths(dir, "_" + config.name + "rc");
|
let rcFile2 = File.joinPaths(dir, "_" + config.name + "rc");
|
||||||
|
|
||||||
if (dactyl.has("Win32"))
|
if (dactyl.has("WINNT"))
|
||||||
[rcFile1, rcFile2] = [rcFile2, rcFile1];
|
[rcFile1, rcFile2] = [rcFile2, rcFile1];
|
||||||
|
|
||||||
if (rcFile1.exists() && rcFile1.isFile())
|
if (rcFile1.exists() && rcFile1.isFile())
|
||||||
@@ -226,9 +226,9 @@ const IO = Module("io", {
|
|||||||
if (File.isAbsolutePath(program))
|
if (File.isAbsolutePath(program))
|
||||||
file = io.File(program, true);
|
file = io.File(program, true);
|
||||||
else {
|
else {
|
||||||
let dirs = services.get("environment").get("PATH").split(dactyl.has("Win32") ? ";" : ":");
|
let dirs = services.get("environment").get("PATH").split(dactyl.has("WINNT") ? ";" : ":");
|
||||||
// Windows tries the CWD first TODO: desirable?
|
// Windows tries the CWD first TODO: desirable?
|
||||||
if (dactyl.has("Win32"))
|
if (dactyl.has("WINNT"))
|
||||||
dirs = [io.getCurrentDirectory().path].concat(dirs);
|
dirs = [io.getCurrentDirectory().path].concat(dirs);
|
||||||
|
|
||||||
lookup:
|
lookup:
|
||||||
@@ -240,7 +240,7 @@ lookup:
|
|||||||
|
|
||||||
// TODO: couldn't we just palm this off to the start command?
|
// TODO: couldn't we just palm this off to the start command?
|
||||||
// automatically try to add the executable path extensions on windows
|
// automatically try to add the executable path extensions on windows
|
||||||
if (dactyl.has("Win32")) {
|
if (dactyl.has("WINNT")) {
|
||||||
let extensions = services.get("environment").get("PATHEXT").split(";");
|
let extensions = services.get("environment").get("PATHEXT").split(";");
|
||||||
for (let [, extension] in Iterator(extensions)) {
|
for (let [, extension] in Iterator(extensions)) {
|
||||||
file = File.joinPaths(dir, program + extension);
|
file = File.joinPaths(dir, program + extension);
|
||||||
@@ -459,7 +459,7 @@ lookup:
|
|||||||
stdin.write(input);
|
stdin.write(input);
|
||||||
|
|
||||||
// TODO: implement 'shellredir'
|
// TODO: implement 'shellredir'
|
||||||
if (dactyl.has("Win32")) {
|
if (dactyl.has("WINNT")) {
|
||||||
command = "cd /D " + this._cwd.path + " && " + command + " > " + stdout.path + " 2>&1" + " < " + stdin.path;
|
command = "cd /D " + this._cwd.path + " && " + command + " > " + stdout.path + " 2>&1" + " < " + stdin.path;
|
||||||
var res = this.run(options["shell"], options["shellcmdflag"].split(/\s+/).concat(command), true);
|
var res = this.run(options["shell"], options["shellcmdflag"].split(/\s+/).concat(command), true);
|
||||||
}
|
}
|
||||||
@@ -513,7 +513,7 @@ lookup:
|
|||||||
const rtpvar = config.idname + "_RUNTIME";
|
const rtpvar = config.idname + "_RUNTIME";
|
||||||
let rtp = services.get("environment").get(rtpvar);
|
let rtp = services.get("environment").get(rtpvar);
|
||||||
if (!rtp) {
|
if (!rtp) {
|
||||||
rtp = "~/" + (dactyl.has("Win32") ? "" : ".") + config.name;
|
rtp = "~/" + (dactyl.has("WINNT") ? "" : ".") + config.name;
|
||||||
services.get("environment").set(rtpvar, rtp);
|
services.get("environment").set(rtpvar, rtp);
|
||||||
}
|
}
|
||||||
return rtp;
|
return rtp;
|
||||||
@@ -703,7 +703,7 @@ lookup:
|
|||||||
};
|
};
|
||||||
|
|
||||||
completion.environment = function environment(context) {
|
completion.environment = function environment(context) {
|
||||||
let command = dactyl.has("Win32") ? "set" : "env";
|
let command = dactyl.has("WINNT") ? "set" : "env";
|
||||||
let lines = io.system(command).split("\n");
|
let lines = io.system(command).split("\n");
|
||||||
lines.pop();
|
lines.pop();
|
||||||
|
|
||||||
@@ -750,7 +750,7 @@ lookup:
|
|||||||
completion.shellCommand = function shellCommand(context) {
|
completion.shellCommand = function shellCommand(context) {
|
||||||
context.title = ["Shell Command", "Path"];
|
context.title = ["Shell Command", "Path"];
|
||||||
context.generate = function () {
|
context.generate = function () {
|
||||||
let dirNames = services.get("environment").get("PATH").split(RegExp(dactyl.has("Win32") ? ";" : ":"));
|
let dirNames = services.get("environment").get("PATH").split(RegExp(dactyl.has("WINNT") ? ";" : ":"));
|
||||||
let commands = [];
|
let commands = [];
|
||||||
|
|
||||||
for (let [, dirName] in Iterator(dirNames)) {
|
for (let [, dirName] in Iterator(dirNames)) {
|
||||||
@@ -780,7 +780,7 @@ lookup:
|
|||||||
},
|
},
|
||||||
options: function () {
|
options: function () {
|
||||||
var shell, shellcmdflag;
|
var shell, shellcmdflag;
|
||||||
if (dactyl.has("Win32")) {
|
if (dactyl.has("WINNT")) {
|
||||||
shell = "cmd.exe";
|
shell = "cmd.exe";
|
||||||
// TODO: setting 'shell' to "something containing sh" updates
|
// TODO: setting 'shell' to "something containing sh" updates
|
||||||
// 'shellcmdflag' appropriately at startup on Windows in Vim
|
// 'shellcmdflag' appropriately at startup on Windows in Vim
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const Tabs = Module("tabs", {
|
|||||||
this._lastBufferSwitchArgs = "";
|
this._lastBufferSwitchArgs = "";
|
||||||
this._lastBufferSwitchSpecial = true;
|
this._lastBufferSwitchSpecial = true;
|
||||||
|
|
||||||
let fragment = dactyl.has("MacUnix") ? "tab-mac" : "tab";
|
let fragment = dactyl.has("Darwin") ? "tab-mac" : "tab";
|
||||||
this.tabBinding = styles.addSheet(true, "tab-binding", "chrome://browser/content/browser.xul",
|
this.tabBinding = styles.addSheet(true, "tab-binding", "chrome://browser/content/browser.xul",
|
||||||
".tabbrowser-tab { -moz-binding: url(chrome://dactyl/content/bindings.xml#" + fragment + ") !important; }" +
|
".tabbrowser-tab { -moz-binding: url(chrome://dactyl/content/bindings.xml#" + fragment + ") !important; }" +
|
||||||
// FIXME: better solution for themes?
|
// FIXME: better solution for themes?
|
||||||
|
|||||||
@@ -1165,7 +1165,7 @@
|
|||||||
<tags>'shell' 'sh'</tags>
|
<tags>'shell' 'sh'</tags>
|
||||||
<spec>'shell' 'sh'</spec>
|
<spec>'shell' 'sh'</spec>
|
||||||
<type>string</type>
|
<type>string</type>
|
||||||
<default type="plain"><em>$SHELL</em> or <str>sh</str>, Win32: <str>cmd.exe</str></default>
|
<default type="plain"><em>$SHELL</em> or <str>sh</str>, Windows: <str>cmd.exe</str></default>
|
||||||
<description>
|
<description>
|
||||||
<p>Shell to use for executing <ex>:!</ex> and <ex>:run</ex> commands.</p>
|
<p>Shell to use for executing <ex>:!</ex> and <ex>:run</ex> commands.</p>
|
||||||
</description>
|
</description>
|
||||||
@@ -1177,7 +1177,7 @@
|
|||||||
<spec>'shellcmdflag' 'shcf'</spec>
|
<spec>'shellcmdflag' 'shcf'</spec>
|
||||||
<strut/>
|
<strut/>
|
||||||
<type>string</type>
|
<type>string</type>
|
||||||
<default type="plain"><str>-c</str>, Win32: <str>/c</str></default>
|
<default type="plain"><str>-c</str>, Windows: <str>/c</str></default>
|
||||||
<description>
|
<description>
|
||||||
<p>Flag passed to shell when executing <ex>:!</ex> and <ex>:run</ex> commands.</p>
|
<p>Flag passed to shell when executing <ex>:!</ex> and <ex>:run</ex> commands.</p>
|
||||||
</description>
|
</description>
|
||||||
|
|||||||
Reference in New Issue
Block a user