mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 05:19:13 +00:00
mini cleanup + switch to new CursorAnimations
This commit is contained in:
@@ -29,16 +29,14 @@ final class SSHTerminalDelegate: TerminalView, Sendable, @preconcurrency Termina
|
|||||||
restoreScrollback()
|
restoreScrollback()
|
||||||
if let hostsManager {
|
if let hostsManager {
|
||||||
font = UIFont(name: hostsManager.selectedFont, size: hostsManager.fontSize)!
|
font = UIFont(name: hostsManager.selectedFont, size: hostsManager.fontSize)!
|
||||||
print(computeFontDimensions())
|
|
||||||
}
|
}
|
||||||
applySelectedTheme()
|
applySelectedTheme()
|
||||||
applyScrollbackLength()
|
applyScrollbackLength()
|
||||||
applyCursorType()
|
applyCursorType()
|
||||||
getTerminal().registerOscHandler(code: 133, handler: { _ in })
|
getTerminal().registerOscHandler(code: 133, handler: { _ in })
|
||||||
// DispatchQueue.main.asyncAfter(deadline: .now()+0.01) {
|
getTerminal().setCursorAnimations(CursorAnimations(type: .stretchAndMove))
|
||||||
self.startFeedLoop()
|
self.startFeedLoop()
|
||||||
let _ = self.becomeFirstResponder()
|
let _ = self.becomeFirstResponder()
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,38 +65,6 @@ final class SSHTerminalDelegate: TerminalView, Sendable, @preconcurrency Termina
|
|||||||
print("hide cursor called")
|
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<NSSize>.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() {
|
func startFeedLoop() {
|
||||||
guard readTimer == nil else { return }
|
guard readTimer == nil else { return }
|
||||||
readTimer = Timer(timeInterval: 0.01, repeats: true) { timer in
|
readTimer = Timer(timeInterval: 0.01, repeats: true) { timer in
|
||||||
|
|||||||
Submodule SwiftTerm updated: a3eda5e08f...66c513bf69
Reference in New Issue
Block a user