kbjr / terminus-scrollbar

A Terminus plugin for adding a scrollbar to the terminal pane
5 stars 3 forks source link

Simplify attachment API #5

Closed Eugeny closed 5 years ago

Eugeny commented 6 years ago

Just noticed you're listening to tabsChanged$ on the AppService. There's actually an API that lets you automatically discover new and closed terminal tabs - TerminalDecorator:

abstract class TerminalDecorator {
    attach (_terminal: TerminalTabComponent): void { }
    detach (_terminal: TerminalTabComponent): void { }
}

You only need to provide it in your module after declaring:

        { provide: TerminalDecorator, useClass: MyDecorator, multi: true },

Here's how it's used in the clickable-links plugin: https://github.com/Eugeny/terminus-clickable-links/blob/master/src/decorator.ts#L7