diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 9e605f4..1aae0f9 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -13,7 +13,7 @@ jobs: - name: Select latest available Xcode uses: maxim-lobanov/setup-xcode@v1.2.1 with: - xcode-version: 13.2.1 + xcode-version: latest - name: Checkout Repository uses: actions/checkout@v2 - name: Build Swift Debug Package diff --git a/.gitignore b/.gitignore index 9dac8f9..ea1098e 100644 --- a/.gitignore +++ b/.gitignore @@ -90,4 +90,5 @@ fastlane/test_output iOSInjectionProject/ Package.resolved +.swiftpm diff --git a/Package@swift-5.10.swift b/Package@swift-5.10.swift new file mode 100644 index 0000000..d319548 --- /dev/null +++ b/Package@swift-5.10.swift @@ -0,0 +1,26 @@ +// swift-tools-version:5.10 + +import PackageDescription + +let package = Package( + + name: "CodeEditor", + + platforms: [ + .macOS(.v10_15), .iOS(.v13), .visionOS(.v1), .watchOS(.v7), .tvOS(.v12) + ], + + products: [ + .library(name: "CodeEditor", targets: [ "CodeEditor" ]) + ], + + dependencies: [ + // Temporary, until upstream PR is merged. + //.package(url: "https://github.com/raspu/Highlightr", from: "2.1.2") + .package(url: "https://github.com/helje5/Highlightr", from: "3.0.2") + ], + + targets: [ + .target(name: "CodeEditor", dependencies: [ "Highlightr" ]) + ] +) diff --git a/README.md b/README.md index d3b376e..53b0750 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,10 @@ ![SwiftUI](https://img.shields.io/badge/SwiftUI-orange.svg) -![Swift5.3](https://img.shields.io/badge/swift-5.3-blue.svg) +![Swift5](https://img.shields.io/badge/swift-5-blue.svg) ![macOS](https://img.shields.io/badge/os-macOS-green.svg?style=flat) ![iOS](https://img.shields.io/badge/os-iOS-green.svg?style=flat) +![visionOS](https://img.shields.io/badge/os-visionOS-green.svg?style=flat) [![Build and Test](https://github.com/ZeeZide/CodeEditor/actions/workflows/swift.yml/badge.svg?branch=main)](https://github.com/ZeeZide/CodeEditor/actions/workflows/swift.yml) A [SwiftUI](https://developer.apple.com/xcode/swiftui/) diff --git a/Sources/CodeEditor/Language.swift b/Sources/CodeEditor/Language.swift index e764f41..52c7933 100644 --- a/Sources/CodeEditor/Language.swift +++ b/Sources/CodeEditor/Language.swift @@ -3,13 +3,13 @@ // CodeEditor // // Created by Helge Heß. -// Copyright © 2021 ZeeZide GmbH. All rights reserved. +// Copyright © 2021-2024 ZeeZide GmbH. All rights reserved. // public extension CodeEditor { @frozen - struct Language: TypedString { + struct Language: TypedString, Sendable { public let rawValue : String @@ -20,45 +20,45 @@ public extension CodeEditor { public extension CodeEditor.Language { - static var accesslog = CodeEditor.Language(rawValue: "accesslog") - static var actionscript = CodeEditor.Language(rawValue: "actionscript") - static var ada = CodeEditor.Language(rawValue: "ada") - static var apache = CodeEditor.Language(rawValue: "apache") - static var applescript = CodeEditor.Language(rawValue: "applescript") - static var bash = CodeEditor.Language(rawValue: "bash") - static var basic = CodeEditor.Language(rawValue: "basic") - static var brainfuck = CodeEditor.Language(rawValue: "brainfuck") - static var c = CodeEditor.Language(rawValue: "c") - static var cpp = CodeEditor.Language(rawValue: "cpp") - static var cs = CodeEditor.Language(rawValue: "cs") - static var css = CodeEditor.Language(rawValue: "css") - static var diff = CodeEditor.Language(rawValue: "diff") - static var dockerfile = CodeEditor.Language(rawValue: "dockerfile") - static var go = CodeEditor.Language(rawValue: "go") - static var http = CodeEditor.Language(rawValue: "http") - static var java = CodeEditor.Language(rawValue: "java") - static var javascript = CodeEditor.Language(rawValue: "javascript") - static var json = CodeEditor.Language(rawValue: "json") - static var lua = CodeEditor.Language(rawValue: "lua") - static var markdown = CodeEditor.Language(rawValue: "markdown") - static var makefile = CodeEditor.Language(rawValue: "makefile") - static var nginx = CodeEditor.Language(rawValue: "nginx") - static var objectivec = CodeEditor.Language(rawValue: "objectivec") - static var pgsql = CodeEditor.Language(rawValue: "pgsql") - static var php = CodeEditor.Language(rawValue: "php") - static var python = CodeEditor.Language(rawValue: "python") - static var ruby = CodeEditor.Language(rawValue: "ruby") - static var rust = CodeEditor.Language(rawValue: "rust") - static var shell = CodeEditor.Language(rawValue: "shell") - static var smalltalk = CodeEditor.Language(rawValue: "smalltalk") - static var sql = CodeEditor.Language(rawValue: "sql") - static var swift = CodeEditor.Language(rawValue: "swift") - static var tcl = CodeEditor.Language(rawValue: "tcl") - static var tex = CodeEditor.Language(rawValue: "tex") - static var twig = CodeEditor.Language(rawValue: "twig") - static var typescript = CodeEditor.Language(rawValue: "typescript") - static var vbnet = CodeEditor.Language(rawValue: "vbnet") - static var vbscript = CodeEditor.Language(rawValue: "vbscript") - static var xml = CodeEditor.Language(rawValue: "xml") - static var yaml = CodeEditor.Language(rawValue: "yaml") + @inlinable static var accesslog : Self { Self(rawValue: "accesslog") } + @inlinable static var actionscript : Self { Self(rawValue: "actionscript") } + @inlinable static var ada : Self { Self(rawValue: "ada") } + @inlinable static var apache : Self { Self(rawValue: "apache") } + @inlinable static var applescript : Self { Self(rawValue: "applescript") } + @inlinable static var bash : Self { Self(rawValue: "bash") } + @inlinable static var basic : Self { Self(rawValue: "basic") } + @inlinable static var brainfuck : Self { Self(rawValue: "brainfuck") } + @inlinable static var c : Self { Self(rawValue: "c") } + @inlinable static var cpp : Self { Self(rawValue: "cpp") } + @inlinable static var cs : Self { Self(rawValue: "cs") } + @inlinable static var css : Self { Self(rawValue: "css") } + @inlinable static var diff : Self { Self(rawValue: "diff") } + @inlinable static var dockerfile : Self { Self(rawValue: "dockerfile") } + @inlinable static var go : Self { Self(rawValue: "go") } + @inlinable static var http : Self { Self(rawValue: "http") } + @inlinable static var java : Self { Self(rawValue: "java") } + @inlinable static var javascript : Self { Self(rawValue: "javascript") } + @inlinable static var json : Self { Self(rawValue: "json") } + @inlinable static var lua : Self { Self(rawValue: "lua") } + @inlinable static var markdown : Self { Self(rawValue: "markdown") } + @inlinable static var makefile : Self { Self(rawValue: "makefile") } + @inlinable static var nginx : Self { Self(rawValue: "nginx") } + @inlinable static var objectivec : Self { Self(rawValue: "objectivec") } + @inlinable static var pgsql : Self { Self(rawValue: "pgsql") } + @inlinable static var php : Self { Self(rawValue: "php") } + @inlinable static var python : Self { Self(rawValue: "python") } + @inlinable static var ruby : Self { Self(rawValue: "ruby") } + @inlinable static var rust : Self { Self(rawValue: "rust") } + @inlinable static var shell : Self { Self(rawValue: "shell") } + @inlinable static var smalltalk : Self { Self(rawValue: "smalltalk") } + @inlinable static var sql : Self { Self(rawValue: "sql") } + @inlinable static var swift : Self { Self(rawValue: "swift") } + @inlinable static var tcl : Self { Self(rawValue: "tcl") } + @inlinable static var tex : Self { Self(rawValue: "tex") } + @inlinable static var twig : Self { Self(rawValue: "twig") } + @inlinable static var typescript : Self { Self(rawValue: "typescript") } + @inlinable static var vbnet : Self { Self(rawValue: "vbnet") } + @inlinable static var vbscript : Self { Self(rawValue: "vbscript") } + @inlinable static var xml : Self { Self(rawValue: "xml") } + @inlinable static var yaml : Self { Self(rawValue: "yaml") } } diff --git a/Sources/CodeEditor/ThemeName.swift b/Sources/CodeEditor/ThemeName.swift index f705c9d..b48f634 100644 --- a/Sources/CodeEditor/ThemeName.swift +++ b/Sources/CodeEditor/ThemeName.swift @@ -3,13 +3,13 @@ // CodeEditor // // Created by Helge Heß. -// Copyright © 2021 ZeeZide GmbH. All rights reserved. +// Copyright © 2021-2024 ZeeZide GmbH. All rights reserved. // public extension CodeEditor { @frozen - struct ThemeName: TypedString { + struct ThemeName: TypedString, Sendable { public let rawValue : String @@ -20,14 +20,15 @@ public extension CodeEditor { public extension CodeEditor.ThemeName { - static var `default` = pojoaque + @inlinable static var `default` : Self { pojoaque } + @inlinable static var pojoaque : Self { Self(rawValue: "pojoaque") } + @inlinable static var agate : Self { Self(rawValue: "agate") } + @inlinable static var ocean : Self { Self(rawValue: "ocean") } - static var pojoaque = CodeEditor.ThemeName(rawValue: "pojoaque") - static var agate = CodeEditor.ThemeName(rawValue: "agate") - static var ocean = CodeEditor.ThemeName(rawValue: "ocean") - - static var atelierSavannaLight = - CodeEditor.ThemeName(rawValue: "atelier-savanna-light") - static var atelierSavannaDark = - CodeEditor.ThemeName(rawValue: "atelier-savanna-dark") + @inlinable + static var atelierSavannaLight : Self { + Self(rawValue: "atelier-savanna-light") } + @inlinable + static var atelierSavannaDark : Self { + Self(rawValue: "atelier-savanna-dark") } } diff --git a/Sources/CodeEditor/UXCodeTextViewRepresentable.swift b/Sources/CodeEditor/UXCodeTextViewRepresentable.swift index 9dfd66c..987b6ac 100644 --- a/Sources/CodeEditor/UXCodeTextViewRepresentable.swift +++ b/Sources/CodeEditor/UXCodeTextViewRepresentable.swift @@ -109,7 +109,7 @@ struct UXCodeTextViewRepresentable : UXViewRepresentable { } textViewDidChange(textView: textView) } - #elseif os(iOS) + #elseif os(iOS) || os(visionOS) public func textViewDidChange(_ textView: UITextView) { textViewDidChange(textView: textView) } @@ -139,7 +139,7 @@ struct UXCodeTextViewRepresentable : UXViewRepresentable { textViewDidChangeSelection(textView: textView as! UXCodeTextView) } - #elseif os(iOS) + #elseif os(iOS) || os(visionOS) public func textViewDidChangeSelection(_ textView: UITextView) { textViewDidChangeSelection(textView: textView as! UXCodeTextView) } @@ -214,7 +214,7 @@ struct UXCodeTextViewRepresentable : UXViewRepresentable { let nsrange = NSRange(range, in: textView.string) #if os(macOS) textView.setSelectedRange(nsrange) - #elseif os(iOS) + #elseif os(iOS) || os(visionOS) textView.selectedRange = nsrange #else #error("Unsupported OS")