diff --git a/ShhShell/SSH/SSHHandler.swift b/ShhShell/SSH/SSHHandler.swift index 168acf6..3435c2f 100644 --- a/ShhShell/SSH/SSHHandler.swift +++ b/ShhShell/SSH/SSHHandler.swift @@ -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") } } diff --git a/ShhShell/Views/Terminal/SSHTerminalView.swift b/ShhShell/Views/Terminal/SSHTerminalView.swift index dde1323..09c30e6 100644 --- a/ShhShell/Views/Terminal/SSHTerminalView.swift +++ b/ShhShell/Views/Terminal/SSHTerminalView.swift @@ -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) { - 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) { diff --git a/ShhShell/Views/Terminal/TerminalController.swift b/ShhShell/Views/Terminal/TerminalController.swift index 9b00f0a..10f2655 100644 --- a/ShhShell/Views/Terminal/TerminalController.swift +++ b/ShhShell/Views/Terminal/TerminalController.swift @@ -21,7 +21,6 @@ struct TerminalController: UIViewRepresentable { ), handler: handler ) -// tv.terminalDelegate = terminalDelegate return tv }