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.
This commit is contained in:
Ticki 2016-03-08 18:38:07 +01:00
parent f5aad5e2b1
commit 45aa8912f9
4 changed files with 12 additions and 8 deletions

View File

@ -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();

View File

@ -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<usize>;
/// Clear the terminal.
/// Clear the entire screen.
fn clear(&mut self) -> IoResult<usize> {
self.csi(b"2J")
}
/// Clear the current line.
fn clear_line(&mut self) -> IoResult<usize> {
self.csi(b"2K")
}
/// Show the cursor.
fn show(&mut self) -> IoResult<usize> {
self.csi(b"?25h")
@ -85,7 +89,7 @@ pub trait TermControl {
])
}
/// Set rendition mode (SGR).
fn mode(&mut self, mode: Mode) -> IoResult<usize> {
fn style(&mut self, mode: Style) -> IoResult<usize> {
self.rendition(mode as u8)
}
}

View File

@ -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;

View File

@ -1,5 +1,5 @@
/// A SGR parameter (rendition mode).
pub enum Mode {
pub enum Style {
/// Reset SGR parameters.
Reset = 0,
/// Bold text.