Move addon manager to common and use in xterm-core
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Vendored
+6
-1
@@ -726,6 +726,12 @@ declare module 'xterm-core' {
|
|||||||
* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1204,4 +1210,3 @@ declare module 'xterm-core' {
|
|||||||
activeVersion: string;
|
activeVersion: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user