mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-05 19:09:54 +00:00
config
This commit is contained in:
parent
c19f0b1895
commit
9c12669e8f
@ -1,7 +1,7 @@
|
||||
title-bar(*ngIf='!config.full().appearance.useNativeFrame && config.full().appearance.dock == "off"')
|
||||
title-bar(*ngIf='!config.store.appearance.useNativeFrame && config.store.appearance.dock == "off"')
|
||||
|
||||
.content(
|
||||
[class.tabs-on-top]='config.full().appearance.tabsOnTop'
|
||||
[class.tabs-on-top]='config.store.appearance.tabsOnTop'
|
||||
)
|
||||
.tab-bar
|
||||
button.btn.btn-secondary(
|
||||
|
@ -110,7 +110,7 @@ export class AppRootComponent {
|
||||
// unfocused, invisible
|
||||
this.electron.app.window.show()
|
||||
} else {
|
||||
if (this.config.full().appearance.dock == 'off') {
|
||||
if (this.config.store.appearance.dock == 'off') {
|
||||
// not docked, visible
|
||||
setTimeout(() => {
|
||||
this.electron.app.window.focus()
|
||||
|
@ -7,42 +7,36 @@ import { ConfigProvider } from '../api/configProvider'
|
||||
|
||||
|
||||
export class ConfigProxy {
|
||||
constructor (real: any, defaults: any, structure: any) {
|
||||
for (let key in structure) {
|
||||
if (!real[key]) {
|
||||
real[key] = {}
|
||||
}
|
||||
let proxy = new ConfigProxy(real[key], defaults[key], structure[key])
|
||||
Object.defineProperty(
|
||||
this,
|
||||
key,
|
||||
{
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
get: () => {
|
||||
return proxy
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
constructor (real: any, defaults: any) {
|
||||
for (let key in defaults) {
|
||||
if (structure[key]) {
|
||||
continue
|
||||
}
|
||||
Object.defineProperty(
|
||||
this,
|
||||
key,
|
||||
{
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
get: () => {
|
||||
return real[key] || defaults[key]
|
||||
},
|
||||
set: (value) => {
|
||||
real[key] = value
|
||||
}
|
||||
if (defaults[key] instanceof Object && Object.keys(defaults[key]).length > 0) {
|
||||
if (!real[key]) {
|
||||
real[key] = {}
|
||||
}
|
||||
)
|
||||
let proxy = new ConfigProxy(real[key], defaults[key])
|
||||
Object.defineProperty(
|
||||
this,
|
||||
key,
|
||||
{
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
get: () => proxy,
|
||||
}
|
||||
)
|
||||
} else {
|
||||
Object.defineProperty(
|
||||
this,
|
||||
key,
|
||||
{
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
get: () => real[key] || defaults[key],
|
||||
set: (value) => {
|
||||
real[key] = value
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,7 +52,6 @@ export class ConfigService {
|
||||
restartRequested: boolean
|
||||
private _store: any
|
||||
private path: string
|
||||
private configStructure: any = require('../defaultConfigStructure.yaml')
|
||||
private defaultConfigValues: any = require('../defaultConfigValues.yaml')
|
||||
|
||||
constructor (
|
||||
@ -66,7 +59,6 @@ export class ConfigService {
|
||||
@Inject(ConfigProvider) configProviders: ConfigProvider[],
|
||||
) {
|
||||
this.path = path.join(electron.app.getPath('userData'), 'config.yaml')
|
||||
this.configStructure = configProviders.map(x => x.configStructure).reduce(configMerge, this.configStructure)
|
||||
this.defaultConfigValues = configProviders.map(x => x.defaultConfigValues).reduce(configMerge, this.defaultConfigValues)
|
||||
this.load()
|
||||
}
|
||||
@ -77,7 +69,7 @@ export class ConfigService {
|
||||
} else {
|
||||
this._store = {}
|
||||
}
|
||||
this.store = new ConfigProxy(this._store, this.defaultConfigValues, this.configStructure)
|
||||
this.store = new ConfigProxy(this._store, this.defaultConfigValues)
|
||||
}
|
||||
|
||||
save (): void {
|
||||
|
@ -19,14 +19,14 @@ export class DockingService {
|
||||
|
||||
dock () {
|
||||
let display = this.electron.screen.getAllDisplays()
|
||||
.filter((x) => x.id == this.config.full().appearance.dockScreen)[0]
|
||||
.filter((x) => x.id == this.config.store.appearance.dockScreen)[0]
|
||||
if (!display) {
|
||||
display = this.getCurrentScreen()
|
||||
}
|
||||
|
||||
let dockSide = this.config.full().appearance.dock
|
||||
let dockSide = this.config.store.appearance.dock
|
||||
let newBounds: Electron.Rectangle = { x: 0, y: 0, width: 0, height: 0 }
|
||||
let fill = this.config.full().appearance.dockFill
|
||||
let fill = this.config.store.appearance.dockFill
|
||||
|
||||
if (dockSide == 'off') {
|
||||
this.hostApp.setAlwaysOnTop(false)
|
||||
|
@ -89,8 +89,8 @@ export class HotkeysService {
|
||||
|
||||
getHotkeysConfig () {
|
||||
let keys = {}
|
||||
for (let key in this.config.full().hotkeys) {
|
||||
let value = this.config.full().hotkeys[key]
|
||||
for (let key in this.config.store.hotkeys) {
|
||||
let value = this.config.store.hotkeys[key]
|
||||
if (typeof value == 'string') {
|
||||
value = [value]
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ export class ThemesService {
|
||||
}
|
||||
|
||||
applyCurrentTheme (): void {
|
||||
let theme = this.findTheme(this.config.full().appearance.theme)
|
||||
let theme = this.findTheme(this.config.store.appearance.theme)
|
||||
if (!theme) {
|
||||
theme = this.findTheme('Standard')
|
||||
}
|
||||
|
@ -3,104 +3,104 @@
|
||||
.form-group
|
||||
label Preview
|
||||
.appearance-preview(
|
||||
[style.font-family]='config.full().terminal.font',
|
||||
[style.font-size]='config.full().terminal.fontSize + "px"',
|
||||
[style.background-color]='(config.full().terminal.background == "theme") ? null : config.full().terminal.colorScheme.background',
|
||||
[style.color]='config.full().terminal.colorScheme.foreground',
|
||||
[style.font-family]='config.store.terminal.font',
|
||||
[style.font-size]='config.store.terminal.fontSize + "px"',
|
||||
[style.background-color]='(config.store.terminal.background == "theme") ? null : config.store.terminal.colorScheme.background',
|
||||
[style.color]='config.store.terminal.colorScheme.foreground',
|
||||
)
|
||||
div
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[0]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[1]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[2]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[3]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[4]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[5]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[6]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[7]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[0]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[1]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[2]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[3]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[4]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[5]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[6]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[7]')
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[0]') B
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[0]') B
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[1]') R
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[1]') R
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[2]') G
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[2]') G
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[3]') Y
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[3]') Y
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[4]') B
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[4]') B
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[5]') M
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[5]') M
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[6]') T
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[6]') T
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[7]') W
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[7]') W
|
||||
div
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[8]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[9]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[10]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[11]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[12]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[13]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[14]')
|
||||
span([style.background-color]='config.full().terminal.colorScheme.colors[15]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[8]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[9]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[10]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[11]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[12]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[13]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[14]')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.colors[15]')
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[8]') B
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[8]') B
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[9]') R
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[9]') R
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[10]') G
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[10]') G
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[11]') Y
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[11]') Y
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[12]') B
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[12]') B
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[13]') M
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[13]') M
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[14]') T
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[14]') T
|
||||
span
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[15]') W
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[15]') W
|
||||
div
|
||||
span
|
||||
div
|
||||
span john@doe-pc
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[1]') $
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[1]') $
|
||||
span webpack
|
||||
div
|
||||
span Asset Size
|
||||
div
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[2]') main.js
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[2]') main.js
|
||||
span 234 kB
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[2]') [emitted]
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[2]') [emitted]
|
||||
div
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[3]') big.js
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[3]') 1.2 MB
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[2]') [emitted]
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[3]') [big]
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[3]') big.js
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[3]') 1.2 MB
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[2]') [emitted]
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[3]') [big]
|
||||
div
|
||||
span
|
||||
div
|
||||
span john@doe-pc
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[1]') $
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[1]') $
|
||||
span ls -l
|
||||
div
|
||||
span drwxr-xr-x 1 root
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[4]') directory
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[4]') directory
|
||||
div
|
||||
span -rw-r--r-- 1 root file
|
||||
div
|
||||
span -rwxr-xr-x 1 root
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[2]') executable
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[2]') executable
|
||||
div
|
||||
span -rwxr-xr-x 1 root
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[6]') sym
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[6]') sym
|
||||
span ->
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[1]') link
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[1]') link
|
||||
div
|
||||
span
|
||||
div
|
||||
span john@doe-pc
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[1]') $
|
||||
span([style.color]='config.store.terminal.colorScheme.colors[1]') $
|
||||
span rm -rf /
|
||||
span([style.background-color]='config.full().terminal.colorScheme.cursor')
|
||||
span([style.background-color]='config.store.terminal.colorScheme.cursor')
|
||||
|
||||
|
||||
.col-md-6
|
||||
@ -130,7 +130,7 @@
|
||||
'[(ngModel)]'='config.store.terminal.colorScheme',
|
||||
(ngModelChange)='config.save()',
|
||||
)
|
||||
option(*ngFor='let scheme of config.full().terminal.customColorSchemes', [ngValue]='scheme') Custom: {{scheme.name}}
|
||||
option(*ngFor='let scheme of config.store.terminal.customColorSchemes', [ngValue]='scheme') Custom: {{scheme.name}}
|
||||
option(*ngFor='let scheme of colorSchemes', [ngValue]='scheme') {{scheme.name}}
|
||||
.input-group-btn
|
||||
button.btn.btn-secondary((click)='editScheme(config.store.terminal.colorScheme)') Edit
|
||||
|
@ -61,7 +61,7 @@ export class TerminalSettingsTabComponent {
|
||||
}
|
||||
|
||||
saveScheme () {
|
||||
let schemes = this.config.full().terminal.customColorSchemes
|
||||
let schemes = this.config.store.terminal.customColorSchemes
|
||||
schemes = schemes.filter(x => x !== this.editingColorScheme && x.name !== this.editingColorScheme.name)
|
||||
schemes.push(this.editingColorScheme)
|
||||
this.config.store.terminal.customColorSchemes = schemes
|
||||
@ -75,7 +75,7 @@ export class TerminalSettingsTabComponent {
|
||||
|
||||
deleteScheme (scheme: ITerminalColorScheme) {
|
||||
if (confirm(`Delete "${scheme.name}"?`)) {
|
||||
let schemes = this.config.full().terminal.customColorSchemes
|
||||
let schemes = this.config.store.terminal.customColorSchemes
|
||||
schemes = schemes.filter(x => x !== scheme)
|
||||
this.config.store.terminal.customColorSchemes = schemes
|
||||
this.config.save()
|
||||
@ -83,7 +83,7 @@ export class TerminalSettingsTabComponent {
|
||||
}
|
||||
|
||||
isCustomScheme (scheme: ITerminalColorScheme) {
|
||||
return this.config.full().terminal.customColorSchemes.some(x => equal(x, scheme))
|
||||
return this.config.store.terminal.customColorSchemes.some(x => equal(x, scheme))
|
||||
}
|
||||
|
||||
colorsTrackBy (index) {
|
||||
|
@ -85,7 +85,7 @@ export class TerminalTabComponent extends BaseTabComponent {
|
||||
}, 1000)
|
||||
|
||||
this.bell$.subscribe(() => {
|
||||
if (this.config.full().terminal.bell != 'off') {
|
||||
if (this.config.store.terminal.bell != 'off') {
|
||||
let bg = preferenceManager.get('background-color')
|
||||
preferenceManager.set('background-color', 'rgba(128,128,128,.25)')
|
||||
setTimeout(() => {
|
||||
@ -178,7 +178,7 @@ export class TerminalTabComponent extends BaseTabComponent {
|
||||
}
|
||||
|
||||
async configure (): Promise<void> {
|
||||
let config = this.config.full()
|
||||
let config = this.config.store
|
||||
preferenceManager.set('font-family', config.terminal.font)
|
||||
preferenceManager.set('font-size', config.terminal.fontSize)
|
||||
preferenceManager.set('enable-bold', true)
|
||||
|
Loading…
x
Reference in New Issue
Block a user