Skip to content

Commit 7cf6937

Browse files
committed
Remove internal, Unnecessary Public Extensions
1 parent 0016b1d commit 7cf6937

10 files changed

+37
-37
lines changed

Sources/CodeEditInputView/Extensions/NSTextStorage+getLine.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import AppKit
99

1010
extension NSString {
11-
public func getNextLine(startingAt location: Int) -> NSRange? {
11+
func getNextLine(startingAt location: Int) -> NSRange? {
1212
let range = NSRange(location: location, length: 0)
1313
var end: Int = NSNotFound
1414
var contentsEnd: Int = NSNotFound
@@ -22,7 +22,7 @@ extension NSString {
2222
}
2323

2424
extension NSTextStorage {
25-
public func getNextLine(startingAt location: Int) -> NSRange? {
25+
func getNextLine(startingAt location: Int) -> NSRange? {
2626
(self.string as NSString).getNextLine(startingAt: location)
2727
}
2828
}

Sources/CodeEditInputView/TextLayoutManager/TextLayoutManager.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ public class TextLayoutManager: NSObject {
7474
/// The calculated maximum width of all laid out lines.
7575
/// - Note: This does not indicate *the* maximum width of the text view if all lines have not been laid out.
7676
/// This will be updated if it comes across a wider line.
77-
internal var maxLineWidth: CGFloat = 0 {
77+
var maxLineWidth: CGFloat = 0 {
7878
didSet {
7979
delegate?.layoutManagerMaxWidthDidChange(newWidth: maxLineWidth + edgeInsets.horizontal)
8080
}
8181
}
8282
/// The maximum width available to lay out lines in.
83-
internal var maxLineLayoutWidth: CGFloat {
83+
var maxLineLayoutWidth: CGFloat {
8484
wrapLines ? (delegate?.textViewportSize().width ?? .greatestFiniteMagnitude) - edgeInsets.horizontal
8585
: .greatestFiniteMagnitude
8686
}
@@ -119,7 +119,7 @@ public class TextLayoutManager: NSObject {
119119

120120
/// Prepares the layout manager for use.
121121
/// Parses the text storage object into lines and builds the `lineStorage` object from those lines.
122-
internal func prepareTextLines() {
122+
func prepareTextLines() {
123123
guard lineStorage.count == 0, let textStorage else { return }
124124
#if DEBUG
125125
// Grab some performance information if debugging.
@@ -141,7 +141,7 @@ public class TextLayoutManager: NSObject {
141141
}
142142

143143
/// Resets the layout manager to an initial state.
144-
internal func reset() {
144+
func reset() {
145145
lineStorage.removeAll()
146146
visibleLineIds.removeAll()
147147
viewReuseQueue.queuedViews.removeAll()
@@ -229,7 +229,7 @@ public class TextLayoutManager: NSObject {
229229
// MARK: - Layout
230230

231231
/// Lays out all visible lines
232-
internal func layoutLines() { // swiftlint:disable:this function_body_length
232+
func layoutLines() { // swiftlint:disable:this function_body_length
233233
guard let visibleRect = delegate?.visibleRect, !isInTransaction, let textStorage else { return }
234234
CATransaction.begin()
235235
let minY = max(visibleRect.minY, 0)

Sources/CodeEditInputView/TextLineStorage/TextLineStorage+Node.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import Foundation
99

1010
extension TextLineStorage {
11-
internal func isRightChild(_ node: Node<Data>) -> Bool {
11+
func isRightChild(_ node: Node<Data>) -> Bool {
1212
node.parent?.right === node
1313
}
1414

15-
internal func isLeftChild(_ node: Node<Data>) -> Bool {
15+
func isLeftChild(_ node: Node<Data>) -> Bool {
1616
node.parent?.left === node
1717
}
1818

@@ -34,7 +34,7 @@ extension TextLineStorage {
3434
/// - Parameters:
3535
/// - nodeU: The node to replace.
3636
/// - nodeV: The node to insert in place of `nodeU`
37-
internal func transplant(_ nodeU: borrowing Node<Data>, with nodeV: Node<Data>?) {
37+
func transplant(_ nodeU: borrowing Node<Data>, with nodeV: Node<Data>?) {
3838
if nodeU.parent == nil {
3939
root = nodeV
4040
} else if isLeftChild(nodeU) {
@@ -105,31 +105,31 @@ extension TextLineStorage {
105105
)
106106
}
107107

108-
internal func sibling() -> Node<NodeData>? {
108+
func sibling() -> Node<NodeData>? {
109109
if parent?.left === self {
110110
return parent?.right
111111
} else {
112112
return parent?.left
113113
}
114114
}
115115

116-
internal func minimum() -> Node<NodeData> {
116+
func minimum() -> Node<NodeData> {
117117
if let left {
118118
return left.minimum()
119119
} else {
120120
return self
121121
}
122122
}
123123

124-
internal func maximum() -> Node<NodeData> {
124+
func maximum() -> Node<NodeData> {
125125
if let right {
126126
return right.maximum()
127127
} else {
128128
return self
129129
}
130130
}
131131

132-
internal func getSuccessor() -> Node<NodeData>? {
132+
func getSuccessor() -> Node<NodeData>? {
133133
// If node has right child: successor is the min of this right tree
134134
if let right {
135135
return right.minimum()

Sources/CodeEditInputView/TextLineStorage/TextLineStorage+Structs.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import Foundation
99

1010
extension TextLineStorage where Data: Identifiable {
1111
public struct TextLinePosition {
12-
internal init(data: Data, range: NSRange, yPos: CGFloat, height: CGFloat, index: Int) {
12+
init(data: Data, range: NSRange, yPos: CGFloat, height: CGFloat, index: Int) {
1313
self.data = data
1414
self.range = range
1515
self.yPos = yPos
1616
self.height = height
1717
self.index = index
1818
}
1919

20-
internal init(position: NodePosition) {
20+
init(position: NodePosition) {
2121
self.data = position.node.data
2222
self.range = NSRange(location: position.textPos, length: position.node.length)
2323
self.yPos = position.yPos
@@ -37,7 +37,7 @@ extension TextLineStorage where Data: Identifiable {
3737
public let index: Int
3838
}
3939

40-
internal struct NodePosition {
40+
struct NodePosition {
4141
/// The node storing information and the data stored at the position.
4242
let node: Node<Data>
4343
/// The y position of the data, on a top down y axis
@@ -48,7 +48,7 @@ extension TextLineStorage where Data: Identifiable {
4848
let index: Int
4949
}
5050

51-
internal struct NodeSubtreeMetadata {
51+
struct NodeSubtreeMetadata {
5252
let height: CGFloat
5353
let offset: Int
5454
let count: Int

Sources/CodeEditInputView/TextLineStorage/TextLineStorage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public final class TextLineStorage<Data: Identifiable> {
3030
case none
3131
}
3232

33-
internal var root: Node<Data>?
33+
var root: Node<Data>?
3434

3535
/// The number of characters in the storage object.
3636
private(set) public var length: Int = 0

Sources/CodeEditInputView/TextSelectionManager/TextSelectionManager+Update.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extension TextSelectionManager {
3939
}
4040
}
4141

42-
internal func notifyAfterEdit() {
42+
func notifyAfterEdit() {
4343
updateSelectionViews()
4444
NotificationCenter.default.post(Notification(name: Self.selectionChangedNotification, object: self))
4545
}

Sources/CodeEditInputView/TextSelectionManager/TextSelectionManager.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public class TextSelectionManager: NSObject {
2323

2424
public class TextSelection: Hashable, Equatable {
2525
public var range: NSRange
26-
internal weak var view: CursorView?
27-
internal var boundingRect: CGRect = .zero
28-
internal var suggestedXPos: CGFloat?
26+
weak var view: CursorView?
27+
var boundingRect: CGRect = .zero
28+
var suggestedXPos: CGFloat?
2929
/// The position this selection should 'rotate' around when modifying selections.
30-
internal var pivot: Int?
30+
var pivot: Int?
3131

3232
init(range: NSRange, view: CursorView? = nil) {
3333
self.range = range
@@ -79,10 +79,10 @@ public class TextSelectionManager: NSObject {
7979
public var selectionBackgroundColor: NSColor = NSColor.selectedTextBackgroundColor
8080

8181
internal(set) public var textSelections: [TextSelection] = []
82-
internal weak var layoutManager: TextLayoutManager?
83-
internal weak var textStorage: NSTextStorage?
84-
internal weak var layoutView: NSView?
85-
internal weak var delegate: TextSelectionManagerDelegate?
82+
weak var layoutManager: TextLayoutManager?
83+
weak var textStorage: NSTextStorage?
84+
weak var layoutView: NSView?
85+
weak var delegate: TextSelectionManagerDelegate?
8686

8787
init(
8888
layoutManager: TextLayoutManager,
@@ -183,7 +183,7 @@ public class TextSelectionManager: NSObject {
183183
}
184184
}
185185

186-
internal func removeCursors() {
186+
func removeCursors() {
187187
for textSelection in textSelections {
188188
textSelection.view?.removeFromSuperview()
189189
}
@@ -193,7 +193,7 @@ public class TextSelectionManager: NSObject {
193193

194194
/// Draws line backgrounds and selection rects for each selection in the given rect.
195195
/// - Parameter rect: The rect to draw in.
196-
internal func drawSelections(in rect: NSRect) {
196+
func drawSelections(in rect: NSRect) {
197197
guard let context = NSGraphicsContext.current?.cgContext else { return }
198198
context.saveGState()
199199
var highlightedLines: Set<UUID> = []

Sources/CodeEditInputView/TextView/TextView+Drag.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extension TextView: NSDraggingSource {
2626
}
2727
}
2828

29-
internal func setUpDragGesture() {
29+
func setUpDragGesture() {
3030
let dragGesture = DragSelectionGesture(target: self, action: #selector(dragGestureHandler(_:)))
3131
dragGesture.minimumPressDuration = NSEvent.doubleClickInterval / 3
3232
dragGesture.isEnabled = isSelectable

Sources/CodeEditInputView/TextView/TextView+Setup.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import AppKit
99

1010
extension TextView {
11-
internal func setUpLayoutManager(lineHeightMultiplier: CGFloat, wrapLines: Bool) -> TextLayoutManager {
11+
func setUpLayoutManager(lineHeightMultiplier: CGFloat, wrapLines: Bool) -> TextLayoutManager {
1212
TextLayoutManager(
1313
textStorage: textStorage,
1414
lineHeightMultiplier: lineHeightMultiplier,
@@ -18,7 +18,7 @@ extension TextView {
1818
)
1919
}
2020

21-
internal func setUpSelectionManager() -> TextSelectionManager {
21+
func setUpSelectionManager() -> TextSelectionManager {
2222
TextSelectionManager(
2323
layoutManager: layoutManager,
2424
textStorage: textStorage,

Sources/CodeEditInputView/TextView/TextView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ public class TextView: NSView, NSTextContent {
195195

196196
// MARK: - Private Properties
197197

198-
internal var isFirstResponder: Bool = false
199-
internal var mouseDragAnchor: CGPoint?
200-
internal var mouseDragTimer: Timer?
198+
var isFirstResponder: Bool = false
199+
var mouseDragAnchor: CGPoint?
200+
var mouseDragTimer: Timer?
201201

202202
private var fontCharWidth: CGFloat {
203203
(" " as NSString).size(withAttributes: [.font: font]).width
@@ -211,7 +211,7 @@ public class TextView: NSView, NSTextContent {
211211
return enclosingScrollView
212212
}
213213

214-
internal var storageDelegate: MultiStorageDelegate!
214+
var storageDelegate: MultiStorageDelegate!
215215

216216
// MARK: - Init
217217

0 commit comments

Comments
 (0)