|
| 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 | +//*============================================================================* |
| 11 | +// MARK: * Normal |
| 12 | +//*============================================================================* |
| 13 | + |
| 14 | +/// A normal text style, without bells and whistles. |
| 15 | +public struct NormalTextStyle: DiffableTextStyle { |
| 16 | + |
| 17 | + //=------------------------------------------------------------------------= |
| 18 | + // MARK: Initializers |
| 19 | + //=------------------------------------------------------------------------= |
| 20 | + |
| 21 | + @inlinable @inline(__always) public init() { } |
| 22 | + |
| 23 | + //=------------------------------------------------------------------------= |
| 24 | + // MARK: Utilities |
| 25 | + //=------------------------------------------------------------------------= |
| 26 | + |
| 27 | + @inlinable @inline(__always) public func format(_ value: String, with cache: inout Void) -> String { |
| 28 | + value |
| 29 | + } |
| 30 | + |
| 31 | + @inlinable public func interpret(_ value: String, with cache: inout Void) -> Commit<String> { |
| 32 | + Commit(value, Snapshot(value)) |
| 33 | + } |
| 34 | + |
| 35 | + @inlinable public func resolve(_ proposal: Proposal, with cache: inout Void) throws -> Commit<String> { |
| 36 | + let S0 = Snapshot(proposal.lazy.merged().nonvirtuals()); return Commit(S0.characters, S0) |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +//*============================================================================* |
| 41 | +// MARK: * Normal x Init |
| 42 | +//*============================================================================* |
| 43 | + |
| 44 | +extension DiffableTextStyle where Self == NormalTextStyle { |
| 45 | + |
| 46 | + //=------------------------------------------------------------------------= |
| 47 | + // MARK: Initializers |
| 48 | + //=------------------------------------------------------------------------= |
| 49 | + |
| 50 | + /// A normal text style, without bells and whistles. |
| 51 | + @inlinable @inline(__always) public static var normal: Self { .init() } |
| 52 | +} |
0 commit comments