zc2 0.0.38

P2P compute broker with credit-based billing, WAL, and broker mesh support
use super::{centered, fg, INK3, SEED};
use ratatui::layout::Rect;
use ratatui::text::{Line, Span};
use ratatui::widgets::{Block, Clear, Paragraph};
use ratatui::Frame;

const KEYS: &[(&str, &str)] = &[
    ("1 2 3, tab", "switch tab"),
    ("↑↓ j k, pgup/pgdn, g G", "move"),
    ("⏎", "open · expand · act"),
    ("/", "filter the list"),
    (":", "command bar"),
    ("r", "refresh now"),
    ("c / y", "copy node address / SDK line"),
    ("space, + -, p", "sharing, workers, price (Share)"),
    ("a", "start zc agent (when it is not running)"),
    ("q, ctrl-c", "quit · esc closes overlays first"),
];
const COMMANDS: &[(&str, &str)] = &[
    (":price <n>", "set this machine's price per hour"),
    (":workers <n>", "set the worker count"),
    (":share on|off", "turn sharing on or off"),
    (":copy <zc://…>", "copy an address"),
    (":refresh  :quit", ""),
    (":connect :disconnect", "run outside the session, with"),
    (":up :down :update :login", "the terminal (sudo, progress)"),
];

pub fn render(f: &mut Frame, area: Rect) {
    let mut lines = vec![Line::from(Span::styled("Keys", fg(SEED)))];
    for (k, v) in KEYS {
        lines.push(Line::from(vec![
            Span::raw(format!("  {k:<26}")),
            Span::styled(*v, fg(INK3)),
        ]));
    }
    lines.push(Line::default());
    lines.push(Line::from(Span::styled("Commands", fg(SEED))));
    for (k, v) in COMMANDS {
        lines.push(Line::from(vec![
            Span::raw(format!("  {k:<26}")),
            Span::styled(*v, fg(INK3)),
        ]));
    }
    let r = centered(area, 80, lines.len() as u16 + 2);
    f.render_widget(Clear, r);
    f.render_widget(
        Paragraph::new(lines).block(
            Block::bordered()
                .border_style(fg(INK3))
                .title(" help · esc to close "),
        ),
        r,
    );
}