diff --git a/README.md b/README.md index b34244b..be47a51 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,29 @@ while let blob = try await asyncStreams.next() { } ``` -Citadel currently does not expose APIs for streaming into a process' `stdin`. If you want this, please create an issue. +Citadel currently expose APIs for streaming into a process' `stdin`. only withPTY and withTTY. + +An example of how pty model can be used: + +```swift +try await client.withPTY( + SSHChannelRequestEvent.PseudoTerminalRequest( + wantReply: true, + term: "xterm", + terminalCharacterWidth: 80, + terminalRowHeight: 24, + terminalPixelWidth: 0, + terminalPixelHeight: 0, + terminalModes: .init([.ECHO: 1]) + ), + environment: [SSHChannelRequestEvent.EnvironmentRequest(wantReply: true, name: "LANG", value: "en_US.UTF-8")]) { + + ttyOutput, ttyStdinWriter in + + ...do something... +} +``` + ### SFTP Client diff --git a/Sources/Citadel/TTY/Client/TTY.swift b/Sources/Citadel/TTY/Client/TTY.swift index 0b73abd..9acf5fd 100644 --- a/Sources/Citadel/TTY/Client/TTY.swift +++ b/Sources/Citadel/TTY/Client/TTY.swift @@ -80,13 +80,13 @@ public struct TTYStdinWriter { try await channel.writeAndFlush(SSHChannelData(type: .channel, data: .byteBuffer(buffer))) } - public func changeSize(cols: Int, rows: Int) async throws { + public func changeSize(cols: Int, rows: Int, pixelWidth:Int, pixelHeight:Int) async throws { try await channel.triggerUserOutboundEvent( SSHChannelRequestEvent.WindowChangeRequest( - terminalCharacterWidth: 0, - terminalRowHeight: 0, - terminalPixelWidth: 0, - terminalPixelHeight: 0 + terminalCharacterWidth: cols, + terminalRowHeight: rows, + terminalPixelWidth: pixelWidth, + terminalPixelHeight: pixelHeight ) ) }