namespace reformat and 2018 style (#208)
This commit is contained in:
parent
ea8a367c11
commit
43aa1c222e
@ -1,12 +1,7 @@
|
||||
//!
|
||||
//! Examples of coloring the terminal.
|
||||
//!
|
||||
#[macro_use]
|
||||
extern crate crossterm_style;
|
||||
|
||||
use self::crossterm_style::{
|
||||
color, style, Attribute, Color, Colored, Colorize, Styler, TerminalColor,
|
||||
};
|
||||
use crossterm_style::{color, Attribute, Color, Colored, Colorize, Styler};
|
||||
|
||||
/// print some red text | demonstration.
|
||||
pub fn paint_foreground() {
|
||||
@ -393,6 +388,4 @@ pub fn reset_fg_and_bg() {
|
||||
println!("{}", Colored::Bg(Color::Reset));
|
||||
}
|
||||
|
||||
fn main() {
|
||||
command()
|
||||
}
|
||||
fn main() {}
|
||||
|
@ -1,12 +1,12 @@
|
||||
//! This is a ANSI specific implementation for styling related action.
|
||||
//! This module is used for Windows 10 terminals and Unix terminals by default.
|
||||
|
||||
use crate::{Attribute, Color, ITerminalColor};
|
||||
use crossterm_utils::{write_cout, Result};
|
||||
|
||||
use crate::Colored;
|
||||
use std::io::Write;
|
||||
|
||||
use crossterm_utils::{csi, write_cout, Result};
|
||||
|
||||
use crate::{Attribute, Color, Colored, ITerminalColor};
|
||||
|
||||
#[inline]
|
||||
pub fn get_set_fg_ansi(fg_color: Color) -> String {
|
||||
format!(csi!("{}m"), color_value(Colored::Fg(fg_color)),)
|
||||
|
@ -1,15 +1,15 @@
|
||||
//! A module that contains all the actions related to the styling of the terminal.
|
||||
//! Like applying attributes to text and changing the foreground and background.
|
||||
|
||||
use std::clone::Clone;
|
||||
use std::io;
|
||||
|
||||
use super::*;
|
||||
use crate::{Color, ITerminalColor};
|
||||
use crossterm_utils::{impl_display, Command, Result};
|
||||
use std::clone::Clone;
|
||||
|
||||
#[cfg(windows)]
|
||||
use crossterm_utils::supports_ansi;
|
||||
use crossterm_utils::{impl_display, Command, Result};
|
||||
|
||||
/// Allows you to style the terminal.
|
||||
///
|
||||
|
@ -1,5 +1,6 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use crossterm_utils::csi;
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
use crate::color::color;
|
||||
use crate::enums::Color;
|
||||
use std::fmt::Display;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::color::color;
|
||||
use crate::enums::Color;
|
||||
|
||||
/// Could be used to color the foreground or background color.
|
||||
///
|
||||
/// `Colored::Fg` represents the foreground color.
|
||||
|
@ -1,5 +1,5 @@
|
||||
pub use self::{attribute::Attribute, color::Color, colored::Colored};
|
||||
|
||||
mod attribute;
|
||||
mod color;
|
||||
mod colored;
|
||||
|
||||
pub use self::{attribute::Attribute, color::Color, colored::Colored};
|
||||
|
@ -1,11 +1,6 @@
|
||||
//! A module that contains all the actions related to the styling of the terminal.
|
||||
//! Like applying attributes to text and changing the foreground and background.
|
||||
|
||||
#[macro_use]
|
||||
extern crate crossterm_utils;
|
||||
#[cfg(windows)]
|
||||
extern crate crossterm_winapi;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
mod color;
|
||||
@ -18,18 +13,18 @@ mod ansi_color;
|
||||
#[cfg(windows)]
|
||||
mod winapi_color;
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
use self::ansi_color::AnsiColor;
|
||||
#[cfg(windows)]
|
||||
use self::winapi_color::WinApiColor;
|
||||
|
||||
use std::fmt::Display;
|
||||
pub use crossterm_utils::{execute, queue, Command, ExecutableCommand, QueueableCommand, Result};
|
||||
|
||||
pub use self::color::{color, PrintStyledFont, SetAttr, SetBg, SetFg, TerminalColor};
|
||||
pub use self::enums::{Attribute, Color, Colored};
|
||||
pub use self::objectstyle::ObjectStyle;
|
||||
pub use self::styledobject::StyledObject;
|
||||
pub use self::traits::{Colorize, Styler};
|
||||
pub use crossterm_utils::{execute, queue, Command, ExecutableCommand, QueueableCommand, Result};
|
||||
|
||||
/// This trait defines the actions that can be performed with terminal colors.
|
||||
/// This trait can be implemented so that a concrete implementation of the ITerminalColor can fulfill
|
||||
|
@ -1,10 +1,8 @@
|
||||
//! This module contains the `object style` that can be applied to an `styled object`.
|
||||
|
||||
use super::{Color, StyledObject};
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
use super::Attribute;
|
||||
use super::{Attribute, Color, StyledObject};
|
||||
|
||||
/// Struct that contains the style properties that can be applied to a displayable object.
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -1,12 +1,15 @@
|
||||
//! This module contains the logic to style an object that contains some 'content' which can be styled.
|
||||
|
||||
use super::{color, Color, ObjectStyle, SetBg, SetFg};
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
use std::result;
|
||||
|
||||
use super::Attribute;
|
||||
use crossterm_utils::{csi, queue};
|
||||
|
||||
use crate::{Colorize, Styler};
|
||||
|
||||
use super::Attribute;
|
||||
use super::{color, Color, ObjectStyle, SetBg, SetFg};
|
||||
|
||||
/// Contains both the style and the content which can be styled.
|
||||
#[derive(Clone)]
|
||||
pub struct StyledObject<D: Display + Clone> {
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::StyledObject;
|
||||
use std::fmt::Display;
|
||||
|
||||
use crate::StyledObject;
|
||||
|
||||
/// Provides a set of methods to color any type implementing `Display` with attributes.
|
||||
///
|
||||
/// This trait is implemented for `&static str` and `StyledObject` and thus the methods of this trait could be called on them.
|
||||
|
@ -1,13 +1,15 @@
|
||||
//! This is a `WinApi` specific implementation for styling related action.
|
||||
//! This module is used for non supporting `ANSI` Windows terminals.
|
||||
|
||||
use crate::{Color, Colored, ITerminalColor};
|
||||
use crossterm_utils::Result;
|
||||
use crossterm_winapi::{Console, Handle, HandleType, ScreenBuffer};
|
||||
use std::io;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
|
||||
use crossterm_utils::Result;
|
||||
use crossterm_winapi::{Console, Handle, HandleType, ScreenBuffer};
|
||||
use winapi::um::wincon;
|
||||
|
||||
use crate::{Color, Colored, ITerminalColor};
|
||||
|
||||
const FG_GREEN: u16 = wincon::FOREGROUND_GREEN;
|
||||
const FG_RED: u16 = wincon::FOREGROUND_RED;
|
||||
const FG_BLUE: u16 = wincon::FOREGROUND_BLUE;
|
||||
|
Loading…
Reference in New Issue
Block a user