diff --git a/examples/simple.rs b/examples/simple.rs index d739482..ce8e107 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -1,6 +1,6 @@ extern crate libterm; -use libterm::{TermControl, IntoRawMode, Color, Mode}; +use libterm::{TermControl, IntoRawMode, Color, Style}; use std::io::{Read, Write, stdout, stdin}; fn main() { @@ -10,7 +10,7 @@ fn main() { stdout.goto(5, 5).unwrap(); stdout.clear().unwrap(); - stdout.mode(Mode::Bold).unwrap(); + stdout.style(Style::Bold).unwrap(); stdout.write(b"yo, 'q' will exit.").unwrap(); stdout.reset().unwrap(); stdout.flush().unwrap(); diff --git a/src/control.rs b/src/control.rs index 8e48ecd..0087180 100644 --- a/src/control.rs +++ b/src/control.rs @@ -1,5 +1,5 @@ use std::io::{Write, Result as IoResult}; -use {Color, Mode}; +use {Color, Style}; /// Controlling terminals. pub trait TermControl { @@ -12,10 +12,14 @@ pub trait TermControl { fn dsc(&mut self, b: &[u8]) -> IoResult; - /// Clear the terminal. + /// Clear the entire screen. fn clear(&mut self) -> IoResult { self.csi(b"2J") } + /// Clear the current line. + fn clear_line(&mut self) -> IoResult { + self.csi(b"2K") + } /// Show the cursor. fn show(&mut self) -> IoResult { self.csi(b"?25h") @@ -85,7 +89,7 @@ pub trait TermControl { ]) } /// Set rendition mode (SGR). - fn mode(&mut self, mode: Mode) -> IoResult { + fn style(&mut self, mode: Style) -> IoResult { self.rendition(mode as u8) } } diff --git a/src/lib.rs b/src/lib.rs index ae67d23..ae7451e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,8 +21,8 @@ pub use size::terminal_size; mod color; pub use color::Color; -mod mode; -pub use mode::Mode; +mod style; +pub use style::Style; mod extra; pub use extra::ReadExt; diff --git a/src/mode.rs b/src/style.rs similarity index 96% rename from src/mode.rs rename to src/style.rs index 38faad6..ac750d4 100644 --- a/src/mode.rs +++ b/src/style.rs @@ -1,5 +1,5 @@ /// A SGR parameter (rendition mode). -pub enum Mode { +pub enum Style { /// Reset SGR parameters. Reset = 0, /// Bold text.