mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 04:07:59 +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]), {
|
XPCOM([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]), {
|
||||||
init: function (doc, callback) {
|
init: function (doc, callback) {
|
||||||
this.callback = callable(callback) ? 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 url = isString(doc) ? doc : doc.location.href;
|
||||||
let uri = util.newURI(url, charset);
|
let uri = util.newURI(url, charset);
|
||||||
@@ -1018,8 +1022,8 @@ const Buffer = Module("buffer", {
|
|||||||
let encoder = services.HtmlEncoder();
|
let encoder = services.HtmlEncoder();
|
||||||
encoder.init(doc, "text/unicode", encoder.OutputRaw|encoder.OutputPreformatted);
|
encoder.init(doc, "text/unicode", encoder.OutputRaw|encoder.OutputPreformatted);
|
||||||
temp.write(encoder.encodeToString(), ">");
|
temp.write(encoder.encodeToString(), ">");
|
||||||
this.callback(temp);
|
return this.callback(temp);
|
||||||
}, this);
|
}, this, true);
|
||||||
|
|
||||||
let file = util.getFile(uri);
|
let file = util.getFile(uri);
|
||||||
if (file)
|
if (file)
|
||||||
@@ -1038,10 +1042,11 @@ const Buffer = Module("buffer", {
|
|||||||
onStateChange: function (progress, request, flag, status) {
|
onStateChange: function (progress, request, flag, status) {
|
||||||
if ((flag & Ci.nsIWebProgressListener.STATE_STOP) && status == 0) {
|
if ((flag & Ci.nsIWebProgressListener.STATE_STOP) && status == 0) {
|
||||||
try {
|
try {
|
||||||
this.callback(this.file);
|
var ok = this.callback(this.file);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
this.file.remove(false);
|
if (ok !== true)
|
||||||
|
this.file.remove(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -241,12 +241,14 @@ const Editor = Module("editor", {
|
|||||||
return -1;
|
return -1;
|
||||||
},
|
},
|
||||||
|
|
||||||
editFileExternally: function (path, line, column, async) {
|
editFileExternally: function (args, blocking) {
|
||||||
let args = options.get("editor").format({ file: path, line: line, column: column });
|
if (!isObject(args))
|
||||||
|
args = { file: args };
|
||||||
|
let args = options.get("editor").format(args);
|
||||||
|
|
||||||
dactyl.assert(args.length >= 1, "No editor specified");
|
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?
|
// TODO: clean up with 2 functions for textboxes and currentEditor?
|
||||||
@@ -309,11 +311,10 @@ const Editor = Module("editor", {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let timer = services.Timer();
|
let timer = services.Timer(update, 100, services.Timer.TYPE_REPEATING_SLACK);
|
||||||
timer.initWithCallback({ notify: update }, 100, timer.TYPE_REPEATING_SLACK);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.editFileExternally(tmpfile.path, line, column);
|
this.editFileExternally({ file: tmpfile.path, line: line, column: column }, true);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
|
|||||||
@@ -230,12 +230,9 @@ const IO = Module("io", {
|
|||||||
*
|
*
|
||||||
* @param {string} program The program to run.
|
* @param {string} program The program to run.
|
||||||
* @param {string[]} args An array of arguments to pass to *program*.
|
* @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) {
|
run: function (program, args, blocking) {
|
||||||
args = args || [];
|
args = args || [];
|
||||||
blocking = !!blocking;
|
|
||||||
|
|
||||||
let file;
|
let file;
|
||||||
|
|
||||||
@@ -274,12 +271,19 @@ lookup:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
let process = services.Process();
|
let process = services.Process(file);
|
||||||
|
|
||||||
process.init(file);
|
|
||||||
process.run(false, args.map(String), args.length);
|
process.run(false, args.map(String), args.length);
|
||||||
try {
|
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)
|
while (process.isRunning)
|
||||||
util.threadYield(false, true);
|
util.threadYield(false, true);
|
||||||
}
|
}
|
||||||
@@ -453,16 +457,18 @@ lookup:
|
|||||||
* @returns {boolean} false if temp files couldn't be created,
|
* @returns {boolean} false if temp files couldn't be created,
|
||||||
* otherwise, the return value of *func*.
|
* 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);
|
let args = util.map(util.range(0, func.length), this.createTempFile);
|
||||||
try {
|
try {
|
||||||
if (!args.every(util.identity))
|
if (!args.every(util.identity))
|
||||||
return false;
|
return false;
|
||||||
return func.apply(self || this, args);
|
var res = func.apply(self || this, args);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
args.forEach(function (f) f && f.remove(false));
|
if (!checked || res !== true)
|
||||||
|
args.forEach(function (f) f && f.remove(false));
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ const Services = Module("Services", {
|
|||||||
this.addClass("Find", "@mozilla.org/embedcomp/rangefind;1", Ci.nsIFind);
|
this.addClass("Find", "@mozilla.org/embedcomp/rangefind;1", Ci.nsIFind);
|
||||||
this.addClass("HtmlConverter","@mozilla.org/widget/htmlformatconverter;1", Ci.nsIFormatConverter);
|
this.addClass("HtmlConverter","@mozilla.org/widget/htmlformatconverter;1", Ci.nsIFormatConverter);
|
||||||
this.addClass("HtmlEncoder", "@mozilla.org/layout/htmlCopyEncoder;1", Ci.nsIDocumentEncoder);
|
this.addClass("HtmlEncoder", "@mozilla.org/layout/htmlCopyEncoder;1", Ci.nsIDocumentEncoder);
|
||||||
this.addClass("Process", "@mozilla.org/process/util;1", Ci.nsIProcess);
|
this.addClass("Process", "@mozilla.org/process/util;1", Ci.nsIProcess, "init");
|
||||||
this.addClass("String", "@mozilla.org/supports-string;1", Ci.nsISupportsString);
|
this.addClass("String", "@mozilla.org/supports-string;1", Ci.nsISupportsString);
|
||||||
this.addClass("Timer", "@mozilla.org/timer;1", Ci.nsITimer);
|
this.addClass("Timer", "@mozilla.org/timer;1", Ci.nsITimer, "initWithCallback");
|
||||||
this.addClass("Xmlhttp", "@mozilla.org/xmlextras/xmlhttprequest;1", Ci.nsIXMLHttpRequest);
|
this.addClass("Xmlhttp", "@mozilla.org/xmlextras/xmlhttprequest;1", Ci.nsIXMLHttpRequest);
|
||||||
this.addClass("ZipReader", "@mozilla.org/libjar/zip-reader;1", Ci.nsIZipReader, "open");
|
this.addClass("ZipReader", "@mozilla.org/libjar/zip-reader;1", Ci.nsIZipReader, "open");
|
||||||
this.addClass("ZipWriter", "@mozilla.org/zipwriter;1", Ci.nsIZipWriter);
|
this.addClass("ZipWriter", "@mozilla.org/zipwriter;1", Ci.nsIZipWriter);
|
||||||
@@ -80,7 +80,7 @@ const Services = Module("Services", {
|
|||||||
if (!ifaces)
|
if (!ifaces)
|
||||||
return res.wrappedJSObject;
|
return res.wrappedJSObject;
|
||||||
Array.concat(ifaces).forEach(function (iface) res.QueryInterface(iface));
|
Array.concat(ifaces).forEach(function (iface) res.QueryInterface(iface));
|
||||||
if (init)
|
if (init && args.length)
|
||||||
res[init].apply(res, args);
|
res[init].apply(res, args);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,9 @@ const Services = Module("Services", {
|
|||||||
*/
|
*/
|
||||||
addClass: function (name, class_, ifaces, init) {
|
addClass: function (name, class_, ifaces, init) {
|
||||||
const self = this;
|
const self = this;
|
||||||
return this[name] = function () self._create(class_, ifaces, "createInstance", init, arguments);
|
this[name] = function () self._create(class_, ifaces, "createInstance", init, arguments);
|
||||||
|
update.apply(null, [this[name]].concat(ifaces));
|
||||||
|
return this[name];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user