diff --git a/Config.xcconfig b/Config.xcconfig index daec1bf..6050993 100644 --- a/Config.xcconfig +++ b/Config.xcconfig @@ -5,7 +5,7 @@ // Created by neon443 on 06/06/2025. // -VERSION = 0.4 +VERSION = 0.5 BUILD = 3 // Configuration settings file format documentation can be found at: diff --git a/ShhShell.xcodeproj/project.pbxproj b/ShhShell.xcodeproj/project.pbxproj index 3646498..293690c 100644 --- a/ShhShell.xcodeproj/project.pbxproj +++ b/ShhShell.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ A92317282E07111E00ECE1E6 /* SwiftTerm in Frameworks */ = {isa = PBXBuildFile; productRef = A92317272E07111E00ECE1E6 /* SwiftTerm */; }; A923172A2E07113100ECE1E6 /* TerminalController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92317292E07113100ECE1E6 /* TerminalController.swift */; }; A923172D2E07138000ECE1E6 /* SSHTerminalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A923172C2E07138000ECE1E6 /* SSHTerminalView.swift */; }; + A923172F2E08851200ECE1E6 /* ShellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A923172E2E08851200ECE1E6 /* ShellView.swift */; }; A92538C82DEE0742007E0A18 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92538C52DEE0742007E0A18 /* ContentView.swift */; }; A92538C92DEE0742007E0A18 /* ShhShellApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92538C62DEE0742007E0A18 /* ShhShellApp.swift */; }; A92538CA2DEE0742007E0A18 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A92538C42DEE0742007E0A18 /* Assets.xcassets */; }; @@ -70,6 +71,7 @@ A9083E3F2DF2225A0042906E /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; A92317292E07113100ECE1E6 /* TerminalController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalController.swift; sourceTree = ""; }; A923172C2E07138000ECE1E6 /* SSHTerminalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHTerminalView.swift; sourceTree = ""; }; + A923172E2E08851200ECE1E6 /* ShellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ShellView.swift; path = ShhShell/Views/Terminal/ShellView.swift; sourceTree = SOURCE_ROOT; }; A925389A2DEE06DC007E0A18 /* ShhShell.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShhShell.app; sourceTree = BUILT_PRODUCTS_DIR; }; A92538A72DEE06DE007E0A18 /* ShhShellTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ShhShellTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; A92538B12DEE06DE007E0A18 /* ShhShellUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ShhShellUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -132,6 +134,7 @@ isa = PBXGroup; children = ( A92317292E07113100ECE1E6 /* TerminalController.swift */, + A923172E2E08851200ECE1E6 /* ShellView.swift */, A923172C2E07138000ECE1E6 /* SSHTerminalView.swift */, ); path = Terminal; @@ -409,6 +412,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + A923172F2E08851200ECE1E6 /* ShellView.swift in Sources */, A985545F2E056EDD009051BD /* KeychainLayer.swift in Sources */, A93143C62DF61FE300FCD5DB /* ViewModifiers.swift in Sources */, A98554632E0587DF009051BD /* HostsView.swift in Sources */, diff --git a/ShhShell/SSH/SSHHandler.swift b/ShhShell/SSH/SSHHandler.swift index 3435c2f..d979a8e 100644 --- a/ShhShell/SSH/SSHHandler.swift +++ b/ShhShell/SSH/SSHHandler.swift @@ -19,6 +19,8 @@ class SSHHandler: ObservableObject { @Published var authorized: Bool = false @Published var testSuceeded: Bool? = nil + @Published var bell: UUID? + @Published var host: Host private let userDefaults = NSUbiquitousKeyValueStore.default diff --git a/ShhShell/Views/ConnectionView.swift b/ShhShell/Views/ConnectionView.swift index 56d5752..5282f46 100644 --- a/ShhShell/Views/ConnectionView.swift +++ b/ShhShell/Views/ConnectionView.swift @@ -132,10 +132,7 @@ struct ConnectionView: View { } NavigationLink() { - Button("send Ax256") { - handler.writeToChannel(Array(repeating: "A", count: 256).joined()) - } - TerminalController(handler: handler) + ShellView(handler: handler) } label: { Label("Open Terminal", systemImage: "apple.terminal") } @@ -183,7 +180,7 @@ struct ConnectionView: View { } handler.openShell() } label: { - Label("Connect", systemImage: "powerplug.portrait") + Label("Connect", systemImage: "power") } .disabled( pubkey == nil && privkey == nil && diff --git a/ShhShell/Views/Terminal/SSHTerminalView.swift b/ShhShell/Views/Terminal/SSHTerminalView.swift index 09c30e6..e595fe1 100644 --- a/ShhShell/Views/Terminal/SSHTerminalView.swift +++ b/ShhShell/Views/Terminal/SSHTerminalView.swift @@ -27,11 +27,9 @@ class SSHTerminalView: TerminalView, TerminalViewDelegate { while handler.connected { guard let handler = self.handler else { break } if let read = handler.readFromChannel() { - DispatchQueue.main.async { - self.feed(text: read) - } + DispatchQueue.main.async { self.feed(text: read) } } else { - usleep(10_000) + usleep(1_000) } } } @@ -55,8 +53,6 @@ class SSHTerminalView: TerminalView, TerminalViewDelegate { public func send(source: TerminalView, data: ArraySlice) { let data = Data(data) -// let dataSlice = Data(bytes: [data], count: data.count) - print("sending \(String(data: data, encoding: .utf8))") handler?.writeToChannel(String(data: data, encoding: .utf8)) } diff --git a/ShhShell/Views/Terminal/ShellView.swift b/ShhShell/Views/Terminal/ShellView.swift new file mode 100644 index 0000000..53415a4 --- /dev/null +++ b/ShhShell/Views/Terminal/ShellView.swift @@ -0,0 +1,41 @@ +// +// ShellView.swift +// ShhShell +// +// Created by neon443 on 22/06/2025. +// + +import SwiftUI + +struct ShellView: View { + @ObservedObject var handler: SSHHandler + + var body: some View { + NavigationStack { + ZStack { + TerminalController(handler: handler) + } + .toolbar { + ToolbarItem { + Button() { + if handler.connected { + handler.disconnect() + } else { + handler.connect() + } + } label: { + if handler.connected { + Label("Disconnect", image: "xmark.square.fill") + } else { + Label("Connect", image: "power") + } + } + } + } + } + } +} + +#Preview { + ShellView(handler: SSHHandler(host: Host.debug)) +}