Skip to content

Commit 44c3545

Browse files
Remove TextStory
1 parent ccebc55 commit 44c3545

14 files changed

Lines changed: 739 additions & 945 deletions

Package.resolved

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.8
1+
// swift-tools-version: 6.0
22

33
import PackageDescription
44

@@ -15,20 +15,9 @@ let package = Package(
1515
],
1616
dependencies: [
1717
.package(url: "https://github.com/ChimeHQ/Rearrange", branch: "main"),
18-
.package(url: "https://github.com/ChimeHQ/TextStory", from: "0.9.0"),
1918
],
2019
targets: [
21-
.target(name: "TextFormation", dependencies: ["Rearrange", "TextStory"]),
20+
.target(name: "TextFormation", dependencies: ["Rearrange"]),
2221
.testTarget(name: "TextFormationTests", dependencies: ["TextFormation"]),
2322
]
2423
)
25-
26-
let swiftSettings: [SwiftSetting] = [
27-
.enableExperimentalFeature("StrictConcurrency")
28-
]
29-
30-
for target in package.targets {
31-
var settings = target.swiftSettings ?? []
32-
settings.append(contentsOf: swiftSettings)
33-
target.swiftSettings = settings
34-
}

Sources/TextFormation/Filter.swift

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,7 @@
11
import Foundation
22

33
import Rearrange
4-
import TextStory
54

6-
/// Describes the action to be taken after the filter has run.
7-
public enum FilterAction {
8-
case none
9-
case stop
10-
case discard
11-
}
12-
13-
extension FilterAction: Hashable {}
14-
extension FilterAction: Sendable {}
15-
16-
public protocol Filter {
17-
func processMutation(_ mutation: TextMutation, in interface: TextInterface, with providers: WhitespaceProviders) -> FilterAction
18-
}
19-
20-
public extension Filter {
21-
func processMutation(_ mutation: TextMutation, in interface: TextInterface) -> FilterAction {
22-
return processMutation(mutation, in: interface, with: .none)
23-
}
24-
}
25-
26-
public extension Filter {
27-
func shouldProcessMutation(_ mutation: TextMutation, in interface: TextInterface, with providers: WhitespaceProviders) -> Bool {
28-
switch processMutation(mutation, in: interface, with: providers) {
29-
case .discard:
30-
return false
31-
case .none, .stop:
32-
return true
33-
}
34-
}
35-
}
36-
37-
// ---
385
public struct NewTextMutation<Interface: TextSystemInterface> {
396
public let range: Interface.TextRange
407
public let interface: Interface

Sources/TextFormation/TextInterface.swift

Lines changed: 0 additions & 95 deletions
This file was deleted.
Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,79 @@
1-
import Foundation
2-
import TextStory
3-
4-
extension TextStoring {
5-
func findFirstLinePreceeding(location: Int, satisifying predicate: TextualIndenter.ReferenceLinePredicate) -> NSRange? {
6-
var startLoc = findStartOfLine(containing: location)
7-
8-
if startLoc == 0 {
9-
return nil
10-
}
11-
12-
startLoc -= 1
13-
14-
while startLoc > 0 {
15-
let preceedingStart = findStartOfLine(containing: startLoc)
16-
let length = startLoc - preceedingStart
17-
18-
assert(length >= 0)
19-
let range = NSRange(location: preceedingStart, length: length)
20-
21-
if predicate(self, range) {
22-
return range
23-
}
24-
25-
startLoc = preceedingStart - 1
26-
}
27-
28-
return .zero
29-
}
30-
31-
func leadingIndentingWhitespace(at location: Int) -> String? {
32-
let set = CharacterSet.whitespacesWithoutNewlines.inverted
33-
34-
let start = findStartOfLine(containing: location)
35-
let end = findNextOccurrenceOfCharacter(in: set, from: start) ?? length
36-
37-
let indentRange = NSRange(start..<end)
38-
39-
return substring(from: indentRange)
40-
}
41-
}
42-
43-
extension TextStoring {
44-
public func whitespaceStringResult(with indentation: Indentation, using indentUnit: String, width: Int) -> Result<String, IndentationError> {
45-
assert(width > 0)
46-
47-
let range = indentation.range
48-
guard let referenceWhitespace = leadingIndentingWhitespace(at: range.location) else {
49-
return .failure(.unableToComputeReferenceRange)
50-
}
51-
52-
// here, we have to determine how many units of indentation currently exist
53-
let spaceOnlyReference = referenceWhitespace.replacingOccurrences(of: "\t", with: String(repeating: " ", count: width))
54-
let spaceCount = spaceOnlyReference.utf8.count
55-
let referenceCount = spaceCount / width
56-
let remainder = spaceCount % width
57-
58-
switch indentation {
59-
case .relativeIncrease:
60-
let value = String(repeating: indentUnit, count: referenceCount + 1) + String(repeating: " ", count: remainder)
61-
62-
return .success(value)
63-
case .relativeDecrease:
64-
guard let indentUnitStringRange = referenceWhitespace.range(of: indentUnit) else {
65-
return .failure(.unableToComputeReferenceRange)
66-
}
67-
68-
var updatedWhitespace = referenceWhitespace
69-
70-
updatedWhitespace.removeSubrange(indentUnitStringRange)
71-
72-
return .success(updatedWhitespace)
73-
case .equal:
74-
let value = String(repeating: indentUnit, count: referenceCount) + String(repeating: " ", count: remainder)
75-
76-
return .success(value)
77-
}
78-
}
79-
}
1+
//import Foundation
2+
//import TextStory
3+
//
4+
//extension TextStoring {
5+
// func findFirstLinePreceeding(location: Int, satisifying predicate: TextualIndenter.ReferenceLinePredicate) -> NSRange? {
6+
// var startLoc = findStartOfLine(containing: location)
7+
//
8+
// if startLoc == 0 {
9+
// return nil
10+
// }
11+
//
12+
// startLoc -= 1
13+
//
14+
// while startLoc > 0 {
15+
// let preceedingStart = findStartOfLine(containing: startLoc)
16+
// let length = startLoc - preceedingStart
17+
//
18+
// assert(length >= 0)
19+
// let range = NSRange(location: preceedingStart, length: length)
20+
//
21+
// if predicate(self, range) {
22+
// return range
23+
// }
24+
//
25+
// startLoc = preceedingStart - 1
26+
// }
27+
//
28+
// return .zero
29+
// }
30+
//
31+
// func leadingIndentingWhitespace(at location: Int) -> String? {
32+
// let set = CharacterSet.whitespacesWithoutNewlines.inverted
33+
//
34+
// let start = findStartOfLine(containing: location)
35+
// let end = findNextOccurrenceOfCharacter(in: set, from: start) ?? length
36+
//
37+
// let indentRange = NSRange(start..<end)
38+
//
39+
// return substring(from: indentRange)
40+
// }
41+
//}
42+
//
43+
//extension TextStoring {
44+
// public func whitespaceStringResult(with indentation: Indentation, using indentUnit: String, width: Int) -> Result<String, IndentationError> {
45+
// assert(width > 0)
46+
//
47+
// let range = indentation.range
48+
// guard let referenceWhitespace = leadingIndentingWhitespace(at: range.location) else {
49+
// return .failure(.unableToComputeReferenceRange)
50+
// }
51+
//
52+
// // here, we have to determine how many units of indentation currently exist
53+
// let spaceOnlyReference = referenceWhitespace.replacingOccurrences(of: "\t", with: String(repeating: " ", count: width))
54+
// let spaceCount = spaceOnlyReference.utf8.count
55+
// let referenceCount = spaceCount / width
56+
// let remainder = spaceCount % width
57+
//
58+
// switch indentation {
59+
// case .relativeIncrease:
60+
// let value = String(repeating: indentUnit, count: referenceCount + 1) + String(repeating: " ", count: remainder)
61+
//
62+
// return .success(value)
63+
// case .relativeDecrease:
64+
// guard let indentUnitStringRange = referenceWhitespace.range(of: indentUnit) else {
65+
// return .failure(.unableToComputeReferenceRange)
66+
// }
67+
//
68+
// var updatedWhitespace = referenceWhitespace
69+
//
70+
// updatedWhitespace.removeSubrange(indentUnitStringRange)
71+
//
72+
// return .success(updatedWhitespace)
73+
// case .equal:
74+
// let value = String(repeating: indentUnit, count: referenceCount) + String(repeating: " ", count: remainder)
75+
//
76+
// return .success(value)
77+
// }
78+
// }
79+
//}

0 commit comments

Comments
 (0)