mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-09 16:04:14 +01:00
Handle sane shells on Windows somewhat better.
This commit is contained in:
@@ -155,8 +155,8 @@ const Browser = Module("browser", {
|
||||
commands.add(["redr[aw]"],
|
||||
"Redraw the screen",
|
||||
function () {
|
||||
window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils).redraw();
|
||||
window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils)
|
||||
.redraw();
|
||||
statusline.updateUrl();
|
||||
commandline.clear();
|
||||
},
|
||||
|
||||
@@ -660,8 +660,7 @@ const Buffer = Module("buffer", {
|
||||
* controller.
|
||||
*/
|
||||
get selectionController() config.browser.docShell
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsISelectionDisplay)
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsISelectionDisplay)
|
||||
.QueryInterface(Ci.nsISelectionController),
|
||||
|
||||
/**
|
||||
@@ -1483,12 +1482,9 @@ const Buffer = Module("buffer", {
|
||||
|
||||
config.browser.addProgressListener(this.progressListener, Ci.nsIWebProgress.NOTIFY_ALL);
|
||||
window.XULBrowserWindow = this.progressListener;
|
||||
window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
.treeOwner
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIXULWindow)
|
||||
window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem).treeOwner
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIXULWindow)
|
||||
.XULBrowserWindow = this.progressListener;
|
||||
|
||||
let appContent = document.getElementById("appcontent");
|
||||
|
||||
@@ -594,8 +594,7 @@ const RangeFind = Class("RangeFind", {
|
||||
this.range = range;
|
||||
this.document = range.startContainer.ownerDocument;
|
||||
this.window = this.document.defaultView;
|
||||
this.docShell = this.window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
this.docShell = this.window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell);
|
||||
|
||||
if (this.selection == null)
|
||||
@@ -629,8 +628,7 @@ const RangeFind = Class("RangeFind", {
|
||||
},
|
||||
|
||||
get selectionController() this.docShell
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsISelectionDisplay)
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsISelectionDisplay)
|
||||
.QueryInterface(Ci.nsISelectionController),
|
||||
get selection() {
|
||||
try {
|
||||
|
||||
@@ -263,7 +263,7 @@ lookup:
|
||||
}
|
||||
|
||||
let process = services.create("process");
|
||||
let isMain = services.get("threadManager").isMainThread;
|
||||
let isMain = services.get("threading").isMainThread;
|
||||
|
||||
process.init(file);
|
||||
process.run(blocking && !isMain, args.map(String), args.length);
|
||||
@@ -294,7 +294,7 @@ lookup:
|
||||
let dirs = options["runtimepath"];
|
||||
let found = false;
|
||||
|
||||
dactyl.echomsg("Searching for " + paths.join(" ").quote() + " in " + options.get("runtimepath").value, 2);
|
||||
dactyl.echomsg("Searching for " + paths.join(" ").quote() + " in " + options.get("runtimepath").stringValue, 2);
|
||||
|
||||
outer:
|
||||
for (let [, dir] in Iterator(dirs)) {
|
||||
@@ -407,7 +407,7 @@ lookup:
|
||||
stdin.write(input);
|
||||
|
||||
// TODO: implement 'shellredir'
|
||||
if (util.isOS("WINNT")) {
|
||||
if (util.isOS("WINNT") && !/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);
|
||||
}
|
||||
@@ -421,10 +421,8 @@ lookup:
|
||||
let output = stdout.read();
|
||||
if (res > 0)
|
||||
output += "\nshell returned " + res;
|
||||
// if there is only one \n at the end, chop it off
|
||||
else if (output && output.indexOf("\n") == output.length - 1)
|
||||
output = output.substr(0, output.length - 1);
|
||||
|
||||
else if (output)
|
||||
output = output.replace(/^(.*)\n$/, "$1");
|
||||
return output;
|
||||
}) || "";
|
||||
},
|
||||
@@ -442,14 +440,13 @@ lookup:
|
||||
*/
|
||||
withTempFiles: function (func, self) {
|
||||
let args = util.map(util.range(0, func.length), this.createTempFile);
|
||||
if (!args.every(util.identity))
|
||||
return false;
|
||||
|
||||
try {
|
||||
if (!args.every(util.identity))
|
||||
return false;
|
||||
return func.apply(self || this, args);
|
||||
}
|
||||
finally {
|
||||
args.forEach(function (f) f.remove(false));
|
||||
args.forEach(function (f) f && f.remove(false));
|
||||
}
|
||||
}
|
||||
}, {
|
||||
@@ -731,8 +728,6 @@ lookup:
|
||||
var shell, shellcmdflag;
|
||||
if (util.isOS("WINNT")) {
|
||||
shell = "cmd.exe";
|
||||
// TODO: setting 'shell' to "something containing sh" updates
|
||||
// 'shellcmdflag' appropriately at startup on Windows in Vim
|
||||
shellcmdflag = "/c";
|
||||
}
|
||||
else {
|
||||
@@ -768,7 +763,14 @@ lookup:
|
||||
|
||||
options.add(["shellcmdflag", "shcf"],
|
||||
"Flag passed to shell when executing :! and :run commands",
|
||||
"string", shellcmdflag);
|
||||
"string", shellcmdflag,
|
||||
{
|
||||
getter: function (value) {
|
||||
if (this.hasChanged || !util.isOS("WINNT"))
|
||||
return value;
|
||||
return /sh/.test(options["shell"]) ? "-c" : "/c";
|
||||
}
|
||||
});
|
||||
|
||||
options.add(["wildignore", "wig"],
|
||||
"List of file patterns to ignore when completing files",
|
||||
|
||||
@@ -661,7 +661,8 @@ const JavaScript = Module("javascript", {
|
||||
"Use the JavaScript debugger service for JavaScript completion",
|
||||
"boolean", false, {
|
||||
setter: function (value) {
|
||||
services.get("debugger")[value ? "on" : "off"]();
|
||||
if (services.get("debugger").isOn != value)
|
||||
services.get("debugger")[value ? "on" : "off"]();
|
||||
},
|
||||
getter: function () services.get("debugger").isOn
|
||||
});
|
||||
|
||||
@@ -597,8 +597,8 @@ function curry(fn, length, self, acc) {
|
||||
*/
|
||||
function requiresMainThread(callback)
|
||||
function wrapper() {
|
||||
let mainThread = services.get("threadManager").mainThread;
|
||||
if (services.get("threadManager").isMainThread)
|
||||
let mainThread = services.get("threading").mainThread;
|
||||
if (services.get("threading").isMainThread)
|
||||
callback.apply(this, arguments);
|
||||
else
|
||||
mainThread.dispatch(Runnable(this, callback, arguments), mainThread.DISPATCH_NORMAL);
|
||||
|
||||
@@ -50,7 +50,7 @@ const Services = Module("Services", {
|
||||
this.add("stylesheet", "@mozilla.org/content/style-sheet-service;1", Ci.nsIStyleSheetService);
|
||||
this.add("subscriptLoader", "@mozilla.org/moz/jssubscript-loader;1", Ci.mozIJSSubScriptLoader);
|
||||
this.add("tagging", "@mozilla.org/browser/tagging-service;1", Ci.nsITaggingService);
|
||||
this.add("threadManager", "@mozilla.org/thread-manager;1", Ci.nsIThreadManager);
|
||||
this.add("threading", "@mozilla.org/thread-manager;1", Ci.nsIThreadManager);
|
||||
this.add("urifixup", "@mozilla.org/docshell/urifixup;1", Ci.nsIURIFixup);
|
||||
this.add("windowMediator", "@mozilla.org/appshell/window-mediator;1", Ci.nsIWindowMediator);
|
||||
this.add("windowWatcher", "@mozilla.org/embedcomp/window-watcher;1", Ci.nsIWindowWatcher);
|
||||
@@ -69,7 +69,14 @@ const Services = Module("Services", {
|
||||
|
||||
_create: function (classes, ifaces, meth) {
|
||||
try {
|
||||
let res = Cc[classes][meth || "getService"]();
|
||||
for (let i = 0; !res && i < 15; i++) // FIXME: Hack.
|
||||
try {
|
||||
var res = Cc[classes][meth || "getService"]();
|
||||
}
|
||||
catch (e if e.result === Cr.NS_ERROR_XPC_BAD_OP_ON_WN_PROTO) {
|
||||
util.dump(String(e));
|
||||
}
|
||||
|
||||
if (!ifaces)
|
||||
return res.wrappedJSObject;
|
||||
Array.concat(ifaces).forEach(function (iface) res.QueryInterface(iface));
|
||||
|
||||
@@ -106,8 +106,8 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
* @returns {function}
|
||||
*/
|
||||
callInMainThread: function (callback, self) {
|
||||
let mainThread = services.get("threadManager").mainThread;
|
||||
if (services.get("threadManager").isMainThread)
|
||||
let mainThread = services.get("threading").mainThread;
|
||||
if (services.get("threading").isMainThread)
|
||||
callback.call(self);
|
||||
else
|
||||
mainThread.dispatch(Runnable(self, callback, Array.slice(arguments, 2)), mainThread.DISPATCH_NORMAL);
|
||||
@@ -125,7 +125,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
*
|
||||
*/
|
||||
callAsync: function (thread, self, func) {
|
||||
thread = thread || services.get("threadManager").newThread(0);
|
||||
thread = thread || services.get("threading").newThread(0);
|
||||
thread.dispatch(Runnable(self, func, Array.slice(arguments, 3)), thread.DISPATCH_NORMAL);
|
||||
},
|
||||
|
||||
@@ -141,7 +141,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
* @param {function} func The function to execute.
|
||||
*/
|
||||
callInThread: function (thread, func) {
|
||||
thread = thread || services.get("threadManager").newThread(0);
|
||||
thread = thread || services.get("threading").newThread(0);
|
||||
thread.dispatch(Runnable(null, func, Array.slice(arguments, 2)), thread.DISPATCH_SYNC);
|
||||
},
|
||||
|
||||
@@ -593,7 +593,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
return ary;
|
||||
},
|
||||
|
||||
newThread: function () services.get("threadManager").newThread(0),
|
||||
newThread: function () services.get("threading").newThread(0),
|
||||
|
||||
/**
|
||||
* Converts a URI string into a URI object.
|
||||
@@ -940,10 +940,8 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
* @returns {nsISelectionController}
|
||||
*/
|
||||
selectionController: function (win)
|
||||
win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsISelectionDisplay)
|
||||
win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsISelectionDisplay)
|
||||
.QueryInterface(Ci.nsISelectionController),
|
||||
|
||||
/**
|
||||
@@ -955,7 +953,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
* @param {number} delay The time period for which to sleep in milliseconds.
|
||||
*/
|
||||
sleep: function (delay) {
|
||||
let mainThread = services.get("threadManager").mainThread;
|
||||
let mainThread = services.get("threading").mainThread;
|
||||
|
||||
let end = Date.now() + delay;
|
||||
while (Date.now() < end)
|
||||
@@ -1034,7 +1032,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
},
|
||||
|
||||
threadYield: function (flush, interruptable) {
|
||||
let mainThread = services.get("threadManager").mainThread;
|
||||
let mainThread = services.get("threading").mainThread;
|
||||
/* FIXME */
|
||||
util.interrupted = false;
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user