| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- import { Injectable } from '@angular/core'
- import { ProfilesService } from './services/profiles.service'
- import { HotkeyDescription, HotkeyProvider } from './api/hotkeyProvider'
- import { PartialProfile, Profile } from './api'
- /** @hidden */
- @Injectable()
- export class AppHotkeyProvider extends HotkeyProvider {
- hotkeys: HotkeyDescription[] = [
- {
- id: 'profile-selector',
- name: 'Show profile selector',
- },
- {
- id: 'toggle-fullscreen',
- name: 'Toggle fullscreen mode',
- },
- {
- id: 'rename-tab',
- name: 'Rename Tab',
- },
- {
- id: 'close-tab',
- name: 'Close tab',
- },
- {
- id: 'reopen-tab',
- name: 'Reopen last tab',
- },
- {
- id: 'toggle-last-tab',
- name: 'Toggle last tab',
- },
- {
- id: 'next-tab',
- name: 'Next tab',
- },
- {
- id: 'previous-tab',
- name: 'Previous tab',
- },
- {
- id: 'move-tab-left',
- name: 'Move tab to the left',
- },
- {
- id: 'move-tab-right',
- name: 'Move tab to the right',
- },
- {
- id: 'rearrange-panes',
- name: 'Show pane labels (for rearranging)',
- },
- {
- id: 'duplicate-tab',
- name: 'Duplicate tab',
- },
- {
- id: 'tab-1',
- name: 'Tab 1',
- },
- {
- id: 'tab-2',
- name: 'Tab 2',
- },
- {
- id: 'tab-3',
- name: 'Tab 3',
- },
- {
- id: 'tab-4',
- name: 'Tab 4',
- },
- {
- id: 'tab-5',
- name: 'Tab 5',
- },
- {
- id: 'tab-6',
- name: 'Tab 6',
- },
- {
- id: 'tab-7',
- name: 'Tab 7',
- },
- {
- id: 'tab-8',
- name: 'Tab 8',
- },
- {
- id: 'tab-9',
- name: 'Tab 9',
- },
- {
- id: 'tab-10',
- name: 'Tab 10',
- },
- {
- id: 'tab-11',
- name: 'Tab 11',
- },
- {
- id: 'tab-12',
- name: 'Tab 12',
- },
- {
- id: 'tab-13',
- name: 'Tab 13',
- },
- {
- id: 'tab-14',
- name: 'Tab 14',
- },
- {
- id: 'tab-15',
- name: 'Tab 15',
- },
- {
- id: 'tab-16',
- name: 'Tab 16',
- },
- {
- id: 'tab-17',
- name: 'Tab 17',
- },
- {
- id: 'tab-18',
- name: 'Tab 18',
- },
- {
- id: 'tab-19',
- name: 'Tab 19',
- },
- {
- id: 'tab-20',
- name: 'Tab 20',
- },
- {
- id: 'split-right',
- name: 'Split to the right',
- },
- {
- id: 'split-bottom',
- name: 'Split to the bottom',
- },
- {
- id: 'split-left',
- name: 'Split to the left',
- },
- {
- id: 'split-top',
- name: 'Split to the top',
- },
- {
- id: 'pane-maximize',
- name: 'Maximize the active pane',
- },
- {
- id: 'pane-nav-up',
- name: 'Focus the pane above',
- },
- {
- id: 'pane-nav-down',
- name: 'Focus the pane below',
- },
- {
- id: 'pane-nav-left',
- name: 'Focus the pane on the left',
- },
- {
- id: 'pane-nav-right',
- name: 'Focus the pane on the right',
- },
- {
- id: 'pane-nav-previous',
- name: 'Focus previous pane',
- },
- {
- id: 'pane-nav-next',
- name: 'Focus next pane',
- },
- {
- id: 'switch-profile',
- name: 'Switch profile in the active pane',
- },
- {
- id: 'close-pane',
- name: 'Close focused pane',
- },
- ]
- constructor (
- private profilesService: ProfilesService,
- ) { super() }
- async provide (): Promise<HotkeyDescription[]> {
- const profiles = await this.profilesService.getProfiles()
- return [
- ...this.hotkeys,
- ...profiles.map(profile => ({
- id: `profile.${AppHotkeyProvider.getProfileHotkeyName(profile)}`,
- name: `New tab: ${profile.name}`,
- })),
- ...this.profilesService.getProviders().map(provider => ({
- id: `profile-selectors.${provider.id}`,
- name: `Show ${provider.name} profile selector`,
- })),
- ]
- }
- static getProfileHotkeyName (profile: PartialProfile<Profile>): string {
- return (profile.id ?? profile.name).replace(/\./g, '-')
- }
- }
|