pub struct StdioTerminal { /* private fields */ }Expand description
Unix terminal using stdin/stdout with termios.
Provides a Terminal implementation for Unix-like systems
(Linux, macOS, BSD) using standard input/output with termios for raw mode
and ANSI escape sequences for cursor control.
§Examples
use editline::terminals::StdioTerminal;
let terminal = StdioTerminal::new();Implementations§
Source§impl StdioTerminal
impl StdioTerminal
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Unix terminal using stdin/stdout.
The terminal starts in normal mode. Call Terminal::enter_raw_mode
to enable character-by-character input.
Examples found in repository?
examples/simple_repl.rs (line 14)
6fn main() {
7 println!("Simple REPL - Type something and press Enter");
8 println!("Type 'exit' or press Ctrl-D to quit");
9 println!("Features: line editing, history (up/down), word navigation (Ctrl+arrows)");
10 println!("Press Ctrl-C to cancel current line");
11 println!();
12
13 let mut editor = LineEditor::new(1024, 50);
14 let mut terminal = StdioTerminal::new();
15
16 loop {
17 print!("> ");
18 std::io::Write::flush(&mut std::io::stdout()).unwrap();
19
20 match editor.read_line(&mut terminal) {
21 Ok(line) => {
22 if line == "exit" {
23 println!("Goodbye!");
24 break;
25 } else if !line.is_empty() {
26 println!("typed: {}", line);
27 }
28 }
29 Err(e) => {
30 // Handle Ctrl-C and Ctrl-D
31 match e {
32 editline::Error::Eof => {
33 // Ctrl-D pressed - exit gracefully
34 println!("\nGoodbye!");
35 break;
36 }
37 editline::Error::Interrupted => {
38 // Ctrl-C pressed - show message and continue
39 println!("\nInterrupted. Type 'exit' or press Ctrl-D to quit.");
40 continue;
41 }
42 _ => {
43 eprintln!("\nError reading input: {}", e);
44 break;
45 }
46 }
47 }
48 }
49 }
50}Trait Implementations§
Source§impl Default for StdioTerminal
impl Default for StdioTerminal
Source§impl Drop for StdioTerminal
impl Drop for StdioTerminal
Source§impl Terminal for StdioTerminal
impl Terminal for StdioTerminal
Source§fn enter_raw_mode(&mut self) -> Result<()>
fn enter_raw_mode(&mut self) -> Result<()>
Enters raw mode for character-by-character input. Read more
Source§fn exit_raw_mode(&mut self) -> Result<()>
fn exit_raw_mode(&mut self) -> Result<()>
Exits raw mode and restores normal terminal settings. Read more
Auto Trait Implementations§
impl Freeze for StdioTerminal
impl RefUnwindSafe for StdioTerminal
impl Send for StdioTerminal
impl Sync for StdioTerminal
impl Unpin for StdioTerminal
impl UnwindSafe for StdioTerminal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more