Skip to content

Commit 6eb9f08

Browse files
committed
Docs, Naming
1 parent 2dd0fad commit 6eb9f08

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

Sources/CodeEditTextView/EmphasisManager/Emphasis.swift

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,39 @@ import AppKit
99

1010
/// Represents a single emphasis with its properties
1111
public struct Emphasis {
12+
/// The range the emphasis applies it's style to, relative to the entire text document.
1213
public let range: NSRange
14+
15+
/// The style to apply emphasis with, handled by the ``EmphasisManager``.
1316
public let style: EmphasisStyle
17+
18+
/// Set to `true` to 'flash' the emphasis before removing it automatically after being added.
19+
///
20+
/// Useful when an emphasis should be temporary and quick, like when emphasizing paired brackets in a document.
1421
public let flash: Bool
22+
23+
/// Set to `true` to style the emphasis as 'inactive'.
24+
///
25+
/// When ``style`` is ``EmphasisStyle/standard``, this reduces shadows and background color.
26+
/// For all styles, if drawing text on top of them, this uses ``EmphasisManager/getInactiveTextColor`` instead of
27+
/// the text view's text color to render the emphasized text.
1528
public let inactive: Bool
16-
public let select: Bool
29+
30+
/// Set to `true` if the emphasis manager should update the text view's selected range to match
31+
/// this object's ``Emphasis/range`` value.
32+
public let selectInDocument: Bool
1733

1834
public init(
1935
range: NSRange,
2036
style: EmphasisStyle = .standard,
2137
flash: Bool = false,
2238
inactive: Bool = false,
23-
select: Bool = false
39+
selectInDocument: Bool = false
2440
) {
2541
self.range = range
2642
self.style = style
2743
self.flash = flash
2844
self.inactive = inactive
29-
self.select = select
45+
self.selectInDocument = selectInDocument
3046
}
3147
}

Sources/CodeEditTextView/EmphasisManager/EmphasisManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public final class EmphasisManager {
299299

300300
/// Handles selection of text ranges for emphases where select is true
301301
private func handleSelections(for emphases: [Emphasis]) {
302-
let selectableRanges = emphases.filter(\.select).map(\.range)
302+
let selectableRanges = emphases.filter(\.selectInDocument).map(\.range)
303303
guard let textView, !selectableRanges.isEmpty else { return }
304304

305305
textView.selectionManager.setSelectedRanges(selectableRanges)

0 commit comments

Comments
 (0)