Skip to content

Commit e893c6e

Browse files
committed
Intermediate checkpoint.
1 parent 9bb4544 commit e893c6e

File tree

5 files changed

+59
-6
lines changed

5 files changed

+59
-6
lines changed

Sources/DiffableTextStylesXNumeric/Models/Adapter.swift renamed to Sources/DiffableTextStylesXNumeric/Helpers/Adapter.swift

File renamed without changes.

Sources/DiffableTextStylesXNumeric/Helpers/Lexicon.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ public final class Lexicon {
2020
// MARK: Constants
2121
//=------------------------------------------------------------------------=
2222

23-
@usableFromInline static let en_US = Lexicon(
24-
locale: Locale(identifier: "en_US"),
25-
signs: .ascii(), digits: .ascii(), separators: .ascii()
26-
)
23+
@usableFromInline static let en_US: Lexicon = .ascii()
2724

2825
//=------------------------------------------------------------------------=
2926
// MARK: State
@@ -38,7 +35,8 @@ public final class Lexicon {
3835
// MARK: Initializers
3936
//=------------------------------------------------------------------------=
4037

41-
@inlinable init(locale: Locale, signs: Links<Sign>, digits: Links<Digit>, separators: Links<Separator>) {
38+
@inlinable init(locale: Locale, signs: Links<Sign>,
39+
digits: Links<Digit>, separators: Links<Separator>) {
4240
self.locale = locale; self.signs = signs
4341
self.digits = digits; self.separators = separators
4442
}
@@ -54,6 +52,17 @@ extension Lexicon {
5452
// MARK: Initializers
5553
//=------------------------------------------------------------------------=
5654

55+
@inlinable static func ascii() -> Lexicon {
56+
let formatter = NumberFormatter()
57+
formatter.numberStyle = .decimal
58+
formatter.locale = Locale(identifier: "en_US")
59+
//=--------------------------------------=
60+
// MARK: Instantiate
61+
//=--------------------------------------=
62+
return .init(locale: formatter.locale,
63+
signs: .ascii(), digits: .ascii(), separators: .ascii())
64+
}
65+
5766
@inlinable static func standard(_ locale: Locale) -> Lexicon {
5867
let formatter = NumberFormatter()
5968
formatter.numberStyle = .decimal
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//=----------------------------------------------------------------------------=
2+
// This source file is part of the DiffableTextViews open source project.
3+
//
4+
// Copyright (c) 2022 Oscar Byström Ericsson
5+
// Licensed under Apache License, Version 2.0
6+
//
7+
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
8+
//=----------------------------------------------------------------------------=
9+
10+
import Foundation
11+
12+
//*============================================================================*
13+
// MARK: * Source
14+
//*============================================================================*
15+
16+
@usableFromInline final class Source {
17+
18+
//=------------------------------------------------------------------------=
19+
// MARK: State
20+
//=------------------------------------------------------------------------=
21+
22+
@usableFromInline let wrapped: NumberFormatter
23+
24+
//=------------------------------------------------------------------------=
25+
// MARK: Initializers
26+
//=------------------------------------------------------------------------=
27+
28+
@inlinable init(_ wrapped: NumberFormatter) { self.wrapped = wrapped }
29+
30+
//=------------------------------------------------------------------------=
31+
// MARK: Accessors
32+
//=------------------------------------------------------------------------=
33+
34+
@inlinable var integerLimits: ClosedRange<Int> {
35+
wrapped.minimumIntegerDigits ...
36+
wrapped.maximumIntegerDigits
37+
}
38+
39+
@inlinable var fractionLimits: ClosedRange<Int> {
40+
wrapped.minimumFractionDigits ...
41+
wrapped.maximumFractionDigits
42+
}
43+
}

Sources/DiffableTextStylesXNumeric/Models/Precision.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ extension Precision {
6969
self = .unchecked()
7070
}
7171

72-
@inlinable init<R>(integer: R) where R: RangeExpression, R.Bound == Int {
72+
@inlinable init<R>(integer: R) where R: RangeExpression, R.Bound == Int {
7373
self = .unchecked(integer: Self.interpret(integer, as: \.integer ))
7474
}
7575

Sources/DiffableTextStylesXNumeric/Style.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public struct _NumericTextStyle<Format: NumericTextFormat>: DiffableTextStyle {
3232
// MARK: Initializers
3333
//=------------------------------------------------------------------------=
3434

35+
#warning("...")
3536
@inlinable init(_ format: Format) {
3637
self.adapter = Adapter(format)
3738
self.bounds = Bounds()

0 commit comments

Comments
 (0)