queue render requests
This commit is contained in:
parent
ad6697719e
commit
35694f5e35
3 changed files with 37 additions and 7 deletions
|
|
@ -11,7 +11,7 @@ var Document = function(text, mode) {
|
||||||
this.modified = true;
|
this.modified = true;
|
||||||
this.lines = [];
|
this.lines = [];
|
||||||
this.selection = new Selection(this);
|
this.selection = new Selection(this);
|
||||||
this.$breakpoints = [];
|
this.$breakpoints = [];
|
||||||
|
|
||||||
this.listeners = [];
|
this.listeners = [];
|
||||||
if (mode) {
|
if (mode) {
|
||||||
|
|
|
||||||
|
|
@ -115,11 +115,13 @@ var Editor = function(renderer, doc) {
|
||||||
this.bgTokenizer.setLines(this.doc.lines);
|
this.bgTokenizer.setLines(this.doc.lines);
|
||||||
this.bgTokenizer.start(0);
|
this.bgTokenizer.start(0);
|
||||||
|
|
||||||
this.renderer.draw();
|
var _self = this;
|
||||||
this.onCursorChange();
|
this.renderer.draw(false, function() {
|
||||||
this.onSelectionChange();
|
_self.onCursorChange();
|
||||||
this.onDocumentChangeBreakpoint();
|
_self.onSelectionChange();
|
||||||
this.renderer.scrollToRow(doc.getScrollTopRow());
|
_self.onDocumentChangeBreakpoint();
|
||||||
|
_self.renderer.scrollToRow(doc.getScrollTopRow());
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getDocument = function() {
|
this.getDocument = function() {
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,8 @@ var VirtualRenderer = function(container) {
|
||||||
column : 0
|
column : 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.$drawCallbacks = [];
|
||||||
|
|
||||||
this.$updatePrintMargin();
|
this.$updatePrintMargin();
|
||||||
this.onResize();
|
this.onResize();
|
||||||
|
|
||||||
|
|
@ -194,7 +196,31 @@ var VirtualRenderer = function(container) {
|
||||||
this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
|
this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.draw = function(scrollOnly) {
|
this.draw = function(scrollOnly, callback) {
|
||||||
|
if (this.$drawTimer) {
|
||||||
|
clearInterval(this.$drawTimer);
|
||||||
|
this.scrollOnly = this.scrollOnly && scrollOnly;
|
||||||
|
} else {
|
||||||
|
this.scollOnly = scrollOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callback)
|
||||||
|
this.$drawCallbacks.push(callback);
|
||||||
|
|
||||||
|
var _self = this;
|
||||||
|
this.$drawTimer = setTimeout(function() {
|
||||||
|
_self.$draw(_self.scrollOnly);
|
||||||
|
for (var i=0; i<_self.$drawCallbacks.length; i++)
|
||||||
|
_self.$drawCallbacks[i]();
|
||||||
|
|
||||||
|
_self.$drawCallbacks = [];
|
||||||
|
delete _self.$drawTimer;
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$draw = function(scrollOnly) {
|
||||||
|
//var start = new Date();
|
||||||
|
|
||||||
var lines = this.lines;
|
var lines = this.lines;
|
||||||
|
|
||||||
var offset = this.scrollTop % this.lineHeight;
|
var offset = this.scrollTop % this.lineHeight;
|
||||||
|
|
@ -235,7 +261,9 @@ var VirtualRenderer = function(container) {
|
||||||
this.$gutterLayer.element.style.marginTop = (-offset) + "px";
|
this.$gutterLayer.element.style.marginTop = (-offset) + "px";
|
||||||
this.$gutterLayer.update(layerConfig);
|
this.$gutterLayer.update(layerConfig);
|
||||||
|
|
||||||
|
//console.log("compute", new Date() - start, "ms")
|
||||||
this.$updateScrollBar();
|
this.$updateScrollBar();
|
||||||
|
//console.log("compute+render", new Date() - start, "ms")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue