scrollDisp -> scrollLines

Fixes #902
This commit is contained in:
Daniel Imms
2017-11-04 03:20:24 -07:00
parent 8ece306dbe
commit 05cbe41d39
9 changed files with 33 additions and 33 deletions
+4 -4
View File
@@ -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();
}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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];
+11 -11
View File
@@ -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(<KeyboardEvent>ev); }
public evaluateKeyEscapeSequence(ev: any): {cancel: boolean, key: string, scrollLines: number} { return this._evaluateKeyEscapeSequence(<KeyboardEvent>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(<KeyboardEvent>{ keyCode: 0 });
assert.equal(term.buffer.ydisp, startYDisp - 1);
+12 -12
View File
@@ -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~';
}
+1 -1
View File
@@ -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);
}
/**
+1 -1
View File
@@ -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;
}
}
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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.