??? Ose: Terminal UI

Colors, formatting, progress bars, and interactive TUI.

Use Case 1: Colorful Output

// colors.ifa - Terminal colors and styling

// Color codes
ayanmo RESET = "\x1b[0m";
ayanmo BOLD = "\x1b[1m";
ayanmo DIM = "\x1b[2m";

ayanmo RED = "\x1b[31m";
ayanmo GREEN = "\x1b[32m";
ayanmo YELLOW = "\x1b[33m";
ayanmo BLUE = "\x1b[34m";
ayanmo MAGENTA = "\x1b[35m";
ayanmo CYAN = "\x1b[36m";

ise color(text, color_code) {
    padap? color_code + text + RESET;
}

ise bold(text) {
    padap? BOLD + text + RESET;
}

ise success(msg) {
    Irosu.fo(color("? " + msg, GREEN));
}

ise warning(msg) {
    Irosu.fo(color("? " + msg, YELLOW));
}

ise error_msg(msg) {
    Irosu.fo(color("? " + msg, RED));
}

ise info(msg) {
    Irosu.fo(color("? " + msg, BLUE));
}

// Usage
Irosu.fo(bold("=== Build Status ==="));
info("Starting build...");
success("Compiled 42 files");
warning("3 deprecation warnings");
error_msg("Test failed: test_auth.ifa");

Irosu.fo("\nAvailable colors:");
Irosu.fo(color("Red", RED));
Irosu.fo(color("Green", GREEN));
Irosu.fo(color("Yellow", YELLOW));
Irosu.fo(color("Blue", BLUE));
Irosu.fo(color("Magenta", MAGENTA));
Irosu.fo(color("Cyan", CYAN));

Use Case 2: Progress Bar

// progress.ifa - Animated progress bar

ise progress_bar(current, total, width, label) {
    ayanmo percent = (current * 100) / total;
    ayanmo filled = (current * width) / total;
    
    ayanmo bar = "";
    ayanmo i = 0;
    nigba (i < width) {
        ti (i < filled) {
            ayanmo bar = bar + "¦";
        } bib?k? {
            ayanmo bar = bar + "¦";
        }
        ayanmo i = i + 1;
    }
    
    // Move cursor to beginning of line
    Irosu.so("\r" + label + " [" + bar + "] " + percent + "%  ");
}

ise spinner(message, duration_ms, callback) {
    ayanmo frames = ["?", "?", "?", "?", "?", "?", "?", "?", "?", "?"];
    ayanmo frame = 0;
    ayanmo start = Iwori.now_ms();
    
    nigba (Iwori.now_ms() - start < duration_ms) {
        Irosu.so("\r" + Ogunda.get(frames, frame) + " " + message);
        ayanmo frame = Oturupon.mod(frame + 1, Ogunda.len(frames));
        Oyeku.sleep(80);
    }
    
    callback();
    Irosu.fo("\r? " + message + "    ");
}

// Usage: Download simulation
Irosu.fo("?? Downloading files...\n");

ayanmo files = ["data.json", "config.yaml", "assets.zip"];
ayanmo file_num = 0;

fun file ninu files {
    ayanmo size = 100;
    ayanmo progress = 0;
    
    nigba (progress <= size) {
        progress_bar(progress, size, 30, file);
        Oyeku.sleep(20);
        ayanmo progress = progress + Owonrin.pese(1, 10);
    }
    progress_bar(size, size, 30, file);
    Irosu.fo("");
    ayanmo file_num = file_num + 1;
}

Irosu.fo("\n? All downloads complete!");

Use Case 3: Interactive Menu

// menu.ifa - Arrow-key navigable menu

ise draw_menu(title, options, selected) {
    Ose.clear();
    
    Irosu.fo("\n  " + BOLD + title + RESET);
    Irosu.fo("  " + Ika.repeat("-", Ika.len(title) + 4));
    
    ayanmo i = 0;
    fun opt ninu options {
        ti (i == selected) {
            Irosu.fo("  " + CYAN + "? " + opt + RESET);
        } bib?k? {
            Irosu.fo("    " + DIM + opt + RESET);
        }
        ayanmo i = i + 1;
    }
    
    Irosu.fo("\n  Use ?? to navigate, Enter to select, q to quit");
}

ise run_menu(title, options) {
    ayanmo selected = 0;
    ayanmo running = otito;
    
    Ose.raw_mode(otito);  // Enable raw input
    
    nigba (running) {
        draw_menu(title, options, selected);
        
        ayanmo key = Ose.read_key();
        
        ti (key == "up" && selected > 0) {
            ayanmo selected = selected - 1;
        } bib?k? ti (key == "down" && selected < Ogunda.len(options) - 1) {
            ayanmo selected = selected + 1;
        } bib?k? ti (key == "enter") {
            Ose.raw_mode(iro);
            padap? selected;
        } bib?k? ti (key == "q") {
            Ose.raw_mode(iro);
            padap? -1;
        }
    }
}

// Usage
ayanmo choice = run_menu("Main Menu", [
    "Start new game",
    "Load saved game",
    "Settings",
    "Exit"
]);

ti (choice >= 0) {
    Irosu.fo("\nYou selected option " + (choice + 1));
}

Use Case 4: Dashboard Layout

// dashboard.ifa - Multi-panel terminal dashboard

ise box(title, content, width) {
    ayanmo lines = [];
    
    // Top border
    ayanmo top = "+- " + title + " " + Ika.repeat("-", width - Ika.len(title) - 4) + "+";
    ayanmo lines = Ogunda.push(lines, top);
    
    // Content lines
    ayanmo content_lines = Ika.split(content, "\n");
    fun line ninu content_lines {
        ayanmo padded = Ika.pad_right(line, width - 4);
        ayanmo lines = Ogunda.push(lines, "¦ " + padded + " ¦");
    }
    
    // Bottom border
    ayanmo bottom = "+" + Ika.repeat("-", width - 2) + "+";
    ayanmo lines = Ogunda.push(lines, bottom);
    
    padap? lines;
}

ise render_dashboard() {
    Ose.clear();
    Irosu.fo(BOLD + "  ?? SYSTEM DASHBOARD" + RESET);
    Irosu.fo("  " + Iwori.format(Iwori.now(), "%Y-%m-%d %H:%M:%S") + "\n");
    
    // CPU box
    ayanmo cpu_content = "Usage: ¦¦¦¦¦¦¦¦¦¦ 40%\nCores: 8\nTemp: 65°C";
    fun line ninu box("CPU", cpu_content, 30) {
        Irosu.fo("  " + line);
    }
    
    Irosu.fo("");
    
    // Memory box
    ayanmo mem_content = "Used: 8.2 GB / 16 GB\n¦¦¦¦¦¦¦¦¦¦ 51%\nSwap: 0 GB";
    fun line ninu box("Memory", mem_content, 30) {
        Irosu.fo("  " + line);
    }
    
    Irosu.fo("");
    
    // Recent activity
    ayanmo activity = "? Build completed\n? Low disk warning\n? 3 users online";
    fun line ninu box("Activity", activity, 30) {
        Irosu.fo("  " + line);
    }
}

// Update every second
nigba (otito) {
    render_dashboard();
    Oyeku.sleep(1000);
}