Skip to content

Commit 0df67cf

Browse files
committed
Cleanup
1 parent 60f933f commit 0df67cf

File tree

12 files changed

+37
-52
lines changed

12 files changed

+37
-52
lines changed

Sources/DiffableTextKit/Models/Attribute.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ public struct Attribute: CustomStringConvertible, OptionSet {
2323
// MARK: Instances
2424
//=------------------------------------------------------------------------=
2525

26-
/// Signifies that the symbol is not real and should not be parsed.
26+
/// Marks that a symbol is not real and should not be parsed.
2727
public static let virtual = Self(rawValue: 1 << 0)
2828

29-
/// Signifies that the symbol should be ignored when it is inserted.
29+
/// Marks that a symbol should be ignored when inserted.
3030
public static let insertable = Self(rawValue: 1 << 1)
3131

32-
/// Signifies that the symbol should be ignored when it is removed.
32+
/// Marks that a symbol should be ignored when removed.
3333
public static let removable = Self(rawValue: 1 << 2)
3434

35-
/// Signifies that the symbol has no interactive size and should be passed through.
35+
/// Marks that a symbol has no real size and should be passed through.
3636
public static let passthrough = Self(rawValue: 1 << 3)
3737

3838
//=------------------------------------------------------------------------=

Sources/DiffableTextKit/Models/Context.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,14 @@ extension Context {
263263
//=--------------------------------------=
264264
// Values
265265
//=--------------------------------------=
266-
let selection = Selection(layout!.snapshot.indices(at: selection))
266+
let selection = Selection(layout!.snapshot.indices(at: selection))
267267
//=--------------------------------------=
268268
// Update
269269
//=--------------------------------------=
270270
self.unique()
271-
self.storage.layout!.merge(selection: selection, momentums: momentums)
271+
self.storage.layout!.merge(
272+
selection: selection, /*-*/
273+
momentums: momentums) /*-*/
272274
//=--------------------------------------=
273275
// Return
274276
//=--------------------------------------=

Sources/DiffableTextKit/Models/Status.swift

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,15 @@ public struct Status<Style: DiffableTextStyle>: Equatable {
3939
// MARK: Transformations
4040
//=------------------------------------------------------------------------=
4141

42-
/// Merges member-wise inequalities.
42+
/// Merges member inequalities on a case-by-case basis.
43+
///
44+
/// A style marked as equals(()) will not be compared or merged.
45+
///
4346
@inlinable mutating func merge(_ other: Self) -> Changes {
44-
let changes = (self .!= other)
45-
//=--------------------------------------=
46-
// Update
47-
//=--------------------------------------=
48-
if changes.contains(.style) { self.style = other.style }
49-
if changes.contains(.value) { self.value = other.value }
50-
if changes.contains(.focus) { self.focus = other.focus }
51-
//=--------------------------------------=
52-
// Return
53-
//=--------------------------------------=
47+
let changes = self .!= other
48+
if changes.contains(.style) { self.style = other.style }
49+
if changes.contains(.value) { self.value = other.value }
50+
if changes.contains(.focus) { self.focus = other.focus }
5451
return changes
5552
}
5653

@@ -77,6 +74,6 @@ public struct Status<Style: DiffableTextStyle>: Equatable {
7774
@inlinable static func .!= (lhs: Self, rhs: Self) -> Changes {[
7875
.style(lhs.style != rhs.style),
7976
.value(lhs.value != rhs.value),
80-
.focus(lhs.focus != rhs.focus),
81-
]}
77+
.focus(lhs.focus != rhs.focus)]
78+
}
8279
}

Sources/DiffableTextKit/Models/Symbol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ extension Sequence where Element == Symbol {
7575

7676
/// A sequence of nonvirtual characters.
7777
@inlinable public func nonvirtuals() -> String {
78-
String(lazy.filter({!$0.attribute.contains(.virtual)}).map({$0.character}))
78+
String(lazy.nonvirtuals())
7979
}
8080
}
8181

Sources/DiffableTextKit/Models/Update.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// MARK: * Update [...]
1212
//*============================================================================*
1313

14-
/// A message describing which remote properties need to be updated.
14+
/// A message describing which properties should be updated.
1515
@frozen public struct Update: OptionSet {
1616

1717
public static let text = Self(rawValue: 1 << 0)

Sources/DiffableTextKit/Utilities/Brrr.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//=----------------------------------------------------------------------------=
99

1010
//*============================================================================*
11-
// MARK: * Brrr
11+
// MARK: * Brrr [...]
1212
//*============================================================================*
1313

1414
/// A model that prints messages in DEBUG mode.
@@ -17,23 +17,15 @@
1717
///
1818
public struct Brrr: Equatable {
1919

20-
//=------------------------------------------------------------------------=
21-
// MARK: Instances
22-
//=------------------------------------------------------------------------=
23-
2420
public static let cancellation = Self("User input cancelled:")
2521
public static let autocorrection = Self("User input autocorrected:")
2622

27-
//=------------------------------------------------------------------------=
28-
// MARK: State
2923
//=------------------------------------------------------------------------=
3024

3125
#if DEBUG
3226
@usableFromInline let context: String
3327
#endif
3428

35-
//=------------------------------------------------------------------------=
36-
// MARK: Initializers
3729
//=------------------------------------------------------------------------=
3830

3931
@inlinable @inline(__always)
@@ -43,10 +35,6 @@ public struct Brrr: Equatable {
4335
#endif
4436
}
4537

46-
//=------------------------------------------------------------------------=
47-
// MARK: Utilities
48-
//=------------------------------------------------------------------------=
49-
5038
@inlinable @inline(__always)
5139
public static func << (brrr: Self, message: @autoclosure () -> Any) {
5240
#if DEBUG

Sources/DiffableTextKitXPattern/Placeholders.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
self.option = .none
3030
}
3131

32-
@inlinable init(_ some: (Character, Predicate)) {
32+
@inlinable init(_ some: Some.Elements) {
3333
self.option = .some(Some(some))
3434
}
3535

36-
@inlinable init(_ many: [Character: Predicate]) {
36+
@inlinable init(_ many: Many.Elements) {
3737
self.option = .many(Many(many))
3838
}
3939

@@ -71,13 +71,15 @@ extension Placeholders {
7171

7272
@usableFromInline struct Some: Equatable {
7373

74+
@usableFromInline typealias Elements = (Character, Predicate)
75+
7476
//=--------------------------------------------------------------------=
7577

76-
@usableFromInline let elements: (Character, Predicate)
78+
@usableFromInline let elements: Elements
7779

7880
//=--------------------------------------------------------------------=
7981

80-
@inlinable init(_ elements: (Character, Predicate)) {
82+
@inlinable init( _ elements: Elements) {
8183
self.elements = elements
8284
}
8385

@@ -96,13 +98,15 @@ extension Placeholders {
9698

9799
@usableFromInline struct Many: Equatable {
98100

101+
@usableFromInline typealias Elements = [Character: Predicate]
102+
99103
//=--------------------------------------------------------------------=
100104

101-
@usableFromInline let elements: [Character: Predicate]
105+
@usableFromInline let elements: Elements
102106

103107
//=--------------------------------------------------------------------=
104108

105-
@inlinable init(_ elements: [Character: Predicate]) {
109+
@inlinable init( _ elements: Elements) {
106110
self.elements = elements
107111
}
108112

Sources/DiffableTextKitXPattern/Style.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,20 +178,13 @@ extension PatternTextStyle {
178178
}
179179
}
180180
}
181-
}
182-
183-
//=----------------------------------------------------------------------------=
184-
// MARK: + Helpers
185-
//=----------------------------------------------------------------------------=
186-
187-
extension PatternTextStyle {
188181

189182
//=------------------------------------------------------------------------=
190-
// MARK: Reduce
183+
// MARK: Inactive, Active, Interactive x Reduce
191184
//=------------------------------------------------------------------------=
192185

193186
@inlinable @inline(never) func reduce<Content, Result>(
194-
with content: Content, into result: Result,
187+
with content: Content,into result: Result,
195188
some: (inout Result, Substring, Character) -> Void,
196189
none: (inout Result, Substring) -> Void,
197190
done: (inout Result, Substring, Content.SubSequence) throws -> Void)

Sources/DiffableTextKitXUIKit/Models/Downstream.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import UIKit
1818
//*============================================================================*
1919

2020
@usableFromInline final class Downstream {
21+
2122
@usableFromInline typealias Offset = DiffableTextKit.Offset<UTF16>
2223

2324
//=------------------------------------------------------------------------=

Sources/DiffableTextKitXUIKit/Models/Sidestream.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import SwiftUI
2626

2727
@inlinable init() { }
2828

29-
@inlinable init(_ environment: EnvironmentValues) {
29+
@inlinable init( _ environment: EnvironmentValues) {
3030
self.onSubmit = environment.diffableTextViews_onSubmit
3131
}
3232
}

0 commit comments

Comments
 (0)