Commit c114b715 authored by Benjamin Fischer's avatar Benjamin Fischer
Browse files

codeeditor: fix "stay at bottom of output" feature:

 allow scrolling during execution
 remove animated scroll to be able to keep up fast output (multiple lines withing some ms)
parent f72b4e0c
......@@ -78,22 +78,18 @@ var CodeEditorOutput = Emitter.extend({
// register events
this.view.onSocket('start', function(data) {
self.wasAtBottom = self.isAtBottom();
self.append(
"executing \"" + data.command + "\"\n" +
"--------------------\n" +
"OUTPUT:\n\n");
if (wasAtBottom) self.goToBottom();
}).onSocket('data', function(data) {
self.append(data);
if (self.wasAtBottom) self.goToBottom();
}).onSocket('done', function(data) {
self.append(
"\n--------------------\n" +
(data.aborted ? "process was aborted!\n" : "") +
"runtime: " + self.formatRuntime(data.runtime) + "\n" +
"====================\n\n\n");
if (self.wasAtBottom) self.goToBottom();
self.running = false;
self.updateExeButtons();
});
......@@ -223,12 +219,12 @@ var CodeEditorOutput = Emitter.extend({
append: function(text) {
this.initialClear();
this.setText(this.getText() + String(text));
/*
var wasAtBottom = this.isAtBottom();
this.setText(this.getText() + String(text));
if (wasAtBottom)
this.goToBottom();
*/
return this;
},
......@@ -247,9 +243,7 @@ var CodeEditorOutput = Emitter.extend({
goTo: function(offset) {
if (this.preNode)
this.preNode.animate({
"scrollTop": offset
}, 100);
this.preNode.scrollTop(offset);
return this;
},
......@@ -265,8 +259,8 @@ var CodeEditorOutput = Emitter.extend({
},
isAtBottom: function() {
var offset = this.preNode.get(0).scrollHeight - this.preNode.innerHeight();
return offset == this.preNode.scrollTop();
var offset = this.preNode.get(0).scrollHeight - this.preNode.innerHeight() - 5;
return offset <= this.preNode.scrollTop();
},
saveAs: function() {
......
Supports Markdown
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