this._terminal.y++;
if (this._terminal.y > this._terminal.scrollBottom) {
this._terminal.y--;
- this._terminal.scroll();
+ this._terminal.scroll(true);
}
} else {
- this._terminal.x = this._terminal.cols - 1;
if (ch_width === 2) // FIXME: check for xterm behavior
return;
}
const removed = this._terminal.lines.get(this._terminal.y + this._terminal.ybase).pop();
if (removed[2] === 0
&& this._terminal.lines.get(row)[this._terminal.cols - 2]
- && this._terminal.lines.get(row)[this._terminal.cols - 2][2] === 2)
+ && this._terminal.lines.get(row)[this._terminal.cols - 2][2] === 2) {
this._terminal.lines.get(row)[this._terminal.cols - 2] = [this._terminal.curAttr, ' ', 1];
+ }
// insert empty cell at cursor
this._terminal.lines.get(row).splice(this._terminal.x, 0, [this._terminal.curAttr, ' ', 1]);
this._terminal.y--;
this._terminal.scroll();
}
+ // If the end of the line is hit, prevent this action from wrapping around to the next line.
+ if (this._terminal.x >= this._terminal.cols) {
+ this._terminal.x--;
+ }
}
/**
if (this._terminal.y >= this._terminal.rows) {
this._terminal.y = this._terminal.rows - 1;
}
+ // If the end of the line is hit, prevent this action from wrapping around to the next line.
+ if (this._terminal.x >= this._terminal.cols) {
+ this._terminal.x--;
+ }
}
/**
if (param < 1) {
param = 1;
}
+ // If the end of the line is hit, prevent this action from wrapping around to the next line.
+ if (this._terminal.x >= this._terminal.cols) {
+ this._terminal.x--;
+ }
this._terminal.x -= param;
if (this._terminal.x < 0) {
this._terminal.x = 0;
while (j--) this._terminal.eraseLine(j);
break;
case 3:
- ; // no saved lines
+ // Clear scrollback (everything not in viewport)
+ const scrollBackSize = this._terminal.lines.length - this._terminal.rows;
+ if (scrollBackSize > 0) {
+ this._terminal.lines.trimStart(scrollBackSize);
+ this._terminal.ybase = Math.max(this._terminal.ybase - scrollBackSize, 0);
+ this._terminal.ydisp = Math.max(this._terminal.ydisp - scrollBackSize, 0);
+ }
break;
}
}
if (this._terminal.y >= this._terminal.rows) {
this._terminal.y = this._terminal.rows - 1;
}
+ // If the end of the line is hit, prevent this action from wrapping around to the next line.
+ if (this._terminal.x >= this._terminal.cols) {
+ this._terminal.x--;
+ }
}
/**
this._terminal.vt200Mouse = params[0] === 1000;
this._terminal.normalMouse = params[0] > 1000;
this._terminal.mouseEvents = true;
- this._terminal.element.style.cursor = 'default';
+ this._terminal.element.classList.add('enable-mouse-events');
+ this._terminal.selectionManager.disable();
this._terminal.log('Binding to mouse events.');
break;
case 1004: // send focusin/focusout events
this._terminal.vt200Mouse = false;
this._terminal.normalMouse = false;
this._terminal.mouseEvents = false;
- this._terminal.element.style.cursor = '';
+ this._terminal.element.classList.remove('enable-mouse-events');
+ this._terminal.selectionManager.enable();
break;
case 1004: // send focusin/focusout events
this._terminal.sendFocus = false;
this._terminal.scrollBottom = this._terminal.normal.scrollBottom;
this._terminal.tabs = this._terminal.normal.tabs;
this._terminal.normal = null;
+ // Ensure the selection manager has the correct buffer
+ this._terminal.selectionManager.setBuffer(this._terminal.lines);
// if (params === 1049) {
// this.x = this.savedX;
// this.y = this.savedY;
// }
- this._terminal.queueRefresh(0, this._terminal.rows - 1);
+ this._terminal.refresh(0, this._terminal.rows - 1);
this._terminal.viewport.syncScrollArea();
this._terminal.showCursor();
}
this._terminal.cursorHidden = false;
this._terminal.insertMode = false;
this._terminal.originMode = false;
- this._terminal.wraparoundMode = false; // autowrap
+ this._terminal.wraparoundMode = true; // defaults: xterm - true, vt100 - false
this._terminal.applicationKeypad = false; // ?
this._terminal.viewport.syncScrollArea();
this._terminal.applicationCursor = false;
public setScrollRegion(params: number[]): void {
if (this._terminal.prefix) return;
this._terminal.scrollTop = (params[0] || 1) - 1;
- this._terminal.scrollBottom = (params[1] || this._terminal.rows) - 1;
+ this._terminal.scrollBottom = (params[1] && params[1] <= this._terminal.rows ? params[1] : this._terminal.rows) - 1;
this._terminal.x = 0;
this._terminal.y = 0;
}