re-implement clear, make it not buggy, fix CMD+K (#1796)

This commit is contained in:
Guillermo Rauch 2017-05-07 14:57:56 -07:00 committed by GitHub
parent fc51f97283
commit c491f7d2e1
2 changed files with 1 additions and 51 deletions

View file

@ -177,14 +177,7 @@ export default class Term extends Component {
}
clear() {
this.term.clearPreserveCursorRow();
// If cursor is still not at the top, a command is probably
// running and we'd like to delete the whole screen.
// Move cursor to top
if (this.term.getCursorRow() !== 0) {
this.write('\x1B[0;0H\x1B[2J');
}
this.term.onVTKeystroke('\f');
}
moveWordLeft() {

View file

@ -260,49 +260,6 @@ hterm.Keyboard.prototype.onKeyDown_ = function (e) {
return oldKeyDown.call(this, e);
};
// we re-implement `wipeContents` to preserve the line
// and cursor position that the client is in.
// otherwise the user ends up with a completely clear
// screen which is really strange
hterm.Terminal.prototype.clearPreserveCursorRow = function () {
this.scrollbackRows_.length = 0;
this.scrollPort_.resetCache();
[this.primaryScreen_, this.alternateScreen_].forEach(screen => {
const bottom = screen.getHeight();
if (bottom > 0) {
this.renumberRows_(0, bottom);
const x = screen.cursorPosition.column;
const y = screen.cursorPosition.row;
if (x === 0) {
// Empty screen, nothing to do.
return;
}
// here we move the row that the user was focused on
// to the top of the screen
this.moveRows_(y, 1, 0);
for (let i = 1; i < bottom; i++) {
screen.setCursorPosition(i, 0);
screen.clearCursorRow();
}
// we restore the cursor position
screen.setCursorPosition(0, x);
}
});
this.syncCursorPosition_();
this.scrollPort_.invalidate();
// this will avoid a bug where the `wipeContents`
// hterm API doesn't send the scroll to the top
this.scrollPort_.redraw_();
};
const oldOnMouse = hterm.Terminal.prototype.onMouse_;
hterm.Terminal.prototype.onMouse_ = function (e) {
// override `preventDefault` to not actually