Terminal-Bugfix: In-App-PTY-Terminal im Dracula-Theme, .command-Fallback, ANSI-Parser-Fix, Doku
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import SwiftUI
|
||||
import AppKit
|
||||
|
||||
/// Offizielle Dracula-Palette (https://draculatheme.com/contribute).
|
||||
enum Dracula {
|
||||
static let background = Color(hex: "282A36")
|
||||
static let currentLine = Color(hex: "44475A")
|
||||
static let foreground = Color(hex: "F8F8F2")
|
||||
static let comment = Color(hex: "6272A4")
|
||||
static let cyan = Color(hex: "8BE9FD")
|
||||
static let green = Color(hex: "50FA7B")
|
||||
static let orange = Color(hex: "FFB86C")
|
||||
static let pink = Color(hex: "FF79C6")
|
||||
static let purple = Color(hex: "BD93F9")
|
||||
static let red = Color(hex: "FF5555")
|
||||
static let yellow = Color(hex: "F1FA8C")
|
||||
|
||||
/// ANSI-Index 0-15 -> Dracula-Farbe.
|
||||
static func color(for index: Int?) -> Color {
|
||||
guard let index else { return foreground }
|
||||
switch index {
|
||||
case 0: return Color(hex: "21222C")
|
||||
case 1: return red
|
||||
case 2: return green
|
||||
case 3: return yellow
|
||||
case 4: return purple
|
||||
case 5: return pink
|
||||
case 6: return cyan
|
||||
case 7: return foreground
|
||||
case 8: return comment
|
||||
case 9: return Color(hex: "FF6E6E")
|
||||
case 10: return Color(hex: "69FF94")
|
||||
case 11: return Color(hex: "FFFFA5")
|
||||
case 12: return Color(hex: "D6ACFF")
|
||||
case 13: return Color(hex: "FF92DF")
|
||||
case 14: return Color(hex: "A4FFFF")
|
||||
default: return Color(hex: "FFFFFF")
|
||||
}
|
||||
}
|
||||
|
||||
static func nsColor(for index: Int?) -> NSColor {
|
||||
NSColor(color(for: index))
|
||||
}
|
||||
|
||||
static let nsBackground = NSColor(Color(hex: "282A36"))
|
||||
static let nsSelection = NSColor(Color(hex: "44475A"))
|
||||
}
|
||||
|
||||
extension Color {
|
||||
init(hex: String) {
|
||||
let clean = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
|
||||
var value: UInt64 = 0
|
||||
Scanner(string: clean).scanHexInt64(&value)
|
||||
let r = Double((value >> 16) & 0xFF) / 255
|
||||
let g = Double((value >> 8) & 0xFF) / 255
|
||||
let b = Double(value & 0xFF) / 255
|
||||
self.init(red: r, green: g, blue: b)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user