mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-28 04:56:16 +03:00
profile and SSH connection colors (fixes #954)
This commit is contained in:
parent
a8d5cf469e
commit
2b5f623b50
@ -173,6 +173,17 @@ export class AppService {
|
||||
}
|
||||
}
|
||||
|
||||
getParentTab (tab: BaseTabComponent): SplitTabComponent|null {
|
||||
for (const topLevelTab of this.tabs) {
|
||||
if (topLevelTab instanceof SplitTabComponent) {
|
||||
if (topLevelTab.getAllTabs().includes(tab)) {
|
||||
return topLevelTab
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/** Switches between the current tab and the previously active one */
|
||||
toggleLastTab () {
|
||||
if (!this.lastTabIndex || this.lastTabIndex >= this.tabs.length) {
|
||||
|
@ -30,6 +30,7 @@ export interface SSHConnection {
|
||||
keepaliveInterval?: number
|
||||
keepaliveCountMax?: number
|
||||
readyTimeout?: number
|
||||
color?: string
|
||||
|
||||
algorithms?: {[t: string]: string[]}
|
||||
}
|
||||
|
@ -67,6 +67,17 @@
|
||||
button.btn.btn-secondary((click)='selectPrivateKey()')
|
||||
i.fas.fa-folder-open
|
||||
|
||||
.form-line
|
||||
.header
|
||||
.title Tab color
|
||||
input.form-control(
|
||||
type='text',
|
||||
autofocus,
|
||||
[(ngModel)]='connection.color',
|
||||
placeholder='#000000'
|
||||
)
|
||||
|
||||
|
||||
ngb-tab(id='advanced')
|
||||
ng-template(ngbTabTitle) Advanced
|
||||
ng-template(ngbTabContent)
|
||||
|
@ -32,10 +32,14 @@ export class SSHService {
|
||||
}
|
||||
|
||||
async openTab (connection: SSHConnection): Promise<SSHTabComponent> {
|
||||
return this.zone.run(() => this.app.openNewTab(
|
||||
const tab = this.zone.run(() => this.app.openNewTab(
|
||||
SSHTabComponent,
|
||||
{ connection }
|
||||
) as SSHTabComponent)
|
||||
if (connection.color) {
|
||||
(this.app.getParentTab(tab) || tab).color = connection.color
|
||||
}
|
||||
return tab
|
||||
}
|
||||
|
||||
createSession (connection: SSHConnection): SSHSession {
|
||||
|
@ -16,8 +16,9 @@ export interface SessionOptions {
|
||||
}
|
||||
|
||||
export interface Profile {
|
||||
name: string,
|
||||
sessionOptions: SessionOptions,
|
||||
name: string
|
||||
color?: string
|
||||
sessionOptions: SessionOptions
|
||||
isBuiltin?: boolean
|
||||
icon?: string
|
||||
}
|
||||
|
@ -53,6 +53,15 @@
|
||||
[(model)]='profile.sessionOptions.env',
|
||||
)
|
||||
|
||||
.form-group
|
||||
label Tab color
|
||||
input.form-control(
|
||||
type='text',
|
||||
autofocus,
|
||||
[(ngModel)]='profile.color',
|
||||
placeholder='#000000'
|
||||
)
|
||||
|
||||
.modal-footer
|
||||
button.btn.btn-outline-primary((click)='save()') Save
|
||||
button.btn.btn-outline-danger((click)='cancel()') Cancel
|
||||
|
@ -88,7 +88,11 @@ export class TerminalService {
|
||||
cwd: cwd || undefined,
|
||||
}
|
||||
|
||||
return this.openTabWithOptions(sessionOptions)
|
||||
const tab = this.openTabWithOptions(sessionOptions)
|
||||
if (profile?.color) {
|
||||
(this.app.getParentTab(tab) || tab).color = profile.color
|
||||
}
|
||||
return tab
|
||||
}
|
||||
|
||||
optionsFromShell (shell: Shell): SessionOptions {
|
||||
|
Loading…
Reference in New Issue
Block a user