Skip to content

Commit

Permalink
ref: implement recentInputs on baseTerminalTab
Browse files Browse the repository at this point in the history
  • Loading branch information
Clem-Fern committed Apr 22, 2023
1 parent f423be1 commit 6498c4f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
9 changes: 5 additions & 4 deletions tabby-serial/src/components/serialTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,18 @@ export class SerialTabComponent extends BaseTerminalTabComponent<SerialProfile>
}
})

this.frontendReady$.pipe(first()).subscribe(() => {
this.initializeSession()
})

super.ngOnInit()

setImmediate(() => {
this.setTitle(this.profile.name)
})
}

protected onFrontendReady (): void {
this.initializeSession()
super.onFrontendReady()
}

async initializeSession () {
const session = new SerialSession(this.injector, this.profile)
this.setSession(session)
Expand Down
14 changes: 5 additions & 9 deletions tabby-ssh/src/components/sshTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export class SSHTabComponent extends BaseTerminalTabComponent<SSHProfile> implem
sftpPath = '/'
enableToolbar = true
activeKIPrompt: KeyboardInteractivePrompt|null = null
private recentInputs = ''
private reconnectOffered = false

constructor (
Expand Down Expand Up @@ -71,17 +70,14 @@ export class SSHTabComponent extends BaseTerminalTabComponent<SSHProfile> 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<SSHSession> {
let session = await this.sshMultiplexer.getSession(profile)
if (!multiplex || !session || !profile.options.reuseSession) {
Expand Down
9 changes: 5 additions & 4 deletions tabby-telnet/src/components/telnetTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ export class TelnetTabComponent extends BaseTerminalTabComponent<TelnetProfile>
}
})

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$, () => {
Expand Down
6 changes: 6 additions & 0 deletions tabby-terminal/src/api/baseTerminalTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class BaseTerminalTabComponent<P extends BaseTerminalProfile> extends Bas
protected output = new Subject<string>()
protected binaryOutput = new Subject<Buffer>()
protected sessionChanged = new Subject<BaseSession|null>()
protected recentInputs = ''
private bellPlayer: HTMLAudioElement
private termContainerSubscriptions = new SubscriptionContainer()
private sessionHandlers = new SubscriptionContainer()
Expand Down Expand Up @@ -415,6 +416,11 @@ export class BaseTerminalTabComponent<P extends BaseTerminalProfile> 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<MenuItemOptions[]> {
Expand Down

0 comments on commit 6498c4f

Please sign in to comment.