eazygit 0.5.1

A fast TUI for Git with staging, conflicts, rebase, and palette-first UX
Documentation
//! Font management utilities.
//!
//! Provides functions to manipulate terminal fonts via OSC sequences.

use std::io::{self, Write};

/// Try to set the terminal font using OSC 50.
///
/// This is supported by terminals like iTerm2, xterm, and some others.
/// It may do nothing on unsupported terminals.
pub fn set_font(font_family: &str) {
    // OSC 50 ; SetFont=Font Family \007
    let sequence = format!("\x1b]50;SetProfile={}\x07", font_family); 
    // Variable mapping for OSC 50 is tricky.
    // iTerm2: \033]50;SetProfile=ProfileName\007
    // Generic XTerm: \033]50;#+1\007 (increase size)
    
    // Better approach for font family:
    // Some terminals support: \033]50;Fn=FontName\007
    
    tracing::info!("Attempting to set font to '{}'", font_family);
    
    // Try both SetProfile (common in macOS iTerm2) and Fn (xterm)
    // We print to stdout.
    print!("\x1b]50;SetProfile={}\x07", font_family);
    print!("\x1b]50;Fn={}\x07", font_family);
    
    // Flush
    let _ = io::stdout().flush();
}

/// Reset font to default.
pub fn reset_font() {
    // OSC 50 without args often resets or we can allow user to specify "Default"
    print!("\x1b]50;SetProfile=Default\x07");
    let _ = io::stdout().flush();
}