diff --git a/terminus-core/src/components/renameTabModal.component.ts b/terminus-core/src/components/renameTabModal.component.ts index 1410568f..95993cef 100644 --- a/terminus-core/src/components/renameTabModal.component.ts +++ b/terminus-core/src/components/renameTabModal.component.ts @@ -16,6 +16,7 @@ export class RenameTabModalComponent { ngOnInit () { setTimeout(() => { this.input.nativeElement.focus() + this.input.nativeElement.select() }, 250) } diff --git a/terminus-core/src/components/tabHeader.component.ts b/terminus-core/src/components/tabHeader.component.ts index af4ee46a..1153b8a1 100644 --- a/terminus-core/src/components/tabHeader.component.ts +++ b/terminus-core/src/components/tabHeader.component.ts @@ -3,6 +3,7 @@ import { SortableComponent } from 'ng2-dnd' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { BaseTabComponent } from './baseTab.component' import { RenameTabModalComponent } from './renameTabModal.component' +import { HotkeysService } from '../services/hotkeys.service' import { ElectronService } from '../services/electron.service' import { AppService } from '../services/app.service' import { HostAppService, Platform } from '../services/hostApp.service' @@ -38,8 +39,17 @@ export class TabHeaderComponent { private zone: NgZone, private hostApp: HostAppService, private ngbModal: NgbModal, + private hotkeys: HotkeysService, private parentDraggable: SortableComponent, - ) { } + ) { + this.hotkeys.matchedHotkey.subscribe((hotkey) => { + if (this.app.activeTab === this.tab) { + if (hotkey === 'rename-tab') { + this.showRenameTabModal() + } + } + }) + } ngOnInit () { 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) modal.componentInstance.value = this.tab.customTitle || this.tab.title modal.result.then(result => { @@ -59,6 +69,10 @@ export class TabHeaderComponent { }).catch(() => null) } + @HostListener('dblclick') onDoubleClick (): void { + this.showRenameTabModal() + } + @HostListener('auxclick', ['$event']) async onAuxClick ($event: MouseEvent) { if ($event.which === 2) { this.app.closeTab(this.tab, true) @@ -97,6 +111,10 @@ export class TabHeaderComponent { } }) }, + { + label: 'Rename', + click: () => this.zone.run( () => this.showRenameTabModal() ) + }, { label: 'Color', sublabel: COLORS.find(x => x.value === this.tab.color).name, diff --git a/terminus-core/src/configDefaults.linux.yaml b/terminus-core/src/configDefaults.linux.yaml index 75671c35..450eb49b 100644 --- a/terminus-core/src/configDefaults.linux.yaml +++ b/terminus-core/src/configDefaults.linux.yaml @@ -11,6 +11,8 @@ hotkeys: toggle-last-tab: - ['Ctrl-A', 'A'] - ['Ctrl-A', 'Ctrl-A'] + rename-tab: + - 'Ctrl-Shift-R' next-tab: - 'Ctrl-Shift-ArrowRight' - ['Ctrl-A', 'N'] diff --git a/terminus-core/src/configDefaults.macos.yaml b/terminus-core/src/configDefaults.macos.yaml index 239f30fc..a5355344 100644 --- a/terminus-core/src/configDefaults.macos.yaml +++ b/terminus-core/src/configDefaults.macos.yaml @@ -8,6 +8,8 @@ hotkeys: close-tab: - '⌘-W' toggle-last-tab: [] + rename-tab: + - '⌘-R' next-tab: - 'Ctrl-Tab' previous-tab: diff --git a/terminus-core/src/configDefaults.windows.yaml b/terminus-core/src/configDefaults.windows.yaml index b5222d65..2b74fd20 100644 --- a/terminus-core/src/configDefaults.windows.yaml +++ b/terminus-core/src/configDefaults.windows.yaml @@ -11,6 +11,8 @@ hotkeys: toggle-last-tab: - ['Ctrl-A', 'A'] - ['Ctrl-A', 'Ctrl-A'] + rename-tab: + - 'Ctrl-Shift-R' next-tab: - 'Ctrl-Shift-ArrowRight' - ['Ctrl-A', 'N'] diff --git a/terminus-core/src/services/hotkeys.service.ts b/terminus-core/src/services/hotkeys.service.ts index 4bd453e9..d8a6ffd0 100644 --- a/terminus-core/src/services/hotkeys.service.ts +++ b/terminus-core/src/services/hotkeys.service.ts @@ -215,6 +215,10 @@ export class AppHotkeyProvider extends HotkeyProvider { id: 'toggle-fullscreen', name: 'Toggle fullscreen mode', }, + { + id: 'rename-tab', + name: 'Rename Tab', + }, { id: 'close-tab', name: 'Close tab', diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index e560b8d0..89e3cb1b 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -278,9 +278,9 @@ export class TerminalTabComponent extends BaseTabComponent { let wheelDeltaY = 0 if ('wheelDeltaY' in event) { - wheelDeltaY = (event as MouseWheelEvent).wheelDeltaY + wheelDeltaY = (event as MouseWheelEvent)['wheelDeltaY'] } else { - wheelDeltaY = (event as MouseWheelEvent).deltaY + wheelDeltaY = (event as MouseWheelEvent)['deltaY'] } if (event.ctrlKey || event.metaKey) {