tabby/terminus-terminal/src/hotkeys.ts

87 lines
2 KiB
TypeScript
Raw Normal View History

import slug from 'slug'
import { Injectable } from '@angular/core'
2019-06-14 21:47:48 +00:00
import { HotkeyDescription, HotkeyProvider } from 'terminus-core'
2018-10-12 15:59:22 +00:00
import { TerminalService } from './services/terminal.service'
2019-03-07 01:05:26 +00:00
/** @hidden */
@Injectable()
export class TerminalHotkeyProvider extends HotkeyProvider {
2019-06-14 21:47:48 +00:00
hotkeys: HotkeyDescription[] = [
2017-07-05 16:46:16 +00:00
{
id: 'copy',
name: 'Copy to clipboard',
},
{
id: 'paste',
name: 'Paste from clipboard',
},
{
id: 'home',
name: 'Beginning of the line',
},
{
id: 'end',
name: 'End of the line',
},
{
id: 'previous-word',
name: 'Jump to previous word',
},
{
id: 'next-word',
name: 'Jump to next word',
},
{
id: 'delete-previous-word',
name: 'Delete previous word',
},
{
id: 'delete-next-word',
name: 'Delete next word',
},
{
id: 'clear',
name: 'Clear terminal',
},
{
id: 'zoom-in',
name: 'Zoom in',
},
{
id: 'zoom-out',
name: 'Zoom out',
},
{
id: 'reset-zoom',
name: 'Reset zoom',
},
{
id: 'new-tab',
name: 'New tab',
},
2018-04-01 17:51:04 +00:00
{
id: 'ctrl-c',
name: 'Intelligent Ctrl-C (copy/abort)',
},
2019-06-05 20:04:40 +00:00
{
id: 'search',
name: 'Search',
},
]
2018-10-12 15:59:22 +00:00
constructor (
private terminal: TerminalService,
) { super() }
2019-06-14 21:47:48 +00:00
async provide (): Promise<HotkeyDescription[]> {
2019-06-14 15:49:42 +00:00
const profiles = await this.terminal.getProfiles()
return [
...this.hotkeys,
2019-05-11 19:28:04 +00:00
...profiles.map(profile => ({
2019-05-17 21:48:59 +00:00
id: `profile.${slug(profile.name).toLowerCase()}`,
2019-06-14 21:47:48 +00:00
name: `New tab: ${profile.name}`,
})),
]
2018-10-12 15:59:22 +00:00
}
}