Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ no-color = []

[dependencies]
lazy_static = "1"
rgb = "0.8"

[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.48"
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_colors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use colored::*;
fn main() {
let my_color = CustomColor::new(0, 120, 120);
let my_color = Rgb::new(0, 120, 120);
println!("{}", "Greetings from Ukraine".custom_color(my_color));
println!("{}", "Slava Ukraini!".on_custom_color(my_color));
println!("{}", "Hello World!".on_custom_color((0, 120, 120)));
Expand Down
45 changes: 0 additions & 45 deletions src/customcolors.rs

This file was deleted.

18 changes: 14 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,23 @@
//! format!("{:30}", "format works as expected. This will be padded".blue());
//! format!("{:.3}", "and this will be green but truncated to 3 chars".green());
//!
//! Custom colours are implemented using the `rgb` crate, which is re-exported for
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using UK English or American English in the rest of our docs? 😆

Copy link
Author

@RuboGubo RuboGubo Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well if UK English is an option....

//! convenience.
//!
//! ```
//! use colored::*;
//! let my_color = Rgb::new(0, 120, 120);
//! println!("{}", "This is using a custom colour".custom_color(my_color));
//! ```
//! see `examples/custom_colors.rs` for more info
//!
//! See [the `Colorize` trait](./trait.Colorize.html) for all the methods.
//!
//! Note: The methods of [`Colorize`], when used on [`str`]'s, return
//! [`ColoredString`]'s. See [`ColoredString`] to learn more about them and
//! what you can do with them beyond continue to use [`Colorize`] to further
//! modify them.
//!
#![warn(missing_docs)]

#[macro_use]
Expand All @@ -40,10 +50,10 @@ pub mod control;
mod error;
mod style;

pub use self::customcolors::CustomColor;
pub use rgb::Rgb;

/// Custom colors support.
pub mod customcolors;
pub use rgb;

pub use color::*;

Expand Down Expand Up @@ -261,7 +271,7 @@ pub trait Colorize {
fn custom_color<T>(self, color: T) -> ColoredString
where
Self: Sized,
T: Into<CustomColor>,
T: Into<Rgb<u8>>,
{
let color = color.into();

Expand Down Expand Up @@ -390,7 +400,7 @@ pub trait Colorize {
fn on_custom_color<T>(self, color: T) -> ColoredString
where
Self: Sized,
T: Into<CustomColor>,
T: Into<Rgb<u8>>,
{
let color = color.into();

Expand Down