typing works
so basically it just stopped tryna read from the server once the server was silent for a sec
so then i removed the return and made it an optional if let and wait 10_000 us if nothing comes back
this is so goood

changed it to get 256 bytes from server
This commit is contained in:
neon443
2025-06-22 19:32:42 +01:00
parent 9338b46760
commit 71c8e3f891
3 changed files with 12 additions and 8 deletions

View File

@@ -315,7 +315,7 @@ class SSHHandler: ObservableObject {
guard ssh_channel_is_open(channel) != 0 else { return nil }
guard ssh_channel_is_eof(channel) == 0 else { return nil }
var buffer: [CChar] = Array(repeating: 0, count: 16)
var buffer: [CChar] = Array(repeating: 0, count: 256)
let nbytes = ssh_channel_read_nonblocking(channel, &buffer, UInt32(buffer.count), 0)
guard nbytes > 0 else { return nil }
@@ -350,6 +350,6 @@ class SSHHandler: ObservableObject {
guard ssh_channel_is_eof(channel) == 0 else { return }
ssh_channel_change_pty_size(channel, Int32(toCols), Int32(toRows))
print("resized tty to \(toRows)rows and \(toCols)cols")
// print("resized tty to \(toRows)rows and \(toCols)cols")
}
}

View File

@@ -26,9 +26,12 @@ class SSHTerminalView: TerminalView, TerminalViewDelegate {
guard let handler = self.handler else { return }
while handler.connected {
guard let handler = self.handler else { break }
guard let read = handler.readFromChannel() else { return }
DispatchQueue.main.async {
self.feed(text: read)
if let read = handler.readFromChannel() {
DispatchQueue.main.async {
self.feed(text: read)
}
} else {
usleep(10_000)
}
}
}
@@ -51,8 +54,10 @@ class SSHTerminalView: TerminalView, TerminalViewDelegate {
}
public func send(source: TerminalView, data: ArraySlice<UInt8>) {
let dataSlice = Data(bytes: [data.first], count: data.count)
handler?.writeToChannel(String(data: dataSlice, encoding: .utf8))
let data = Data(data)
// let dataSlice = Data(bytes: [data], count: data.count)
print("sending \(String(data: data, encoding: .utf8))")
handler?.writeToChannel(String(data: data, encoding: .utf8))
}
public func clipboardCopy(source: TerminalView, content: Data) {

View File

@@ -21,7 +21,6 @@ struct TerminalController: UIViewRepresentable {
),
handler: handler
)
// tv.terminalDelegate = terminalDelegate
return tv
}