1
0
mirror of https://github.com/Eugeny/tabby.git synced 2025-07-16 08:29:58 +00:00

Merge pull request from ehwarren/feature/rename-tab-qol

Feature/rename tab qol
This commit is contained in:
Eugene 2018-12-19 10:17:08 +01:00 committed by GitHub
commit 3192a14c9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 4 deletions

@ -16,6 +16,7 @@ export class RenameTabModalComponent {
ngOnInit () { ngOnInit () {
setTimeout(() => { setTimeout(() => {
this.input.nativeElement.focus() this.input.nativeElement.focus()
this.input.nativeElement.select()
}, 250) }, 250)
} }

@ -3,6 +3,7 @@ import { SortableComponent } from 'ng2-dnd'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { BaseTabComponent } from './baseTab.component' import { BaseTabComponent } from './baseTab.component'
import { RenameTabModalComponent } from './renameTabModal.component' import { RenameTabModalComponent } from './renameTabModal.component'
import { HotkeysService } from '../services/hotkeys.service'
import { ElectronService } from '../services/electron.service' import { ElectronService } from '../services/electron.service'
import { AppService } from '../services/app.service' import { AppService } from '../services/app.service'
import { HostAppService, Platform } from '../services/hostApp.service' import { HostAppService, Platform } from '../services/hostApp.service'
@ -38,8 +39,17 @@ export class TabHeaderComponent {
private zone: NgZone, private zone: NgZone,
private hostApp: HostAppService, private hostApp: HostAppService,
private ngbModal: NgbModal, private ngbModal: NgbModal,
private hotkeys: HotkeysService,
private parentDraggable: SortableComponent, private parentDraggable: SortableComponent,
) { } ) {
this.hotkeys.matchedHotkey.subscribe((hotkey) => {
if (this.app.activeTab === this.tab) {
if (hotkey === 'rename-tab') {
this.showRenameTabModal()
}
}
})
}
ngOnInit () { ngOnInit () {
if (this.hostApp.platform === Platform.macOS) { if (this.hostApp.platform === Platform.macOS) {
@ -50,7 +60,7 @@ export class TabHeaderComponent {
}) })
} }
@HostListener('dblclick') onDoubleClick (): void { showRenameTabModal (): void {
let modal = this.ngbModal.open(RenameTabModalComponent) let modal = this.ngbModal.open(RenameTabModalComponent)
modal.componentInstance.value = this.tab.customTitle || this.tab.title modal.componentInstance.value = this.tab.customTitle || this.tab.title
modal.result.then(result => { modal.result.then(result => {
@ -59,6 +69,10 @@ export class TabHeaderComponent {
}).catch(() => null) }).catch(() => null)
} }
@HostListener('dblclick') onDoubleClick (): void {
this.showRenameTabModal()
}
@HostListener('auxclick', ['$event']) async onAuxClick ($event: MouseEvent) { @HostListener('auxclick', ['$event']) async onAuxClick ($event: MouseEvent) {
if ($event.which === 2) { if ($event.which === 2) {
this.app.closeTab(this.tab, true) this.app.closeTab(this.tab, true)
@ -97,6 +111,10 @@ export class TabHeaderComponent {
} }
}) })
}, },
{
label: 'Rename',
click: () => this.zone.run( () => this.showRenameTabModal() )
},
{ {
label: 'Color', label: 'Color',
sublabel: COLORS.find(x => x.value === this.tab.color).name, sublabel: COLORS.find(x => x.value === this.tab.color).name,

@ -11,6 +11,8 @@ hotkeys:
toggle-last-tab: toggle-last-tab:
- ['Ctrl-A', 'A'] - ['Ctrl-A', 'A']
- ['Ctrl-A', 'Ctrl-A'] - ['Ctrl-A', 'Ctrl-A']
rename-tab:
- 'Ctrl-Shift-R'
next-tab: next-tab:
- 'Ctrl-Shift-ArrowRight' - 'Ctrl-Shift-ArrowRight'
- ['Ctrl-A', 'N'] - ['Ctrl-A', 'N']

@ -8,6 +8,8 @@ hotkeys:
close-tab: close-tab:
- '⌘-W' - '⌘-W'
toggle-last-tab: [] toggle-last-tab: []
rename-tab:
- '⌘-R'
next-tab: next-tab:
- 'Ctrl-Tab' - 'Ctrl-Tab'
previous-tab: previous-tab:

@ -11,6 +11,8 @@ hotkeys:
toggle-last-tab: toggle-last-tab:
- ['Ctrl-A', 'A'] - ['Ctrl-A', 'A']
- ['Ctrl-A', 'Ctrl-A'] - ['Ctrl-A', 'Ctrl-A']
rename-tab:
- 'Ctrl-Shift-R'
next-tab: next-tab:
- 'Ctrl-Shift-ArrowRight' - 'Ctrl-Shift-ArrowRight'
- ['Ctrl-A', 'N'] - ['Ctrl-A', 'N']

@ -215,6 +215,10 @@ export class AppHotkeyProvider extends HotkeyProvider {
id: 'toggle-fullscreen', id: 'toggle-fullscreen',
name: 'Toggle fullscreen mode', name: 'Toggle fullscreen mode',
}, },
{
id: 'rename-tab',
name: 'Rename Tab',
},
{ {
id: 'close-tab', id: 'close-tab',
name: 'Close tab', name: 'Close tab',

@ -264,9 +264,9 @@ export class TerminalTabComponent extends BaseTabComponent {
let wheelDeltaY = 0 let wheelDeltaY = 0
if ('wheelDeltaY' in event) { if ('wheelDeltaY' in event) {
wheelDeltaY = (event as MouseWheelEvent).wheelDeltaY wheelDeltaY = (event as MouseWheelEvent)['wheelDeltaY']
} else { } else {
wheelDeltaY = (event as MouseWheelEvent).deltaY wheelDeltaY = (event as MouseWheelEvent)['deltaY']
} }
if (event.ctrlKey || event.metaKey) { if (event.ctrlKey || event.metaKey) {