-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
terminalFrontend.service.ts
33 lines (30 loc) · 1.04 KB
/
terminalFrontend.service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Injectable, Injector } from '@angular/core'
import { ConfigService } from 'tabby-core'
import { Frontend } from '../frontends/frontend'
import { XTermFrontend, XTermWebGLFrontend } from '../frontends/xtermFrontend'
import { BaseSession } from '../session'
@Injectable({ providedIn: 'root' })
export class TerminalFrontendService {
private containers = new WeakMap<BaseSession, Frontend>()
/** @hidden */
private constructor (
private config: ConfigService,
private injector: Injector,
) { }
getFrontend (session?: BaseSession|null): Frontend {
if (!session) {
const cls = {
xterm: XTermFrontend,
'xterm-webgl': XTermWebGLFrontend,
}[this.config.store.terminal.frontend] ?? XTermFrontend
return new cls(this.injector)
}
if (!this.containers.has(session)) {
this.containers.set(
session,
this.getFrontend(),
)
}
return this.containers.get(session)!
}
}