In iTerm2, in the menu bar go to Scripts > Manage > New Python Script
Select Basic. Select Long-Running Daemon
Give the script a decent name (I chose auto_dark_mode.py)
Save and open the script in your editor of choice.
| # XTerm Control Sequences based on: | |
| # - https://invisible-island.net/xterm/ctlseqs/ctlseqs.html | |
| # ========================================================================= # | |
| # XTerm Control Sequences from invisible-island.net as pythonic code. | |
| # Basic control sequences are string variables. | |
| # - eg: ESC = '\033' | |
| # CSI = ESC + '[' | |
| # Control sequences that have args can be called to return a string. | |
| # - eg: sgr = CSI + Ps + 'm' |
| import SwiftUI | |
| public struct FormattedTextField<Formatter: TextFieldFormatter>: View { | |
| public init(_ title: String, | |
| value: Binding<Formatter.Value>, | |
| formatter: Formatter) { | |
| self.title = title | |
| self.value = value | |
| self.formatter = formatter | |
| } |
| // | |
| // KeyboardResponder.swift | |
| // MoveMAD | |
| // | |
| // Created by Adolfo Vera Blasco on 19/11/2019. | |
| // Copyright © 2019 desappstre {eStudio}. All rights reserved. | |
| // | |
| import SwiftUI |
| // Run any SwiftUI view as a Mac app. | |
| import Cocoa | |
| import SwiftUI | |
| NSApplication.shared.run { | |
| VStack { | |
| Text("Hello, World") | |
| .padding() | |
| .background(Capsule().fill(Color.blue)) |
| import SwiftUI | |
| extension View { | |
| /// https://stackoverflow.com/a/61985678/3393964 | |
| public func cursor(_ cursor: NSCursor) -> some View { | |
| self.onHover { inside in | |
| if inside { | |
| cursor.push() | |
| } else { | |
| NSCursor.pop() |
| struct Colors { | |
| let primary: Color | |
| } | |
| struct Fonts { | |
| let body: Font | |
| } | |
| class Theme: ObservableObject { | |
| let color: Colors |
According to the docs, the non-DI way to associate an view model with an @Composable is via the viewModel() function from androidx.lifecycle.viewmodel.compose.viewModel, like this:
@Composable
fun ProfileScreen(val viewModel: ProfileViewModel = viewModel() {
...But if your view model requires dependencies, you have to pass a subclass of ViewModelProvider.Factory that holds the dependency and knows how to construct the view model for you. Like this:
| SDKROOT=`/usr/bin/xcrun --show-sdk-path -sdk macosx` | |
| as test.s -o test.o | |
| ld test.o -lSystem -L $(SDKROOT)/usr/lib -o test |