diff --git a/Package.swift b/Package.swift index 49b45bc..bd8e3a2 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 6.0 +// swift-tools-version: 6.2 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -6,8 +6,8 @@ import PackageDescription let package = Package( name: "AgentKit", platforms: [ - .macOS(.v15), - .iOS(.v18), + .macOS(.v26), + .iOS(.v26), ], products: [ // Products define the executables and libraries a package produces, making them visible to other packages. diff --git a/Sources/AgentLayout/Markdown/SyntaxHighlighting/SplashSyntaxHighlighter.swift b/Sources/AgentLayout/Markdown/SyntaxHighlighting/SplashSyntaxHighlighter.swift index 1cbae66..c0b6f3f 100644 --- a/Sources/AgentLayout/Markdown/SyntaxHighlighting/SplashSyntaxHighlighter.swift +++ b/Sources/AgentLayout/Markdown/SyntaxHighlighting/SplashSyntaxHighlighter.swift @@ -40,7 +40,11 @@ extension TextOutputFormat { fileprivate init(theme: Splash.Theme) { var theme = theme + #if canImport(UIKit) + theme.plainTextColor = .label + #elseif canImport(AppKit) theme.plainTextColor = .textColor + #endif theme.tokenColors[.keyword] = .blue theme.tokenColors[.string] = .blue theme.tokenColors[.comment] = .gray @@ -52,14 +56,28 @@ extension TextOutputFormat { } mutating func addToken(_ token: String, ofType type: TokenType) { + #if canImport(UIKit) + let color = self.theme.tokenColors[type] ?? .label + #elseif canImport(AppKit) let color = self.theme.tokenColors[type] ?? .textColor + #endif + #if canImport(UIKit) + self.accumulatedText.append(Text(token).foregroundColor(.init(uiColor: color))) + #elseif canImport(AppKit) self.accumulatedText.append(Text(token).foregroundColor(.init(nsColor: color))) + #endif } mutating func addPlainText(_ text: String) { + #if canImport(UIKit) + self.accumulatedText.append( + Text(text).foregroundColor(.init(uiColor: self.theme.plainTextColor)) + ) + #elseif canImport(AppKit) self.accumulatedText.append( Text(text).foregroundColor(.init(nsColor: self.theme.plainTextColor)) ) + #endif } mutating func addWhitespace(_ whitespace: String) {