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 std::fmt::Display;
|
||||||
|
|
||||||
use crate::{ansi_colors, ansi_colors_2};
|
|
||||||
use crate::ansi_styles::Style as AnsiStyle;
|
use crate::ansi_styles::Style as AnsiStyle;
|
||||||
|
use crate::{ansi_colors, ansi_colors_2};
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct AnsiCodes {
|
pub struct AnsiCodes {
|
||||||
pub prefix: String,
|
pub prefix: String,
|
||||||
@@ -15,6 +15,9 @@ impl AnsiCodes {
|
|||||||
}
|
}
|
||||||
impl Display for AnsiCodes {
|
impl Display for AnsiCodes {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
if self.codes.is_empty() { // optim?
|
||||||
|
return write!(f, "");
|
||||||
|
}
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"{}{}{}",
|
"{}{}{}",
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ pub struct ColorConstruct {
|
|||||||
color: Color,
|
color: Color,
|
||||||
is_bright: bool,
|
is_bright: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// do not assume context by default. because like its a color in a [`ColorConstruct`] broski
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
Black,
|
Black,
|
||||||
|
|||||||
+8
-3
@@ -19,10 +19,10 @@ pub mod ansi_backbone;
|
|||||||
use ansi_backbone::{AnsiCodes, ColorTrait, Style};
|
use ansi_backbone::{AnsiCodes, ColorTrait, Style};
|
||||||
|
|
||||||
mod test;
|
mod test;
|
||||||
|
/// text as text and styles will be turned to [`AnsiCodes`]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct AnsiStyles {
|
pub struct AnsiStyles {
|
||||||
text: String,
|
pub text: String,
|
||||||
styles: Vec<Style>, // no
|
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