diff options
Diffstat (limited to 'cli/ops/io.rs')
-rw-r--r-- | cli/ops/io.rs | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/cli/ops/io.rs b/cli/ops/io.rs index 8edb1f748..ad3949a03 100644 --- a/cli/ops/io.rs +++ b/cli/ops/io.rs @@ -57,7 +57,7 @@ pub fn init(i: &mut Isolate, s: &State) { } pub fn get_stdio() -> (StreamResource, StreamResource, StreamResource) { - let stdin = StreamResource::Stdin(tokio::io::stdin()); + let stdin = StreamResource::Stdin(tokio::io::stdin(), TTYMetadata::default()); let stdout = StreamResource::Stdout({ let stdout = STDOUT_HANDLE .try_clone() @@ -69,11 +69,25 @@ pub fn get_stdio() -> (StreamResource, StreamResource, StreamResource) { (stdin, stdout, stderr) } +#[cfg(unix)] +use nix::sys::termios; + +#[derive(Default)] +pub struct TTYMetadata { + #[cfg(unix)] + pub mode: Option<termios::Termios>, +} + +#[derive(Default)] +pub struct FileMetadata { + pub tty: TTYMetadata, +} + pub enum StreamResource { - Stdin(tokio::io::Stdin), + Stdin(tokio::io::Stdin, TTYMetadata), Stdout(tokio::fs::File), Stderr(tokio::io::Stderr), - FsFile(tokio::fs::File), + FsFile(tokio::fs::File, FileMetadata), TcpStream(tokio::net::TcpStream), ServerTlsStream(Box<ServerTlsStream<TcpStream>>), ClientTlsStream(Box<ClientTlsStream<TcpStream>>), @@ -101,8 +115,8 @@ impl DenoAsyncRead for StreamResource { ) -> Poll<Result<usize, OpError>> { use StreamResource::*; let mut f: Pin<Box<dyn AsyncRead>> = match self { - FsFile(f) => Box::pin(f), - Stdin(f) => Box::pin(f), + FsFile(f, _) => Box::pin(f), + Stdin(f, _) => Box::pin(f), TcpStream(f) => Box::pin(f), ClientTlsStream(f) => Box::pin(f), ServerTlsStream(f) => Box::pin(f), @@ -203,7 +217,7 @@ impl DenoAsyncWrite for StreamResource { ) -> Poll<Result<usize, OpError>> { use StreamResource::*; let mut f: Pin<Box<dyn AsyncWrite>> = match self { - FsFile(f) => Box::pin(f), + FsFile(f, _) => Box::pin(f), Stdout(f) => Box::pin(f), Stderr(f) => Box::pin(f), TcpStream(f) => Box::pin(f), @@ -220,7 +234,7 @@ impl DenoAsyncWrite for StreamResource { fn poll_flush(&mut self, cx: &mut Context) -> Poll<Result<(), OpError>> { use StreamResource::*; let mut f: Pin<Box<dyn AsyncWrite>> = match self { - FsFile(f) => Box::pin(f), + FsFile(f, _) => Box::pin(f), Stdout(f) => Box::pin(f), Stderr(f) => Box::pin(f), TcpStream(f) => Box::pin(f), |