mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
adding theme support!!
looking at swiftermapp, it uses string splitting to parse a plist of colours i couldnt be asked to do this, so i made my own codable types and non codable types to automatically parse the plist lol anyways might merge the Codable and non codabel types later, but i thik it works now so im leaving it as is rn moved scrollback restore funcito higher
This commit is contained in:
@@ -39,6 +39,7 @@
|
|||||||
A9B15A9A2E0ABA0400F66E02 /* DialogView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B15A992E0ABA0400F66E02 /* DialogView.swift */; };
|
A9B15A9A2E0ABA0400F66E02 /* DialogView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B15A992E0ABA0400F66E02 /* DialogView.swift */; };
|
||||||
A9C4140C2E096DB7005E3047 /* SSHError.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C4140B2E096DB7005E3047 /* SSHError.swift */; };
|
A9C4140C2E096DB7005E3047 /* SSHError.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C4140B2E096DB7005E3047 /* SSHError.swift */; };
|
||||||
A9C897EF2DF1A9A400EF9A5F /* SSHHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C897EE2DF1A9A400EF9A5F /* SSHHandler.swift */; };
|
A9C897EF2DF1A9A400EF9A5F /* SSHHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C897EE2DF1A9A400EF9A5F /* SSHHandler.swift */; };
|
||||||
|
A9D819292E0E904200442D38 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D819282E0E904200442D38 /* Theme.swift */; };
|
||||||
A9DA97712E0D30ED00142DDC /* HostSymbol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9DA97702E0D30ED00142DDC /* HostSymbol.swift */; };
|
A9DA97712E0D30ED00142DDC /* HostSymbol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9DA97702E0D30ED00142DDC /* HostSymbol.swift */; };
|
||||||
A9DA97732E0D40C100142DDC /* SymbolPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9DA97722E0D40C100142DDC /* SymbolPreview.swift */; };
|
A9DA97732E0D40C100142DDC /* SymbolPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9DA97722E0D40C100142DDC /* SymbolPreview.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
@@ -112,6 +113,7 @@
|
|||||||
A9B15A992E0ABA0400F66E02 /* DialogView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DialogView.swift; sourceTree = "<group>"; };
|
A9B15A992E0ABA0400F66E02 /* DialogView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DialogView.swift; sourceTree = "<group>"; };
|
||||||
A9C4140B2E096DB7005E3047 /* SSHError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHError.swift; sourceTree = "<group>"; };
|
A9C4140B2E096DB7005E3047 /* SSHError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHError.swift; sourceTree = "<group>"; };
|
||||||
A9C897EE2DF1A9A400EF9A5F /* SSHHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHHandler.swift; sourceTree = "<group>"; };
|
A9C897EE2DF1A9A400EF9A5F /* SSHHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHHandler.swift; sourceTree = "<group>"; };
|
||||||
|
A9D819282E0E904200442D38 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = "<group>"; };
|
||||||
A9DA97702E0D30ED00142DDC /* HostSymbol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostSymbol.swift; sourceTree = "<group>"; };
|
A9DA97702E0D30ED00142DDC /* HostSymbol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostSymbol.swift; sourceTree = "<group>"; };
|
||||||
A9DA97722E0D40C100142DDC /* SymbolPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SymbolPreview.swift; sourceTree = "<group>"; };
|
A9DA97722E0D40C100142DDC /* SymbolPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SymbolPreview.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
@@ -185,6 +187,7 @@
|
|||||||
children = (
|
children = (
|
||||||
A92538C62DEE0742007E0A18 /* ShhShellApp.swift */,
|
A92538C62DEE0742007E0A18 /* ShhShellApp.swift */,
|
||||||
A93143C22DF61F5700FCD5DB /* ShhShell.entitlements */,
|
A93143C22DF61F5700FCD5DB /* ShhShell.entitlements */,
|
||||||
|
A9D8192A2E0E904900442D38 /* Themes */,
|
||||||
A98554572E055398009051BD /* Keys */,
|
A98554572E055398009051BD /* Keys */,
|
||||||
A98554562E055394009051BD /* Host */,
|
A98554562E055394009051BD /* Host */,
|
||||||
A93143C12DF61E8500FCD5DB /* SSH */,
|
A93143C12DF61E8500FCD5DB /* SSH */,
|
||||||
@@ -310,6 +313,14 @@
|
|||||||
name = Frameworks;
|
name = Frameworks;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
A9D8192A2E0E904900442D38 /* Themes */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
A9D819282E0E904200442D38 /* Theme.swift */,
|
||||||
|
);
|
||||||
|
path = Themes;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
@@ -455,6 +466,7 @@
|
|||||||
A96C6B022E0C49E800F377FE /* CenteredLabel.swift in Sources */,
|
A96C6B022E0C49E800F377FE /* CenteredLabel.swift in Sources */,
|
||||||
A923172F2E08851200ECE1E6 /* ShellView.swift in Sources */,
|
A923172F2E08851200ECE1E6 /* ShellView.swift in Sources */,
|
||||||
A985545F2E056EDD009051BD /* KeychainLayer.swift in Sources */,
|
A985545F2E056EDD009051BD /* KeychainLayer.swift in Sources */,
|
||||||
|
A9D819292E0E904200442D38 /* Theme.swift in Sources */,
|
||||||
A93143C62DF61FE300FCD5DB /* ViewModifiers.swift in Sources */,
|
A93143C62DF61FE300FCD5DB /* ViewModifiers.swift in Sources */,
|
||||||
A98554632E0587DF009051BD /* HostsView.swift in Sources */,
|
A98554632E0587DF009051BD /* HostsView.swift in Sources */,
|
||||||
A96C6A8A2E0C0B1100F377FE /* SSHState.swift in Sources */,
|
A96C6A8A2E0C0B1100F377FE /* SSHState.swift in Sources */,
|
||||||
|
|||||||
@@ -21,6 +21,224 @@ struct ShhShellApp: App {
|
|||||||
keyManager: keyManager
|
keyManager: keyManager
|
||||||
)
|
)
|
||||||
.colorScheme(.dark)
|
.colorScheme(.dark)
|
||||||
|
.onAppear {
|
||||||
|
let data = """
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>Ansi 0 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.0</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.0</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.0</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 1 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.40000000000000002</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.40000000000000002</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.80000000000000004</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 10 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.40784313729999999</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.74117647060000003</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.70980392160000005</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 11 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.4549019608</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.77647058820000003</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.94117647059999998</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 12 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.74509803919999995</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.63529411759999999</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.50588235290000005</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 13 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.73333333329999995</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.58039215690000001</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.69803921570000005</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 14 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.71764705880000002</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.74509803919999995</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.54117647059999996</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 15 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.99999129772186279</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.99997437000274658</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>1</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 2 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.40784313725490196</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.74117647058823533</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.70980392156862748</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 3 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.45490196078431372</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.77647058823529413</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.94117647058823528</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 4 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.74509803921568629</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.63529411764705879</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.50588235294117645</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 5 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.73333333333333328</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.58039215686274503</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.69803921568627447</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 6 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.71764705882352942</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.74509803921568629</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.54117647058823526</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 7 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.99999129772186279</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.99997437000274658</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>1</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 8 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.0</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.0</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.0</real>
|
||||||
|
</dict>
|
||||||
|
<key>Ansi 9 Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.40000000000000002</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.40000000000000002</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.80000000000000004</real>
|
||||||
|
</dict>
|
||||||
|
<key>Background Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.12941177189350128</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.12156862765550613</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.11372549086809158</real>
|
||||||
|
</dict>
|
||||||
|
<key>Bold Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.77647058820000003</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.7843137255</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.7725490196</real>
|
||||||
|
</dict>
|
||||||
|
<key>Cursor Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.77647058820000003</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.7843137255</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.7725490196</real>
|
||||||
|
</dict>
|
||||||
|
<key>Cursor Text Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.12941177189350128</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.12156862765550613</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.11372549086809158</real>
|
||||||
|
</dict>
|
||||||
|
<key>Foreground Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.77647058823529413</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.78431372549019607</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.77254901960784317</real>
|
||||||
|
</dict>
|
||||||
|
<key>Selected Text Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.77647058820000003</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.7843137255</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.7725490196</real>
|
||||||
|
</dict>
|
||||||
|
<key>Selection Color</key>
|
||||||
|
<dict>
|
||||||
|
<key>Blue Component</key>
|
||||||
|
<real>0.25490196078431371</real>
|
||||||
|
<key>Green Component</key>
|
||||||
|
<real>0.23137254901960785</real>
|
||||||
|
<key>Red Component</key>
|
||||||
|
<real>0.21568627450980393</real>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
|
""".data(using: .utf8)
|
||||||
|
print("theme \(Theme.fromiTermColors(name: "tomorrow night", data: data))")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
125
ShhShell/Themes/Theme.swift
Normal file
125
ShhShell/Themes/Theme.swift
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
//
|
||||||
|
// Theme.swift
|
||||||
|
// ShhShell
|
||||||
|
//
|
||||||
|
// Created by neon443 on 27/06/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import SwiftTerm
|
||||||
|
|
||||||
|
struct Theme: Hashable, Equatable {
|
||||||
|
var name: String
|
||||||
|
var ansi: [SwiftTerm.Color]
|
||||||
|
var foreground: SwiftTerm.Color
|
||||||
|
var background: SwiftTerm.Color
|
||||||
|
var cursor: SwiftTerm.Color
|
||||||
|
var cursorText: SwiftTerm.Color
|
||||||
|
var bold: SwiftTerm.Color
|
||||||
|
var selectedText: SwiftTerm.Color
|
||||||
|
var selection: SwiftTerm.Color
|
||||||
|
|
||||||
|
static func fromiTermColors(name: String, data: Data?) -> Theme? {
|
||||||
|
guard let data else { return nil }
|
||||||
|
guard let string = String(data: data, encoding: .utf8) else { return nil }
|
||||||
|
|
||||||
|
let decoder = PropertyListDecoder()
|
||||||
|
|
||||||
|
guard let decoded = try? decoder.decode(ThemeCodable.self, from: data) else { return nil }
|
||||||
|
|
||||||
|
let theme = Theme(
|
||||||
|
name: name,
|
||||||
|
ansi: decoded.ansi,
|
||||||
|
foreground: Color(decoded.foreground),
|
||||||
|
background: Color(decoded.background),
|
||||||
|
cursor: Color(decoded.cursor),
|
||||||
|
cursorText: Color(decoded.cursorText),
|
||||||
|
bold: Color(decoded.bold),
|
||||||
|
selectedText: Color(decoded.selectedText),
|
||||||
|
selection: Color(decoded.selection)
|
||||||
|
)
|
||||||
|
return theme
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct ThemeCodable: Codable {
|
||||||
|
var ansi0: ColorCodable
|
||||||
|
var ansi1: ColorCodable
|
||||||
|
var ansi2: ColorCodable
|
||||||
|
var ansi3: ColorCodable
|
||||||
|
var ansi4: ColorCodable
|
||||||
|
var ansi5: ColorCodable
|
||||||
|
var ansi6: ColorCodable
|
||||||
|
var ansi7: ColorCodable
|
||||||
|
var ansi8: ColorCodable
|
||||||
|
var ansi9: ColorCodable
|
||||||
|
var ansi10: ColorCodable
|
||||||
|
var ansi11: ColorCodable
|
||||||
|
var ansi12: ColorCodable
|
||||||
|
var ansi13: ColorCodable
|
||||||
|
var ansi14: ColorCodable
|
||||||
|
var ansi15: ColorCodable
|
||||||
|
var foreground: ColorCodable
|
||||||
|
var background: ColorCodable
|
||||||
|
var cursor: ColorCodable
|
||||||
|
var cursorText: ColorCodable
|
||||||
|
var bold: ColorCodable
|
||||||
|
var selectedText: ColorCodable
|
||||||
|
var selection: ColorCodable
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case ansi0 = "Ansi 0 Color"
|
||||||
|
case ansi1 = "Ansi 1 Color"
|
||||||
|
case ansi2 = "Ansi 2 Color"
|
||||||
|
case ansi3 = "Ansi 3 Color"
|
||||||
|
case ansi4 = "Ansi 4 Color"
|
||||||
|
case ansi5 = "Ansi 5 Color"
|
||||||
|
case ansi6 = "Ansi 6 Color"
|
||||||
|
case ansi7 = "Ansi 7 Color"
|
||||||
|
case ansi8 = "Ansi 8 Color"
|
||||||
|
case ansi9 = "Ansi 9 Color"
|
||||||
|
case ansi10 = "Ansi 10 Color"
|
||||||
|
case ansi11 = "Ansi 11 Color"
|
||||||
|
case ansi12 = "Ansi 12 Color"
|
||||||
|
case ansi13 = "Ansi 13 Color"
|
||||||
|
case ansi14 = "Ansi 14 Color"
|
||||||
|
case ansi15 = "Ansi 15 Color"
|
||||||
|
case foreground = "Foreground Color"
|
||||||
|
case background = "Background Color"
|
||||||
|
case cursor = "Cursor Color"
|
||||||
|
case cursorText = "Cursor Text Color"
|
||||||
|
case bold = "Bold Color"
|
||||||
|
case selectedText = "Selected Text Color"
|
||||||
|
case selection = "Selection Color"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ThemeCodable {
|
||||||
|
var ansi: [Color] {
|
||||||
|
let arr = [ansi0, ansi1, ansi2, ansi3, ansi4, ansi5, ansi6, ansi7, ansi8, ansi9, ansi10, ansi11, ansi12, ansi13, ansi14, ansi15]
|
||||||
|
return arr.map(SwiftTerm.Color.init)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ColorCodable: Codable {
|
||||||
|
var red: Double
|
||||||
|
var green: Double
|
||||||
|
var blue: Double
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case red = "Red Component"
|
||||||
|
case green = "Green Component"
|
||||||
|
case blue = "Blue Component"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extension SwiftTerm.Color {
|
||||||
|
convenience init(_ colorCodable: ColorCodable) {
|
||||||
|
let red = UInt16(colorCodable.red * 65535)
|
||||||
|
let green = UInt16(colorCodable.green * 65535)
|
||||||
|
let blue = UInt16(colorCodable.blue * 65535)
|
||||||
|
self.init(red: red, green: green, blue: blue)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,6 +34,20 @@ final class SSHTerminalView: TerminalView, Sendable, @preconcurrency TerminalVie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func restoreScrollback() {
|
||||||
|
guard let scrollback = handler?.scrollback else { return }
|
||||||
|
guard !scrollback.isEmpty else { return }
|
||||||
|
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
|
||||||
|
self.getTerminal().resetToInitialState()
|
||||||
|
for line in scrollback {
|
||||||
|
self.feed(text: line)
|
||||||
|
}
|
||||||
|
self.setNeedsLayout()
|
||||||
|
self.setNeedsDisplay()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override init(frame: CGRect) {
|
public override init(frame: CGRect) {
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
terminalDelegate = self
|
terminalDelegate = self
|
||||||
@@ -82,18 +96,4 @@ final class SSHTerminalView: TerminalView, Sendable, @preconcurrency TerminalVie
|
|||||||
public func bell(source: TerminalView) {
|
public func bell(source: TerminalView) {
|
||||||
handler?.ring()
|
handler?.ring()
|
||||||
}
|
}
|
||||||
|
|
||||||
func restoreScrollback() {
|
|
||||||
guard let scrollback = handler?.scrollback else { return }
|
|
||||||
guard !scrollback.isEmpty else { return }
|
|
||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
|
|
||||||
self.getTerminal().resetToInitialState()
|
|
||||||
for line in scrollback {
|
|
||||||
self.feed(text: line)
|
|
||||||
}
|
|
||||||
self.setNeedsLayout()
|
|
||||||
self.setNeedsDisplay()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user