Commit 005698a4 authored by ThorbenQuast's avatar ThorbenQuast
Browse files

editor (output handling): enable autoClear preference, prevent 'append flood' by

appending bundled new lines only every 0.5s
parent da3f5b5d
......@@ -6,6 +6,8 @@ var CodeEditorOutput = Emitter.extend({
this.view = view;
this.textSet = false;
this.temporaryText = "";
this.appendInterval = null;
this.preNode = null;
......@@ -54,14 +56,22 @@ var CodeEditorOutput = Emitter.extend({
// register events
this.view.onSocket("start", function(data) {
var autoClear = self.view.getPreference("autoClear");
self.textSet = self.textSet && !autoClear;
self.append(
self.getDate() + ": \n" +
"executing \"" + data.command + "\"\n" +
"--------------------\n" +
"OUTPUT:\n\n");
self.appendInterval = setInterval(function() {
self.append();
}, 500);
}).onSocket("data", function(data) {
self.append(data);
self.attachToTemporary(data);
}).onSocket("done", function(data) {
clearInterval(self.appendInterval);
self.appendInterval = null;
self.append(); //append the remaining temporaries
self.append(
"\n--------------------\n" +
(data.aborted ? "process was aborted!\n" : "") +
......@@ -174,7 +184,6 @@ var CodeEditorOutput = Emitter.extend({
this.preNode.text(text);
return this;
}
this.initialClear();
var textarray = text.split("\n");
var maxlines = this.view.getPreference("maxLines") < textarray.length ?
this.view.getPreference("maxLines") : textarray.length;
......@@ -187,11 +196,15 @@ var CodeEditorOutput = Emitter.extend({
return this.preNode.text();
},
attachToTemporary: function(text) {
this.temporaryText = this.temporaryText + String(text);
},
append: function(text) {
this.initialClear();
var wasAtBottom = this.isAtBottom();
this.setText(this.getText() + String(text));
this.setText(this.getText() + String(text === undefined ? this.temporaryText : text));
this.temporaryText = "";
if (wasAtBottom)
this.goToBottom();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment