bell ringing backend done now need to actually trigger it

added ring() to ring the bell
terminal is now a fullscreencover
can be dismissed and reopened or disconnected
 - need to make it keep the scrollback
increased sleep between reads
added support for title
added setTitle function, defaults to username@server
increased the buffer to 16384 bytes
This commit is contained in:
neon443
2025-06-25 11:12:10 +01:00
parent bf4a273a46
commit f71bd0ddf2
8 changed files with 76 additions and 40 deletions

View File

@@ -17,11 +17,12 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
// @Published var hostsManager = HostsManager()
@Published var title: String = ""
@Published var connected: Bool = false
@Published var authorized: Bool = false
@Published var testSuceeded: Bool? = nil
@Published var bell: UUID?
@Published var bell: UUID? = nil
@Published var host: Host
@@ -76,6 +77,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
}
}
openShell()
setTitle("\(host.username)@\(host.address)")
ssh_channel_request_env(channel, "TERM", "xterm-256color")
ssh_channel_request_env(channel, "LANG", "en_US.UTF-8")
ssh_channel_request_env(channel, "LC_ALL", "en_US.UTF-8")
@@ -132,6 +134,17 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
}
func ring() {
withAnimation { bell = UUID() }
DispatchQueue.main.asyncAfter(deadline: .now()+1) {
withAnimation { self.bell = nil }
}
}
func setTitle(_ newTitle: String) {
self.title = newTitle
}
func testExec() {
if ssh_is_connected(session) == 0 {
withAnimation { testSuceeded = false }
@@ -208,6 +221,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
return
}
//MARK: auth
func authWithPubkey(pub pubInp: Data, priv privInp: Data, pass: String) throws(KeyError) {
guard session != nil else {
withAnimation { authorized = false }
@@ -309,6 +323,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
print(recievedMethod)
}
//MARK: shell
func openShell() {
var status: CInt
@@ -346,7 +361,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
return nil
}
var buffer: [CChar] = Array(repeating: 0, count: 4096)
var buffer: [CChar] = Array(repeating: 0, count: 16_384)
let nbytes = ssh_channel_read_nonblocking(channel, &buffer, UInt32(buffer.count), 0)
guard nbytes > 0 else { return nil }
@@ -354,7 +369,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
let data = Data(bytes: buffer, count: Int(nbytes))
if let string = String(data: data, encoding: .utf8) {
#if DEBUG
print(String(data: Data(bytes: buffer, count: Int(nbytes)), encoding: .utf8)!)
// print(String(data: Data(bytes: buffer, count: Int(nbytes)), encoding: .utf8)!)
#endif
return string
}