From 05cbe41d39df839135f00d9d17976f26cba89a82 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 4 Nov 2017 03:20:24 -0700 Subject: [PATCH] scrollDisp -> scrollLines Fixes #902 --- fixtures/typings-test/typings-test.ts | 8 ++++---- src/Interfaces.ts | 2 +- src/SelectionManager.ts | 2 +- src/Terminal.test.ts | 22 +++++++++++----------- src/Terminal.ts | 24 ++++++++++++------------ src/Viewport.ts | 2 +- src/addons/search/SearchHelper.ts | 2 +- src/utils/TestUtils.test.ts | 2 +- typings/xterm.d.ts | 2 +- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/fixtures/typings-test/typings-test.ts b/fixtures/typings-test/typings-test.ts index c0ac8b50..703793ca 100644 --- a/fixtures/typings-test/typings-test.ts +++ b/fixtures/typings-test/typings-test.ts @@ -181,10 +181,10 @@ namespace methods_core { namespace scrolling { { const t: Terminal = new Terminal(); - t.scrollDisp(-1); - t.scrollDisp(1); - t.scrollDisp(-1); - t.scrollDisp(1); + t.scrollLines(-1); + t.scrollLines(1); + t.scrollLines(-1); + t.scrollLines(1); t.scrollToTop(); t.scrollToBottom(); } diff --git a/src/Interfaces.ts b/src/Interfaces.ts index 1b912cac..e98385c1 100644 --- a/src/Interfaces.ts +++ b/src/Interfaces.ts @@ -54,7 +54,7 @@ export interface ITerminal extends ILinkifierAccessor, IBufferAccessor, IElement * @param data The data to populate in the event. */ handler(data: string): void; - scrollDisp(disp: number, suppressScrollEvent?: boolean): void; + scrollLines(disp: number, suppressScrollEvent?: boolean): void; cancel(ev: Event, force?: boolean): boolean | void; log(text: string): void; reset(): void; diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index 5dd652e0..c5fa354d 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -517,7 +517,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager */ private _dragScroll(): void { if (this._dragScrollAmount) { - this._terminal.scrollDisp(this._dragScrollAmount, false); + this._terminal.scrollLines(this._dragScrollAmount, false); // Re-evaluate selection if (this._dragScrollAmount > 0) { this._model.selectionEnd = [this._terminal.cols - 1, this._terminal.buffer.ydisp + this._terminal.rows]; diff --git a/src/Terminal.test.ts b/src/Terminal.test.ts index fd173831..e9acd537 100644 --- a/src/Terminal.test.ts +++ b/src/Terminal.test.ts @@ -12,7 +12,7 @@ const INIT_COLS = 80; const INIT_ROWS = 24; class TestTerminal extends Terminal { - public evaluateKeyEscapeSequence(ev: any): {cancel: boolean, key: string, scrollDisp: number} { return this._evaluateKeyEscapeSequence(ev); } + public evaluateKeyEscapeSequence(ev: any): {cancel: boolean, key: string, scrollLines: number} { return this._evaluateKeyEscapeSequence(ev); } public keyDown(ev: any): boolean { return this._keyDown(ev); } public keyPress(ev: any): boolean { return this._keyPress(ev); } } @@ -164,7 +164,7 @@ describe('term.js addons', () => { }); describe('scroll', () => { - describe('scrollDisp', () => { + describe('scrollLines', () => { let startYDisp; beforeEach(() => { for (let i = 0; i < term.rows * 2; i++) { @@ -174,27 +174,27 @@ describe('term.js addons', () => { }); it('should scroll a single line', () => { assert.equal(term.buffer.ydisp, startYDisp); - term.scrollDisp(-1); + term.scrollLines(-1); assert.equal(term.buffer.ydisp, startYDisp - 1); - term.scrollDisp(1); + term.scrollLines(1); assert.equal(term.buffer.ydisp, startYDisp); }); it('should scroll multiple lines', () => { assert.equal(term.buffer.ydisp, startYDisp); - term.scrollDisp(-5); + term.scrollLines(-5); assert.equal(term.buffer.ydisp, startYDisp - 5); - term.scrollDisp(5); + term.scrollLines(5); assert.equal(term.buffer.ydisp, startYDisp); }); it('should not scroll beyond the bounds of the buffer', () => { assert.equal(term.buffer.ydisp, startYDisp); - term.scrollDisp(1); + term.scrollLines(1); assert.equal(term.buffer.ydisp, startYDisp); for (let i = 0; i < startYDisp; i++) { - term.scrollDisp(-1); + term.scrollLines(-1); } assert.equal(term.buffer.ydisp, 0); - term.scrollDisp(-1); + term.scrollLines(-1); assert.equal(term.buffer.ydisp, 0); }); }); @@ -245,7 +245,7 @@ describe('term.js addons', () => { startYDisp = (term.rows * 2) + 1; }); it('should scroll to the bottom', () => { - term.scrollDisp(-1); + term.scrollLines(-1); term.scrollToBottom(); assert.equal(term.buffer.ydisp, startYDisp); term.scrollPages(-1); @@ -289,7 +289,7 @@ describe('term.js addons', () => { }); assert.equal(term.buffer.ydisp, startYDisp); - term.scrollDisp(-1); + term.scrollLines(-1); assert.equal(term.buffer.ydisp, startYDisp - 1); term.keyDown({ keyCode: 0 }); assert.equal(term.buffer.ydisp, startYDisp - 1); diff --git a/src/Terminal.ts b/src/Terminal.ts index 394fb4de..73863dd3 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -1119,11 +1119,11 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT /** * Scroll the display of the terminal * @param {number} disp The number of lines to scroll down (negative scroll up). - * @param {boolean} suppressScrollEvent Don't emit the scroll event as scrollDisp. This is used + * @param {boolean} suppressScrollEvent Don't emit the scroll event as scrollLines. This is used * to avoid unwanted events being handled by the viewport when the event was triggered from the * viewport originally. */ - public scrollDisp(disp: number, suppressScrollEvent?: boolean): void { + public scrollLines(disp: number, suppressScrollEvent?: boolean): void { if (disp < 0) { if (this.buffer.ydisp === 0) { return; @@ -1153,21 +1153,21 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT * @param {number} pageCount The number of pages to scroll (negative scrolls up). */ public scrollPages(pageCount: number): void { - this.scrollDisp(pageCount * (this.rows - 1)); + this.scrollLines(pageCount * (this.rows - 1)); } /** * Scrolls the display of the terminal to the top. */ public scrollToTop(): void { - this.scrollDisp(-this.buffer.ydisp); + this.scrollLines(-this.buffer.ydisp); } /** * Scrolls the display of the terminal to the bottom. */ public scrollToBottom(): void { - this.scrollDisp(this.buffer.ybase - this.buffer.ydisp); + this.scrollLines(this.buffer.ybase - this.buffer.ydisp); } /** @@ -1372,8 +1372,8 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT this.writeStopped = false; } - if (result.scrollDisp) { - this.scrollDisp(result.scrollDisp); + if (result.scrollLines) { + this.scrollLines(result.scrollLines); return this.cancel(ev, true); } @@ -1405,15 +1405,15 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT * Reference: http://invisible-island.net/xterm/ctlseqs/ctlseqs.html * @param ev The keyboard event to be translated to key escape sequence. */ - protected _evaluateKeyEscapeSequence(ev: KeyboardEvent): {cancel: boolean, key: string, scrollDisp: number} { - const result: {cancel: boolean, key: string, scrollDisp: number} = { + protected _evaluateKeyEscapeSequence(ev: KeyboardEvent): {cancel: boolean, key: string, scrollLines: number} { + const result: {cancel: boolean, key: string, scrollLines: number} = { // Whether to cancel event propogation (NOTE: this may not be needed since the event is // canceled at the end of keyDown cancel: false, // The new key even to emit key: undefined, // The number of characters to scroll, if this is defined it will cancel the event - scrollDisp: undefined + scrollLines: undefined }; const modifiers = (ev.shiftKey ? 1 : 0) | (ev.altKey ? 2 : 0) | (ev.ctrlKey ? 4 : 0) | (ev.metaKey ? 8 : 0); switch (ev.keyCode) { @@ -1543,7 +1543,7 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT case 33: // page up if (ev.shiftKey) { - result.scrollDisp = -(this.rows - 1); + result.scrollLines = -(this.rows - 1); } else { result.key = C0.ESC + '[5~'; } @@ -1551,7 +1551,7 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT case 34: // page down if (ev.shiftKey) { - result.scrollDisp = this.rows - 1; + result.scrollLines = this.rows - 1; } else { result.key = C0.ESC + '[6~'; } diff --git a/src/Viewport.ts b/src/Viewport.ts index d20749c3..1ea7fa0b 100644 --- a/src/Viewport.ts +++ b/src/Viewport.ts @@ -95,7 +95,7 @@ export class Viewport implements IViewport { private onScroll(ev: Event): void { const newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight); const diff = newRow - this.terminal.buffer.ydisp; - this.terminal.scrollDisp(diff, true); + this.terminal.scrollLines(diff, true); } /** diff --git a/src/addons/search/SearchHelper.ts b/src/addons/search/SearchHelper.ts index 1747e747..5735dd48 100644 --- a/src/addons/search/SearchHelper.ts +++ b/src/addons/search/SearchHelper.ts @@ -134,7 +134,7 @@ export class SearchHelper { return false; } this._terminal.selectionManager.setSelection(result.col, result.row, result.term.length); - this._terminal.scrollDisp(result.row - this._terminal.buffer.ydisp, false); + this._terminal.scrollLines(result.row - this._terminal.buffer.ydisp, false); return true; } } diff --git a/src/utils/TestUtils.test.ts b/src/utils/TestUtils.test.ts index 26573319..c76266a9 100644 --- a/src/utils/TestUtils.test.ts +++ b/src/utils/TestUtils.test.ts @@ -41,7 +41,7 @@ export class MockTerminal implements ITerminal { off(type: string, listener: IListenerType): void { throw new Error('Method not implemented.'); } - scrollDisp(disp: number, suppressScrollEvent: boolean): void { + scrollLines(disp: number, suppressScrollEvent: boolean): void { throw new Error('Method not implemented.'); } cancel(ev: Event, force?: boolean): void { diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index f0ab9daf..f331ec3a 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -369,7 +369,7 @@ declare module 'xterm' { * Scroll the display of the terminal * @param amount The number of lines to scroll down (negative scroll up). */ - scrollDisp(amount: number): void; + scrollLines(amount: number): void; /** * Scroll the display of the terminal by a number of pages.