From d1dd77fde367aff0a73ed616d5743988fe896b4e Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Sun, 24 Aug 2025 12:09:43 +0100 Subject: [PATCH] added miniterminalcontroller fix miniterminaldelegate moved stuff around --- ShhShell.xcodeproj/project.pbxproj | 20 ++++++-- .../Terminal/MiniTerminalController.swift | 29 +++++++++++ .../Terminal/MiniTerminalDelegate.swift | 51 +++++-------------- .../Terminal/SSHTerminalDelegate.swift | 0 .../Terminal/TerminalController.swift | 0 .../Terminal/TerminalViewContainer.swift | 0 ShhShell/Views/Settings/SettingsView.swift | 3 +- 7 files changed, 60 insertions(+), 43 deletions(-) create mode 100644 ShhShell/Terminal/MiniTerminalController.swift rename ShhShell/{Views => }/Terminal/MiniTerminalDelegate.swift (69%) rename ShhShell/{Views => }/Terminal/SSHTerminalDelegate.swift (100%) rename ShhShell/{Views => }/Terminal/TerminalController.swift (100%) rename ShhShell/{Views => }/Terminal/TerminalViewContainer.swift (100%) diff --git a/ShhShell.xcodeproj/project.pbxproj b/ShhShell.xcodeproj/project.pbxproj index 33afa95..73cdceb 100644 --- a/ShhShell.xcodeproj/project.pbxproj +++ b/ShhShell.xcodeproj/project.pbxproj @@ -78,6 +78,7 @@ A98554632E0587DF009051BD /* HostsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98554622E0587DF009051BD /* HostsView.swift */; }; A98CAB442E4229F7005E4C42 /* HostSymbolPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98CAB432E4229F7005E4C42 /* HostSymbolPicker.swift */; }; A99604432E5A0E8F007CA460 /* MiniTerminalDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A99604422E5A0E8F007CA460 /* MiniTerminalDelegate.swift */; }; + A99604462E5A257B007CA460 /* MiniTerminalController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A99604452E5A257B007CA460 /* MiniTerminalController.swift */; }; A9A2F4F62E3001D300D0AE9B /* AddSnippetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A2F4F52E3001D300D0AE9B /* AddSnippetView.swift */; }; A9BA1D192E1D9AE1005BDCEF /* SwiftTerm.Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BA1D182E1D9AE1005BDCEF /* SwiftTerm.Color.swift */; }; A9BA1D1E2E1EAD51005BDCEF /* SF-Mono-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = A9BA1D1C2E1EAD51005BDCEF /* SF-Mono-Bold.otf */; }; @@ -216,6 +217,7 @@ A98554622E0587DF009051BD /* HostsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostsView.swift; sourceTree = ""; }; A98CAB432E4229F7005E4C42 /* HostSymbolPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostSymbolPicker.swift; sourceTree = ""; }; A99604422E5A0E8F007CA460 /* MiniTerminalDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MiniTerminalDelegate.swift; sourceTree = ""; }; + A99604452E5A257B007CA460 /* MiniTerminalController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MiniTerminalController.swift; sourceTree = ""; }; A9A2F4F52E3001D300D0AE9B /* AddSnippetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddSnippetView.swift; sourceTree = ""; }; A9BA1D182E1D9AE1005BDCEF /* SwiftTerm.Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftTerm.Color.swift; sourceTree = ""; }; A9BA1D1C2E1EAD51005BDCEF /* SF-Mono-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SF-Mono-Bold.otf"; sourceTree = ""; }; @@ -352,12 +354,8 @@ A923172B2E0712F200ECE1E6 /* Terminal */ = { isa = PBXGroup; children = ( - A92317292E07113100ECE1E6 /* TerminalController.swift */, A923172E2E08851200ECE1E6 /* ShellView.swift */, - A923172C2E07138000ECE1E6 /* SSHTerminalDelegate.swift */, - A96BE6A92E116EC000C0FEE9 /* TerminalViewContainer.swift */, A9FD37682E16A6BF005319A8 /* ShellTabView.swift */, - A99604422E5A0E8F007CA460 /* MiniTerminalDelegate.swift */, ); path = Terminal; sourceTree = ""; @@ -391,6 +389,7 @@ children = ( A92538C62DEE0742007E0A18 /* ShhShellApp.swift */, A93143C12DF61E8500FCD5DB /* SSH */, + A99604442E5A255E007CA460 /* Terminal */, A98554562E055394009051BD /* Host */, A98554572E055398009051BD /* Keys */, A9D8192A2E0E904900442D38 /* Themes */, @@ -583,6 +582,18 @@ path = Keys; sourceTree = ""; }; + A99604442E5A255E007CA460 /* Terminal */ = { + isa = PBXGroup; + children = ( + A923172C2E07138000ECE1E6 /* SSHTerminalDelegate.swift */, + A99604422E5A0E8F007CA460 /* MiniTerminalDelegate.swift */, + A96BE6A92E116EC000C0FEE9 /* TerminalViewContainer.swift */, + A92317292E07113100ECE1E6 /* TerminalController.swift */, + A99604452E5A257B007CA460 /* MiniTerminalController.swift */, + ); + path = Terminal; + sourceTree = ""; + }; A9C060E92E357FC400CA9374 /* Misc */ = { isa = PBXGroup; children = ( @@ -854,6 +865,7 @@ A98554612E058433009051BD /* HostsManager.swift in Sources */, A985545D2E055D4D009051BD /* ConnectionView.swift in Sources */, A9FD37592E143D74005319A8 /* GenericPasswordConvertible.swift in Sources */, + A99604462E5A257B007CA460 /* MiniTerminalController.swift in Sources */, A9485C762E1AF59F00209824 /* FontManagerView.swift in Sources */, A98554592E0553AA009051BD /* KeyManager.swift in Sources */, A93F283D2E2A5DCB0092B8D5 /* SnippetManagerView.swift in Sources */, diff --git a/ShhShell/Terminal/MiniTerminalController.swift b/ShhShell/Terminal/MiniTerminalController.swift new file mode 100644 index 0000000..27c8a18 --- /dev/null +++ b/ShhShell/Terminal/MiniTerminalController.swift @@ -0,0 +1,29 @@ +// +// MiniTerminalController.swift +// ShhShell +// +// Created by neon443 on 23/08/2025. +// + +import Foundation +import UIKit +import SwiftUI +import SwiftTerm + +struct MiniTerminalController: UIViewRepresentable { + func feed() { + + } + + func makeUIView(context: Context) -> TerminalView { + let tv = MiniTerminalDelegate(frame: CGRect(origin: CGPoint(x: 0, y: 0), size: .zero)) + tv.translatesAutoresizingMaskIntoConstraints = true + tv.autoresizingMask = [.flexibleWidth, .flexibleHeight] + return tv + } + + func updateUIView(_ tv: TerminalView, context: Context) { + tv.setNeedsLayout() + tv.layoutIfNeeded() + } +} diff --git a/ShhShell/Views/Terminal/MiniTerminalDelegate.swift b/ShhShell/Terminal/MiniTerminalDelegate.swift similarity index 69% rename from ShhShell/Views/Terminal/MiniTerminalDelegate.swift rename to ShhShell/Terminal/MiniTerminalDelegate.swift index 0a7f5f1..b835a8c 100644 --- a/ShhShell/Views/Terminal/MiniTerminalDelegate.swift +++ b/ShhShell/Terminal/MiniTerminalDelegate.swift @@ -12,49 +12,24 @@ import SwiftTerm @MainActor class MiniTerminalDelegate: TerminalView, TerminalViewDelegate { - - nonisolated public func sizeChanged(source: TerminalView, newCols: Int, newRows: Int) { - <#code#> + func setCursorType(_ style: CursorType) { + getTerminal().setCursorStyle(style.stCursorStyle) } - nonisolated public func setTerminalTitle(source: TerminalView, title: String) { - <#code#> - } - - nonisolated public func hostCurrentDirectoryUpdate(source: TerminalView, directory: String?) { - <#code#> - } - - nonisolated public func send(source: TerminalView, data: ArraySlice) { - <#code#> - } - - nonisolated public func scrolled(source: TerminalView, position: Double) { - <#code#> - } - - nonisolated public func requestOpenLink(source: SwiftTerm.TerminalView, link: String, params: [String : String]) { - <#code#> - } - - nonisolated public func bell(source: TerminalView) { - <#code#> - } - - nonisolated public func clipboardCopy(source: SwiftTerm.TerminalView, content: Data) { - <#code#> - } - - nonisolated public func iTermContent (source: TerminalView, content: ArraySlice) { - <#code#> - } - - nonisolated public func rangeChanged(source: SwiftTerm.TerminalView, startY: Int, endY: Int) { - <#code#> - } + nonisolated public func sizeChanged(source: TerminalView, newCols: Int, newRows: Int) {} + nonisolated public func setTerminalTitle(source: TerminalView, title: String) {} + nonisolated public func hostCurrentDirectoryUpdate(source: TerminalView, directory: String?) {} + nonisolated public func send(source: TerminalView, data: ArraySlice) {} + nonisolated public func scrolled(source: TerminalView, position: Double) {} + nonisolated public func requestOpenLink(source: SwiftTerm.TerminalView, link: String, params: [String : String]) {} + nonisolated public func bell(source: TerminalView) {} + nonisolated public func clipboardCopy(source: SwiftTerm.TerminalView, content: Data) {} + nonisolated public func iTermContent (source: TerminalView, content: ArraySlice) {} + nonisolated public func rangeChanged(source: SwiftTerm.TerminalView, startY: Int, endY: Int) {} public convenience required override init(frame: CGRect) { self.init(frame: .zero) + terminalDelegate = self } public convenience required init?(coder: NSCoder) { diff --git a/ShhShell/Views/Terminal/SSHTerminalDelegate.swift b/ShhShell/Terminal/SSHTerminalDelegate.swift similarity index 100% rename from ShhShell/Views/Terminal/SSHTerminalDelegate.swift rename to ShhShell/Terminal/SSHTerminalDelegate.swift diff --git a/ShhShell/Views/Terminal/TerminalController.swift b/ShhShell/Terminal/TerminalController.swift similarity index 100% rename from ShhShell/Views/Terminal/TerminalController.swift rename to ShhShell/Terminal/TerminalController.swift diff --git a/ShhShell/Views/Terminal/TerminalViewContainer.swift b/ShhShell/Terminal/TerminalViewContainer.swift similarity index 100% rename from ShhShell/Views/Terminal/TerminalViewContainer.swift rename to ShhShell/Terminal/TerminalViewContainer.swift diff --git a/ShhShell/Views/Settings/SettingsView.swift b/ShhShell/Views/Settings/SettingsView.swift index 0718d01..1445e46 100644 --- a/ShhShell/Views/Settings/SettingsView.swift +++ b/ShhShell/Views/Settings/SettingsView.swift @@ -39,7 +39,8 @@ struct SettingsView: View { .pickerStyle(.segmented) ForEach(CursorShape.allCases, id: \.self) { type in - + MiniTerminalController() + } Picker("Cursor", selection: $hostsManager.settings.cursorType.cursorShape) { ForEach(CursorShape.allCases, id: \.self) { type in