- // resize cols
- j = this.cols;
- if (j < x) {
- ch = [this.defAttr, ' ', 1]; // does xterm use the default attr?
- i = this.lines.length;
- while (i--) {
- while (this.lines.get(i).length < x) {
- this.lines.get(i).push(ch);
- }
- }
- }
-
- this.cols = x;
- this.setupStops(this.cols);
-
- // resize rows
- j = this.rows;
- addToY = 0;
- if (j < y) {
- el = this.element;
- while (j++ < y) {
- // y is rows, not this.y
- if (this.lines.length < y + this.ybase) {
- if (this.ybase > 0 && this.lines.length <= this.ybase + this.y + addToY + 1) {
- // There is room above the buffer and there are no empty elements below the line,
- // scroll up
- this.ybase--;
- addToY++
- if (this.ydisp > 0) {
- // Viewport is at the top of the buffer, must increase downwards
- this.ydisp--;
- }
- } else {
- // Add a blank line if there is no buffer left at the top to scroll to, or if there
- // are blank lines after the cursor
- this.lines.push(this.blankLine());
- }
- }
- if (this.children.length < y) {
- this.insertRow();
- }
- }
- } else { // (j > y)
- while (j-- > y) {
- if (this.lines.length > y + this.ybase) {
- if (this.lines.length > this.ybase + this.y + 1) {
- // The line is a blank line below the cursor, remove it
- this.lines.pop();
- } else {
- // The line is the cursor, scroll down
- this.ybase++;
- this.ydisp++;
- }
- }
- if (this.children.length > y) {
- el = this.children.shift();
- if (!el) continue;
- el.parentNode.removeChild(el);
- }
- }
- }
- this.rows = y;