Skip to content

Commit

Permalink
Merge pull request #59 from codelathe/programatic_themes
Browse files Browse the repository at this point in the history
Programatic themes
  • Loading branch information
ruddfawcett committed Apr 20, 2020
2 parents 2a6ac0e + ec7226d commit 11e260e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Notepad/Style.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import Foundation

public struct Style {
var regex: NSRegularExpression!
var attributes: [NSAttributedString.Key: Any] = [:]
public var attributes: [NSAttributedString.Key: Any] = [:]

init(element: Element, attributes: [NSAttributedString.Key: Any]) {
public init(element: Element, attributes: [NSAttributedString.Key: Any]) {
self.regex = element.toRegex()
self.attributes = attributes
}

init(regex: NSRegularExpression, attributes: [NSAttributedString.Key: Any]) {
public init(regex: NSRegularExpression, attributes: [NSAttributedString.Key: Any]) {
self.regex = regex
self.attributes = attributes
}

init() {
public init() {
self.regex = Element.unknown.toRegex()
}
}
11 changes: 7 additions & 4 deletions Notepad/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ public struct Theme {
}

/// The body style for the Notepad editor.
public fileprivate(set) var body: Style = Style()
public var body: Style = Style()
/// The background color of the Notepad.
public fileprivate(set) var backgroundColor: UniversalColor = UniversalColor.clear
public var backgroundColor: UniversalColor = UniversalColor.clear
/// The tint color (AKA cursor color) of the Notepad.
public fileprivate(set) var tintColor: UniversalColor = UniversalColor.blue
public var tintColor: UniversalColor = UniversalColor.blue

/// All of the other styles for the Notepad editor.
var styles: [Style] = []
public var styles: [Style] = []


/// Build a theme from a JSON theme file.
Expand Down Expand Up @@ -85,6 +85,9 @@ public struct Theme {
configure(data)
}
}

public init() {
}

/// Configures all of the styles for the Theme.
///
Expand Down

0 comments on commit 11e260e

Please sign in to comment.