use thag_styling::{ColorInitStrategy, Styleable, TermAttributes};
fn main() {
TermAttributes::get_or_init_with_strategy(&ColorInitStrategy::Match);
println!("=== ANSI Code Generation and Parsing Debug ===\n");
println!("1. ANSI code generation:");
let plain_text = "plain";
let bold_text = plain_text.normal().bold();
let italic_text = plain_text.normal().italic();
let underline_text = plain_text.normal().underline();
let combined_text = plain_text.normal().bold().italic().underline();
let colored_text = plain_text.error();
let colored_bold_text = plain_text.error().bold();
println!(" Plain: {:?}", plain_text);
println!(" Bold: {:?}", bold_text.to_string());
println!(" Italic: {:?}", italic_text.to_string());
println!(" Underline: {:?}", underline_text.to_string());
println!(" Combined (B+I+U): {:?}", combined_text.to_string());
println!(" Colored (Error): {:?}", colored_text.to_string());
println!(" Colored + Bold: {:?}", colored_bold_text.to_string());
println!();
println!("2. Attribute leakage test:");
let inner_bold = "INNER".normal().bold();
let outer_result = format!("outer {inner_bold} outer").info();
println!(" Inner bold: {:?}", inner_bold.to_string());
println!(" Final result: {:?}", outer_result.to_string());
println!(" Rendered: {}", outer_result);
println!();
println!("3. Multi-level nesting:");
let level2 = "L2".normal().italic();
let level1 = format!("L1 {level2} L1").warning().bold();
let level0 = format!("L0 {level1} L0").success();
println!(" Level 2 (italic): {:?}", level2.to_string());
println!(" Level 1 (bold): {:?}", level1.to_string());
println!(" Level 0 (normal): {:?}", level0.to_string());
println!(" Final rendered: {}", level0);
println!();
println!("4. Raw ANSI sequence analysis:");
let test_bold = "test".normal().bold();
let test_with_bold = format!("before {test_bold} after").error();
let bold_str = test_bold.to_string();
let final_str = test_with_bold.to_string();
println!(
" Bold string raw: {}",
bold_str
.chars()
.map(|c| if c == '\x1b' {
"\\x1b".to_string()
} else {
c.to_string()
})
.collect::<String>()
);
println!(
" Final string raw: {}",
final_str
.chars()
.map(|c| if c == '\x1b' {
"\\x1b".to_string()
} else {
c.to_string()
})
.collect::<String>()
);
println!("\n=== Analysis ===");
println!("This debug output shows:");
println!("1. How ANSI codes are generated by the styling system");
println!("2. Whether reset replacement is working correctly");
println!("3. The exact ANSI sequences being produced");
println!("4. Whether attribute resets are being inserted properly");
}