2019-02-17 12:12:05 +00:00
|
|
|
import slug from 'slug'
|
2017-07-05 09:01:03 +00:00
|
|
|
import { Injectable } from '@angular/core'
|
2019-02-17 12:12:05 +00:00
|
|
|
import { IHotkeyDescription, HotkeyProvider, ConfigService } from 'terminus-core'
|
2018-10-12 15:59:22 +00:00
|
|
|
import { TerminalService } from './services/terminal.service'
|
2017-07-05 09:01:03 +00:00
|
|
|
|
2019-03-07 01:05:26 +00:00
|
|
|
/** @hidden */
|
2017-07-05 09:01:03 +00:00
|
|
|
@Injectable()
|
|
|
|
export class TerminalHotkeyProvider extends HotkeyProvider {
|
|
|
|
hotkeys: IHotkeyDescription[] = [
|
2017-07-05 16:46:16 +00:00
|
|
|
{
|
|
|
|
id: 'copy',
|
|
|
|
name: 'Copy to clipboard',
|
|
|
|
},
|
2018-03-30 21:33:46 +00:00
|
|
|
{
|
|
|
|
id: 'paste',
|
|
|
|
name: 'Paste from clipboard',
|
|
|
|
},
|
2018-01-24 15:40:30 +00:00
|
|
|
{
|
|
|
|
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',
|
|
|
|
},
|
2017-07-05 17:31:58 +00:00
|
|
|
{
|
|
|
|
id: 'clear',
|
|
|
|
name: 'Clear terminal',
|
|
|
|
},
|
2017-07-05 09:01:03 +00:00
|
|
|
{
|
|
|
|
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)',
|
|
|
|
},
|
2017-07-05 09:01:03 +00:00
|
|
|
]
|
2018-10-12 15:59:22 +00:00
|
|
|
|
|
|
|
constructor (
|
2019-02-17 12:12:05 +00:00
|
|
|
private config: ConfigService,
|
2018-10-12 15:59:22 +00:00
|
|
|
private terminal: TerminalService,
|
|
|
|
) { super() }
|
|
|
|
|
|
|
|
async provide (): Promise<IHotkeyDescription[]> {
|
|
|
|
let shells = await this.terminal.shells$.toPromise()
|
2019-02-17 12:12:05 +00:00
|
|
|
return [
|
|
|
|
...this.hotkeys,
|
|
|
|
...shells.map(shell => ({
|
|
|
|
id: `shell.${shell.id}`,
|
|
|
|
name: `New tab: ${shell.name}`
|
|
|
|
})),
|
|
|
|
...this.config.store.terminal.profiles.map(profile => ({
|
|
|
|
id: `profile.${slug(profile.name)}`,
|
|
|
|
name: `New tab: ${profile.name}`
|
|
|
|
})),
|
|
|
|
]
|
2018-10-12 15:59:22 +00:00
|
|
|
}
|
2017-07-05 09:01:03 +00:00
|
|
|
}
|