mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 21:36:17 +00:00
added bell - the title will show a bell emoji if the bell has been rung for 0.2s
fix massive memory leak :cry it liteally got to 10gigs :wilt fixed cpu usage - 90+% lower
This commit is contained in:
@@ -22,7 +22,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
|
|||||||
|
|
||||||
@Published var testSuceeded: Bool? = nil
|
@Published var testSuceeded: Bool? = nil
|
||||||
|
|
||||||
@Published var bell: UUID? = nil
|
@Published var bell: Bool = false
|
||||||
|
|
||||||
@Published var host: Host
|
@Published var host: Host
|
||||||
|
|
||||||
@@ -150,9 +150,9 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ring() {
|
func ring() {
|
||||||
withAnimation { bell = UUID() }
|
bell = true
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now()+1) {
|
DispatchQueue.main.asyncAfter(deadline: .now()+0.2) {
|
||||||
withAnimation { self.bell = nil }
|
self.bell = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,7 +383,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var buffer: [CChar] = Array(repeating: 0, count: 1024)
|
var buffer: [CChar] = Array(repeating: 0, count: 1024)
|
||||||
let nbytes = ssh_channel_read(channel, &buffer, UInt32(buffer.count), 0)
|
let nbytes = ssh_channel_read_nonblocking(channel, &buffer, UInt32(buffer.count), 0)
|
||||||
|
|
||||||
guard nbytes > 0 else { return nil }
|
guard nbytes > 0 else { return nil }
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ final class SSHTerminalView: TerminalView, Sendable, @preconcurrency TerminalVie
|
|||||||
self.feed(text: read)
|
self.feed(text: read)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Task {try? await Task.sleep(nanoseconds: 10_000_000) } //10ms
|
try? await Task.sleep(nanoseconds: 10_000_000) //10ms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handler.disconnect()
|
handler.disconnect()
|
||||||
@@ -83,7 +83,6 @@ final class SSHTerminalView: TerminalView, Sendable, @preconcurrency TerminalVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func bell(source: TerminalView) {
|
public func bell(source: TerminalView) {
|
||||||
print("bell rung")
|
|
||||||
handler?.ring()
|
handler?.ring()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,6 @@ struct ShellView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
ZStack {
|
ZStack {
|
||||||
if handler.bell != nil {
|
|
||||||
Text("🔔")
|
|
||||||
.font(.title)
|
|
||||||
.transition(.scale)
|
|
||||||
}
|
|
||||||
if !handler.connected {
|
if !handler.connected {
|
||||||
DialogView(handler: handler, showDialog: !handler.connected)
|
DialogView(handler: handler, showDialog: !handler.connected)
|
||||||
}
|
}
|
||||||
@@ -50,7 +45,7 @@ struct ShellView: View {
|
|||||||
.onChange(of: handler.connected) { _ in
|
.onChange(of: handler.connected) { _ in
|
||||||
if !handler.connected { dismiss() }
|
if !handler.connected { dismiss() }
|
||||||
}
|
}
|
||||||
.navigationTitle(handler.title)
|
.navigationTitle(handler.bell ? "🔔" : handler.title)
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user