diff --git a/src/InputHandler.ts b/src/InputHandler.ts index ca4fa2da..7bdd5fe4 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -2040,7 +2040,12 @@ export class InputHandler extends Disposable implements IInputHandler { */ public index(): void { this._restrictCursor(); - this._terminal.index(); // TODO: save to move from terminal? + this._terminal.buffer.y++; + if (this._terminal.buffer.y > this._terminal.buffer.scrollBottom) { + this._terminal.buffer.y--; + this._terminal.scroll(); + } + this._restrictCursor(); } /** @@ -2051,7 +2056,7 @@ export class InputHandler extends Disposable implements IInputHandler { * the value of the active column when the terminal receives an HTS. */ public tabSet(): void { - this._terminal.tabSet(); // TODO: save to move from terminal? + this._terminal.buffer.tabs[this._terminal.buffer.x] = true; } /** @@ -2063,7 +2068,20 @@ export class InputHandler extends Disposable implements IInputHandler { */ public reverseIndex(): void { this._restrictCursor(); - this._terminal.reverseIndex(); // TODO: save to move from terminal? + const buffer = this._terminal.buffer; + if (buffer.y === buffer.scrollTop) { + // possibly move the code below to term.reverseScroll(); + // test: echo -ne '\e[1;1H\e[44m\eM\e[0m' + // blankLine(true) is xterm/linux behavior + const scrollRegionHeight = buffer.scrollBottom - buffer.scrollTop; + buffer.lines.shiftElements(buffer.y + buffer.ybase, scrollRegionHeight, 1); + buffer.lines.set(buffer.y + buffer.ybase, buffer.getBlankLine(this._terminal.eraseAttrData())); + this._terminal.updateRange(buffer.scrollTop); + this._terminal.updateRange(buffer.scrollBottom); + } else { + buffer.y--; + this._restrictCursor(); // quickfix to not run out of bounds + } } /** diff --git a/src/Terminal.ts b/src/Terminal.ts index ccbca340..d40d622f 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -1824,48 +1824,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp } /** - * ESC - */ - - /** - * ESC D Index (IND is 0x84). - */ - public index(): void { - this.buffer.y++; - if (this.buffer.y > this.buffer.scrollBottom) { - this.buffer.y--; - this.scroll(); - } - // If the end of the line is hit, prevent this action from wrapping around to the next line. - if (this.buffer.x >= this.cols) { - this.buffer.x--; - } - } - - /** - * ESC M Reverse Index (RI is 0x8d). - * - * Move the cursor up one row, inserting a new blank line if necessary. - * FIXME: This method is seriously broken. - */ - public reverseIndex(): void { - if (this.buffer.y === this.buffer.scrollTop) { - // possibly move the code below to term.reverseScroll(); - // test: echo -ne '\e[1;1H\e[44m\eM\e[0m' - // blankLine(true) is xterm/linux behavior - const scrollRegionHeight = this.buffer.scrollBottom - this.buffer.scrollTop; - this.buffer.lines.shiftElements(this.buffer.y + this.buffer.ybase, scrollRegionHeight, 1); - this.buffer.lines.set(this.buffer.y + this.buffer.ybase, this.buffer.getBlankLine(this.eraseAttrData())); - this.updateRange(this.buffer.scrollTop); - this.updateRange(this.buffer.scrollBottom); - } else { - this.buffer.y--; - (this._inputHandler as any)._restrictCursor(); // quickfix to not run out of bounds - } - } - - /** - * ESC c Full Reset (RIS). + * Full reset of the terminal. */ public reset(): void { /** @@ -1907,14 +1866,6 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp } } - - /** - * ESC H Tab Set (HTS is 0x88). - */ - public tabSet(): void { - this.buffer.tabs[this.buffer.x] = true; - } - // TODO: Remove cancel function and cancelEvents option public cancel(ev: Event, force?: boolean): boolean { if (!this.options.cancelEvents && !force) { diff --git a/src/TestUtils.test.ts b/src/TestUtils.test.ts index 62ae609e..15f30565 100644 --- a/src/TestUtils.test.ts +++ b/src/TestUtils.test.ts @@ -295,21 +295,12 @@ export class MockInputHandlingTerminal implements IInputHandlingTerminal { addDisposableListener(type: string, handler: XtermListener): IDisposable { throw new Error('Method not implemented.'); } - tabSet(): void { - throw new Error('Method not implemented.'); - } handler(data: string): void { throw new Error('Method not implemented.'); } handleTitle(title: string): void { throw new Error('Method not implemented.'); } - index(): void { - throw new Error('Method not implemented.'); - } - reverseIndex(): void { - throw new Error('Method not implemented.'); - } } export class MockBuffer implements IBuffer { diff --git a/src/Types.d.ts b/src/Types.d.ts index 1ebc800e..0614d626 100644 --- a/src/Types.d.ts +++ b/src/Types.d.ts @@ -70,10 +70,7 @@ export interface IInputHandlingTerminal { showCursor(): void; refresh(start: number, end: number): void; error(text: string, data?: any): void; - tabSet(): void; handleTitle(title: string): void; - index(): void; - reverseIndex(): void; } export interface IViewport extends IDisposable {