Skip to content
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
2 changes: 1 addition & 1 deletion SyntaxKit/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ open class Parser {
print("Attention unexpected capture (\(index) to \(result.numberOfRanges)): \(expression.pattern)")
continue
}
let range = result.rangeAt(Int(index))
let range = result.range(at: Int(index))
if range.location == NSNotFound {
continue
}
Expand Down
16 changes: 8 additions & 8 deletions SyntaxKit/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import UIKit
#endif

public typealias Attributes = [String: AnyObject]
public typealias Attributes = [NSAttributedStringKey: Any]

public struct Theme {

Expand All @@ -26,11 +26,11 @@ public struct Theme {
public let attributes: [String: Attributes]

public var backgroundColor: Color {
return attributes[Language.globalScope]?[NSBackgroundColorAttributeName] as? Color ?? Color.white
return attributes[Language.globalScope]?[NSAttributedStringKey.backgroundColor] as? Color ?? Color.white
}

public var foregroundColor: Color {
return attributes[Language.globalScope]?[NSForegroundColorAttributeName] as? Color ?? Color.black
return attributes[Language.globalScope]?[NSAttributedStringKey.foregroundColor] as? Color ?? Color.black
}

// MARK: - Initializers
Expand All @@ -47,14 +47,14 @@ public struct Theme {

var attributes = [String: Attributes]()
for raw in rawSettings {
guard var setting = raw["settings"] as? [String: AnyObject] else { continue }
guard var setting = raw["settings"] as? [NSAttributedStringKey: Any] else { continue }

if let value = setting.removeValue(forKey: "foreground") as? String {
setting[NSForegroundColorAttributeName] = Color(hex: value)
if let value = setting.removeValue(forKey: NSAttributedStringKey(rawValue: "foreground")) as? String {
setting[NSAttributedStringKey.foregroundColor] = Color(hex: value)
}

if let value = setting.removeValue(forKey: "background") as? String {
setting[NSBackgroundColorAttributeName] = Color(hex: value)
if let value = setting.removeValue(forKey: NSAttributedStringKey(rawValue: "background")) as? String {
setting[NSAttributedStringKey.backgroundColor] = Color(hex: value)
}

if let patternIdentifiers = raw["scope"] as? String {
Expand Down