From 392461d253ddc9a5a2adb22a52723111e67ee548 Mon Sep 17 00:00:00 2001 From: Jomar Milan Date: Tue, 5 Sep 2023 21:30:26 -0700 Subject: Initial commit --- src/osc-notify-decorator.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/osc-notify-decorator.ts (limited to 'src/osc-notify-decorator.ts') diff --git a/src/osc-notify-decorator.ts b/src/osc-notify-decorator.ts new file mode 100644 index 0000000..7d32f1c --- /dev/null +++ b/src/osc-notify-decorator.ts @@ -0,0 +1,26 @@ +import OscNotifyMiddleware from "./osc-notify-middleware"; +import { Injectable } from "@angular/core"; +import { TerminalDecorator, BaseSession, BaseTerminalTabComponent } from "tabby-terminal"; + +@Injectable() +export default class OscNotifyDecorator extends TerminalDecorator { + attach(tab: BaseTerminalTabComponent): void { + // Subscribe to attach to future sessions in this tab + tab.sessionChanged$.subscribe((session) => { + if (session) { + this.attachToSession(session, (tab).title); + } + }); + + // Attach the current session for this tab + if (tab.session) { + this.attachToSession(tab.session, (tab).title); + } + } + + private attachToSession(session: BaseSession, tabTitle: string) { + const middleware = new OscNotifyMiddleware(tabTitle); + + session.middleware.push(middleware); + } +} -- cgit v1.3.1