1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-11 07:28:08 +03:00
This commit is contained in:
Eugene Pankov 2017-04-17 13:26:33 +02:00
parent be72ad3c36
commit 36c2aef860
9 changed files with 170 additions and 32 deletions

View File

@ -1,4 +1,4 @@
export abstract class ConfigProvider {
configStructure: any = {}
defaultConfigValues: any = {}
defaults: any = {}
platformDefaults: any = {}
}

View File

@ -0,0 +1,12 @@
import { ConfigProvider } from './api/configProvider'
import { Platform } from './services/hostApp.service'
export class CoreConfigProvider extends ConfigProvider {
platformDefaults = {
[Platform.macOS]: require('./configDefaults.macos.yaml'),
[Platform.Windows]: require('./configDefaults.windows.yaml'),
[Platform.Linux]: require('./configDefaults.linux.yaml'),
}
defaults = require('./configDefaults.yaml')
}

View File

@ -1,10 +1,3 @@
appearance:
dock: 'off'
dockScreen: 'current'
dockFill: 50
tabsOnTop: true
theme: 'Standard'
useNativeFrame: false
hotkeys:
toggle-window:
- 'Ctrl+Space'

View File

@ -0,0 +1,45 @@
hotkeys:
toggle-window:
- 'Ctrl+Space'
close-tab:
- 'Cmd-W'
- ['Ctrl-A', 'K']
toggle-last-tab:
- ['Ctrl-A', 'A']
- ['Ctrl-A', 'Ctrl-A']
next-tab:
- 'Cmd-ArrowRight'
- ['Ctrl-A', 'N']
previous-tab:
- 'Cmd-ArrowLeft'
- ['Ctrl-A', 'P']
tab-1:
- 'Cmd-1'
- ['Ctrl-A', '1']
tab-2:
- 'Cmd-2'
- ['Ctrl-A', '2']
tab-3:
- 'Cmd-3'
- ['Ctrl-A', '3']
tab-4:
- 'Cmd-4'
- ['Ctrl-A', '4']
tab-5:
- 'Cmd-5'
- ['Ctrl-A', '5']
tab-6:
- 'Cmd-6'
- ['Ctrl-A', '6']
tab-7:
- 'Cmd-7'
- ['Ctrl-A', '7']
tab-8:
- 'Cmd-8'
- ['Ctrl-A', '8']
tab-9:
- 'Cmd-9'
- ['Ctrl-A', '9']
tab-10:
- 'Cmd-0'
- ['Ctrl-A', '0']

View File

@ -0,0 +1,45 @@
hotkeys:
toggle-window:
- 'Ctrl+Space'
close-tab:
- 'Ctrl-Shift-W'
- ['Ctrl-A', 'K']
toggle-last-tab:
- ['Ctrl-A', 'A']
- ['Ctrl-A', 'Ctrl-A']
next-tab:
- 'Ctrl-Shift-ArrowRight'
- ['Ctrl-A', 'N']
previous-tab:
- 'Ctrl-Shift-ArrowLeft'
- ['Ctrl-A', 'P']
tab-1:
- 'Alt-1'
- ['Ctrl-A', '1']
tab-2:
- 'Alt-2'
- ['Ctrl-A', '2']
tab-3:
- 'Alt-3'
- ['Ctrl-A', '3']
tab-4:
- 'Alt-4'
- ['Ctrl-A', '4']
tab-5:
- 'Alt-5'
- ['Ctrl-A', '5']
tab-6:
- 'Alt-6'
- ['Ctrl-A', '6']
tab-7:
- 'Alt-7'
- ['Ctrl-A', '7']
tab-8:
- 'Alt-8'
- ['Ctrl-A', '8']
tab-9:
- 'Alt-9'
- ['Ctrl-A', '9']
tab-10:
- 'Alt-0'
- ['Ctrl-A', '0']

View File

@ -0,0 +1,7 @@
appearance:
dock: 'off'
dockScreen: 'current'
dockFill: 50
tabsOnTop: true
theme: 'Standard'
useNativeFrame: false

View File

@ -26,9 +26,11 @@ import { TabHeaderComponent } from './components/tabHeader.component'
import { TitleBarComponent } from './components/titleBar.component'
import { HotkeyProvider } from './api/hotkeyProvider'
import { ConfigProvider } from './api/configProvider'
import { Theme } from './api/theme'
import { StandardTheme } from './theme'
import { CoreConfigProvider } from './config'
import 'perfect-scrollbar/dist/css/perfect-scrollbar.css'
@ -47,6 +49,7 @@ const PROVIDERS = [
QuitterService,
{ provide: HotkeyProvider, useClass: AppHotkeyProvider, multi: true },
{ provide: Theme, useClass: StandardTheme, multi: true },
{ provide: ConfigProvider, useClass: CoreConfigProvider, multi: true },
]

View File

@ -3,7 +3,8 @@ import * as path from 'path'
import * as fs from 'fs'
import { EventEmitter, Injectable, Inject } from '@angular/core'
import { ConfigProvider } from '../api/configProvider'
import { ElectronService } from '../services/electron.service'
import { ElectronService } from './electron.service'
import { HostAppService } from './hostApp.service'
export class ConfigProxy {
@ -57,14 +58,24 @@ export class ConfigService {
restartRequested: boolean
private _store: any
private path: string
private defaultConfigValues: any = require('../defaultConfigValues.yaml')
private defaults: any
constructor (
electron: ElectronService,
hostApp: HostAppService,
@Inject(ConfigProvider) configProviders: ConfigProvider[],
) {
this.path = path.join(electron.app.getPath('userData'), 'config.yaml')
this.defaultConfigValues = configProviders.map(x => x.defaultConfigValues).reduce(configMerge, this.defaultConfigValues)
this.defaults = configProviders.map(provider => {
let defaults = {}
if (provider.platformDefaults) {
defaults = configMerge(defaults, provider.platformDefaults[hostApp.platform])
}
if (provider.defaults) {
defaults = configMerge(defaults, provider.defaults)
}
return defaults
}).reduce(configMerge)
this.load()
}
@ -74,7 +85,7 @@ export class ConfigService {
} else {
this._store = {}
}
this.store = new ConfigProxy(this._store, this.defaultConfigValues)
this.store = new ConfigProxy(this._store, this.defaults)
}
save (): void {
@ -82,10 +93,6 @@ export class ConfigService {
this.emitChange()
}
full (): any {
return configMerge(this.defaultConfigValues, this._store)
}
emitChange (): void {
this.change.emit()
}

View File

@ -1,15 +1,13 @@
import { ConfigProvider } from 'terminus-core'
import { ConfigProvider, Platform } from 'terminus-core'
export class TerminalConfigProvider extends ConfigProvider {
defaultConfigValues: any = {
defaults = {
terminal: {
font: 'monospace',
fontSize: 14,
bell: 'off',
bracketedPaste: true,
background: 'theme',
shell: 'auto',
colorScheme: {
__nonStructural: true,
foreground: null,
@ -19,19 +17,47 @@ export class TerminalConfigProvider extends ConfigProvider {
},
customColorSchemes: []
},
hotkeys: {
'new-tab': [
['Ctrl-A', 'C'],
['Ctrl-A', 'Ctrl-C'],
'Ctrl-Shift-T',
]
},
}
configStructure: any = {
terminal: {
colorScheme: {},
platformDefaults = {
[Platform.macOS]: {
terminal: {
font: 'Menlo',
shell: 'zsh',
},
hotkeys: {
'new-tab': [
['Ctrl-A', 'C'],
['Ctrl-A', 'Ctrl-C'],
'Cmd-T',
]
},
},
[Platform.Windows]: {
terminal: {
font: 'Consolas',
shell: 'cmd.exe',
},
hotkeys: {
'new-tab': [
['Ctrl-A', 'C'],
['Ctrl-A', 'Ctrl-C'],
'Ctrl-Shift-T',
]
},
},
[Platform.Linux]: {
terminal: {
font: 'Liberation Mono',
shell: 'auto',
},
hotkeys: {
'new-tab': [
['Ctrl-A', 'C'],
['Ctrl-A', 'Ctrl-C'],
'Ctrl-Shift-T',
]
},
},
hotkeys: {},
}
}