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