summaryrefslogtreecommitdiff
path: root/src/osc-notify-decorator.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/osc-notify-decorator.ts')
-rw-r--r--src/osc-notify-decorator.ts24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/osc-notify-decorator.ts b/src/osc-notify-decorator.ts
index 7d32f1c..abfb796 100644
--- a/src/osc-notify-decorator.ts
+++ b/src/osc-notify-decorator.ts
@@ -1,25 +1,41 @@
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, (<any>tab).title);
+ this.attachToSession(session, tab);
}
});
// Attach the current session for this tab
if (tab.session) {
- this.attachToSession(tab.session, (<any>tab).title);
+ this.attachToSession(tab.session, tab);
}
}
- private attachToSession(session: BaseSession, tabTitle: string) {
- const middleware = new OscNotifyMiddleware(tabTitle);
+ 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);
}