Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,24 @@ pub trait Terminal<T: Write>: Write {
/// was an I/O error.
fn reset(&mut self) -> io::Result<bool>;

/// Moves the cursor up one line.
///
/// Returns `Ok(true)` if the cursor was moved, `Ok(false)` otherwise, and `Err(e)`
/// if there was an I/O error.
fn cursor_up(&mut self) -> io::Result<bool>;

/// Deletes the text from the cursor location to the end of the line.
///
/// Returns `Ok(true)` if the text was deleted, `Ok(false)` otherwise, and `Err(e)`
/// 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
12 changes: 12 additions & 0 deletions src/terminfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,18 @@ impl<T: Write+Send> Terminal<T> for TerminfoTerminal<T> {
self.out.write_all(&cmd).map(|_|true)
}

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

fn delete_line(&mut self) -> io::Result<bool> {
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