-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Choose between multiple versions of a Colors object containing escape sequences rather than having a 'colored' boolean. Later on, html will just be another Colors object.
- Loading branch information
1 parent
3b3ab35
commit 7d91da2
Showing
4 changed files
with
106 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
pub struct Colors { | ||
pub normal: EscapeSequence, | ||
pub red: EscapeSequence, | ||
pub green: EscapeSequence, | ||
pub cyan: EscapeSequence, | ||
pub blue: EscapeSequence, | ||
pub bold: EscapeSequence, | ||
} | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct EscapeSequence { | ||
pub enable: &'static str, | ||
pub disable: &'static str, | ||
} | ||
|
||
impl EscapeSequence { | ||
pub const fn new(enable: &'static str, disable: &'static str) -> Self { | ||
EscapeSequence { enable, disable } | ||
} | ||
} | ||
|
||
const EMPTY: EscapeSequence = EscapeSequence::new("", ""); | ||
|
||
pub static NO_COLORS: &Colors = &Colors { | ||
normal: EMPTY, | ||
bold: EMPTY, | ||
red: EMPTY, | ||
green: EMPTY, | ||
cyan: EMPTY, | ||
blue: EMPTY, | ||
}; | ||
|
||
#[allow(dead_code)] | ||
pub static DEBUG_COLORS: &Colors = &Colors { | ||
normal: EscapeSequence::new("«-»", ""), | ||
red: EscapeSequence::new("«red»", ""), | ||
green: EscapeSequence::new("«green»", ""), | ||
cyan: EscapeSequence::new("«cyan»", ""), | ||
blue: EscapeSequence::new("«blue»", ""), | ||
bold: EscapeSequence::new("«bold»", "«/bold»"), | ||
}; | ||
|
||
// Black=30 Red=31 Green=32 Yellow=33 Blue=34 Magenta=35 Cyan=36 White=37 | ||
|
||
pub static VT100_COLORS: &Colors = &Colors { | ||
normal: EscapeSequence::new("\u{1b}[39m", ""), | ||
red: EscapeSequence::new("\u{1b}[31m", ""), | ||
green: EscapeSequence::new("\u{1b}[32m", ""), | ||
cyan: EscapeSequence::new("\u{1b}[36m", ""), | ||
blue: EscapeSequence::new("\u{1b}[34m", ""), | ||
bold: EscapeSequence::new("\u{1b}[1m", "\u{1b}[0m"), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters