mirror of
https://github.com/Eugeny/tabby.git
synced 2024-11-22 11:52:03 +03:00
Merge pull request #8201 from Clem-Fern/feat#7723
This commit is contained in:
commit
ada47d0cfa
@ -22,6 +22,7 @@ hotkeys:
|
||||
- 'Ctrl-Shift'
|
||||
duplicate-tab: []
|
||||
restart-tab: []
|
||||
reconnect-tab: []
|
||||
explode-tab:
|
||||
- 'Ctrl-Shift-.'
|
||||
combine-tabs:
|
||||
|
@ -39,6 +39,7 @@ hotkeys:
|
||||
tab-10: []
|
||||
duplicate-tab: []
|
||||
restart-tab: []
|
||||
reconnect-tab: []
|
||||
explode-tab:
|
||||
- '⌘-Shift-.'
|
||||
combine-tabs:
|
||||
|
@ -23,6 +23,7 @@ hotkeys:
|
||||
- 'Ctrl-Shift'
|
||||
duplicate-tab: []
|
||||
restart-tab: []
|
||||
reconnect-tab: []
|
||||
explode-tab:
|
||||
- 'Ctrl-Shift-.'
|
||||
combine-tabs:
|
||||
|
@ -4,7 +4,7 @@ import colors from 'ansi-colors'
|
||||
import { Component, Injector } from '@angular/core'
|
||||
import { first } from 'rxjs'
|
||||
import { GetRecoveryTokenOptions, Platform, SelectorService } from 'tabby-core'
|
||||
import { BaseTerminalTabComponent } from 'tabby-terminal'
|
||||
import { BaseTerminalTabComponent, Reconnectable } from 'tabby-terminal'
|
||||
import { SerialSession, BAUD_RATES, SerialProfile } from '../api'
|
||||
|
||||
/** @hidden */
|
||||
@ -14,7 +14,7 @@ import { SerialSession, BAUD_RATES, SerialProfile } from '../api'
|
||||
styleUrls: ['./serialTab.component.scss', ...BaseTerminalTabComponent.styles],
|
||||
animations: BaseTerminalTabComponent.animations,
|
||||
})
|
||||
export class SerialTabComponent extends BaseTerminalTabComponent<SerialProfile> {
|
||||
export class SerialTabComponent extends BaseTerminalTabComponent<SerialProfile> implements Reconnectable {
|
||||
session: SerialSession|null = null
|
||||
Platform = Platform
|
||||
|
||||
|
@ -4,7 +4,7 @@ import { Component, Injector, HostListener } from '@angular/core'
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { first } from 'rxjs'
|
||||
import { GetRecoveryTokenOptions, Platform, ProfilesService, RecoveryToken } from 'tabby-core'
|
||||
import { BaseTerminalTabComponent } from 'tabby-terminal'
|
||||
import { BaseTerminalTabComponent, Reconnectable } from 'tabby-terminal'
|
||||
import { SSHService } from '../services/ssh.service'
|
||||
import { KeyboardInteractivePrompt, SSHSession } from '../session/ssh'
|
||||
import { SSHPortForwardingModalComponent } from './sshPortForwardingModal.component'
|
||||
@ -22,7 +22,7 @@ import { SSHMultiplexerService } from '../services/sshMultiplexer.service'
|
||||
],
|
||||
animations: BaseTerminalTabComponent.animations,
|
||||
})
|
||||
export class SSHTabComponent extends BaseTerminalTabComponent<SSHProfile> {
|
||||
export class SSHTabComponent extends BaseTerminalTabComponent<SSHProfile> implements Reconnectable {
|
||||
Platform = Platform
|
||||
sshSession: SSHSession|null = null
|
||||
session: SSHShellSession|null = null
|
||||
|
@ -3,7 +3,7 @@ import colors from 'ansi-colors'
|
||||
import { Component, Injector } from '@angular/core'
|
||||
import { first } from 'rxjs'
|
||||
import { GetRecoveryTokenOptions, Platform, RecoveryToken } from 'tabby-core'
|
||||
import { BaseTerminalTabComponent } from 'tabby-terminal'
|
||||
import { BaseTerminalTabComponent, Reconnectable } from 'tabby-terminal'
|
||||
import { TelnetProfile, TelnetSession } from '../session'
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ import { TelnetProfile, TelnetSession } from '../session'
|
||||
styleUrls: ['./telnetTab.component.scss', ...BaseTerminalTabComponent.styles],
|
||||
animations: BaseTerminalTabComponent.animations,
|
||||
})
|
||||
export class TelnetTabComponent extends BaseTerminalTabComponent<TelnetProfile> {
|
||||
export class TelnetTabComponent extends BaseTerminalTabComponent<TelnetProfile> implements Reconnectable {
|
||||
Platform = Platform
|
||||
session: TelnetSession|null = null
|
||||
private reconnectOffered = false
|
||||
|
@ -9,7 +9,7 @@ import { BaseSession } from '../session'
|
||||
|
||||
import { Frontend } from '../frontends/frontend'
|
||||
import { XTermFrontend, XTermWebGLFrontend } from '../frontends/xtermFrontend'
|
||||
import { ResizeEvent, BaseTerminalProfile } from './interfaces'
|
||||
import { ResizeEvent, BaseTerminalProfile, isReconnectable } from './interfaces'
|
||||
import { TerminalDecorator } from './decorator'
|
||||
import { SearchPanelComponent } from '../components/searchPanel.component'
|
||||
import { MultifocusService } from '../services/multifocus.service'
|
||||
@ -306,6 +306,11 @@ export class BaseTerminalTabComponent<P extends BaseTerminalProfile> extends Bas
|
||||
case 'scroll-to-bottom':
|
||||
this.frontend?.scrollToBottom()
|
||||
break
|
||||
case 'reconnect-tab':
|
||||
if (isReconnectable(this)) {
|
||||
this.reconnect()
|
||||
}
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -19,3 +19,12 @@ export interface TerminalColorScheme {
|
||||
export interface BaseTerminalProfile extends Profile {
|
||||
terminalColorScheme?: TerminalColorScheme
|
||||
}
|
||||
|
||||
export interface Reconnectable {
|
||||
reconnect: () => Promise<void>;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
export function isReconnectable (object: any): object is Reconnectable {
|
||||
return 'reconnect' in object
|
||||
}
|
||||
|
@ -97,6 +97,10 @@ export class TerminalHotkeyProvider extends HotkeyProvider {
|
||||
id: 'scroll-to-bottom',
|
||||
name: this.translate.instant('Scroll terminal to bottom'),
|
||||
},
|
||||
{
|
||||
id: 'reconnect-tab',
|
||||
name: this.translate.instant('Reconnect current tab (Serial/Telnet/SSH)'),
|
||||
},
|
||||
]
|
||||
|
||||
constructor (private translate: TranslateService) { super() }
|
||||
|
@ -28,7 +28,7 @@ import { PathDropDecorator } from './features/pathDrop'
|
||||
import { ZModemDecorator } from './features/zmodem'
|
||||
import { TerminalConfigProvider } from './config'
|
||||
import { TerminalHotkeyProvider } from './hotkeys'
|
||||
import { CopyPasteContextMenu, MiscContextMenu, LegacyContextMenu } from './tabContextMenu'
|
||||
import { CopyPasteContextMenu, MiscContextMenu, LegacyContextMenu, ReconnectContextMenu } from './tabContextMenu'
|
||||
|
||||
import { Frontend } from './frontends/frontend'
|
||||
import { XTermFrontend, XTermWebGLFrontend } from './frontends/xtermFrontend'
|
||||
@ -58,6 +58,7 @@ import { TerminalCLIHandler } from './cli'
|
||||
{ provide: TabContextMenuItemProvider, useClass: CopyPasteContextMenu, multi: true },
|
||||
{ provide: TabContextMenuItemProvider, useClass: MiscContextMenu, multi: true },
|
||||
{ provide: TabContextMenuItemProvider, useClass: LegacyContextMenu, multi: true },
|
||||
{ provide: TabContextMenuItemProvider, useClass: ReconnectContextMenu, multi: true },
|
||||
|
||||
{ provide: CLIHandler, useClass: TerminalCLIHandler, multi: true },
|
||||
],
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Injectable, Optional, Inject } from '@angular/core'
|
||||
import { BaseTabComponent, TabContextMenuItemProvider, NotificationsService, MenuItemOptions, TranslateService, SplitTabComponent } from 'tabby-core'
|
||||
import { BaseTerminalTabComponent } from './api/baseTerminalTab.component'
|
||||
import { isReconnectable } from './api/interfaces'
|
||||
import { TerminalContextMenuItemProvider } from './api/contextMenuProvider'
|
||||
import { MultifocusService } from './services/multifocus.service'
|
||||
|
||||
@ -85,6 +86,35 @@ export class MiscContextMenu extends TabContextMenuItemProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/** @hidden */
|
||||
@Injectable()
|
||||
export class ReconnectContextMenu extends TabContextMenuItemProvider {
|
||||
weight = 1
|
||||
|
||||
constructor (
|
||||
private translate: TranslateService,
|
||||
private notifications: NotificationsService,
|
||||
) { super() }
|
||||
|
||||
async getItems (tab: BaseTabComponent): Promise<MenuItemOptions[]> {
|
||||
if (isReconnectable(tab)) {
|
||||
return [
|
||||
{
|
||||
label: this.translate.instant('Reconnect'),
|
||||
click: (): void => {
|
||||
setTimeout(() => {
|
||||
tab.reconnect()
|
||||
this.notifications.notice(this.translate.instant('Reconnect'))
|
||||
})
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** @hidden */
|
||||
@Injectable()
|
||||
export class LegacyContextMenu extends TabContextMenuItemProvider {
|
||||
@ -109,4 +139,5 @@ export class LegacyContextMenu extends TabContextMenuItemProvider {
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user