Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Refactors #2

Merged
merged 21 commits into from
Sep 30, 2019
Merged
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Build only pushed (merged) master or any pull request. This avoids the
# pull request to be build twice.
branches:
only:
- master

language: rust

rust:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version master
- Added unit tests
TimonPost marked this conversation as resolved.
Show resolved Hide resolved
- Restructured files

# Version 0.5.1

- Maintenance release only
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ edition = "2018"
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.8", features = ["wincon"] }
crossterm_winapi = { version = "0.2.1" }
lazy_static = "1.4"

[dependencies]
crossterm_utils = { version = "0.3.1" }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ crossterm_style = "0.5"
And import the `crossterm_style` modules you want to use.

```rust
pub use crossterm_style::{color, style, Attribute, Color, ColorType, ObjectStyle, StyledObject, TerminalColor, Colorize, Styler};
pub use crossterm_style::{color, style, Attribute, Color, ObjectStyle, StyledObject, TerminalColor, Colorize, Styler};
```

### Useful Links
Expand Down
106 changes: 0 additions & 106 deletions src/ansi_color.rs

This file was deleted.

166 changes: 0 additions & 166 deletions src/color.rs

This file was deleted.

18 changes: 10 additions & 8 deletions src/enums/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fmt::Display;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

use crossterm_utils::csi;
use crate::SetAttr;

/// Enum with the different attributes to style your test.
///
Expand All @@ -17,7 +17,9 @@ use crossterm_utils::csi;
/// # Example
/// You can use an attribute in a write statement to apply the attribute to the terminal output.
///
/// ```ignore
/// ```no_run
/// use crossterm_style::Attribute;
///
/// println!(
/// "{} Underlined {} No Underline",
/// Attribute::Underlined,
Expand All @@ -26,12 +28,12 @@ use crossterm_utils::csi;
/// ```
///
/// You can also call attribute functions on a `&'static str`:
/// ```ignore
/// use Colorizer;
/// ```no_run
/// use crossterm_style::Styler;
///
/// println!("{}", style("Bold text").bold());
/// println!("{}", style("Underlined text").underlined());
/// println!("{}", style("Negative text").negative());
/// println!("{}", "Bold text".bold());
/// println!("{}", "Underlined text".underlined());
/// println!("{}", "Negative text".negative());
/// ```
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)]
Expand Down Expand Up @@ -142,7 +144,7 @@ pub enum Attribute {

impl Display for Attribute {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> {
write!(f, "{}", format!(csi!("{}m"), *self as i16))?;
write!(f, "{}", SetAttr(*self))?;
Ok(())
}
}
20 changes: 7 additions & 13 deletions src/enums/colored.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,26 @@ use std::fmt::Display;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

use crate::color::color;
use crate::color;
use crate::enums::Color;

/// Could be used to color the foreground or background color.
///
/// `Colored::Fg` represents the foreground color.
/// `Color::Bg` represents the background color.
/// Can be used to easily change the front and back ground color
///
/// # Example
///
/// You can use `Colored` in a write statement to apply the attribute to the terminal output.
/// `Colored` implements `Display` therefore you can use it in any `write` operation.
///
/// ```ignore
/// ```no_run
/// use crossterm_style::{Colored, Color};
/// println!("{} Red foreground color", Colored::Fg(Color::Red));
/// println!("{} Blue background color", Colored::Bg(Color::Blue));
/// ```
///
/// You can also call coloring functions on a `&'static str`:
/// ```ignore
/// let styled_text = "Red forground color on blue background.".red().on_blue();
/// println!("{}", styled_text);
/// ```
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub enum Colored {
/// Use this if you want to change the foreground color
Fg(Color),
/// Use this if you want to change the background color
Bg(Color),
}

Expand Down
Loading