Move addon manager to common and use in xterm-core

This commit is contained in:
Daniel Imms
2021-08-10 05:08:03 -07:00
parent a6e6c07a3c
commit f43fcafc99
5 changed files with 128 additions and 115 deletions
+3 -3
View File
@@ -5,12 +5,12 @@
import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight } from 'xterm'; import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight } from 'xterm';
import { ITerminal } from 'browser/Types'; import { ITerminal } from 'browser/Types';
import { Terminal as TerminalCore } from '../Terminal'; import { Terminal as TerminalCore } from 'browser/Terminal';
import * as Strings from '../LocalizableStrings'; import * as Strings from 'browser/LocalizableStrings';
import { IEvent } from 'common/EventEmitter'; import { IEvent } from 'common/EventEmitter';
import { ParserApi } from 'common/public/ParserApi'; import { ParserApi } from 'common/public/ParserApi';
import { UnicodeApi } from 'common/public/UnicodeApi'; import { UnicodeApi } from 'common/public/UnicodeApi';
import { AddonManager } from './AddonManager'; import { AddonManager } from 'common/public/AddonManager';
import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi';
export class Terminal implements ITerminalApi { export class Terminal implements ITerminalApi {
+9 -1
View File
@@ -7,16 +7,19 @@ import { IEvent } from 'common/EventEmitter';
import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi';
import { ParserApi } from 'common/public/ParserApi'; import { ParserApi } from 'common/public/ParserApi';
import { UnicodeApi } from 'common/public/UnicodeApi'; import { UnicodeApi } from 'common/public/UnicodeApi';
import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalAddon, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core';
import { Terminal as TerminalCore } from 'headless/Terminal'; import { Terminal as TerminalCore } from 'headless/Terminal';
import { AddonManager } from 'common/public/AddonManager';
export class Terminal implements ITerminalApi { export class Terminal implements ITerminalApi {
private _core: TerminalCore; private _core: TerminalCore;
private _addonManager: AddonManager;
private _parser: IParser | undefined; private _parser: IParser | undefined;
private _buffer: BufferNamespaceApi | undefined; private _buffer: BufferNamespaceApi | undefined;
constructor(options?: ITerminalOptions) { constructor(options?: ITerminalOptions) {
this._core = new TerminalCore(options); this._core = new TerminalCore(options);
this._addonManager = new AddonManager();
} }
private _checkProposedApi(): void { private _checkProposedApi(): void {
@@ -69,6 +72,7 @@ export class Terminal implements ITerminalApi {
return this.registerMarker(cursorYOffset); return this.registerMarker(cursorYOffset);
} }
public dispose(): void { public dispose(): void {
this._addonManager.dispose();
this._core.dispose(); this._core.dispose();
} }
public clear(): void { public clear(): void {
@@ -106,6 +110,10 @@ export class Terminal implements ITerminalApi {
public reset(): void { public reset(): void {
this._core.reset(); this._core.reset();
} }
public loadAddon(addon: ITerminalAddon): void {
// TODO: This could cause issues if the addon calls renderer apis
return this._addonManager.loadAddon(this as any, addon);
}
private _verifyIntegers(...values: number[]): void { private _verifyIntegers(...values: number[]): void {
for (const value of values) { for (const value of values) {
+116 -111
View File
@@ -12,7 +12,7 @@ declare module 'xterm-core' {
* A string representing log level. * A string representing log level.
*/ */
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off';
/** /**
* An object containing start up options for the terminal. * An object containing start up options for the terminal.
*/ */
@@ -23,7 +23,7 @@ declare module 'xterm-core' {
* true currently, but will change to false in v5.0. * true currently, but will change to false in v5.0.
*/ */
allowProposedApi?: boolean; allowProposedApi?: boolean;
/** /**
* Whether background should support non-opaque color. It must be set before * Whether background should support non-opaque color. It must be set before
* executing the `Terminal.open()` method and can't be changed later without * executing the `Terminal.open()` method and can't be changed later without
@@ -31,23 +31,23 @@ declare module 'xterm-core' {
* performance. * performance.
*/ */
allowTransparency?: boolean; allowTransparency?: boolean;
/** /**
* If enabled, alt + click will move the prompt cursor to position * If enabled, alt + click will move the prompt cursor to position
* underneath the mouse. The default is true. * underneath the mouse. The default is true.
*/ */
altClickMovesCursor?: boolean; altClickMovesCursor?: boolean;
/** /**
* A data uri of the sound to use for the bell when `bellStyle = 'sound'`. * A data uri of the sound to use for the bell when `bellStyle = 'sound'`.
*/ */
bellSound?: string; bellSound?: string;
/** /**
* The type of the bell notification the terminal will use. * The type of the bell notification the terminal will use.
*/ */
bellStyle?: 'none' | 'sound'; bellStyle?: 'none' | 'sound';
/** /**
* When enabled the cursor will be set to the beginning of the next line * When enabled the cursor will be set to the beginning of the next line
* with every new line. This is equivalent to sending '\r\n' for each '\n'. * with every new line. This is equivalent to sending '\r\n' for each '\n'.
@@ -57,59 +57,59 @@ declare module 'xterm-core' {
* useful. * useful.
*/ */
convertEol?: boolean; convertEol?: boolean;
/** /**
* The number of columns in the terminal. * The number of columns in the terminal.
*/ */
cols?: number; cols?: number;
/** /**
* Whether the cursor blinks. * Whether the cursor blinks.
*/ */
cursorBlink?: boolean; cursorBlink?: boolean;
/** /**
* The style of the cursor. * The style of the cursor.
*/ */
cursorStyle?: 'block' | 'underline' | 'bar'; cursorStyle?: 'block' | 'underline' | 'bar';
/** /**
* The width of the cursor in CSS pixels when `cursorStyle` is set to 'bar'. * The width of the cursor in CSS pixels when `cursorStyle` is set to 'bar'.
*/ */
cursorWidth?: number; cursorWidth?: number;
/** /**
* Whether input should be disabled. * Whether input should be disabled.
*/ */
disableStdin?: boolean; disableStdin?: boolean;
/** /**
* Whether to draw bold text in bright colors. The default is true. * Whether to draw bold text in bright colors. The default is true.
*/ */
drawBoldTextInBrightColors?: boolean; drawBoldTextInBrightColors?: boolean;
/** /**
* The modifier key hold to multiply scroll speed. * The modifier key hold to multiply scroll speed.
*/ */
fastScrollModifier?: 'alt' | 'ctrl' | 'shift' | undefined; fastScrollModifier?: 'alt' | 'ctrl' | 'shift' | undefined;
/** /**
* The spacing in whole pixels between characters. * The spacing in whole pixels between characters.
*/ */
letterSpacing?: number; letterSpacing?: number;
/** /**
* The line height used to render text. * The line height used to render text.
*/ */
lineHeight?: number; lineHeight?: number;
/** /**
* The duration in milliseconds before link tooltip events fire when * The duration in milliseconds before link tooltip events fire when
* hovering on a link. * hovering on a link.
* @deprecated This will be removed when the link matcher API is removed. * @deprecated This will be removed when the link matcher API is removed.
*/ */
linkTooltipHoverDuration?: number; linkTooltipHoverDuration?: number;
/** /**
* What log level to use, this will log for all levels below and including * What log level to use, this will log for all levels below and including
* what is set: * what is set:
@@ -121,12 +121,12 @@ declare module 'xterm-core' {
* 5. off * 5. off
*/ */
logLevel?: LogLevel; logLevel?: LogLevel;
/** /**
* Whether to treat option as the meta key. * Whether to treat option as the meta key.
*/ */
macOptionIsMeta?: boolean; macOptionIsMeta?: boolean;
/** /**
* Whether holding a modifier key will force normal selection behavior, * Whether holding a modifier key will force normal selection behavior,
* regardless of whether the terminal is in mouse events mode. This will * regardless of whether the terminal is in mouse events mode. This will
@@ -135,7 +135,7 @@ declare module 'xterm-core' {
* with mouse mode enabled. * with mouse mode enabled.
*/ */
macOptionClickForcesSelection?: boolean; macOptionClickForcesSelection?: boolean;
/** /**
* The minimum contrast ratio for text in the terminal, setting this will * The minimum contrast ratio for text in the terminal, setting this will
* change the foreground color dynamically depending on whether the contrast * change the foreground color dynamically depending on whether the contrast
@@ -147,47 +147,47 @@ declare module 'xterm-core' {
* - 21: White on black or black on white. * - 21: White on black or black on white.
*/ */
minimumContrastRatio?: number; minimumContrastRatio?: number;
/** /**
* Whether to select the word under the cursor on right click, this is * Whether to select the word under the cursor on right click, this is
* standard behavior in a lot of macOS applications. * standard behavior in a lot of macOS applications.
*/ */
rightClickSelectsWord?: boolean; rightClickSelectsWord?: boolean;
/** /**
* The number of rows in the terminal. * The number of rows in the terminal.
*/ */
rows?: number; rows?: number;
/** /**
* Whether screen reader support is enabled. When on this will expose * Whether screen reader support is enabled. When on this will expose
* supporting elements in the DOM to support NVDA on Windows and VoiceOver * supporting elements in the DOM to support NVDA on Windows and VoiceOver
* on macOS. * on macOS.
*/ */
screenReaderMode?: boolean; screenReaderMode?: boolean;
/** /**
* The amount of scrollback in the terminal. Scrollback is the amount of * The amount of scrollback in the terminal. Scrollback is the amount of
* rows that are retained when lines are scrolled beyond the initial * rows that are retained when lines are scrolled beyond the initial
* viewport. * viewport.
*/ */
scrollback?: number; scrollback?: number;
/** /**
* The scrolling speed multiplier used for adjusting normal scrolling speed. * The scrolling speed multiplier used for adjusting normal scrolling speed.
*/ */
scrollSensitivity?: number; scrollSensitivity?: number;
/** /**
* The size of tab stops in the terminal. * The size of tab stops in the terminal.
*/ */
tabStopWidth?: number; tabStopWidth?: number;
/** /**
* The color theme of the terminal. * The color theme of the terminal.
*/ */
theme?: ITheme; theme?: ITheme;
/** /**
* Whether "Windows mode" is enabled. Because Windows backends winpty and * Whether "Windows mode" is enabled. Because Windows backends winpty and
* conpty operate by doing line wrapping on their side, xterm.js does not * conpty operate by doing line wrapping on their side, xterm.js does not
@@ -199,20 +199,20 @@ declare module 'xterm-core' {
* not whitespace. * not whitespace.
*/ */
windowsMode?: boolean; windowsMode?: boolean;
/** /**
* A string containing all characters that are considered word separated by the * A string containing all characters that are considered word separated by the
* double click to select work logic. * double click to select work logic.
*/ */
wordSeparator?: string; wordSeparator?: string;
/** /**
* Enable various window manipulation and report features. * Enable various window manipulation and report features.
* All features are disabled by default for security reasons. * All features are disabled by default for security reasons.
*/ */
windowOptions?: IWindowOptions; windowOptions?: IWindowOptions;
} }
/** /**
* Contains colors to theme the terminal with. * Contains colors to theme the terminal with.
*/ */
@@ -260,14 +260,14 @@ declare module 'xterm-core' {
/** ANSI bright white (eg. `\x1b[1;37m`) */ /** ANSI bright white (eg. `\x1b[1;37m`) */
brightWhite?: string; brightWhite?: string;
} }
/** /**
* An object that can be disposed via a dispose function. * An object that can be disposed via a dispose function.
*/ */
export interface IDisposable { export interface IDisposable {
dispose(): void; dispose(): void;
} }
/** /**
* An event that can be listened to. * An event that can be listened to.
* @returns an `IDisposable` to stop listening. * @returns an `IDisposable` to stop listening.
@@ -275,7 +275,7 @@ declare module 'xterm-core' {
export interface IEvent<T, U = void> { export interface IEvent<T, U = void> {
(listener: (arg1: T, arg2: U) => any): IDisposable; (listener: (arg1: T, arg2: U) => any): IDisposable;
} }
/** /**
* Represents a specific line in the terminal that is tracked when scrollback * Represents a specific line in the terminal that is tracked when scrollback
* is trimmed and lines are added or removed. This is a single line that may * is trimmed and lines are added or removed. This is a single line that may
@@ -286,18 +286,18 @@ declare module 'xterm-core' {
* A unique identifier for this marker. * A unique identifier for this marker.
*/ */
readonly id: number; readonly id: number;
/** /**
* Whether this marker is disposed. * Whether this marker is disposed.
*/ */
readonly isDisposed: boolean; readonly isDisposed: boolean;
/** /**
* The actual line index in the buffer at this point in time. This is set to * The actual line index in the buffer at this point in time. This is set to
* -1 if the marker has been disposed. * -1 if the marker has been disposed.
*/ */
readonly line: number; readonly line: number;
/** /**
* Event listener to get notified when the marker gets disposed. Automatic disposal * Event listener to get notified when the marker gets disposed. Automatic disposal
* might happen for a marker, that got invalidated by scrolling out or removal of * might happen for a marker, that got invalidated by scrolling out or removal of
@@ -305,7 +305,7 @@ declare module 'xterm-core' {
*/ */
onDispose: IEvent<void>; onDispose: IEvent<void>;
} }
/** /**
* The set of localizable strings. * The set of localizable strings.
*/ */
@@ -314,14 +314,14 @@ declare module 'xterm-core' {
* The aria label for the underlying input textarea for the terminal. * The aria label for the underlying input textarea for the terminal.
*/ */
promptLabel: string; promptLabel: string;
/** /**
* Announcement for when line reading is suppressed due to too many lines * Announcement for when line reading is suppressed due to too many lines
* being printed to the terminal when `screenReaderMode` is enabled. * being printed to the terminal when `screenReaderMode` is enabled.
*/ */
tooMuchOutput: string; tooMuchOutput: string;
} }
/** /**
* Enable various window manipulation and report features (CSI Ps ; Ps ; Ps t). * Enable various window manipulation and report features (CSI Ps ; Ps ; Ps t).
* *
@@ -477,7 +477,7 @@ declare module 'xterm-core' {
*/ */
setWinLines?: boolean; setWinLines?: boolean;
} }
/** /**
* The class that represents an xterm.js terminal. * The class that represents an xterm.js terminal.
*/ */
@@ -488,51 +488,51 @@ declare module 'xterm-core' {
* `Terminal.resize` for when the terminal exists. * `Terminal.resize` for when the terminal exists.
*/ */
readonly rows: number; readonly rows: number;
/** /**
* The number of columns in the terminal's viewport. Use * The number of columns in the terminal's viewport. Use
* `ITerminalOptions.cols` to set this in the constructor and * `ITerminalOptions.cols` to set this in the constructor and
* `Terminal.resize` for when the terminal exists. * `Terminal.resize` for when the terminal exists.
*/ */
readonly cols: number; readonly cols: number;
/** /**
* (EXPERIMENTAL) The terminal's current buffer, this might be either the * (EXPERIMENTAL) The terminal's current buffer, this might be either the
* normal buffer or the alt buffer depending on what's running in the * normal buffer or the alt buffer depending on what's running in the
* terminal. * terminal.
*/ */
readonly buffer: IBufferNamespace; readonly buffer: IBufferNamespace;
/** /**
* (EXPERIMENTAL) Get all markers registered against the buffer. If the alt * (EXPERIMENTAL) Get all markers registered against the buffer. If the alt
* buffer is active this will always return []. * buffer is active this will always return [].
*/ */
readonly markers: ReadonlyArray<IMarker>; readonly markers: ReadonlyArray<IMarker>;
/** /**
* (EXPERIMENTAL) Get the parser interface to register * (EXPERIMENTAL) Get the parser interface to register
* custom escape sequence handlers. * custom escape sequence handlers.
*/ */
readonly parser: IParser; readonly parser: IParser;
/** /**
* (EXPERIMENTAL) Get the Unicode handling interface * (EXPERIMENTAL) Get the Unicode handling interface
* to register and switch Unicode version. * to register and switch Unicode version.
*/ */
readonly unicode: IUnicodeHandling; readonly unicode: IUnicodeHandling;
/** /**
* Natural language strings that can be localized. * Natural language strings that can be localized.
*/ */
static strings: ILocalizableStrings; static strings: ILocalizableStrings;
/** /**
* Creates a new `Terminal` object. * Creates a new `Terminal` object.
* *
* @param options An object containing a set of options. * @param options An object containing a set of options.
*/ */
constructor(options?: ITerminalOptions); constructor(options?: ITerminalOptions);
/** /**
* Adds an event listener for when a binary event fires. This is used to * Adds an event listener for when a binary event fires. This is used to
* enable non UTF-8 conformant binary messages to be sent to the backend. * enable non UTF-8 conformant binary messages to be sent to the backend.
@@ -543,13 +543,13 @@ declare module 'xterm-core' {
* @returns an `IDisposable` to stop listening. * @returns an `IDisposable` to stop listening.
*/ */
onBinary: IEvent<string>; onBinary: IEvent<string>;
/** /**
* Adds an event listener for the cursor moves. * Adds an event listener for the cursor moves.
* @returns an `IDisposable` to stop listening. * @returns an `IDisposable` to stop listening.
*/ */
onCursorMove: IEvent<void>; onCursorMove: IEvent<void>;
/** /**
* Adds an event listener for when a data event fires. This happens for * Adds an event listener for when a data event fires. This happens for
* example when the user types or pastes into the terminal. The event value * example when the user types or pastes into the terminal. The event value
@@ -558,20 +558,20 @@ declare module 'xterm-core' {
* @returns an `IDisposable` to stop listening. * @returns an `IDisposable` to stop listening.
*/ */
onData: IEvent<string>; onData: IEvent<string>;
/** /**
* Adds an event listener for when a line feed is added. * Adds an event listener for when a line feed is added.
* @returns an `IDisposable` to stop listening. * @returns an `IDisposable` to stop listening.
*/ */
onLineFeed: IEvent<void>; onLineFeed: IEvent<void>;
/** /**
* Adds an event listener for when the terminal is resized. The event value * Adds an event listener for when the terminal is resized. The event value
* contains the new size. * contains the new size.
* @returns an `IDisposable` to stop listening. * @returns an `IDisposable` to stop listening.
*/ */
onResize: IEvent<{ cols: number, rows: number }>; onResize: IEvent<{ cols: number, rows: number }>;
/** /**
* Adds an event listener for when an OSC 0 or OSC 2 title change occurs. * Adds an event listener for when an OSC 0 or OSC 2 title change occurs.
* The event value is the new title. * The event value is the new title.
@@ -595,7 +595,7 @@ declare module 'xterm-core' {
* @returns The new marker or undefined. * @returns The new marker or undefined.
*/ */
registerMarker(cursorYOffset: number): IMarker | undefined; registerMarker(cursorYOffset: number): IMarker | undefined;
/** /**
* @deprecated use `registerMarker` instead. * @deprecated use `registerMarker` instead.
*/ */
@@ -611,7 +611,7 @@ declare module 'xterm-core' {
* Clear the entire buffer, making the prompt line the new first line. * Clear the entire buffer, making the prompt line the new first line.
*/ */
clear(): void; clear(): void;
/** /**
* Write data to the terminal. * Write data to the terminal.
* @param data The data to write to the terminal. This can either be raw * @param data The data to write to the terminal. This can either be raw
@@ -621,7 +621,7 @@ declare module 'xterm-core' {
* by the parser. * by the parser.
*/ */
write(data: string | Uint8Array, callback?: () => void): void; write(data: string | Uint8Array, callback?: () => void): void;
/** /**
* Writes data to the terminal, followed by a break line character (\n). * Writes data to the terminal, followed by a break line character (\n).
* @param data The data to write to the terminal. This can either be raw * @param data The data to write to the terminal. This can either be raw
@@ -631,7 +631,7 @@ declare module 'xterm-core' {
* by the parser. * by the parser.
*/ */
writeln(data: string | Uint8Array, callback?: () => void): void; writeln(data: string | Uint8Array, callback?: () => void): void;
/** /**
* Write UTF8 data to the terminal. * Write UTF8 data to the terminal.
* @param data The data to write to the terminal. * @param data The data to write to the terminal.
@@ -639,7 +639,7 @@ declare module 'xterm-core' {
* @deprecated use `write` instead * @deprecated use `write` instead
*/ */
writeUtf8(data: Uint8Array, callback?: () => void): void; writeUtf8(data: Uint8Array, callback?: () => void): void;
/** /**
* Retrieves an option's value from the terminal. * Retrieves an option's value from the terminal.
* @param key The option key. * @param key The option key.
@@ -660,7 +660,7 @@ declare module 'xterm-core' {
* @param key The option key. * @param key The option key.
*/ */
getOption(key: string): any; getOption(key: string): any;
/** /**
* Sets an option on the terminal. * Sets an option on the terminal.
* @param key The option key. * @param key The option key.
@@ -721,13 +721,19 @@ declare module 'xterm-core' {
* @param value The option value. * @param value The option value.
*/ */
setOption(key: string, value: any): void; setOption(key: string, value: any): void;
/** /**
* Perform a full reset (RIS, aka '\x1bc'). * Perform a full reset (RIS, aka '\x1bc').
*/ */
reset(): void; reset(): void;
/**
* Loads an addon into this instance of xterm.js.
* @param addon The addon to load.
*/
loadAddon(addon: ITerminalAddon): void;
} }
/** /**
* An addon that can provide additional functionality to the terminal. * An addon that can provide additional functionality to the terminal.
*/ */
@@ -737,7 +743,7 @@ declare module 'xterm-core' {
*/ */
activate(terminal: Terminal): void; activate(terminal: Terminal): void;
} }
/** /**
* An object representing a selection within the terminal. * An object representing a selection within the terminal.
*/ */
@@ -746,23 +752,23 @@ declare module 'xterm-core' {
* The start column of the selection. * The start column of the selection.
*/ */
startColumn: number; startColumn: number;
/** /**
* The start row of the selection. * The start row of the selection.
*/ */
startRow: number; startRow: number;
/** /**
* The end column of the selection. * The end column of the selection.
*/ */
endColumn: number; endColumn: number;
/** /**
* The end row of the selection. * The end row of the selection.
*/ */
endRow: number; endRow: number;
} }
/** /**
* An object representing a range within the viewport of the terminal. * An object representing a range within the viewport of the terminal.
*/ */
@@ -771,13 +777,13 @@ declare module 'xterm-core' {
* The start of the range. * The start of the range.
*/ */
start: IViewportRangePosition; start: IViewportRangePosition;
/** /**
* The end of the range. * The end of the range.
*/ */
end: IViewportRangePosition; end: IViewportRangePosition;
} }
/** /**
* An object representing a cell position within the viewport of the terminal. * An object representing a cell position within the viewport of the terminal.
*/ */
@@ -790,14 +796,14 @@ declare module 'xterm-core' {
* a text editor. * a text editor.
*/ */
x: number; x: number;
/** /**
* The y position of the cell. This is a 0-based index that refers to a * The y position of the cell. This is a 0-based index that refers to a
* specific row. * specific row.
*/ */
y: number; y: number;
} }
/** /**
* A range within a buffer. * A range within a buffer.
*/ */
@@ -806,13 +812,13 @@ declare module 'xterm-core' {
* The start position of the range. * The start position of the range.
*/ */
start: IBufferCellPosition; start: IBufferCellPosition;
/** /**
* The end position of the range. * The end position of the range.
*/ */
end: IBufferCellPosition; end: IBufferCellPosition;
} }
/** /**
* A position within a buffer. * A position within a buffer.
*/ */
@@ -821,13 +827,13 @@ declare module 'xterm-core' {
* The x position within the buffer. * The x position within the buffer.
*/ */
x: number; x: number;
/** /**
* The y position within the buffer. * The y position within the buffer.
*/ */
y: number; y: number;
} }
/** /**
* Represents a terminal buffer. * Represents a terminal buffer.
*/ */
@@ -836,36 +842,36 @@ declare module 'xterm-core' {
* The type of the buffer. * The type of the buffer.
*/ */
readonly type: 'normal' | 'alternate'; readonly type: 'normal' | 'alternate';
/** /**
* The y position of the cursor. This ranges between `0` (when the * The y position of the cursor. This ranges between `0` (when the
* cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the * cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the
* last row). * last row).
*/ */
readonly cursorY: number; readonly cursorY: number;
/** /**
* The x position of the cursor. This ranges between `0` (left side) and * The x position of the cursor. This ranges between `0` (left side) and
* `Terminal.cols` (after last cell of the row). * `Terminal.cols` (after last cell of the row).
*/ */
readonly cursorX: number; readonly cursorX: number;
/** /**
* The line within the buffer where the top of the viewport is. * The line within the buffer where the top of the viewport is.
*/ */
readonly viewportY: number; readonly viewportY: number;
/** /**
* The line within the buffer where the top of the bottom page is (when * The line within the buffer where the top of the bottom page is (when
* fully scrolled down). * fully scrolled down).
*/ */
readonly baseY: number; readonly baseY: number;
/** /**
* The amount of lines in the buffer. * The amount of lines in the buffer.
*/ */
readonly length: number; readonly length: number;
/** /**
* Gets a line from the buffer, or undefined if the line index does not * Gets a line from the buffer, or undefined if the line index does not
* exist. * exist.
@@ -877,7 +883,7 @@ declare module 'xterm-core' {
* @param y The line index to get. * @param y The line index to get.
*/ */
getLine(y: number): IBufferLine | undefined; getLine(y: number): IBufferLine | undefined;
/** /**
* Creates an empty cell object suitable as a cell reference in * Creates an empty cell object suitable as a cell reference in
* `line.getCell(x, cell)`. Use this to avoid costly recreation of * `line.getCell(x, cell)`. Use this to avoid costly recreation of
@@ -885,7 +891,7 @@ declare module 'xterm-core' {
*/ */
getNullCell(): IBufferCell; getNullCell(): IBufferCell;
} }
/** /**
* Represents the terminal's set of buffers. * Represents the terminal's set of buffers.
*/ */
@@ -894,25 +900,25 @@ declare module 'xterm-core' {
* The active buffer, this will either be the normal or alternate buffers. * The active buffer, this will either be the normal or alternate buffers.
*/ */
readonly active: IBuffer; readonly active: IBuffer;
/** /**
* The normal buffer. * The normal buffer.
*/ */
readonly normal: IBuffer; readonly normal: IBuffer;
/** /**
* The alternate buffer, this becomes the active buffer when an application * The alternate buffer, this becomes the active buffer when an application
* enters this mode via DECSET (`CSI ? 4 7 h`) * enters this mode via DECSET (`CSI ? 4 7 h`)
*/ */
readonly alternate: IBuffer; readonly alternate: IBuffer;
/** /**
* Adds an event listener for when the active buffer changes. * Adds an event listener for when the active buffer changes.
* @returns an `IDisposable` to stop listening. * @returns an `IDisposable` to stop listening.
*/ */
onBufferChange: IEvent<IBuffer>; onBufferChange: IEvent<IBuffer>;
} }
/** /**
* Represents a line in the terminal's buffer. * Represents a line in the terminal's buffer.
*/ */
@@ -921,13 +927,13 @@ declare module 'xterm-core' {
* Whether the line is wrapped from the previous line. * Whether the line is wrapped from the previous line.
*/ */
readonly isWrapped: boolean; readonly isWrapped: boolean;
/** /**
* The length of the line, all call to getCell beyond the length will result * The length of the line, all call to getCell beyond the length will result
* in `undefined`. * in `undefined`.
*/ */
readonly length: number; readonly length: number;
/** /**
* Gets a cell from the line, or undefined if the line index does not exist. * Gets a cell from the line, or undefined if the line index does not exist.
* *
@@ -941,7 +947,7 @@ declare module 'xterm-core' {
* looped over to avoid creating new objects for every cell. * looped over to avoid creating new objects for every cell.
*/ */
getCell(x: number, cell?: IBufferCell): IBufferCell | undefined; getCell(x: number, cell?: IBufferCell): IBufferCell | undefined;
/** /**
* Gets the line as a string. Note that this is gets only the string for the * Gets the line as a string. Note that this is gets only the string for the
* line, not taking isWrapped into account. * line, not taking isWrapped into account.
@@ -952,7 +958,7 @@ declare module 'xterm-core' {
*/ */
translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string; translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string;
} }
/** /**
* Represents a single cell in the terminal's buffer. * Represents a single cell in the terminal's buffer.
*/ */
@@ -965,7 +971,7 @@ declare module 'xterm-core' {
* - `0` for cells immediately following cells with a width of `2`. * - `0` for cells immediately following cells with a width of `2`.
*/ */
getWidth(): number; getWidth(): number;
/** /**
* The character(s) within the cell. Examples of what this can contain: * The character(s) within the cell. Examples of what this can contain:
* *
@@ -974,13 +980,13 @@ declare module 'xterm-core' {
* - An emoji * - An emoji
*/ */
getChars(): string; getChars(): string;
/** /**
* Gets the UTF32 codepoint of single characters, if content is a combined * Gets the UTF32 codepoint of single characters, if content is a combined
* string it returns the codepoint of the last character in the string. * string it returns the codepoint of the last character in the string.
*/ */
getCode(): number; getCode(): number;
/** /**
* Gets the number representation of the foreground color mode, this can be * Gets the number representation of the foreground color mode, this can be
* used to perform quick comparisons of 2 cells to see if they're the same. * used to perform quick comparisons of 2 cells to see if they're the same.
@@ -988,7 +994,7 @@ declare module 'xterm-core' {
* a cell is. * a cell is.
*/ */
getFgColorMode(): number; getFgColorMode(): number;
/** /**
* Gets the number representation of the background color mode, this can be * Gets the number representation of the background color mode, this can be
* used to perform quick comparisons of 2 cells to see if they're the same. * used to perform quick comparisons of 2 cells to see if they're the same.
@@ -996,7 +1002,7 @@ declare module 'xterm-core' {
* a cell is. * a cell is.
*/ */
getBgColorMode(): number; getBgColorMode(): number;
/** /**
* Gets a cell's foreground color number, this differs depending on what the * Gets a cell's foreground color number, this differs depending on what the
* color mode of the cell is: * color mode of the cell is:
@@ -1009,7 +1015,7 @@ declare module 'xterm-core' {
* (CSI 3 8 ; 2 ; Pi ; Pr ; Pg ; Pb) * (CSI 3 8 ; 2 ; Pi ; Pr ; Pg ; Pb)
*/ */
getFgColor(): number; getFgColor(): number;
/** /**
* Gets a cell's background color number, this differs depending on what the * Gets a cell's background color number, this differs depending on what the
* color mode of the cell is: * color mode of the cell is:
@@ -1022,7 +1028,7 @@ declare module 'xterm-core' {
* (CSI 4 8 ; 2 ; Pi ; Pr ; Pg ; Pb) * (CSI 4 8 ; 2 ; Pi ; Pr ; Pg ; Pb)
*/ */
getBgColor(): number; getBgColor(): number;
/** Whether the cell has the bold attribute (CSI 1 m). */ /** Whether the cell has the bold attribute (CSI 1 m). */
isBold(): number; isBold(): number;
/** Whether the cell has the inverse attribute (CSI 3 m). */ /** Whether the cell has the inverse attribute (CSI 3 m). */
@@ -1037,7 +1043,7 @@ declare module 'xterm-core' {
isInverse(): number; isInverse(): number;
/** Whether the cell has the inverse attribute (CSI 8 m). */ /** Whether the cell has the inverse attribute (CSI 8 m). */
isInvisible(): number; isInvisible(): number;
/** Whether the cell is using the RGB foreground color mode. */ /** Whether the cell is using the RGB foreground color mode. */
isFgRGB(): boolean; isFgRGB(): boolean;
/** Whether the cell is using the RGB background color mode. */ /** Whether the cell is using the RGB background color mode. */
@@ -1050,11 +1056,11 @@ declare module 'xterm-core' {
isFgDefault(): boolean; isFgDefault(): boolean;
/** Whether the cell is using the default background color mode. */ /** Whether the cell is using the default background color mode. */
isBgDefault(): boolean; isBgDefault(): boolean;
/** Whether the cell has the default attribute (no color or style). */ /** Whether the cell has the default attribute (no color or style). */
isAttributeDefault(): boolean; isAttributeDefault(): boolean;
} }
/** /**
* Data type to register a CSI, DCS or ESC callback in the parser * Data type to register a CSI, DCS or ESC callback in the parser
* in the form: * in the form:
@@ -1098,7 +1104,7 @@ declare module 'xterm-core' {
*/ */
final: string; final: string;
} }
/** /**
* Allows hooking into the parser for custom handling of escape sequences. * Allows hooking into the parser for custom handling of escape sequences.
*/ */
@@ -1116,7 +1122,7 @@ declare module 'xterm-core' {
* @return An IDisposable you can call to remove this handler. * @return An IDisposable you can call to remove this handler.
*/ */
registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable; registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable;
/** /**
* Adds a handler for DCS escape sequences. * Adds a handler for DCS escape sequences.
* @param id Specifies the function identifier under which the callback * @param id Specifies the function identifier under which the callback
@@ -1135,7 +1141,7 @@ declare module 'xterm-core' {
* @return An IDisposable you can call to remove this handler. * @return An IDisposable you can call to remove this handler.
*/ */
registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable; registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable;
/** /**
* Adds a handler for ESC escape sequences. * Adds a handler for ESC escape sequences.
* @param id Specifies the function identifier under which the callback * @param id Specifies the function identifier under which the callback
@@ -1148,7 +1154,7 @@ declare module 'xterm-core' {
* @return An IDisposable you can call to remove this handler. * @return An IDisposable you can call to remove this handler.
*/ */
registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable; registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable;
/** /**
* Adds a handler for OSC escape sequences. * Adds a handler for OSC escape sequences.
* @param ident The number (first parameter) of the sequence. * @param ident The number (first parameter) of the sequence.
@@ -1167,7 +1173,7 @@ declare module 'xterm-core' {
*/ */
registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable;
} }
/** /**
* (EXPERIMENTAL) Unicode version provider. * (EXPERIMENTAL) Unicode version provider.
* Used to register custom Unicode versions with `Terminal.unicode.register`. * Used to register custom Unicode versions with `Terminal.unicode.register`.
@@ -1177,13 +1183,13 @@ declare module 'xterm-core' {
* String indicating the Unicode version provided. * String indicating the Unicode version provided.
*/ */
readonly version: string; readonly version: string;
/** /**
* Unicode version dependent wcwidth implementation. * Unicode version dependent wcwidth implementation.
*/ */
wcwidth(codepoint: number): 0 | 1 | 2; wcwidth(codepoint: number): 0 | 1 | 2;
} }
/** /**
* (EXPERIMENTAL) Unicode handling interface. * (EXPERIMENTAL) Unicode handling interface.
*/ */
@@ -1192,16 +1198,15 @@ declare module 'xterm-core' {
* Register a custom Unicode version provider. * Register a custom Unicode version provider.
*/ */
register(provider: IUnicodeVersionProvider): void; register(provider: IUnicodeVersionProvider): void;
/** /**
* Registered Unicode versions. * Registered Unicode versions.
*/ */
readonly versions: ReadonlyArray<string>; readonly versions: ReadonlyArray<string>;
/** /**
* Getter/setter for active Unicode version. * Getter/setter for active Unicode version.
*/ */
activeVersion: string; activeVersion: string;
} }
} }