|
|
|
@@ -214,7 +214,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new `Terminal` object.
|
|
|
|
|
*
|
|
|
|
|
* @param {object} options An object containing a set of options, the available options are:
|
|
|
|
|
* @param options An object containing a set of options, the available options are:
|
|
|
|
|
* - `cursorBlink` (boolean): Whether the terminal cursor blinks
|
|
|
|
|
* - `cols` (number): The number of columns of the terminal (horizontal size)
|
|
|
|
|
* - `rows` (number): The number of rows of the terminal (vertical size)
|
|
|
|
@@ -348,7 +348,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieves an option's value from the terminal.
|
|
|
|
|
* @param {string} key The option key.
|
|
|
|
|
* @param key The option key.
|
|
|
|
|
*/
|
|
|
|
|
public getOption(key: string): any {
|
|
|
|
|
if (!(key in DEFAULT_OPTIONS)) {
|
|
|
|
@@ -360,8 +360,8 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets an option on the terminal.
|
|
|
|
|
* @param {string} key The option key.
|
|
|
|
|
* @param {any} value The option value.
|
|
|
|
|
* @param key The option key.
|
|
|
|
|
* @param value The option value.
|
|
|
|
|
*/
|
|
|
|
|
public setOption(key: string, value: any): void {
|
|
|
|
|
if (!(key in DEFAULT_OPTIONS)) {
|
|
|
|
@@ -602,7 +602,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
/**
|
|
|
|
|
* Opens the terminal within an element.
|
|
|
|
|
*
|
|
|
|
|
* @param {HTMLElement} parent The element to create the terminal within.
|
|
|
|
|
* @param parent The element to create the terminal within.
|
|
|
|
|
*/
|
|
|
|
|
public open(parent: HTMLElement): void {
|
|
|
|
|
this._parent = parent || this._parent;
|
|
|
|
@@ -1098,8 +1098,8 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
/**
|
|
|
|
|
* Tells the renderer to refresh terminal content between two rows (inclusive) at the next
|
|
|
|
|
* opportunity.
|
|
|
|
|
* @param {number} start The row to start from (between 0 and this.rows - 1).
|
|
|
|
|
* @param {number} end The row to end at (between start and this.rows - 1).
|
|
|
|
|
* @param start The row to start from (between 0 and this.rows - 1).
|
|
|
|
|
* @param end The row to end at (between start and this.rows - 1).
|
|
|
|
|
*/
|
|
|
|
|
public refresh(start: number, end: number): void {
|
|
|
|
|
if (this.renderer) {
|
|
|
|
@@ -1109,8 +1109,8 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Queues linkification for the specified rows.
|
|
|
|
|
* @param {number} start The row to start from (between 0 and this.rows - 1).
|
|
|
|
|
* @param {number} end The row to end at (between start and this.rows - 1).
|
|
|
|
|
* @param start The row to start from (between 0 and this.rows - 1).
|
|
|
|
|
* @param end The row to end at (between start and this.rows - 1).
|
|
|
|
|
*/
|
|
|
|
|
private _queueLinkification(start: number, end: number): void {
|
|
|
|
|
if (this.linkifier) {
|
|
|
|
@@ -1202,8 +1202,8 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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 scrollLines. This is used
|
|
|
|
|
* @param disp The number of lines to scroll down (negative scroll up).
|
|
|
|
|
* @param 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.
|
|
|
|
|
*/
|
|
|
|
@@ -1234,7 +1234,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Scroll the display of the terminal by a number of pages.
|
|
|
|
|
* @param {number} pageCount The number of pages to scroll (negative scrolls up).
|
|
|
|
|
* @param pageCount The number of pages to scroll (negative scrolls up).
|
|
|
|
|
*/
|
|
|
|
|
public scrollPages(pageCount: number): void {
|
|
|
|
|
this.scrollLines(pageCount * (this.rows - 1));
|
|
|
|
@@ -1263,7 +1263,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Writes text to the terminal.
|
|
|
|
|
* @param {string} data The text to write to the terminal.
|
|
|
|
|
* @param data The text to write to the terminal.
|
|
|
|
|
*/
|
|
|
|
|
public write(data: string): void {
|
|
|
|
|
// Ignore falsy data values (including the empty string)
|
|
|
|
@@ -1329,7 +1329,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Writes text to the terminal, followed by a break line character (\n).
|
|
|
|
|
* @param {string} data The text to write to the terminal.
|
|
|
|
|
* @param data The text to write to the terminal.
|
|
|
|
|
*/
|
|
|
|
|
public writeln(data: string): void {
|
|
|
|
|
this.write(data + '\r\n');
|
|
|
|
@@ -1442,7 +1442,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
* Handle a keydown event
|
|
|
|
|
* Key Resources:
|
|
|
|
|
* - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
|
|
|
|
|
* @param {KeyboardEvent} ev The keydown event to be handled.
|
|
|
|
|
* @param ev The keydown event to be handled.
|
|
|
|
|
*/
|
|
|
|
|
protected _keyDown(event: KeyboardEvent): boolean {
|
|
|
|
|
if (this._customKeyEventHandler && this._customKeyEventHandler(event) === false) {
|
|
|
|
@@ -1539,7 +1539,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
* Handle a keypress event.
|
|
|
|
|
* Key Resources:
|
|
|
|
|
* - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
|
|
|
|
|
* @param {KeyboardEvent} ev The keypress event to be handled.
|
|
|
|
|
* @param ev The keypress event to be handled.
|
|
|
|
|
*/
|
|
|
|
|
protected _keyPress(ev: KeyboardEvent): boolean {
|
|
|
|
|
let key;
|
|
|
|
@@ -1578,7 +1578,6 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Send data for handling to the terminal
|
|
|
|
|
* @param {string} data
|
|
|
|
|
*/
|
|
|
|
|
public send(data: string): void {
|
|
|
|
|
if (!this._sendDataQueue) {
|
|
|
|
@@ -1631,8 +1630,8 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
/**
|
|
|
|
|
* Resizes the terminal.
|
|
|
|
|
*
|
|
|
|
|
* @param {number} x The number of columns to resize to.
|
|
|
|
|
* @param {number} y The number of rows to resize to.
|
|
|
|
|
* @param x The number of columns to resize to.
|
|
|
|
|
* @param y The number of rows to resize to.
|
|
|
|
|
*/
|
|
|
|
|
public resize(x: number, y: number): void {
|
|
|
|
|
if (isNaN(x) || isNaN(y)) {
|
|
|
|
@@ -1666,7 +1665,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the range of rows to refresh
|
|
|
|
|
* @param {number} y The number of rows to refresh next.
|
|
|
|
|
* @param y The number of rows to refresh next.
|
|
|
|
|
*/
|
|
|
|
|
public updateRange(y: number): void {
|
|
|
|
|
if (y < this._refreshStart) this._refreshStart = y;
|
|
|
|
@@ -1689,8 +1688,8 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Erase in the identified line everything from "x" to the end of the line (right).
|
|
|
|
|
* @param {number} x The column from which to start erasing to the end of the line.
|
|
|
|
|
* @param {number} y The line in which to operate.
|
|
|
|
|
* @param x The column from which to start erasing to the end of the line.
|
|
|
|
|
* @param y The line in which to operate.
|
|
|
|
|
*/
|
|
|
|
|
public eraseRight(x: number, y: number): void {
|
|
|
|
|
const line = this.buffer.lines.get(this.buffer.ybase + y);
|
|
|
|
@@ -1706,8 +1705,8 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Erase in the identified line everything from "x" to the start of the line (left).
|
|
|
|
|
* @param {number} x The column from which to start erasing to the start of the line.
|
|
|
|
|
* @param {number} y The line in which to operate.
|
|
|
|
|
* @param x The column from which to start erasing to the start of the line.
|
|
|
|
|
* @param y The line in which to operate.
|
|
|
|
|
*/
|
|
|
|
|
public eraseLeft(x: number, y: number): void {
|
|
|
|
|
const line = this.buffer.lines.get(this.buffer.ybase + y);
|
|
|
|
@@ -1744,7 +1743,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Erase all content in the given line
|
|
|
|
|
* @param {number} y The line to erase all of its contents.
|
|
|
|
|
* @param y The line to erase all of its contents.
|
|
|
|
|
*/
|
|
|
|
|
public eraseLine(y: number): void {
|
|
|
|
|
this.eraseRight(0, y);
|
|
|
|
@@ -1752,9 +1751,9 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the data array of a blank line
|
|
|
|
|
* @param {boolean} cur First bunch of data for each "blank" character.
|
|
|
|
|
* @param {boolean} isWrapped Whether the new line is wrapped from the previous line.
|
|
|
|
|
* @param {boolean} cols The number of columns in the terminal, if this is not
|
|
|
|
|
* @param cur First bunch of data for each "blank" character.
|
|
|
|
|
* @param isWrapped Whether the new line is wrapped from the previous line.
|
|
|
|
|
* @param cols The number of columns in the terminal, if this is not
|
|
|
|
|
* set, the terminal's current column count would be used.
|
|
|
|
|
*/
|
|
|
|
|
public blankLine(cur?: boolean, isWrapped?: boolean, cols?: number): LineData {
|
|
|
|
@@ -1798,7 +1797,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Emit the 'data' event and populate the given data.
|
|
|
|
|
* @param {string} data The data to populate in the event.
|
|
|
|
|
* @param data The data to populate in the event.
|
|
|
|
|
*/
|
|
|
|
|
public handler(data: string): void {
|
|
|
|
|
// Prevents all events to pty process if stdin is disabled
|
|
|
|
@@ -1820,7 +1819,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Emit the 'title' event and populate the given title.
|
|
|
|
|
* @param {string} title The title to populate in the event.
|
|
|
|
|
* @param title The title to populate in the event.
|
|
|
|
|
*/
|
|
|
|
|
public handleTitle(title: string): void {
|
|
|
|
|
/**
|
|
|
|
|