Skip to content

Commit

Permalink
Add support for terminfo normalized carriage return.
Browse files Browse the repository at this point in the history
  • Loading branch information
asolove committed Apr 25, 2015
1 parent 4c9e41d commit 10cc9f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ pub trait Terminal<T: Write>: Write {
/// if there was an I/O error.
fn delete_line(&mut self) -> io::Result<bool>;

/// Moves the cursor to the left edge of the current line.
///
/// Returns `Ok(true)` if the text was deleted, `Ok(false)` otherwise, and `Err(e)`
/// if there was an I/O error.
fn carriage_return(&mut self) -> io::Result<bool>;

/// Gets an immutable reference to the stream inside
fn get_ref<'a>(&'a self) -> &'a T;

Expand Down
4 changes: 4 additions & 0 deletions src/terminfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ impl<T: Write+Send> Terminal<T> for TerminfoTerminal<T> {
self.apply_cap("dl", &[])
}

fn carriage_return(&mut self) -> io::Result<bool> {
self.apply_cap("cr", &[])
}

fn get_ref<'a>(&'a self) -> &'a T { &self.out }

fn get_mut<'a>(&'a mut self) -> &'a mut T { &mut self.out }
Expand Down

0 comments on commit 10cc9f2

Please sign in to comment.