blob: abfb7960a496a8d289d4ce5057533d01a9464924 (
plain)
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
34
35
36
37
38
39
40
41
42
|
import OscNotifyMiddleware from "./osc-notify-middleware";
import { Injectable } from "@angular/core";
import { TerminalDecorator, BaseSession, BaseTerminalTabComponent } from "tabby-terminal";
import { AppService, HostWindowService } from "tabby-core";
@Injectable()
export default class OscNotifyDecorator extends TerminalDecorator {
constructor(
private app: AppService,
private hostWindow: HostWindowService,
) {
super();
}
attach(tab: BaseTerminalTabComponent<any>): void {
// Subscribe to attach to future sessions in this tab
tab.sessionChanged$.subscribe((session) => {
if (session) {
this.attachToSession(session, tab);
}
});
// Attach the current session for this tab
if (tab.session) {
this.attachToSession(tab.session, tab);
}
}
private attachToSession(session: BaseSession, tab: BaseTerminalTabComponent<any>) {
const middleware = new OscNotifyMiddleware(
() => (<any>tab).title,
() => {
this.hostWindow.bringToFront();
const parent = this.app.getParentTab(tab);
this.app.selectTab(parent ?? tab);
parent?.focus(tab);
},
);
session.middleware.push(middleware);
}
}
|