-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the observation framework
- Loading branch information
1 parent
53858f1
commit e0a03f1
Showing
70 changed files
with
1,022 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Sources/Adwaita/Model/Extensions/DefaultStringInterpolation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// DefaultStringInterpolation.swift | ||
// Adwaita | ||
// | ||
// Created by david-swift on 01.05.24. | ||
// | ||
// Thanks to Eneko Alonso, Pyry Jahkola, cukr for the comments in this Swift forum discussion: | ||
// "Multi-line string nested indentation with interpolation" | ||
// https://forums.swift.org/t/multi-line-string-nested-indentation-with-interpolation/36933 | ||
// | ||
|
||
extension DefaultStringInterpolation { | ||
|
||
/// Preserve the indentation in a multi line string. | ||
/// - Parameter string: The string. | ||
/// | ||
/// Use it the following way: | ||
/// """ | ||
/// Hello | ||
/// \(indented: "World\n Test") | ||
/// """ | ||
public mutating func appendInterpolation(indented string: String) { | ||
// swiftlint:disable compiler_protocol_init | ||
let indent = String(stringInterpolation: self).reversed().prefix { " \t".contains($0) } | ||
// swiftlint:enable compiler_protocol_init | ||
if indent.isEmpty { | ||
appendInterpolation(string) | ||
} else { | ||
appendLiteral( | ||
string.split(separator: "\n", omittingEmptySubsequences: false).joined(separator: "\n" + indent) | ||
) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Optional.swift | ||
// Adwaita | ||
// | ||
// Created by david-swift on 01.05.20204. | ||
// | ||
|
||
extension Optional: CustomStringConvertible where Wrapped: CustomStringConvertible { | ||
|
||
/// A textual description of the wrapped value. | ||
public var description: String { | ||
self?.description ?? "nil" | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.