mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 21:52:27 +01:00
Merge change from key-processing. Closes issue #303.
This commit is contained in:
@@ -1224,17 +1224,19 @@ var CommandLine = Module("commandline", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
withOutputToString: function (fn, self) {
|
withOutputToString: function (fn, self) {
|
||||||
let buffer = [];
|
|
||||||
dactyl.registerObserver("echoLine", observe, true);
|
dactyl.registerObserver("echoLine", observe, true);
|
||||||
dactyl.registerObserver("echoMultiline", observe, true);
|
dactyl.registerObserver("echoMultiline", observe, true);
|
||||||
|
|
||||||
|
let output = [];
|
||||||
function observe(str, highlight, dom) {
|
function observe(str, highlight, dom) {
|
||||||
buffer.push(dom && !isString(str) ? util.domToString(dom) : str);
|
output.push(dom && !isString(str) ? dom : str);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.savingOutput = true;
|
this.savingOutput = true;
|
||||||
dactyl.trapErrors.apply(dactyl, [fn, self].concat(Array.slice(arguments, 2)));
|
dactyl.trapErrors.apply(dactyl, [fn, self].concat(Array.slice(arguments, 2)));
|
||||||
this.savingOutput = false;
|
this.savingOutput = false;
|
||||||
return buffer.join("\n");
|
return output.map(function (elem) elem instanceof Node ? util.domToString(elem) : elem)
|
||||||
|
.join("\n");
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user