diff --git a/fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.in b/fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.in new file mode 100644 index 00000000..b279f92a --- /dev/null +++ b/fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.in @@ -0,0 +1,24 @@ +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x12 diff --git a/fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.text b/fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.text new file mode 100644 index 00000000..3acccf1a --- /dev/null +++ b/fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.text @@ -0,0 +1,25 @@ +a +b +c +d +e +f +g +h +i +2 +k +l +m +n +o +p +q +r +1 +t +u +v +w +x + diff --git a/fixtures/escape_sequence_files/t0079-DECSTBM_VPR.in b/fixtures/escape_sequence_files/t0079-DECSTBM_VPR.in new file mode 100644 index 00000000..f818ad7f --- /dev/null +++ b/fixtures/escape_sequence_files/t0079-DECSTBM_VPR.in @@ -0,0 +1,24 @@ +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x1 diff --git a/fixtures/escape_sequence_files/t0079-DECSTBM_VPR.text b/fixtures/escape_sequence_files/t0079-DECSTBM_VPR.text new file mode 100644 index 00000000..a2d66f8e --- /dev/null +++ b/fixtures/escape_sequence_files/t0079-DECSTBM_VPR.text @@ -0,0 +1,25 @@ +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x +1 diff --git a/src/InputHandler.ts b/src/InputHandler.ts index f243433a..746f4345 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -616,7 +616,13 @@ export class InputHandler extends Disposable implements IInputHandler { * Cursor Up Ps Times (default = 1) (CUU). */ public cursorUp(params: IParams): void { - this._moveCursor(0, -(params.params[0] || 1)); + // stop at scrollTop + const diffToTop = this._bufferService.buffer.y - this._bufferService.buffer.scrollTop; + if (diffToTop >= 0) { + this._moveCursor(0, -Math.min(diffToTop, params.params[0] || 1)); + } else { + this._moveCursor(0, -(params.params[0] || 1)); + } } /** @@ -624,7 +630,13 @@ export class InputHandler extends Disposable implements IInputHandler { * Cursor Down Ps Times (default = 1) (CUD). */ public cursorDown(params: IParams): void { - this._moveCursor(0, params.params[0] || 1); + // stop at scrollBottom + const diffToBottom = this._bufferService.buffer.scrollBottom - this._bufferService.buffer.y; + if (diffToBottom >= 0) { + this._moveCursor(0, Math.min(diffToBottom, params.params[0] || 1)); + } else { + this._moveCursor(0, params.params[0] || 1); + } } /** @@ -649,7 +661,7 @@ export class InputHandler extends Disposable implements IInputHandler { * Other than cursorDown (CUD) also set the cursor to first column. */ public cursorNextLine(params: IParams): void { - this._moveCursor(0, params.params[0] || 1); + this.cursorDown(params); this._bufferService.buffer.x = 0; } @@ -659,7 +671,7 @@ export class InputHandler extends Disposable implements IInputHandler { * Other than cursorUp (CUU) also set the cursor to first column. */ public cursorPrecedingLine(params: IParams): void { - this._moveCursor(0, -(params.params[0] || 1)); + this.cursorUp(params); this._bufferService.buffer.x = 0; } diff --git a/src/Terminal2.test.ts b/src/Terminal2.test.ts index f87ecd3a..2462fb19 100644 --- a/src/Terminal2.test.ts +++ b/src/Terminal2.test.ts @@ -17,7 +17,6 @@ const ROWS = 25; const TESTFILES = glob.sync('**/escape_sequence_files/*.in', { cwd: path.join(__dirname, '..')}); const SKIP_FILES = [ - 't0075-DECSTBM_CUU_CUD.in', 't0076-DECSTBM_IL_DL.in', // not working due to lineFeed 't0077-DECSTBM_quirks.in', 't0084-CBT.in',