Skip to content
Open
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
2 changes: 1 addition & 1 deletion Sources/Runestone/StringSyntaxHighlighter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class StringSyntaxHighlighter {
/// - language: The language to use when parsing the text
/// - languageProvider: Object that can provide embedded languages on demand. A strong reference will be stored to the language provider..
public init(
theme: Theme = DefaultTheme(),
theme: Theme = DefaultTheme.share,
language: TreeSitterLanguage,
languageProvider: TreeSitterLanguageProvider? = nil
) {
Expand Down
2 changes: 2 additions & 0 deletions Sources/Runestone/TextView/Appearance/DefaultTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public final class DefaultTheme: Runestone.Theme {
public let selectionColor = UIColor(themeColorNamed: "selection")

public init() {}

public static let share = DefaultTheme()

// swiftlint:disable:next cyclomatic_complexity
public func textColor(for highlightName: String) -> UIColor? {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Runestone/TextView/Core/LayoutManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class LayoutManager {
}
}
}
var theme: Theme = DefaultTheme() {
var theme: Theme = DefaultTheme.share {
didSet {
if theme !== oldValue {
gutterBackgroundView.backgroundColor = theme.gutterBackgroundColor
Expand Down
2 changes: 1 addition & 1 deletion Sources/Runestone/TextView/Core/TextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ open class TextView: UIScrollView {
/// Create a new text view.
/// - Parameter frame: The frame rectangle of the text view.
override public init(frame: CGRect) {
textInputView = TextInputView(theme: DefaultTheme())
textInputView = TextInputView(theme: DefaultTheme.share)
super.init(frame: frame)
backgroundColor = .white
textInputView.delegate = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class LineController {
}
}
}
var theme: Theme = DefaultTheme() {
var theme: Theme = DefaultTheme.share {
didSet {
syntaxHighlighter?.theme = theme
applyThemeToAllLineFragmentControllers()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import CoreGraphics
import Foundation

final class PlainTextSyntaxHighlighter: LineSyntaxHighlighter {
var theme: Theme = DefaultTheme()
var theme: Theme = DefaultTheme.share
var kern: CGFloat = 0
var canHighlight: Bool {
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum TreeSitterSyntaxHighlighterError: LocalizedError {
}

final class TreeSitterSyntaxHighlighter: LineSyntaxHighlighter {
var theme: Theme = DefaultTheme()
var theme: Theme = DefaultTheme.share
var kern: CGFloat = 0
var canHighlight: Bool {
languageMode.canHighlight
Expand Down