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
/// The `=!=` operator assigns the value on the right-hand side to the variable on the left-hand side | |
/// only if the two values are not equal. This operator is designed for types conforming to the `Equatable` protocol. | |
/// | |
/// - Parameters: | |
/// - lhs: The variable to be assigned a new value if not equal. | |
/// - rhs: The value to be assigned to the variable if it is not equal to the current value. | |
/// | |
/// - Precondition: The type of the operands must conform to the `Equatable` protocol. | |
/// | |
/// - Precedence: `AssignIfNotEqualPrecedence` |
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
#if os(macOS) | |
import SwiftUI | |
public extension View { | |
func hostingWindow(_ callback: @escaping (NSWindow?) -> Void) -> some View { | |
background(HostingWindowFinder(callback: callback)) | |
} | |
func windowTitle(_ title: String) -> some View { | |
hostingWindow { $0?.title = title } |
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
#!/bin/bash | |
# ======================================== | |
# ANSI Color escape codes: | |
# ======================================== | |
# Black 0;30 Dark Gray 1;30 | |
# Red 0;31 Light Red 1;31 | |
# Green 0;32 Light Green 1;32 | |
# Brown/Orange 0;33 Yellow 1;33 |
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
// TassenGugelhupf.swift | |
// Created by Frank Gregor on 18.03.23. | |
// | |
// This code compiles perfectly. Just paste it into a Playground and... | |
// "Let it go" | |
// | |
// You nay ask: "Why so complicated?" | |
// Well, the initial impulse came from this Mastodon thread: | |
// https://swiftdev.space/@phranck/110045414485613046 | |
// |
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
import Carbon.HIToolbox | |
import SwiftUI | |
/// Keyboard layout independent keycodes | |
public enum ViewKeyCode: UInt16 { | |
case Return = 0x24 | |
case Tab = 0x30 | |
case Space = 0x31 | |
case Delete = 0x33 | |
case Escape = 0x35 |
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
import SwiftUI | |
public struct Platform: OptionSet { | |
public var rawValue: UInt8 | |
public static let iOS = Platform(rawValue: 1 << 0) | |
public static let macOS = Platform(rawValue: 1 << 1) | |
public static let tvOS = Platform(rawValue: 1 << 2) | |
public static let watchOS = Platform(rawValue: 1 << 3) | |
public static let all: Platform = [.iOS, .macOS, .tvOS, .watchOS] |