Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programatic themes #59

Merged
merged 3 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -81,6 +81,9 @@ public struct Theme {
configure(data)
}
}

public init() {
}

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