diff options
| author | Jomar Milan <jomarm@jomarm.tech> | 2023-09-05 21:30:26 -0700 |
|---|---|---|
| committer | Jomar Milan <jomarm@jomarm.tech> | 2023-09-05 21:30:26 -0700 |
| commit | 392461d253ddc9a5a2adb22a52723111e67ee548 (patch) | |
| tree | 129d24f87c00c81fc1df181ca25a14406c259cb4 /src/osc-notify-decorator.ts | |
Initial commit
Diffstat (limited to 'src/osc-notify-decorator.ts')
| -rw-r--r-- | src/osc-notify-decorator.ts | 26 |
1 files changed, 26 insertions, 0 deletions
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<any>): void { + // Subscribe to attach to future sessions in this tab + tab.sessionChanged$.subscribe((session) => { + if (session) { + this.attachToSession(session, (<any>tab).title); + } + }); + + // Attach the current session for this tab + if (tab.session) { + this.attachToSession(tab.session, (<any>tab).title); + } + } + + private attachToSession(session: BaseSession, tabTitle: string) { + const middleware = new OscNotifyMiddleware(tabTitle); + + session.middleware.push(middleware); + } +} |
