3
3
* @license MIT
4
4
*/
5
5
6
- import { Terminal as ITerminalApi , IMarker , IDisposable , ILocalizableStrings , ITerminalAddon , IBufferNamespace as IBufferNamespaceApi , IParser , ILinkProvider , IUnicodeHandling , IModes , IDecorationOptions , IDecoration , IBufferElementProvider } from 'xterm' ;
6
+ import { Terminal as ITerminalApi , IMarker , IDisposable , ILocalizableStrings , ITerminalAddon , IBufferNamespace as IBufferNamespaceApi , IParser , ILinkProvider , IUnicodeHandling , IModes , IDecorationOptions , IDecoration , IBufferElementProvider , ITerminalInitOnlyOptions } from 'xterm' ;
7
7
import { IBufferRange , ITerminal } from 'browser/Types' ;
8
8
import { Terminal as TerminalCore } from 'browser/Terminal' ;
9
9
import * as Strings from 'browser/LocalizableStrings' ;
@@ -13,22 +13,25 @@ import { UnicodeApi } from 'common/public/UnicodeApi';
13
13
import { AddonManager } from 'common/public/AddonManager' ;
14
14
import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi' ;
15
15
import { ITerminalOptions } from 'common/Types' ;
16
+ import { Disposable } from 'common/Lifecycle' ;
16
17
17
18
/**
18
19
* The set of options that only have an effect when set in the Terminal constructor.
19
20
*/
20
21
const CONSTRUCTOR_ONLY_OPTIONS = [ 'cols' , 'rows' ] ;
21
22
22
- export class Terminal implements ITerminalApi {
23
+ export class Terminal extends Disposable implements ITerminalApi {
23
24
private _core : ITerminal ;
24
25
private _addonManager : AddonManager ;
25
26
private _parser : IParser | undefined ;
26
27
private _buffer : BufferNamespaceApi | undefined ;
27
28
private _publicOptions : Required < ITerminalOptions > ;
28
29
29
- constructor ( options ?: ITerminalOptions ) {
30
- this . _core = new TerminalCore ( options ) ;
31
- this . _addonManager = new AddonManager ( ) ;
30
+ constructor ( options ?: ITerminalOptions & ITerminalInitOnlyOptions ) {
31
+ super ( ) ;
32
+
33
+ this . _core = this . register ( new TerminalCore ( options ) ) ;
34
+ this . _addonManager = this . register ( new AddonManager ( ) ) ;
32
35
33
36
this . _publicOptions = { ... this . _core . options } ;
34
37
const getter = ( propName : string ) : any => {
@@ -92,7 +95,7 @@ export class Terminal implements ITerminalApi {
92
95
public get cols ( ) : number { return this . _core . cols ; }
93
96
public get buffer ( ) : IBufferNamespaceApi {
94
97
if ( ! this . _buffer ) {
95
- this . _buffer = new BufferNamespaceApi ( this . _core ) ;
98
+ this . _buffer = this . register ( new BufferNamespaceApi ( this . _core ) ) ;
96
99
}
97
100
return this . _buffer ;
98
101
}
@@ -189,8 +192,7 @@ export class Terminal implements ITerminalApi {
189
192
this . _core . selectLines ( start , end ) ;
190
193
}
191
194
public dispose ( ) : void {
192
- this . _addonManager . dispose ( ) ;
193
- this . _core . dispose ( ) ;
195
+ super . dispose ( ) ;
194
196
}
195
197
public scrollLines ( amount : number ) : void {
196
198
this . _verifyIntegers ( amount ) ;
0 commit comments