1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! # Pseudoterminal
//!
//! A cross-platform Rust library for creating and managing pseudoterminals.
//!
//! This crate provides a unified interface for working with pseudoterminals (PTYs)
//! across different operating systems, allowing you to spawn processes within
//! a virtual terminal environment and interact with them programmatically.
//!
//! ## Example
//!
//! ```no_run
//! use std::process::Command;
//! use std::io::{Read, Write};
//! use pseudoterminal::CommandExt;
//!
//! fn main() -> std::io::Result<()> {
//! // Create a command to run in the terminal
//! let mut cmd = Command::new("bash");
//!
//! // Spawn the command in a pseudoterminal
//! let mut terminal = cmd.spawn_terminal()?;
//!
//! // Write to the terminal
//! if let Some(ref mut input) = terminal.terminal_in {
//! input.write_all(b"echo Hello from pseudoterminal!\n")?;
//! input.flush()?;
//! }
//!
//! // Read from the terminal
//! if let Some(ref mut output) = terminal.terminal_out {
//! let mut buffer = [0; 1024];
//! let bytes_read = output.read(&mut buffer)?;
//! println!("{}", String::from_utf8_lossy(&buffer[..bytes_read]));
//! }
//!
//! Ok(())
//! }
//! ```
// Re-export CommandExt traits at the root level for backward compatibility
pub use r#CommandExt as AsyncCommandExt;
pub use CommandExt;
/// Represents the dimensions of a terminal in rows and columns.
///
/// This struct is used when creating or resizing a pseudoterminal to
/// specify its dimensions.
///
/// # Examples
///
/// ```
/// use pseudoterminal::TerminalSize;
///
/// // Create a standard terminal size (80x24)
/// let size = TerminalSize {
/// rows: 24,
/// columns: 80,
/// };
///
/// // Create a larger terminal size
/// let large_size = TerminalSize {
/// rows: 50,
/// columns: 132,
/// };
/// ```