From 6498c4f92332ec75be8cfe2ea38c0dfb069846d2 Mon Sep 17 00:00:00 2001 From: Clem Date: Sat, 22 Apr 2023 15:23:59 +0200 Subject: [PATCH] ref: implement recentInputs on baseTerminalTab --- tabby-serial/src/components/serialTab.component.ts | 9 +++++---- tabby-ssh/src/components/sshTab.component.ts | 14 +++++--------- tabby-telnet/src/components/telnetTab.component.ts | 9 +++++---- .../src/api/baseTerminalTab.component.ts | 6 ++++++ 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/tabby-serial/src/components/serialTab.component.ts b/tabby-serial/src/components/serialTab.component.ts index d648dac4..f9293be4 100644 --- a/tabby-serial/src/components/serialTab.component.ts +++ b/tabby-serial/src/components/serialTab.component.ts @@ -47,10 +47,6 @@ export class SerialTabComponent extends BaseTerminalTabComponent } }) - this.frontendReady$.pipe(first()).subscribe(() => { - this.initializeSession() - }) - super.ngOnInit() setImmediate(() => { @@ -58,6 +54,11 @@ export class SerialTabComponent extends BaseTerminalTabComponent }) } + protected onFrontendReady (): void { + this.initializeSession() + super.onFrontendReady() + } + async initializeSession () { const session = new SerialSession(this.injector, this.profile) this.setSession(session) diff --git a/tabby-ssh/src/components/sshTab.component.ts b/tabby-ssh/src/components/sshTab.component.ts index 11af1368..ea2df932 100644 --- a/tabby-ssh/src/components/sshTab.component.ts +++ b/tabby-ssh/src/components/sshTab.component.ts @@ -30,7 +30,6 @@ export class SSHTabComponent extends BaseTerminalTabComponent implem sftpPath = '/' enableToolbar = true activeKIPrompt: KeyboardInteractivePrompt|null = null - private recentInputs = '' private reconnectOffered = false constructor ( @@ -71,17 +70,14 @@ export class SSHTabComponent extends BaseTerminalTabComponent implem } }) - this.frontendReady$.pipe(first()).subscribe(() => { - this.initializeSession() - this.input$.subscribe(data => { - this.recentInputs += data - this.recentInputs = this.recentInputs.substring(this.recentInputs.length - 32) - }) - }) - super.ngOnInit() } + protected onFrontendReady (): void { + this.initializeSession() + super.onFrontendReady() + } + async setupOneSession (injector: Injector, profile: SSHProfile, multiplex = true): Promise { let session = await this.sshMultiplexer.getSession(profile) if (!multiplex || !session || !profile.options.reuseSession) { diff --git a/tabby-telnet/src/components/telnetTab.component.ts b/tabby-telnet/src/components/telnetTab.component.ts index 440e3432..ac9cf429 100644 --- a/tabby-telnet/src/components/telnetTab.component.ts +++ b/tabby-telnet/src/components/telnetTab.component.ts @@ -36,13 +36,14 @@ export class TelnetTabComponent extends BaseTerminalTabComponent } }) - this.frontendReady$.pipe(first()).subscribe(() => { - this.initializeSession() - }) - super.ngOnInit() } + protected onFrontendReady (): void { + this.initializeSession() + super.onFrontendReady() + } + protected attachSessionHandlers (): void { const session = this.session! this.attachSessionHandler(session.destroyed$, () => { diff --git a/tabby-terminal/src/api/baseTerminalTab.component.ts b/tabby-terminal/src/api/baseTerminalTab.component.ts index f781afd6..bfc406ad 100644 --- a/tabby-terminal/src/api/baseTerminalTab.component.ts +++ b/tabby-terminal/src/api/baseTerminalTab.component.ts @@ -129,6 +129,7 @@ export class BaseTerminalTabComponent

extends Bas protected output = new Subject() protected binaryOutput = new Subject() protected sessionChanged = new Subject() + protected recentInputs = '' private bellPlayer: HTMLAudioElement private termContainerSubscriptions = new SubscriptionContainer() private sessionHandlers = new SubscriptionContainer() @@ -415,6 +416,11 @@ export class BaseTerminalTabComponent

extends Bas this.frontend!.write('\r\n\r\n') } } + + this.input$.subscribe(data => { + this.recentInputs += data + this.recentInputs = this.recentInputs.substring(this.recentInputs.length - 32) + }) } async buildContextMenu (): Promise {