Skip to content

Commit

Permalink
fix: fix TextMateTheme types and props
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Aug 8, 2021
1 parent 63c05ac commit 5159a4b
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/text-mate-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,33 @@
import plist from "@atom/plist"
import { ScopeSelector } from "first-mate"

export type RuleSet = {
selector: string
comment?: string
properties: Record<string, string>
}

export type ScopeSelectorSettings = {
"font-weight"?: string
"font-style"?: string
"text-decoration"?: string
color?: string
"background-color"?: string
}

export default class TextMateTheme {
contents: string
rulesets: RuleSet[]
syntaxVariables: string
constructor(contents) {
this.contents = contents
this.rulesets = []
this.buildRulesets()
}

buildRulesets() {
let left, variableSettings
let { settings } = (left = plist.parseStringSync(this.contents)) != null ? left : {}
if (settings == null) {
settings = []
}
let variableSettings
const settings = plist.parseStringSync(this.contents)?.settings ?? []

for (const setting of settings) {
const { scope, name } = setting.settings
Expand Down Expand Up @@ -188,7 +202,7 @@ atom-text-editor.is-focused .line.cursor-line`,
}

translateScopeSelectorSettings({ foreground, background, fontStyle }) {
const properties = {}
const properties: ScopeSelectorSettings = {}

if (fontStyle) {
const fontStyles = fontStyle.split(/\s+/)
Expand Down

0 comments on commit 5159a4b

Please sign in to comment.