1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 21:18:00 +01:00

Fix Windows platform detection.

--HG--
extra : rebase_source : 22fa7cb45e3571c2fd4fe527121c50ceac249b25
This commit is contained in:
Doug Kearns
2010-09-22 17:36:04 +10:00
parent 60eac8d752
commit 542086159f
7 changed files with 20 additions and 24 deletions

View File

@@ -1143,7 +1143,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("Win32"),
dactyl.assert(!arg || arg[0] == ">" && !dactyl.has("WINNT"),
"E488: Trailing characters");
options.withContext(function () {

View File

@@ -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
getMenuItems: function () {
function addChildren(node, parent) {
@@ -1193,7 +1187,9 @@ const Dactyl = Module("dactyl", {
}
}, {
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

View File

@@ -54,7 +54,7 @@ const Editor = Module("editor", {
},
pasteClipboard: function () {
if (dactyl.has("Win32")) {
if (dactyl.has("WINNT")) {
this.executeCommand("cmd_paste");
return;
}

View File

@@ -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
// ---
//
// 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
// <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("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
key = "Esc";
modifier = modifier.replace("C-", "");

View File

@@ -182,7 +182,7 @@ const IO = Module("io", {
let rcFile1 = 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];
if (rcFile1.exists() && rcFile1.isFile())
@@ -226,9 +226,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("Win32") ? ";" : ":");
let dirs = services.get("environment").get("PATH").split(dactyl.has("WINNT") ? ";" : ":");
// Windows tries the CWD first TODO: desirable?
if (dactyl.has("Win32"))
if (dactyl.has("WINNT"))
dirs = [io.getCurrentDirectory().path].concat(dirs);
lookup:
@@ -240,7 +240,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("Win32")) {
if (dactyl.has("WINNT")) {
let extensions = services.get("environment").get("PATHEXT").split(";");
for (let [, extension] in Iterator(extensions)) {
file = File.joinPaths(dir, program + extension);
@@ -459,7 +459,7 @@ lookup:
stdin.write(input);
// TODO: implement 'shellredir'
if (dactyl.has("Win32")) {
if (dactyl.has("WINNT")) {
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);
}
@@ -513,7 +513,7 @@ lookup:
const rtpvar = config.idname + "_RUNTIME";
let rtp = services.get("environment").get(rtpvar);
if (!rtp) {
rtp = "~/" + (dactyl.has("Win32") ? "" : ".") + config.name;
rtp = "~/" + (dactyl.has("WINNT") ? "" : ".") + config.name;
services.get("environment").set(rtpvar, rtp);
}
return rtp;
@@ -703,7 +703,7 @@ lookup:
};
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");
lines.pop();
@@ -750,7 +750,7 @@ lookup:
completion.shellCommand = function shellCommand(context) {
context.title = ["Shell Command", "Path"];
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 = [];
for (let [, dirName] in Iterator(dirNames)) {
@@ -780,7 +780,7 @@ lookup:
},
options: function () {
var shell, shellcmdflag;
if (dactyl.has("Win32")) {
if (dactyl.has("WINNT")) {
shell = "cmd.exe";
// TODO: setting 'shell' to "something containing sh" updates
// 'shellcmdflag' appropriately at startup on Windows in Vim

View File

@@ -21,7 +21,7 @@ const Tabs = Module("tabs", {
this._lastBufferSwitchArgs = "";
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",
".tabbrowser-tab { -moz-binding: url(chrome://dactyl/content/bindings.xml#" + fragment + ") !important; }" +
// FIXME: better solution for themes?

View File

@@ -1165,7 +1165,7 @@
<tags>'shell' 'sh'</tags>
<spec>'shell' 'sh'</spec>
<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>
<p>Shell to use for executing <ex>:!</ex> and <ex>:run</ex> commands.</p>
</description>
@@ -1177,7 +1177,7 @@
<spec>'shellcmdflag' 'shcf'</spec>
<strut/>
<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>
<p>Flag passed to shell when executing <ex>:!</ex> and <ex>:run</ex> commands.</p>
</description>