basic_usage/
basic_usage.rs

1//! Basic usage example for unicode-rs
2//!
3//! This example demonstrates the basic functionality of the unicode-rs crate,
4//! showing how to use different symbols with various themes.
5
6use unicode_rs::prelude::*;
7
8fn main() {
9    println!("Unicode-rs Basic Usage Example");
10    println!("==============================\n");
11
12    // Demonstrate different themes for the same symbol
13    println!("Symbol themes:");
14    println!(
15        "  Minimal: {}",
16        Symbol::Check.get_char(UnicodeTheme::Minimal)
17    );
18    println!("  Basic:   {}", Symbol::Check.get_char(UnicodeTheme::Basic));
19    println!("  Rich:    {}", Symbol::Check.get_char(UnicodeTheme::Rich));
20    println!("  Fancy:   {}", Symbol::Check.get_char(UnicodeTheme::Fancy));
21    println!();
22
23    // Show various symbol categories
24    println!("Symbol categories:");
25
26    // Symbols
27    println!("  Symbols:");
28    println!("    Check: {}", Symbol::Check.get_char(UnicodeTheme::Rich));
29    println!("    X:     {}", Symbol::X.get_char(UnicodeTheme::Rich));
30    println!(
31        "    !:     {}",
32        Symbol::Exclamation.get_char(UnicodeTheme::Rich)
33    );
34    println!(
35        "    ?:     {}",
36        Symbol::Question.get_char(UnicodeTheme::Rich)
37    );
38    println!();
39
40    // Arrows
41    println!("  Arrows:");
42    println!("    Up:    {}", Arrow::Up.get_char(UnicodeTheme::Rich));
43    println!("    Down:  {}", Arrow::Down.get_char(UnicodeTheme::Rich));
44    println!("    Left:  {}", Arrow::Left.get_char(UnicodeTheme::Rich));
45    println!("    Right: {}", Arrow::Right.get_char(UnicodeTheme::Rich));
46    println!();
47
48    // Git symbols
49    println!("  Git Status:");
50    println!(
51        "    Modified:  {}",
52        GitStatus::Modified.get_char(UnicodeTheme::Rich)
53    );
54    println!(
55        "    Added:     {}",
56        GitStatus::Added.get_char(UnicodeTheme::Rich)
57    );
58    println!(
59        "    Deleted:   {}",
60        GitStatus::Deleted.get_char(UnicodeTheme::Rich)
61    );
62    println!(
63        "    Untracked: {}",
64        GitStatus::Untracked.get_char(UnicodeTheme::Rich)
65    );
66    println!();
67
68    // Demonstrate global configuration
69    println!("Global configuration example:");
70
71    // Set global theme to minimal
72    set_global_config(UnicodeConfig::with_theme(UnicodeTheme::Minimal));
73    println!("  With Minimal theme:");
74    println!("    Check: {}", get_char(&Symbol::Check, None));
75    println!("    Arrow: {}", get_char(&Arrow::Right, None));
76
77    // Set global theme to rich with fallback
78    set_global_config(
79        UnicodeConfig::with_theme(UnicodeTheme::Rich)
80            .with_fallback()
81            .with_override("custom_check", '√'),
82    );
83    println!("  With Rich theme + fallback:");
84    println!("    Check: {}", get_char(&Symbol::Check, None));
85    println!(
86        "    Custom: {}",
87        get_char(&Symbol::Check, Some("custom_check"))
88    );
89
90    println!("\nExample complete!");
91}