mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
move erase methods to InputHandler
This commit is contained in:
@@ -261,13 +261,13 @@ describe('InputHandler', () => {
|
||||
function eraseInLine(params: number[]): void {
|
||||
switch (params[0]) {
|
||||
case 0:
|
||||
term.eraseRight(term.buffer.x, term.buffer.y);
|
||||
inputHandler.eraseRight(term.buffer.x, term.buffer.y);
|
||||
break;
|
||||
case 1:
|
||||
term.eraseLeft(term.buffer.x, term.buffer.y);
|
||||
inputHandler.eraseLeft(term.buffer.x, term.buffer.y);
|
||||
break;
|
||||
case 2:
|
||||
term.eraseLine(term.buffer.y);
|
||||
inputHandler.eraseLine(term.buffer.y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -321,22 +321,22 @@ describe('InputHandler', () => {
|
||||
let j;
|
||||
switch (params[0]) {
|
||||
case 0:
|
||||
termOld.eraseRight(termOld.buffer.x, termOld.buffer.y);
|
||||
inputHandlerOld.eraseRight(termOld.buffer.x, termOld.buffer.y);
|
||||
j = termOld.buffer.y + 1;
|
||||
for (; j < termOld.rows; j++) {
|
||||
termOld.eraseLine(j);
|
||||
inputHandlerOld.eraseLine(j);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
termOld.eraseLeft(termOld.buffer.x, termOld.buffer.y);
|
||||
inputHandlerOld.eraseLeft(termOld.buffer.x, termOld.buffer.y);
|
||||
j = termOld.buffer.y;
|
||||
while (j--) {
|
||||
termOld.eraseLine(j);
|
||||
inputHandlerOld.eraseLine(j);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
j = termOld.rows;
|
||||
while (j--) termOld.eraseLine(j);
|
||||
while (j--) inputHandlerOld.eraseLine(j);
|
||||
break;
|
||||
case 3:
|
||||
// Clear scrollback (everything not in viewport)
|
||||
|
||||
@@ -1986,4 +1986,67 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
public setgLevel(level: number): void {
|
||||
this._terminal.setgLevel(level); // TODO: save to move from terminal?
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Erase in the identified line everything from "x" to the end of the line (right).
|
||||
* @param x The column from which to start erasing to the end of the line.
|
||||
* @param y The line in which to operate.
|
||||
*/
|
||||
// FIXME: decide whether to remove from Terminal
|
||||
public eraseRight(x: number, y: number): void {
|
||||
const line = this._terminal.buffer.lines.get(this._terminal.buffer.ybase + y);
|
||||
if (!line) {
|
||||
return;
|
||||
}
|
||||
line.replaceCells(x, this._terminal.cols, [this._terminal.eraseAttr(), NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);
|
||||
this._terminal.updateRange(y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erase in the identified line everything from "x" to the start of the line (left).
|
||||
* @param x The column from which to start erasing to the start of the line.
|
||||
* @param y The line in which to operate.
|
||||
*/
|
||||
// FIXME: decide whether to remove from Terminal
|
||||
public eraseLeft(x: number, y: number): void {
|
||||
const line = this._terminal.buffer.lines.get(this._terminal.buffer.ybase + y);
|
||||
if (!line) {
|
||||
return;
|
||||
}
|
||||
line.replaceCells(0, x + 1, [this._terminal.eraseAttr(), NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);
|
||||
this._terminal.updateRange(y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erase all content in the given line
|
||||
* @param y The line to erase all of its contents.
|
||||
*/
|
||||
// FIXME: decide whether to remove from Terminal
|
||||
public eraseLine(y: number): void {
|
||||
this.eraseRight(0, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1709,36 +1709,6 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
||||
this._refreshEnd = this.rows - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Erase in the identified line everything from "x" to the end of the line (right).
|
||||
* @param x The column from which to start erasing to the end of the line.
|
||||
* @param y The line in which to operate.
|
||||
*/
|
||||
// FIXME: decide whether to remove from Terminal
|
||||
public eraseRight(x: number, y: number): void {
|
||||
const line = this.buffer.lines.get(this.buffer.ybase + y);
|
||||
if (!line) {
|
||||
return;
|
||||
}
|
||||
line.replaceCells(x, this.cols, [this.eraseAttr(), NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);
|
||||
this.updateRange(y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erase in the identified line everything from "x" to the start of the line (left).
|
||||
* @param x The column from which to start erasing to the start of the line.
|
||||
* @param y The line in which to operate.
|
||||
*/
|
||||
// FIXME: decide whether to remove from Terminal
|
||||
public eraseLeft(x: number, y: number): void {
|
||||
const line = this.buffer.lines.get(this.buffer.ybase + y);
|
||||
if (!line) {
|
||||
return;
|
||||
}
|
||||
line.replaceCells(0, x + 1, [this.eraseAttr(), NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);
|
||||
this.updateRange(y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the entire buffer, making the prompt line the new first line.
|
||||
*/
|
||||
@@ -1759,15 +1729,6 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
||||
this.emit('scroll', this.buffer.ydisp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erase all content in the given line
|
||||
* @param y The line to erase all of its contents.
|
||||
*/
|
||||
// FIXME: decide whether to remove from Terminal
|
||||
public eraseLine(y: number): void {
|
||||
this.eraseRight(0, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* If cur return the back color xterm feature attribute. Else return default attribute.
|
||||
* @param cur
|
||||
|
||||
+3
-3
@@ -71,9 +71,6 @@ export interface IInputHandlingTerminal extends IEventEmitter {
|
||||
scroll(isWrapped?: boolean): void;
|
||||
setgLevel(g: number): void;
|
||||
eraseAttr(): number;
|
||||
eraseRight(x: number, y: number): void;
|
||||
eraseLine(y: number): void;
|
||||
eraseLeft(x: number, y: number): void;
|
||||
is(term: string): boolean;
|
||||
setgCharset(g: number, charset: ICharset): void;
|
||||
resize(x: number, y: number): void;
|
||||
@@ -115,6 +112,9 @@ export interface ICompositionHelper {
|
||||
export interface IInputHandler {
|
||||
parse(data: string): void;
|
||||
print(data: string, start: number, end: number): void;
|
||||
eraseRight(x: number, y: number): void;
|
||||
eraseLine(y: number): void;
|
||||
eraseLeft(x: number, y: number): void;
|
||||
|
||||
/** C0 BEL */ bell(): void;
|
||||
/** C0 LF */ lineFeed(): void;
|
||||
|
||||
Reference in New Issue
Block a user