move leftover sequence methods to InputHandler

This commit is contained in:
Jörg Breitbart
2019-07-08 00:39:05 +02:00
parent 41cc99a919
commit 8654133b15
4 changed files with 22 additions and 65 deletions
+21 -3
View File
@@ -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
}
}
/**
+1 -50
View File
@@ -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) {
-9
View File
@@ -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 {
-3
View File
@@ -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 {