From 28b92466a5e511303f733c5f3303696b9fa360b9 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Sun, 31 Aug 2025 22:23:17 +0100 Subject: [PATCH] remove overlay jelly cursor implementation, check jelly branch on https://github.com/neon443/SwiftTerm add empty handler for 133 iterm2 --- ShhShell.xcodeproj/project.pbxproj | 34 +++++++---- .../xcshareddata/swiftpm/Package.resolved | 9 +-- ShhShell/Terminal/SSHTerminalDelegate.swift | 1 + ShhShell/Views/Terminal/ShellView.swift | 58 ++++++++++++++----- 4 files changed, 74 insertions(+), 28 deletions(-) diff --git a/ShhShell.xcodeproj/project.pbxproj b/ShhShell.xcodeproj/project.pbxproj index d7bed58..cdef496 100644 --- a/ShhShell.xcodeproj/project.pbxproj +++ b/ShhShell.xcodeproj/project.pbxproj @@ -83,6 +83,9 @@ A9921DE12E5F5710009F72A8 /* WelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9921DE02E5F5710009F72A8 /* WelcomeView.swift */; }; A9921FFF2E61D537009F72A8 /* libssh2.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9921FFE2E61D537009F72A8 /* libssh2.xcframework */; }; A994D64A2E5C94E200672395 /* ShaderTestingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A994D6492E5C94E200672395 /* ShaderTestingView.swift */; }; + A99D9F7B2E63513E00259166 /* SwiftTerm in Frameworks */ = {isa = PBXBuildFile; productRef = A99D9F7A2E63513E00259166 /* SwiftTerm */; }; + A99D9F7E2E6351D100259166 /* SwiftTerm in Frameworks */ = {isa = PBXBuildFile; productRef = A99D9F7D2E6351D100259166 /* SwiftTerm */; }; + A99D9F812E64F45B00259166 /* SwiftTerm in Frameworks */ = {isa = PBXBuildFile; productRef = A99D9F802E64F45B00259166 /* SwiftTerm */; }; A9A2F4F62E3001D300D0AE9B /* AddSnippetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A2F4F52E3001D300D0AE9B /* AddSnippetView.swift */; }; A9B1E5852E5F8E86009309E5 /* WelcomeChunk.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B1E5842E5F8E86009309E5 /* WelcomeChunk.swift */; }; A9BA1D192E1D9AE1005BDCEF /* SwiftTerm.Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BA1D182E1D9AE1005BDCEF /* SwiftTerm.Color.swift */; }; @@ -100,7 +103,6 @@ A9D819312E102D8700442D38 /* HostkeysView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D819302E102D8700442D38 /* HostkeysView.swift */; }; A9DA97712E0D30ED00142DDC /* HostSymbol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9DA97702E0D30ED00142DDC /* HostSymbol.swift */; }; A9DA97732E0D40C100142DDC /* HostSymbolPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9DA97722E0D40C100142DDC /* HostSymbolPreview.swift */; }; - A9E78F422E58BD770079F3CC /* SwiftTerm in Frameworks */ = {isa = PBXBuildFile; productRef = A9E78F412E58BD770079F3CC /* SwiftTerm */; }; A9FD37552E143D23005319A8 /* SecKeyConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FD37542E143D23005319A8 /* SecKeyConvertible.swift */; }; A9FD37572E143D5A005319A8 /* SecKeyStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FD37562E143D5A005319A8 /* SecKeyStore.swift */; }; A9FD37592E143D74005319A8 /* GenericPasswordConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FD37582E143D74005319A8 /* GenericPasswordConvertible.swift */; }; @@ -260,11 +262,13 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + A99D9F7E2E6351D100259166 /* SwiftTerm in Frameworks */, + A99D9F7B2E63513E00259166 /* SwiftTerm in Frameworks */, A95FAA542DF4B62900DE2F5A /* LibSSH.xcframework in Frameworks */, - A9E78F422E58BD770079F3CC /* SwiftTerm in Frameworks */, A93143BE2DF4D0B300FCD5DB /* libpthread.tbd in Frameworks */, A9921FFF2E61D537009F72A8 /* libssh2.xcframework in Frameworks */, A9083E402DF2226F0042906E /* libz.tbd in Frameworks */, + A99D9F812E64F45B00259166 /* SwiftTerm in Frameworks */, A95FAA562DF4B62A00DE2F5A /* openssl.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -698,7 +702,9 @@ ); name = ShhShell; packageProductDependencies = ( - A9E78F412E58BD770079F3CC /* SwiftTerm */, + A99D9F7A2E63513E00259166 /* SwiftTerm */, + A99D9F7D2E6351D100259166 /* SwiftTerm */, + A99D9F802E64F45B00259166 /* SwiftTerm */, ); productName = ShhShell; productReference = A925389A2DEE06DC007E0A18 /* ShhShell.app */; @@ -778,7 +784,7 @@ mainGroup = A92538912DEE06DC007E0A18; minimizedProjectReferenceProxies = 1; packageReferences = ( - A9E78F402E58BD770079F3CC /* XCRemoteSwiftPackageReference "SwiftTerm" */, + A99D9F7F2E64F45B00259166 /* XCRemoteSwiftPackageReference "SwiftTerm" */, ); productRefGroup = A925389B2DEE06DC007E0A18 /* Products */; projectDirPath = ""; @@ -1273,20 +1279,28 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - A9E78F402E58BD770079F3CC /* XCRemoteSwiftPackageReference "SwiftTerm" */ = { + A99D9F7F2E64F45B00259166 /* XCRemoteSwiftPackageReference "SwiftTerm" */ = { isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/migueldeicaza/SwiftTerm"; + repositoryURL = "https://github.com/neon443/SwiftTerm"; requirement = { - kind = revision; - revision = b48ebbbffee544df3f5dc8f43258f44f95d75c6f; + branch = jelly; + kind = branch; }; }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - A9E78F412E58BD770079F3CC /* SwiftTerm */ = { + A99D9F7A2E63513E00259166 /* SwiftTerm */ = { isa = XCSwiftPackageProductDependency; - package = A9E78F402E58BD770079F3CC /* XCRemoteSwiftPackageReference "SwiftTerm" */; + productName = SwiftTerm; + }; + A99D9F7D2E6351D100259166 /* SwiftTerm */ = { + isa = XCSwiftPackageProductDependency; + productName = SwiftTerm; + }; + A99D9F802E64F45B00259166 /* SwiftTerm */ = { + isa = XCSwiftPackageProductDependency; + package = A99D9F7F2E64F45B00259166 /* XCRemoteSwiftPackageReference "SwiftTerm" */; productName = SwiftTerm; }; /* End XCSwiftPackageProductDependency section */ diff --git a/ShhShell.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ShhShell.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 755a29f..3f19e72 100644 --- a/ShhShell.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ShhShell.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "4d9d9af82f23f3c708bdd502fed3939413b4f2a95a79ae568364cc92bca1527e", + "originHash" : "702d8e7b18adc80c84aa168885ba00fbb7440c6e9f59acbbf93da8a625ebf380", "pins" : [ { "identity" : "swift-argument-parser", @@ -16,7 +16,7 @@ "location" : "https://github.com/swiftlang/swift-subprocess", "state" : { "branch" : "main", - "revision" : "7dc6e548114db7d6b10fddf29bcd5215c3875891" + "revision" : "f0ba4f43931c4e0f6d15078421dee7cb1415ce5d" } }, { @@ -31,9 +31,10 @@ { "identity" : "swiftterm", "kind" : "remoteSourceControl", - "location" : "https://github.com/migueldeicaza/SwiftTerm", + "location" : "https://github.com/neon443/SwiftTerm", "state" : { - "revision" : "b48ebbbffee544df3f5dc8f43258f44f95d75c6f" + "branch" : "jelly", + "revision" : "a3eda5e08f019ce2b6f21b03e1e1e71e75ee0591" } } ], diff --git a/ShhShell/Terminal/SSHTerminalDelegate.swift b/ShhShell/Terminal/SSHTerminalDelegate.swift index cf2c9ec..de668e2 100644 --- a/ShhShell/Terminal/SSHTerminalDelegate.swift +++ b/ShhShell/Terminal/SSHTerminalDelegate.swift @@ -32,6 +32,7 @@ final class SSHTerminalDelegate: TerminalView, Sendable, @preconcurrency Termina applySelectedTheme() applyScrollbackLength() applyCursorType() + getTerminal().registerOscHandler(code: 133, handler: { _ in }) // DispatchQueue.main.asyncAfter(deadline: .now()+0.01) { self.startFeedLoop() let _ = self.becomeFirstResponder() diff --git a/ShhShell/Views/Terminal/ShellView.swift b/ShhShell/Views/Terminal/ShellView.swift index 570a88b..3615a13 100644 --- a/ShhShell/Views/Terminal/ShellView.swift +++ b/ShhShell/Views/Terminal/ShellView.swift @@ -13,8 +13,34 @@ struct ShellView: View { @ObservedObject var hostsManager: HostsManager @ObservedObject var container = TerminalViewContainer.shared - @State var jellyLoc: (x: Int, y: Int) = (0, 0) - @State var jellySize: CGSize = CGSize(width: 0, height: 0) + @State var cursorPos: (x: Int, y: Int) = (0, 0) + var jellyLoc: CGSize { + var offset = CGSize(width: cursorPos.x, height: cursorPos.y) + offset.width *= cellDimension.width + offset.height *= cellDimension.height + switch hostsManager.settings.cursorType.cursorShape { + case .block, .bar: + fallthrough + case .underline: + offset.height += cellDimension.height * 0.8 + } + return offset + } + + @State var cellDimension: CGSize = CGSize(width: 0, height: 0) + var jellySize: CGSize { + var cellDimension: CGSize = cellDimension + switch hostsManager.settings.cursorType.cursorShape { + case .block: + fallthrough + case .bar: + cellDimension.width *= 0.3 + case .underline: + cellDimension.height *= 0.2 + } + return cellDimension + } + @State var jellyShow: Bool = true @Environment(\.dismiss) var dismiss @@ -34,23 +60,27 @@ struct ShellView: View { let terminalView = container.sessions[handler.sessionID ?? UUID()]?.terminalView let delegate = terminalView?.terminalDelegate as? SSHTerminalDelegate terminalView?.getTerminal().hideCursor() - jellyLoc = terminalView?.getTerminal().getCursorLocation() ?? jellyLoc - jellySize = delegate?.computeFontDimensions() ?? jellySize + cursorPos = terminalView?.getTerminal().getCursorLocation() ?? cursorPos + cellDimension = delegate?.computeFontDimensions() ?? cellDimension // jellyShow = terminalView?.getTerminal().buffer.isCursorInViewPort ?? jellyShow } } - RunLoop.main.add(timer, forMode: .common) +// RunLoop.main.add(timer, forMode: .common) } - Rectangle() - .frame(width: jellySize.width, height: jellySize.height) - .offset( - x: CGFloat(jellyLoc.x)*jellySize.width, - y: CGFloat(jellyLoc.y)*jellySize.height - ) - .opacity(jellyShow ? 1 : 0) - .animation(.spring, value: jellyLoc.x) - .animation(.spring, value: jellyLoc.y) +// Rectangle() +// .frame(width: jellySize.width, height: jellySize.height) +// .offset( +// x: jellyLoc.width, +// y: jellyLoc.height +// ) +// .opacity(jellyShow ? 1 : 0) +// .animation(.spring(duration: 0.2, bounce: 0.6), value: cursorPos.x) +// .animation(.spring(duration: 0.2, bounce: 0.6), value: cursorPos.y) +// .animation(.spring(duration: 0.2, bounce: 0.6), value: jellyLoc.width) +// .animation(.spring(duration: 0.2, bounce: 0.6), value: jellyLoc.height) +// .animation(.spring(duration: 0.2, bounce: 0.6), value: jellySize.width) +// .animation(.spring(duration: 0.2, bounce: 0.6), value: jellySize.height) if hostsManager.settings.filter == .crt { CRTView()