Skip to content

Commit

Permalink
Renamed module to STPluginNeon (#12)
Browse files Browse the repository at this point in the history
Renamed the module `NeonPlugin` → `STPluginNeon` In order to avoid a
name collision with the main type `NeonPlugin`.
This in turn, allows for easier disambiguation for projects that also
have their own `Theme` or `Colors` type.

E.g. it is now possible to do this, even if your project has its own
`Theme` type:

```swift
import SwiftUI
import STTextViewSwiftUI
import STPluginNeon

extension STPluginNeon.Theme {
    public static let myCustomTheme = STPluginNeon.Theme(colors: [:], fonts: [:])
}
```

## Discussion
See issue #11
  • Loading branch information
jeanetienne authored Nov 10, 2024
1 parent 07c0a41 commit e0055d1
Show file tree
Hide file tree
Showing 34 changed files with 10 additions and 15 deletions.
11 changes: 3 additions & 8 deletions DemoApp/EditorViewController.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AppKit
import STTextView

import NeonPlugin
import STPluginNeon

class EditorViewController: NSViewController {

Expand All @@ -20,13 +20,8 @@ class EditorViewController: NSViewController {

let sourceCodeTheme = Theme(
///Themes.xcassets
colors: Theme.Colors(bundle: Bundle(path: Bundle.main.resourcePath! + "/STTextView-Plugin-Neon_NeonPlugin.bundle")!, name: "neon.plugin.default"),
tokensCustomFontDict: [
"default": NSFont.monospacedSystemFont(ofSize: 14, weight: .regular),
"keyword": NSFont.monospacedSystemFont(ofSize: 14, weight: .medium),
"constructor": NSFont.monospacedSystemFont(ofSize: 14, weight: .medium),
"text.title": NSFont.monospacedSystemFont(ofSize: 14, weight: .medium)
]
colors: Theme.Colors(bundle: Bundle(path: Bundle.main.resourcePath! + "/STTextView-Plugin-Neon_STPluginNeon.bundle")!, name: "neon.plugin.default"),
fonts: Theme.Fonts(bundle: Bundle(path: Bundle.main.resourcePath! + "/STTextView-Plugin-Neon_STPluginNeon.bundle")!, name: "neon.plugin.default")
)

textView.addPlugin(
Expand Down
6 changes: 3 additions & 3 deletions DemoAppSwiftUI/DemoAppSwiftUI/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
//

import SwiftUI
import STTextViewUI
import NeonPlugin
import STTextViewSwiftUI
import STPluginNeon

struct ContentView: View {
@State private var text: AttributedString = ""
@State private var selection: NSRange?
var body: some View {
STTextViewUI.TextView(
TextView(
text: $text,
selection: $selection,
options: [.wrapLines, .highlightSelectedLine],
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let package = Package(
products: [
.library(
name: "STTextView-Plugin-Neon",
targets: ["NeonPlugin"]),
targets: ["STPluginNeon"]),
],
dependencies: [
.package(url: "https://github.com/krzyzanowskim/STTextView", branch: "main"),
Expand All @@ -18,7 +18,7 @@ let package = Package(
],
targets: [
.target(
name: "NeonPlugin",
name: "STPluginNeon",
dependencies: [
.product(name: "STTextView", package: "STTextView"),
.product(name: "Neon", package: "Neon"),
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ https://github.com/user-attachments/assets/910b9862-c682-4dcc-ae0e-dbb55e8a3fe5
Add the plugin package as a dependency of your application, then register/add it to the STTextView instance:

```swift
import NeonPlugin
import STPluginNeon

textView.addPlugin(
NeonPlugin(
Expand All @@ -21,7 +21,7 @@ SwiftUI:
```swift
import SwiftUI
import STTextViewUI
import NeonPlugin
import STPluginNeon

struct ContentView: View {
@State private var text: AttributedString = ""
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e0055d1

Please sign in to comment.