Skip to content

Commit 055bcce

Browse files
committed
Remove instantiation service from canvas addon completely
1 parent 60f9bf4 commit 055bcce

File tree

8 files changed

+36
-30
lines changed

8 files changed

+36
-30
lines changed

addons/xterm-addon-canvas/src/CanvasAddon.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* @license MIT
44
*/
55

6-
import { ICharSizeService, IRenderService } from 'browser/services/Services';
6+
import { ICharacterJoinerService, ICharSizeService, ICoreBrowserService, IRenderService } from 'browser/services/Services';
77
import { IColorSet } from 'browser/Types';
88
import { CanvasRenderer } from './CanvasRenderer';
9-
import { IBufferService, IInstantiationService, IOptionsService } from 'common/services/Services';
9+
import { IBufferService, ICoreService, IDecorationService, IOptionsService } from 'common/services/Services';
1010
import { ITerminalAddon, Terminal } from 'xterm';
1111

1212
export class CanvasAddon implements ITerminalAddon {
@@ -18,15 +18,18 @@ export class CanvasAddon implements ITerminalAddon {
1818
throw new Error('Cannot activate CanvasAddon before Terminal.open');
1919
}
2020
this._terminal = terminal;
21-
const instantiationService: IInstantiationService = (terminal as any)._core._instantiationService;
2221
const bufferService: IBufferService = (terminal as any)._core._bufferService;
2322
const renderService: IRenderService = (terminal as any)._core._renderService;
23+
const characterJoinerService: ICharacterJoinerService = (terminal as any)._core._characterJoinerService;
2424
const charSizeService: ICharSizeService = (terminal as any)._core._charSizeService;
25+
const coreService: ICoreService = (terminal as any)._core.coreService;
26+
const coreBrowserService: ICoreBrowserService = (terminal as any)._core._coreBrowserService;
27+
const decorationService: IDecorationService = (terminal as any)._core._decorationService;
2528
const optionsService: IOptionsService = (terminal as any)._core.optionsService;
2629
const colors: IColorSet = (terminal as any)._core._colorManager.colors;
2730
const screenElement: HTMLElement = (terminal as any)._core.screenElement;
2831
const linkifier = (terminal as any)._core.linkifier2;
29-
this._renderer = new CanvasRenderer(colors, screenElement, linkifier, instantiationService, bufferService, charSizeService, optionsService);
32+
this._renderer = new CanvasRenderer(colors, screenElement, linkifier, bufferService, charSizeService, optionsService, characterJoinerService, coreService, coreBrowserService, decorationService);
3033
renderService.setRenderer(this._renderer);
3134
renderService.onResize(bufferService.cols, bufferService.rows);
3235
}

addons/xterm-addon-canvas/src/CanvasRenderer.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { IRenderLayer } from './Types';
1111
import { LinkRenderLayer } from './LinkRenderLayer';
1212
import { Disposable } from 'common/Lifecycle';
1313
import { IColorSet, ILinkifier2 } from 'browser/Types';
14-
import { ICharSizeService } from 'browser/services/Services';
15-
import { IBufferService, IOptionsService, IInstantiationService } from 'common/services/Services';
14+
import { ICharacterJoinerService, ICharSizeService, ICoreBrowserService } from 'browser/services/Services';
15+
import { IBufferService, IOptionsService, IInstantiationService, IDecorationService, ICoreService } from 'common/services/Services';
1616
import { removeTerminalFromCache } from './atlas/CharAtlasCache';
1717
import { EventEmitter, IEvent } from 'common/EventEmitter';
1818
import { observeDevicePixelDimensions } from 'browser/renderer/DevicePixelObserver';
@@ -34,18 +34,21 @@ export class CanvasRenderer extends Disposable implements IRenderer {
3434
private _colors: IColorSet,
3535
private readonly _screenElement: HTMLElement,
3636
linkifier2: ILinkifier2,
37-
instantiationService: IInstantiationService,
3837
private readonly _bufferService: IBufferService,
3938
private readonly _charSizeService: ICharSizeService,
40-
private readonly _optionsService: IOptionsService
39+
private readonly _optionsService: IOptionsService,
40+
characterJoinerService: ICharacterJoinerService,
41+
coreService: ICoreService,
42+
coreBrowserService: ICoreBrowserService,
43+
decorationService: IDecorationService
4144
) {
4245
super();
4346
const allowTransparency = this._optionsService.rawOptions.allowTransparency;
4447
this._renderLayers = [
45-
instantiationService.createInstance(TextRenderLayer, this._screenElement, 0, this._colors, allowTransparency, this._id),
46-
instantiationService.createInstance(SelectionRenderLayer, this._screenElement, 1, this._colors, this._id),
47-
instantiationService.createInstance(LinkRenderLayer, this._screenElement, 2, this._colors, this._id, linkifier2),
48-
instantiationService.createInstance(CursorRenderLayer, this._screenElement, 3, this._colors, this._id, this._onRequestRedraw)
48+
new TextRenderLayer(this._screenElement, 0, this._colors, allowTransparency, this._id, this._bufferService, this._optionsService, characterJoinerService, decorationService),
49+
new SelectionRenderLayer(this._screenElement, 1, this._colors, this._id, this._bufferService, this._optionsService, decorationService),
50+
new LinkRenderLayer(this._screenElement, 2, this._colors, this._id, linkifier2, this._bufferService, this._optionsService, decorationService),
51+
new CursorRenderLayer(this._screenElement, 3, this._colors, this._id, this._onRequestRedraw, this._bufferService, this._optionsService, coreService, coreBrowserService, decorationService)
4952
];
5053
this.dimensions = {
5154
scaledCharWidth: 0,

addons/xterm-addon-canvas/src/CursorRenderLayer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ export class CursorRenderLayer extends BaseRenderLayer {
3737
colors: IColorSet,
3838
rendererId: number,
3939
private _onRequestRedraw: IEventEmitter<IRequestRedrawEvent>,
40-
@IBufferService bufferService: IBufferService,
41-
@IOptionsService optionsService: IOptionsService,
42-
@ICoreService private readonly _coreService: ICoreService,
43-
@ICoreBrowserService private readonly _coreBrowserService: ICoreBrowserService,
44-
@IDecorationService decorationService: IDecorationService
40+
bufferService: IBufferService,
41+
optionsService: IOptionsService,
42+
private readonly _coreService: ICoreService,
43+
private readonly _coreBrowserService: ICoreBrowserService,
44+
decorationService: IDecorationService
4545
) {
4646
super(container, 'cursor', zIndex, true, colors, rendererId, bufferService, optionsService, decorationService);
4747
this._state = {

addons/xterm-addon-canvas/src/LinkRenderLayer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ export class LinkRenderLayer extends BaseRenderLayer {
1919
colors: IColorSet,
2020
rendererId: number,
2121
linkifier2: ILinkifier2,
22-
@IBufferService bufferService: IBufferService,
23-
@IOptionsService optionsService: IOptionsService,
24-
@IDecorationService decorationService: IDecorationService
22+
bufferService: IBufferService,
23+
optionsService: IOptionsService,
24+
decorationService: IDecorationService
2525
) {
2626
super(container, 'link', zIndex, true, colors, rendererId, bufferService, optionsService, decorationService);
2727

addons/xterm-addon-canvas/src/SelectionRenderLayer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ export class SelectionRenderLayer extends BaseRenderLayer {
2323
zIndex: number,
2424
colors: IColorSet,
2525
rendererId: number,
26-
@IBufferService bufferService: IBufferService,
27-
@IOptionsService optionsService: IOptionsService,
28-
@IDecorationService decorationService: IDecorationService
26+
bufferService: IBufferService,
27+
optionsService: IOptionsService,
28+
decorationService: IDecorationService
2929
) {
3030
super(container, 'selection', zIndex, true, colors, rendererId, bufferService, optionsService, decorationService);
3131
this._clearState();

addons/xterm-addon-canvas/src/TextRenderLayer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ export class TextRenderLayer extends BaseRenderLayer {
3535
colors: IColorSet,
3636
alpha: boolean,
3737
rendererId: number,
38-
@IBufferService bufferService: IBufferService,
39-
@IOptionsService optionsService: IOptionsService,
40-
@ICharacterJoinerService private readonly _characterJoinerService: ICharacterJoinerService,
41-
@IDecorationService decorationService: IDecorationService
38+
bufferService: IBufferService,
39+
optionsService: IOptionsService,
40+
private readonly _characterJoinerService: ICharacterJoinerService,
41+
decorationService: IDecorationService
4242
) {
4343
super(container, 'text', zIndex, alpha, colors, rendererId, bufferService, optionsService, decorationService);
4444
this._state = new GridCache<CharData>();

addons/xterm-addon-canvas/src/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
},
2222
"strict": true,
2323
"downlevelIteration": true,
24-
"experimentalDecorators": true,
2524
"types": [
2625
"../../../node_modules/@types/mocha"
2726
]

src/browser/Terminal.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
8181
// browser services
8282
private _decorationService: DecorationService;
8383
private _charSizeService: ICharSizeService | undefined;
84+
private _coreBrowserService: ICoreBrowserService | undefined;
8485
private _mouseService: IMouseService | undefined;
8586
private _renderService: IRenderService | undefined;
8687
private _characterJoinerService: ICharacterJoinerService | undefined;
@@ -494,8 +495,8 @@ export class Terminal extends CoreTerminal implements ITerminal {
494495
this.register(addDisposableDomListener(this.textarea, 'blur', () => this._onTextAreaBlur()));
495496
this._helperContainer.appendChild(this.textarea);
496497

497-
const coreBrowserService = this._instantiationService.createInstance(CoreBrowserService, this.textarea);
498-
this._instantiationService.setService(ICoreBrowserService, coreBrowserService);
498+
this._coreBrowserService = this._instantiationService.createInstance(CoreBrowserService, this.textarea);
499+
this._instantiationService.setService(ICoreBrowserService, this._coreBrowserService);
499500

500501
this._charSizeService = this._instantiationService.createInstance(CharSizeService, this._document, this._helperContainer);
501502
this._instantiationService.setService(ICharSizeService, this._charSizeService);

0 commit comments

Comments
 (0)