From a71c99410360df2a7ada701d14ada776936e2dd9 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Tue, 2 Sep 2025 18:48:32 +0100 Subject: [PATCH] mini cleanup + switch to new CursorAnimations --- ShhShell/Terminal/SSHTerminalDelegate.swift | 40 ++------------------- SwiftTerm | 2 +- 2 files changed, 4 insertions(+), 38 deletions(-) diff --git a/ShhShell/Terminal/SSHTerminalDelegate.swift b/ShhShell/Terminal/SSHTerminalDelegate.swift index 24af308..29414bb 100644 --- a/ShhShell/Terminal/SSHTerminalDelegate.swift +++ b/ShhShell/Terminal/SSHTerminalDelegate.swift @@ -29,16 +29,14 @@ final class SSHTerminalDelegate: TerminalView, Sendable, @preconcurrency Termina restoreScrollback() if let hostsManager { font = UIFont(name: hostsManager.selectedFont, size: hostsManager.fontSize)! - print(computeFontDimensions()) } applySelectedTheme() applyScrollbackLength() applyCursorType() getTerminal().registerOscHandler(code: 133, handler: { _ in }) -// DispatchQueue.main.asyncAfter(deadline: .now()+0.01) { - self.startFeedLoop() - let _ = self.becomeFirstResponder() -// } + getTerminal().setCursorAnimations(CursorAnimations(type: .stretchAndMove)) + self.startFeedLoop() + let _ = self.becomeFirstResponder() } } @@ -67,38 +65,6 @@ final class SSHTerminalDelegate: TerminalView, Sendable, @preconcurrency Termina print("hide cursor called") } - override func cursorStyleChanged(source: Terminal, newStyle: CursorStyle) { - super.cursorStyleChanged(source: source, newStyle: newStyle) - } - - //excerpt from SwiftTerm, modified to get around private properties - func computeFontDimensions () -> CGSize - { - let lineAscent = CTFontGetAscent (font) - let lineDescent = CTFontGetDescent (font) - let lineLeading = CTFontGetLeading (font) - let cellHeight = ceil(lineAscent + lineDescent + lineLeading) -#if os(macOS) - // The following is a more robust way of getting the largest ascii character width, but comes with a performance hit. - // See: https://github.com/migueldeicaza/SwiftTerm/issues/286 - // var sizes = UnsafeMutablePointer.allocate(capacity: 95) - // let ctFont = (font as CTFont) - // var glyphs = (32..<127).map { CTFontGetGlyphWithName(ctFont, String(Unicode.Scalar($0)) as CFString) } - // withUnsafePointer(to: glyphs[0]) { glyphsPtr in - // fontSet.normal.getAdvancements(NSSizeArray(sizes), forCGGlyphs: glyphsPtr, count: 95) - // } - // let cellWidth = (0..<95).reduce(into: 0) { partialResult, idx in - // partialResult = max(partialResult, sizes[idx].width) - // } - let glyph = font.glyph(withName: "W") - let cellWidth = font.advancement(forGlyph: glyph).width -#else - let fontAttributes = [NSAttributedString.Key.font: font] - let cellWidth = "W".size(withAttributes: fontAttributes).width -#endif - return CGSize(width: max (1, cellWidth), height: max (min (cellHeight, 8192), 1)) - } - func startFeedLoop() { guard readTimer == nil else { return } readTimer = Timer(timeInterval: 0.01, repeats: true) { timer in diff --git a/SwiftTerm b/SwiftTerm index a3eda5e..66c513b 160000 --- a/SwiftTerm +++ b/SwiftTerm @@ -1 +1 @@ -Subproject commit a3eda5e08f019ce2b6f21b03e1e1e71e75ee0591 +Subproject commit 66c513bf69b6268de25f6f0b83ad2999c1cc8936