mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-13 23:45:47 +01:00
Fix gF and so forth.
This commit is contained in:
@@ -1007,7 +1007,11 @@ const Buffer = Module("buffer", {
|
||||
XPCOM([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]), {
|
||||
init: function (doc, callback) {
|
||||
this.callback = callable(callback) ? callback :
|
||||
function (file) editor.editFileExternally(file.path, callback, null, true);
|
||||
function (file) {
|
||||
editor.editFileExternally({ file: file.path, line: callback },
|
||||
function () { file.remove(false) });
|
||||
return true;
|
||||
}
|
||||
|
||||
let url = isString(doc) ? doc : doc.location.href;
|
||||
let uri = util.newURI(url, charset);
|
||||
@@ -1018,8 +1022,8 @@ const Buffer = Module("buffer", {
|
||||
let encoder = services.HtmlEncoder();
|
||||
encoder.init(doc, "text/unicode", encoder.OutputRaw|encoder.OutputPreformatted);
|
||||
temp.write(encoder.encodeToString(), ">");
|
||||
this.callback(temp);
|
||||
}, this);
|
||||
return this.callback(temp);
|
||||
}, this, true);
|
||||
|
||||
let file = util.getFile(uri);
|
||||
if (file)
|
||||
@@ -1038,10 +1042,11 @@ const Buffer = Module("buffer", {
|
||||
onStateChange: function (progress, request, flag, status) {
|
||||
if ((flag & Ci.nsIWebProgressListener.STATE_STOP) && status == 0) {
|
||||
try {
|
||||
this.callback(this.file);
|
||||
var ok = this.callback(this.file);
|
||||
}
|
||||
finally {
|
||||
this.file.remove(false);
|
||||
if (ok !== true)
|
||||
this.file.remove(false);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -241,12 +241,14 @@ const Editor = Module("editor", {
|
||||
return -1;
|
||||
},
|
||||
|
||||
editFileExternally: function (path, line, column, async) {
|
||||
let args = options.get("editor").format({ file: path, line: line, column: column });
|
||||
editFileExternally: function (args, blocking) {
|
||||
if (!isObject(args))
|
||||
args = { file: args };
|
||||
let args = options.get("editor").format(args);
|
||||
|
||||
dactyl.assert(args.length >= 1, "No editor specified");
|
||||
|
||||
io.run(io.expandPath(args.shift()), args, !async);
|
||||
io.run(io.expandPath(args.shift()), args, blocking);
|
||||
},
|
||||
|
||||
// TODO: clean up with 2 functions for textboxes and currentEditor?
|
||||
@@ -309,11 +311,10 @@ const Editor = Module("editor", {
|
||||
}
|
||||
}
|
||||
|
||||
let timer = services.Timer();
|
||||
timer.initWithCallback({ notify: update }, 100, timer.TYPE_REPEATING_SLACK);
|
||||
let timer = services.Timer(update, 100, services.Timer.TYPE_REPEATING_SLACK);
|
||||
|
||||
try {
|
||||
this.editFileExternally(tmpfile.path, line, column);
|
||||
this.editFileExternally({ file: tmpfile.path, line: line, column: column }, true);
|
||||
}
|
||||
finally {
|
||||
timer.cancel();
|
||||
|
||||
@@ -230,12 +230,9 @@ const IO = Module("io", {
|
||||
*
|
||||
* @param {string} program The program to run.
|
||||
* @param {string[]} args An array of arguments to pass to *program*.
|
||||
* @param {boolean} blocking Whether to wait until the process terminates.
|
||||
*/
|
||||
blockingProcesses: [],
|
||||
run: function (program, args, blocking) {
|
||||
args = args || [];
|
||||
blocking = !!blocking;
|
||||
|
||||
let file;
|
||||
|
||||
@@ -274,12 +271,19 @@ lookup:
|
||||
return -1;
|
||||
}
|
||||
|
||||
let process = services.Process();
|
||||
|
||||
process.init(file);
|
||||
let process = services.Process(file);
|
||||
process.run(false, args.map(String), args.length);
|
||||
try {
|
||||
if (blocking)
|
||||
if (callable(blocking))
|
||||
var timer = services.Timer(
|
||||
function () {
|
||||
if (!process.isRunning) {
|
||||
timer.cancel();
|
||||
callback();
|
||||
}
|
||||
},
|
||||
100, services.Timer.TYPE_REPEATING_SLACK);
|
||||
else if (blocking)
|
||||
while (process.isRunning)
|
||||
util.threadYield(false, true);
|
||||
}
|
||||
@@ -453,16 +457,18 @@ lookup:
|
||||
* @returns {boolean} false if temp files couldn't be created,
|
||||
* otherwise, the return value of *func*.
|
||||
*/
|
||||
withTempFiles: function (func, self) {
|
||||
withTempFiles: function (func, self, checked) {
|
||||
let args = util.map(util.range(0, func.length), this.createTempFile);
|
||||
try {
|
||||
if (!args.every(util.identity))
|
||||
return false;
|
||||
return func.apply(self || this, args);
|
||||
var res = func.apply(self || this, args);
|
||||
}
|
||||
finally {
|
||||
args.forEach(function (f) f && f.remove(false));
|
||||
if (!checked || res !== true)
|
||||
args.forEach(function (f) f && f.remove(false));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}, {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user