mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-05 06:24:56 +00:00
project rename
This commit is contained in:
50
tabby-community-color-schemes/src/colorSchemes.ts
Normal file
50
tabby-community-color-schemes/src/colorSchemes.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { TerminalColorSchemeProvider, TerminalColorScheme } from 'tabby-terminal'
|
||||
|
||||
const schemeContents = require.context('../schemes/', false, /.*/)
|
||||
|
||||
@Injectable()
|
||||
export class ColorSchemes extends TerminalColorSchemeProvider {
|
||||
async getSchemes (): Promise<TerminalColorScheme[]> {
|
||||
const schemes: TerminalColorScheme[] = []
|
||||
|
||||
schemeContents.keys().filter(x => !x.startsWith('./')).forEach(schemeFile => {
|
||||
const lines = (schemeContents(schemeFile).default as string).split('\n')
|
||||
|
||||
// process #define variables
|
||||
const variables: any = {}
|
||||
lines
|
||||
.filter(x => x.startsWith('#define'))
|
||||
.map(x => x.split(' ').map(v => v.trim()))
|
||||
.forEach(([_, variableName, variableValue]) => {
|
||||
variables[variableName] = variableValue
|
||||
})
|
||||
|
||||
const values: any = {}
|
||||
lines
|
||||
.filter(x => x.startsWith('*.'))
|
||||
.map(x => x.substring(2))
|
||||
.map(x => x.split(':').map(v => v.trim()))
|
||||
.forEach(([key, value]) => {
|
||||
values[key] = variables[value] ? variables[value] : value
|
||||
})
|
||||
|
||||
const colors: string[] = []
|
||||
let colorIndex = 0
|
||||
while (values[`color${colorIndex}`]) {
|
||||
colors.push(values[`color${colorIndex}`])
|
||||
colorIndex++
|
||||
}
|
||||
|
||||
schemes.push({
|
||||
name: schemeFile.split('/')[1].trim(),
|
||||
foreground: values.foreground,
|
||||
background: values.background,
|
||||
cursor: values.cursorColor,
|
||||
colors,
|
||||
})
|
||||
})
|
||||
|
||||
return schemes
|
||||
}
|
||||
}
|
11
tabby-community-color-schemes/src/index.ts
Normal file
11
tabby-community-color-schemes/src/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { NgModule } from '@angular/core'
|
||||
import { TerminalColorSchemeProvider } from 'tabby-terminal'
|
||||
|
||||
import { ColorSchemes } from './colorSchemes'
|
||||
|
||||
@NgModule({
|
||||
providers: [
|
||||
{ provide: TerminalColorSchemeProvider, useClass: ColorSchemes, multi: true },
|
||||
],
|
||||
})
|
||||
export default class PopularThemesModule { } // eslint-disable-line @typescript-eslint/no-extraneous-class
|
Reference in New Issue
Block a user