From 45aa8912f98e89ad2926402798ad7d2486c39b96 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 8 Mar 2016 18:38:07 +0100 Subject: [PATCH] Rename Mode to Style Mode is somewhat ambiguous term, which is often overused, for that reason I want to avoid it. This is a breaking change, but I don't guarantee stability yet, however I'll do my best to not break things. --- examples/simple.rs | 4 ++-- src/control.rs | 10 +++++++--- src/lib.rs | 4 ++-- src/{mode.rs => style.rs} | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) rename src/{mode.rs => style.rs} (96%) 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.