You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some reasons, it return Color::BrightMagenta instead of some green:
But should be like on this picture:
Not sure it's bug in my integration or this format not supported yet. I'm using following code to integrate cansi with GTK TextTag by extracting with categorise_text function:
mod tag;use tag::Tag;use cansi::{v3::categorise_text,Color};use gtk::{
gdk::RGBA,
pango::{Style,Underline},
prelude::TextTagExt,TextTag,};/// Apply `ANSI`/`SGR` format to new bufferpubfnformat(source_code:&str) -> Vec<(TextTag,String)>{// Init new line bufferletmut buffer = Vec::new();// Begin entities parsefor entity incategorise_text(source_code){// Create new tag from default presetlet tag = Tag::new();// Apply supported decorationsifletSome(color) = entity.fg{
tag.text_tag.set_foreground_rgba(Some(&color_to_rgba(color)));}ifletSome(color) = entity.bg{
tag.text_tag.set_background_rgba(Some(&color_to_rgba(color)));}ifletSome(is_italic) = entity.italic{if is_italic {
tag.text_tag.set_style(Style::Italic);}}ifletSome(is_underline) = entity.underline{if is_underline {
tag.text_tag.set_underline(Underline::Single);}}ifletSome(is_strikethrough) = entity.strikethrough{
tag.text_tag.set_strikethrough(is_strikethrough);}// Append
buffer.push((tag.text_tag, entity.text.to_string()));}
buffer
}fncolor_to_rgba(value:Color) -> RGBA{match value {Color::Black => RGBA::new(0.0,0.0,0.0,1.0),Color::Red => RGBA::new(0.8,0.0,0.0,1.0),Color::Green => RGBA::new(0.0,0.8,0.0,1.0),Color::Yellow => RGBA::new(0.8,0.8,0.0,1.0),Color::Blue => RGBA::new(0.0,0.0,0.9,1.0),Color::Magenta => RGBA::new(0.8,0.0,0.8,1.0),Color::Cyan => RGBA::new(0.0,0.8,0.8,1.0),Color::White => RGBA::new(0.9,0.9,0.9,1.0),Color::BrightBlack => RGBA::new(0.5,0.5,0.5,1.0),Color::BrightRed => RGBA::new(1.0,0.0,0.0,1.0),Color::BrightGreen => RGBA::new(0.0,1.0,0.0,1.0),Color::BrightYellow => RGBA::new(1.0,1.0,0.0,1.0),Color::BrightBlue => RGBA::new(0.4,0.4,1.0,1.0),Color::BrightMagenta => RGBA::new(1.0,0.0,1.0,1.0),Color::BrightCyan => RGBA::new(0.0,1.0,1.0,1.0),Color::BrightWhite => RGBA::new(1.0,1.0,1.0,1.0),}}
for a note: I'm parsing line-by line, maybe reason in that, even all lines could be parsed separately on subject example
The text was updated successfully, but these errors were encountered:
Could somebody please try to parse this code:
For some reasons, it return
Color::BrightMagenta
instead of some green:But should be like on this picture:
Not sure it's bug in my integration or this format not supported yet. I'm using following code to integrate
cansi
with GTKTextTag
by extracting withcategorise_text
function:The text was updated successfully, but these errors were encountered: