mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
if edited theme is selected, make selectedtheme = the newly edited theme
fix color selection by converting color spaces version bump
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
// Created by neon443 on 06/06/2025.
|
// Created by neon443 on 06/06/2025.
|
||||||
//
|
//
|
||||||
|
|
||||||
VERSION = 1.5.5
|
VERSION = 1.6
|
||||||
BUILD = 51
|
BUILD = 51
|
||||||
|
|
||||||
// Configuration settings file format documentation can be found at:
|
// Configuration settings file format documentation can be found at:
|
||||||
|
|||||||
@@ -120,6 +120,9 @@ class HostsManager: ObservableObject, @unchecked Sendable {
|
|||||||
func updateTheme(_ theme: Theme) {
|
func updateTheme(_ theme: Theme) {
|
||||||
guard let index = themes.firstIndex(where: { $0.id == theme.id }) else { return }
|
guard let index = themes.firstIndex(where: { $0.id == theme.id }) else { return }
|
||||||
themes[index] = theme
|
themes[index] = theme
|
||||||
|
if selectedTheme.id == theme.id {
|
||||||
|
selectedTheme = theme
|
||||||
|
}
|
||||||
saveThemes()
|
saveThemes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,10 +40,21 @@ extension SwiftTerm.Color {
|
|||||||
|
|
||||||
extension SwiftTerm.Color {
|
extension SwiftTerm.Color {
|
||||||
convenience init(_ color: SwiftUI.Color) {
|
convenience init(_ color: SwiftUI.Color) {
|
||||||
var r: CGFloat = 0; var g: CGFloat = 0; var b: CGFloat = 0; var a: CGFloat = 0
|
|
||||||
let uiColor = UIColor(color)
|
let uiColor = UIColor(color)
|
||||||
uiColor.getRed(&r, green: &g, blue: &b, alpha: &a)
|
guard let rgbColor = uiColor.cgColor.converted(
|
||||||
|
to: CGColorSpace(name: CGColorSpace.sRGB)!,
|
||||||
|
intent: .defaultIntent,
|
||||||
|
options: nil
|
||||||
|
),
|
||||||
|
let components = rgbColor.components
|
||||||
|
else {
|
||||||
|
self.init(red: 0, green: 0, blue: 0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let r = components[0] ?? 0
|
||||||
|
let g = components[1] ?? 0
|
||||||
|
let b = components[2] ?? 0
|
||||||
|
print(r,g,b)
|
||||||
self.init(red: UInt16(r*65535), green: UInt16(g*65535), blue: UInt16(b*65535))
|
self.init(red: UInt16(r*65535), green: UInt16(g*65535), blue: UInt16(b*65535))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user