Skip to content

Commit 50081c0

Browse files
committed
Move Emphasis and EmphasisStyle to Files
1 parent d1f56d6 commit 50081c0

File tree

3 files changed

+62
-46
lines changed

3 files changed

+62
-46
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// Emphasis.swift
3+
// CodeEditTextView
4+
//
5+
// Created by Khan Winter on 3/31/25.
6+
//
7+
8+
import AppKit
9+
10+
/// Represents a single emphasis with its properties
11+
public struct Emphasis {
12+
public let range: NSRange
13+
public let style: EmphasisStyle
14+
public let flash: Bool
15+
public let inactive: Bool
16+
public let select: Bool
17+
18+
public init(
19+
range: NSRange,
20+
style: EmphasisStyle = .standard,
21+
flash: Bool = false,
22+
inactive: Bool = false,
23+
select: Bool = false
24+
) {
25+
self.range = range
26+
self.style = style
27+
self.flash = flash
28+
self.inactive = inactive
29+
self.select = select
30+
}
31+
}

Sources/CodeEditTextView/EmphasisManager/EmphasisManager.swift

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,6 @@
77

88
import AppKit
99

10-
/// Defines the style of emphasis to apply to text ranges
11-
public enum EmphasisStyle: Equatable {
12-
/// Standard emphasis with background color
13-
case standard
14-
/// Underline emphasis with a line color
15-
case underline(color: NSColor)
16-
/// Outline emphasis with a border color
17-
case outline(color: NSColor)
18-
19-
public static func == (lhs: EmphasisStyle, rhs: EmphasisStyle) -> Bool {
20-
switch (lhs, rhs) {
21-
case (.standard, .standard):
22-
return true
23-
case (.underline(let lhsColor), .underline(let rhsColor)):
24-
return lhsColor == rhsColor
25-
case (.outline(let lhsColor), .outline(let rhsColor)):
26-
return lhsColor == rhsColor
27-
default:
28-
return false
29-
}
30-
}
31-
}
32-
33-
/// Represents a single emphasis with its properties
34-
public struct Emphasis {
35-
public let range: NSRange
36-
public let style: EmphasisStyle
37-
public let flash: Bool
38-
public let inactive: Bool
39-
public let select: Bool
40-
41-
public init(
42-
range: NSRange,
43-
style: EmphasisStyle = .standard,
44-
flash: Bool = false,
45-
inactive: Bool = false,
46-
select: Bool = false
47-
) {
48-
self.range = range
49-
self.style = style
50-
self.flash = flash
51-
self.inactive = inactive
52-
self.select = select
53-
}
54-
}
55-
5610
/// Manages text emphases within a text view, supporting multiple styles and groups.
5711
public final class EmphasisManager {
5812
/// Internal representation of a emphasis layer with its associated text layer
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// EmphasisStyle.swift
3+
// CodeEditTextView
4+
//
5+
// Created by Khan Winter on 3/31/25.
6+
//
7+
8+
import AppKit
9+
10+
/// Defines the style of emphasis to apply to text ranges
11+
public enum EmphasisStyle: Equatable {
12+
/// Standard emphasis with background color
13+
case standard
14+
/// Underline emphasis with a line color
15+
case underline(color: NSColor)
16+
/// Outline emphasis with a border color
17+
case outline(color: NSColor)
18+
19+
public static func == (lhs: EmphasisStyle, rhs: EmphasisStyle) -> Bool {
20+
switch (lhs, rhs) {
21+
case (.standard, .standard):
22+
return true
23+
case (.underline(let lhsColor), .underline(let rhsColor)):
24+
return lhsColor == rhsColor
25+
case (.outline(let lhsColor), .outline(let rhsColor)):
26+
return lhsColor == rhsColor
27+
default:
28+
return false
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)