Set charMeasure.height values to each row height

This commit is contained in:
yutaka
2017-03-03 07:57:05 +00:00
parent 8693d067e3
commit 43cb4f471f
+17 -6
View File
@@ -562,6 +562,7 @@ Terminal.bindKeys = function(term) {
Terminal.prototype.insertRow = function (row) { Terminal.prototype.insertRow = function (row) {
if (typeof row != 'object') { if (typeof row != 'object') {
row = document.createElement('div'); row = document.createElement('div');
row.style.height = this.charMeasure.height + 'px';
} }
this.rowContainer.appendChild(row); this.rowContainer.appendChild(row);
@@ -642,17 +643,18 @@ Terminal.prototype.open = function(parent) {
this.charSizeStyleElement = document.createElement('style'); this.charSizeStyleElement = document.createElement('style');
this.helperContainer.appendChild(this.charSizeStyleElement); this.helperContainer.appendChild(this.charSizeStyleElement);
this.charMeasure = new CharMeasure(document, this.helperContainer);
this.charMeasure.on('charsizechanged', function () {
self.updateCharSizeCSS();
self.updateRowHeight();
});
this.charMeasure.measure();
for (; i < this.rows; i++) { for (; i < this.rows; i++) {
this.insertRow(); this.insertRow();
} }
this.parent.appendChild(this.element); this.parent.appendChild(this.element);
this.charMeasure = new CharMeasure(document, this.helperContainer);
this.charMeasure.on('charsizechanged', function () {
self.updateCharSizeCSS();
});
this.charMeasure.measure();
this.viewport = new Viewport(this, this.viewportElement, this.viewportScrollArea, this.charMeasure); this.viewport = new Viewport(this, this.viewportElement, this.viewportScrollArea, this.charMeasure);
this.renderer = new Renderer(this); this.renderer = new Renderer(this);
@@ -714,6 +716,15 @@ Terminal.prototype.updateCharSizeCSS = function() {
this.charSizeStyleElement.textContent = '.xterm-wide-char{width:' + (this.charMeasure.width * 2) + 'px;}'; this.charSizeStyleElement.textContent = '.xterm-wide-char{width:' + (this.charMeasure.width * 2) + 'px;}';
} }
/**
* Updates the height for each rows
*/
Terminal.prototype.updateRowHeight = function() {
for (var i = 0; i < this.children.length; ++i) {
this.children[i].style.height = this.charMeasure.height + 'px';
}
}
/** /**
* XTerm mouse events * XTerm mouse events
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking