minor change for optim?
This commit is contained in:
1 parent
03e55e7ae7
commit
de4c23020d
3 files changed
+14
-4
No files matched your search
@@ -1,7 +1,7 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use crate::{ansi_colors, ansi_colors_2};
|
||||
use crate::ansi_styles::Style as AnsiStyle;
|
||||
use crate::{ansi_colors, ansi_colors_2};
|
||||
#[derive(Clone)]
|
||||
pub struct AnsiCodes {
|
||||
pub prefix: String,
|
||||
@@ -15,6 +15,9 @@ impl AnsiCodes {
|
||||
}
|
||||
impl Display for AnsiCodes {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
if self.codes.is_empty() { // optim?
|
||||
return write!(f, "");
|
||||
}
|
||||
write!(
|
||||
f,
|
||||
"{}{}{}",
|
||||
|
||||
@@ -5,6 +5,8 @@ pub struct ColorConstruct {
|
||||
color: Color,
|
||||
is_bright: bool,
|
||||
}
|
||||
|
||||
/// do not assume context by default. because like its a color in a [`ColorConstruct`] broski
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum Color {
|
||||
Black,
|
||||
|
||||
+8
-3
@@ -19,10 +19,10 @@ pub mod ansi_backbone;
|
||||
use ansi_backbone::{AnsiCodes, ColorTrait, Style};
|
||||
|
||||
mod test;
|
||||
|
||||
/// text as text and styles will be turned to [`AnsiCodes`]
|
||||
#[derive(Clone)]
|
||||
struct AnsiStyles {
|
||||
text: String,
|
||||
pub struct AnsiStyles {
|
||||
pub text: String,
|
||||
styles: Vec<Style>, // no
|
||||
}
|
||||
|
||||
@@ -59,3 +59,8 @@ impl Display for AnsiStyles {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AnsiStyles> for String {
|
||||
fn from(value: AnsiStyles) -> Self {
|
||||
format!("{value}") // wow
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user