2026-09-12 00:15:19 -04:00
|
|
|
use std::io::{self, IsTerminal};
|
|
|
|
|
use std::sync::{Arc, mpsc};
|
2026-09-11 22:33:55 -04:00
|
|
|
use std::time::Duration;
|
2026-09-10 01:54:19 -04:00
|
|
|
|
|
|
|
|
use ratatui::crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
use ratatui::layout::{Constraint, Layout, Rect};
|
|
|
|
|
use ratatui::style::{Color, Modifier, Style};
|
2026-09-12 00:54:16 -04:00
|
|
|
use ratatui::symbols::border;
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
use ratatui::widgets::{Block, Borders, Clear, List, ListItem, ListState, Paragraph, Wrap};
|
2026-09-10 01:54:19 -04:00
|
|
|
use ratatui::{DefaultTerminal, Frame};
|
|
|
|
|
|
2026-09-10 02:43:45 -04:00
|
|
|
use crate::node::Node;
|
2026-09-10 01:54:19 -04:00
|
|
|
use crate::qr::{self, QrPayload};
|
2026-09-11 23:42:48 -04:00
|
|
|
use crate::sanitize;
|
2026-09-10 14:25:31 -04:00
|
|
|
use crate::store::{Friend, FriendProfile};
|
2026-09-10 01:54:19 -04:00
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
const C_ACCENT: Color = Color::Rgb(232, 165, 75);
|
|
|
|
|
const C_TEXT: Color = Color::Rgb(196, 214, 176);
|
|
|
|
|
const C_DIM: Color = Color::Rgb(98, 110, 92);
|
|
|
|
|
const C_ALERT: Color = Color::Rgb(220, 80, 70);
|
|
|
|
|
const C_STALE: Color = Color::Rgb(210, 180, 80);
|
|
|
|
|
const C_HL_BG: Color = Color::Rgb(48, 42, 28);
|
|
|
|
|
const C_BORDER: Color = Color::Rgb(72, 84, 64);
|
|
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
enum ColorMode {
|
|
|
|
|
Rgb,
|
|
|
|
|
Ansi16,
|
|
|
|
|
None,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn color_mode() -> ColorMode {
|
|
|
|
|
if std::env::var_os("NO_COLOR").is_some() {
|
|
|
|
|
ColorMode::None
|
|
|
|
|
} else if std::env::var("TERM").ok().as_deref() == Some("dumb") || !io::stdout().is_terminal() {
|
|
|
|
|
ColorMode::Ansi16
|
|
|
|
|
} else {
|
|
|
|
|
ColorMode::Rgb
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-12 00:54:16 -04:00
|
|
|
/// ASCII chrome when `ONIONWIRE_ASCII` or `NO_COLOR` is set. No extra crate.
|
|
|
|
|
pub fn ascii_chrome() -> bool {
|
|
|
|
|
std::env::var_os("ONIONWIRE_ASCII").is_some() || std::env::var_os("NO_COLOR").is_some()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ASCII_BORDERS: border::Set = border::Set {
|
|
|
|
|
top_left: "+",
|
|
|
|
|
top_right: "+",
|
|
|
|
|
bottom_left: "+",
|
|
|
|
|
bottom_right: "+",
|
|
|
|
|
vertical_left: "|",
|
|
|
|
|
vertical_right: "|",
|
|
|
|
|
horizontal_top: "-",
|
|
|
|
|
horizontal_bottom: "-",
|
|
|
|
|
};
|
|
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
fn ellipsis() -> &'static str {
|
2026-09-12 00:54:16 -04:00
|
|
|
if ascii_chrome() { "..." } else { "…" }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Truncate or keep an alert so it cannot spill into the roster row.
|
|
|
|
|
pub fn alert_line(msg: &str, width: u16) -> String {
|
|
|
|
|
let mut text = msg.to_string();
|
|
|
|
|
if color_mode() == ColorMode::None && !text.starts_with("! ") {
|
|
|
|
|
text = format!("! {text}");
|
|
|
|
|
}
|
|
|
|
|
truncate_chars(&text, width as usize)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Wrap an invite at `:` so a mouse-copy cannot lose a mid-hex continuation.
|
|
|
|
|
/// Joining the lines (no extra spaces) reconstructs `payload`.
|
|
|
|
|
pub fn wrap_invite(payload: &str, width: usize) -> String {
|
|
|
|
|
if width == 0 {
|
|
|
|
|
return String::new();
|
|
|
|
|
}
|
|
|
|
|
let mut lines: Vec<String> = Vec::new();
|
|
|
|
|
let mut cur = String::new();
|
|
|
|
|
let parts: Vec<&str> = payload.split(':').collect();
|
|
|
|
|
for (i, part) in parts.iter().enumerate() {
|
|
|
|
|
let piece = if i + 1 < parts.len() {
|
|
|
|
|
format!("{part}:")
|
|
|
|
|
} else {
|
|
|
|
|
(*part).to_string()
|
|
|
|
|
};
|
|
|
|
|
for chunk in char_chunks(&piece, width) {
|
|
|
|
|
if cur.is_empty() {
|
|
|
|
|
cur = chunk;
|
|
|
|
|
} else if char_len(&cur) + char_len(&chunk) <= width {
|
|
|
|
|
cur.push_str(&chunk);
|
|
|
|
|
} else {
|
|
|
|
|
lines.push(std::mem::take(&mut cur));
|
|
|
|
|
cur = chunk;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !cur.is_empty() {
|
|
|
|
|
lines.push(cur);
|
|
|
|
|
}
|
|
|
|
|
lines.join("\n")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn char_chunks(s: &str, width: usize) -> Vec<String> {
|
|
|
|
|
if width == 0 {
|
|
|
|
|
return Vec::new();
|
|
|
|
|
}
|
|
|
|
|
if char_len(s) <= width {
|
|
|
|
|
return vec![s.to_string()];
|
|
|
|
|
}
|
|
|
|
|
let chars: Vec<char> = s.chars().collect();
|
|
|
|
|
chars.chunks(width).map(|c| c.iter().collect()).collect()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Friend selected, no messages yet.
|
|
|
|
|
pub fn empty_friend_chat_text() -> &'static str {
|
|
|
|
|
"no messages\ntype below, Enter sends"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Paste overlay copy. Error keeps the resubmit hint.
|
|
|
|
|
pub fn paste_screen_text(buf: &str, err: Option<&str>) -> String {
|
|
|
|
|
let hint = match err {
|
|
|
|
|
Some(e) => format!("{e}\nEnter resubmits Esc back"),
|
|
|
|
|
None => "paste onionwire:v1 payload, Enter to submit".to_string(),
|
|
|
|
|
};
|
|
|
|
|
format!("{hint}\n\n{buf}")
|
2026-09-12 00:15:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn char_len(s: &str) -> usize {
|
|
|
|
|
s.chars().count()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn truncate_chars(s: &str, max: usize) -> String {
|
|
|
|
|
if char_len(s) <= max {
|
|
|
|
|
return s.to_string();
|
|
|
|
|
}
|
|
|
|
|
let e = ellipsis();
|
|
|
|
|
let el = char_len(e);
|
|
|
|
|
if max <= el {
|
|
|
|
|
return e.chars().take(max).collect();
|
|
|
|
|
}
|
|
|
|
|
let head: String = s.chars().take(max - el).collect();
|
|
|
|
|
format!("{head}{e}")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn style_fg(rgb: Color, ansi: Color) -> Style {
|
|
|
|
|
match color_mode() {
|
|
|
|
|
ColorMode::None => Style::default(),
|
|
|
|
|
ColorMode::Ansi16 => Style::default().fg(ansi),
|
|
|
|
|
ColorMode::Rgb => Style::default().fg(rgb),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn style_accent() -> Style {
|
|
|
|
|
match color_mode() {
|
|
|
|
|
ColorMode::None => Style::default().add_modifier(Modifier::BOLD),
|
|
|
|
|
ColorMode::Ansi16 => Style::default().fg(Color::Yellow),
|
|
|
|
|
ColorMode::Rgb => Style::default().fg(C_ACCENT),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn style_text() -> Style {
|
|
|
|
|
style_fg(C_TEXT, Color::White)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn style_dim() -> Style {
|
|
|
|
|
style_fg(C_DIM, Color::DarkGray)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn style_alert() -> Style {
|
|
|
|
|
style_fg(C_ALERT, Color::Red)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn style_stale() -> Style {
|
|
|
|
|
style_fg(C_STALE, Color::Yellow)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn style_border() -> Style {
|
|
|
|
|
style_fg(C_BORDER, Color::DarkGray)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn style_highlight() -> Style {
|
|
|
|
|
match color_mode() {
|
|
|
|
|
ColorMode::None => Style::default().add_modifier(Modifier::BOLD | Modifier::REVERSED),
|
|
|
|
|
ColorMode::Ansi16 => Style::default().add_modifier(Modifier::REVERSED | Modifier::BOLD),
|
|
|
|
|
ColorMode::Rgb => Style::default()
|
|
|
|
|
.bg(C_HL_BG)
|
|
|
|
|
.fg(C_ACCENT)
|
|
|
|
|
.add_modifier(Modifier::BOLD),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-11 22:33:55 -04:00
|
|
|
/// How long the TUI waits for a key before redrawing (so background send can update status).
|
|
|
|
|
pub const TUI_POLL: Duration = Duration::from_millis(100);
|
|
|
|
|
|
|
|
|
|
/// Non-blocking read of a background send/job status. Never waits on Tor.
|
|
|
|
|
pub fn take_job_result(rx: &mpsc::Receiver<String>) -> Option<String> {
|
|
|
|
|
match rx.try_recv() {
|
|
|
|
|
Ok(s) => Some(s),
|
|
|
|
|
Err(mpsc::TryRecvError::Empty) => None,
|
|
|
|
|
Err(mpsc::TryRecvError::Disconnected) => Some("send failed".into()),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 02:07:40 -04:00
|
|
|
pub fn fingerprint_mismatch_banner() -> &'static str {
|
|
|
|
|
"fingerprint mismatch"
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 02:43:45 -04:00
|
|
|
pub fn rotate_screen_text() -> &'static str {
|
|
|
|
|
"Rotate onion address?\n\
|
|
|
|
|
Your identity key stays the same.\n\
|
|
|
|
|
Online friends get a signed location update.\n\
|
2026-09-10 16:53:03 -04:00
|
|
|
Offline friends CANNOT find you until they F3-paste your new invite.\n\
|
2026-09-10 02:43:45 -04:00
|
|
|
Type ROTATE to confirm Esc to cancel"
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 17:19:50 -04:00
|
|
|
pub fn quit_screen_text() -> &'static str {
|
|
|
|
|
"Quit OnionWire?\n\
|
|
|
|
|
Message history can be cleared; identity and friends stay.\n\
|
|
|
|
|
This is not /wipe-all.\n\
|
|
|
|
|
Type CLEAR then Enter to clear history and quit.\n\
|
|
|
|
|
Type QUIT then Enter to quit without clearing.\n\
|
|
|
|
|
Esc to cancel"
|
|
|
|
|
}
|
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
/// Full Main-screen wordmark. Every line is <= 80 ASCII characters.
|
|
|
|
|
pub fn wordmark_banner() -> &'static str {
|
|
|
|
|
"\
|
|
|
|
|
.-~~-. .-~~-. .-~~-. ONIONWIRE\n\
|
|
|
|
|
( o )( o )( o ) identity = pubkey onion = locator\n\
|
|
|
|
|
`-..-' `-..-' `-..-' tor messenger no server"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// One-line fallback when the terminal is narrower than the wordmark.
|
|
|
|
|
pub fn compact_banner() -> &'static str {
|
|
|
|
|
"ONIONWIRE (o) tor"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn onion_glyph() -> &'static str {
|
|
|
|
|
"\
|
|
|
|
|
.-.\n\
|
|
|
|
|
( o )\n\
|
|
|
|
|
'-'"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn help_overlay_text() -> &'static str {
|
|
|
|
|
"\
|
|
|
|
|
OnionWire keys\n\
|
|
|
|
|
\n\
|
|
|
|
|
Tab / Shift-Tab cycle roster, chat, composer\n\
|
|
|
|
|
1 / 2 / 3 focus roster / chat / composer\n\
|
|
|
|
|
j k or Up Down move or scroll focused pane\n\
|
|
|
|
|
g / G jump to top / bottom\n\
|
2026-09-10 23:07:22 -04:00
|
|
|
Enter send chat to selected friend, or a /command\n\
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
Esc close overlay, go back, clear composer\n\
|
2026-09-10 16:53:03 -04:00
|
|
|
F2 share invite\n\
|
|
|
|
|
F3 paste invite\n\
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
F4 rotate onion locator\n\
|
2026-09-10 14:25:31 -04:00
|
|
|
F5 selected friend's profile (/who)\n\
|
|
|
|
|
/profile edit name, bio, Monero address\n\
|
2026-09-10 14:37:43 -04:00
|
|
|
/pay <xmr> [memo] invoice to receive\n\
|
|
|
|
|
/tip <xmr> [memo] pay selected friend\n\
|
2026-09-10 23:32:06 -04:00
|
|
|
/file /path send file to selected friend (1 MiB)\n\
|
2026-09-10 14:50:01 -04:00
|
|
|
/backup /path encrypted identity export\n\
|
|
|
|
|
/restore /path overwrite self keys\n\
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
? this help\n\
|
2026-09-10 17:19:50 -04:00
|
|
|
Ctrl-Q quit; type CLEAR or QUIT\n\
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
\n\
|
|
|
|
|
Esc closes this overlay"
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:25:31 -04:00
|
|
|
pub fn who_overlay_text(fingerprint: &str, onion: &str, profile: Option<&FriendProfile>) -> String {
|
|
|
|
|
match profile {
|
|
|
|
|
None => format!(
|
|
|
|
|
"friend profile\n\nfp {fingerprint}\nonion {onion}\n\nno profile yet\n\nEsc closes"
|
|
|
|
|
),
|
|
|
|
|
Some(p) => {
|
|
|
|
|
let name = if p.display_name.is_empty() {
|
|
|
|
|
"(none)"
|
|
|
|
|
} else {
|
|
|
|
|
p.display_name.as_str()
|
|
|
|
|
};
|
|
|
|
|
let bio = if p.bio.is_empty() {
|
|
|
|
|
"(none)"
|
|
|
|
|
} else {
|
|
|
|
|
p.bio.as_str()
|
|
|
|
|
};
|
|
|
|
|
let xmr = if p.xmr_addr.is_empty() {
|
|
|
|
|
"(none)"
|
|
|
|
|
} else {
|
|
|
|
|
p.xmr_addr.as_str()
|
|
|
|
|
};
|
|
|
|
|
format!(
|
|
|
|
|
"friend profile\n\nname {name}\nbio {bio}\nxmr {xmr}\nfp {fingerprint}\nonion {onion}\n\nEsc closes"
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
pub fn banner_for_width(width: u16) -> &'static str {
|
|
|
|
|
let full = wordmark_banner();
|
|
|
|
|
let max_line = full.lines().map(|l| l.chars().count()).max().unwrap_or(0);
|
|
|
|
|
if (width as usize) >= max_line {
|
|
|
|
|
full
|
|
|
|
|
} else {
|
|
|
|
|
compact_banner()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
/// One-line main-screen header. Do not use `banner_for_width(80)` here — that stays the wordmark.
|
|
|
|
|
pub fn main_header_line(width: u16, me_fp: &str, me_onion: &str) -> String {
|
|
|
|
|
let fp: String = me_fp.chars().take(8).collect();
|
|
|
|
|
let onion = if me_onion.is_empty() {
|
|
|
|
|
"unset".to_string()
|
|
|
|
|
} else {
|
|
|
|
|
me_onion.chars().take(8).collect()
|
|
|
|
|
};
|
|
|
|
|
let line = format!("onionwire tor me:{fp} onion:{onion}");
|
|
|
|
|
truncate_chars(&line, width as usize)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Roster column in cells: 22 at 80-wide, 28 at 120+.
|
|
|
|
|
pub fn roster_col_width(term_width: u16) -> u16 {
|
|
|
|
|
if term_width >= 120 { 28 } else { 22 }
|
|
|
|
|
}
|
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
pub enum Pane {
|
|
|
|
|
Roster,
|
|
|
|
|
Chat,
|
|
|
|
|
Composer,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Pane {
|
|
|
|
|
pub fn next(self) -> Self {
|
|
|
|
|
match self {
|
|
|
|
|
Self::Roster => Self::Chat,
|
|
|
|
|
Self::Chat => Self::Composer,
|
|
|
|
|
Self::Composer => Self::Roster,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn prev(self) -> Self {
|
|
|
|
|
match self {
|
|
|
|
|
Self::Roster => Self::Composer,
|
|
|
|
|
Self::Chat => Self::Roster,
|
|
|
|
|
Self::Composer => Self::Chat,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
pub enum WipeKind {
|
|
|
|
|
Messages,
|
|
|
|
|
All,
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:37:43 -04:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
2026-09-10 14:25:31 -04:00
|
|
|
pub enum SlashCmd {
|
|
|
|
|
Wipe(WipeKind),
|
|
|
|
|
Profile,
|
|
|
|
|
Who,
|
2026-09-10 14:37:43 -04:00
|
|
|
Pay { atomic: String, memo: String },
|
|
|
|
|
Tip { atomic: String, memo: String },
|
2026-09-10 14:50:01 -04:00
|
|
|
Backup { path: String },
|
|
|
|
|
Restore { path: String },
|
2026-09-10 23:32:06 -04:00
|
|
|
File { path: String },
|
2026-09-10 14:25:31 -04:00
|
|
|
}
|
|
|
|
|
|
2026-09-10 23:07:22 -04:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
|
|
|
pub enum ComposerAction {
|
|
|
|
|
Cmd(SlashCmd),
|
|
|
|
|
Send(String),
|
|
|
|
|
UnknownSlash(String),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Enter in the composer: slash command, chat send, or unknown `/cmd`.
|
|
|
|
|
pub fn composer_enter(raw: &str) -> Option<ComposerAction> {
|
|
|
|
|
let s = raw.trim();
|
|
|
|
|
if s.is_empty() {
|
|
|
|
|
return None;
|
|
|
|
|
}
|
|
|
|
|
if let Some(cmd) = parse_cmd(raw) {
|
|
|
|
|
return Some(ComposerAction::Cmd(cmd));
|
|
|
|
|
}
|
|
|
|
|
if s.starts_with('/') {
|
|
|
|
|
return Some(ComposerAction::UnknownSlash(s.to_string()));
|
|
|
|
|
}
|
|
|
|
|
Some(ComposerAction::Send(s.to_string()))
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:25:31 -04:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
|
|
|
pub struct ProfileDraft {
|
|
|
|
|
pub display_name: String,
|
|
|
|
|
pub bio: String,
|
|
|
|
|
pub xmr_addr: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
|
pub struct ProfileEditor {
|
|
|
|
|
name: String,
|
|
|
|
|
bio: String,
|
|
|
|
|
xmr: String,
|
|
|
|
|
field: usize,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ProfileEditor {
|
|
|
|
|
pub fn new(display_name: &str, bio: &str, xmr_addr: &str) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
name: display_name.to_string(),
|
|
|
|
|
bio: bio.to_string(),
|
|
|
|
|
xmr: xmr_addr.to_string(),
|
|
|
|
|
field: 0,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn on_enter(&self) -> ProfileDraft {
|
|
|
|
|
ProfileDraft {
|
|
|
|
|
display_name: self.name.clone(),
|
|
|
|
|
bio: self.bio.clone(),
|
|
|
|
|
xmr_addr: self.xmr.clone(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn on_tab(&mut self) {
|
|
|
|
|
self.field = (self.field + 1) % 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn on_backtab(&mut self) {
|
|
|
|
|
self.field = (self.field + 2) % 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn on_char(&mut self, c: char) {
|
|
|
|
|
if c == '\n' {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
self.field_mut().push(c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn on_backspace(&mut self) {
|
|
|
|
|
self.field_mut().pop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn field(&self) -> usize {
|
|
|
|
|
self.field
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn display_name(&self) -> &str {
|
|
|
|
|
&self.name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn bio(&self) -> &str {
|
|
|
|
|
&self.bio
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn xmr_addr(&self) -> &str {
|
|
|
|
|
&self.xmr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn field_mut(&mut self) -> &mut String {
|
|
|
|
|
match self.field {
|
|
|
|
|
0 => &mut self.name,
|
|
|
|
|
1 => &mut self.bio,
|
|
|
|
|
_ => &mut self.xmr,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
pub enum WipeDecision {
|
|
|
|
|
Pending,
|
|
|
|
|
Confirm,
|
|
|
|
|
Cancel,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
pub enum AppExit {
|
|
|
|
|
Quit,
|
|
|
|
|
WipeAll,
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:25:31 -04:00
|
|
|
pub fn parse_cmd(raw: &str) -> Option<SlashCmd> {
|
2026-09-10 14:37:43 -04:00
|
|
|
let s = raw.trim();
|
|
|
|
|
match s {
|
|
|
|
|
"/wipe" => return Some(SlashCmd::Wipe(WipeKind::Messages)),
|
|
|
|
|
"/wipe-all" => return Some(SlashCmd::Wipe(WipeKind::All)),
|
|
|
|
|
"/profile" => return Some(SlashCmd::Profile),
|
|
|
|
|
"/who" => return Some(SlashCmd::Who),
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
|
|
|
|
if let Some(rest) = s.strip_prefix("/pay")
|
|
|
|
|
&& (rest.is_empty() || rest.starts_with(char::is_whitespace))
|
|
|
|
|
{
|
|
|
|
|
return parse_amount_cmd(rest).map(|(atomic, memo)| SlashCmd::Pay { atomic, memo });
|
|
|
|
|
}
|
|
|
|
|
if let Some(rest) = s.strip_prefix("/tip")
|
|
|
|
|
&& (rest.is_empty() || rest.starts_with(char::is_whitespace))
|
|
|
|
|
{
|
|
|
|
|
return parse_amount_cmd(rest).map(|(atomic, memo)| SlashCmd::Tip { atomic, memo });
|
|
|
|
|
}
|
2026-09-10 14:50:01 -04:00
|
|
|
if let Some(rest) = s.strip_prefix("/backup")
|
|
|
|
|
&& (rest.is_empty() || rest.starts_with(char::is_whitespace))
|
|
|
|
|
{
|
|
|
|
|
return parse_path_cmd(rest).map(|path| SlashCmd::Backup { path });
|
|
|
|
|
}
|
|
|
|
|
if let Some(rest) = s.strip_prefix("/restore")
|
|
|
|
|
&& (rest.is_empty() || rest.starts_with(char::is_whitespace))
|
|
|
|
|
{
|
|
|
|
|
return parse_path_cmd(rest).map(|path| SlashCmd::Restore { path });
|
|
|
|
|
}
|
2026-09-10 23:32:06 -04:00
|
|
|
if let Some(rest) = s.strip_prefix("/file")
|
|
|
|
|
&& (rest.is_empty() || rest.starts_with(char::is_whitespace))
|
|
|
|
|
{
|
|
|
|
|
return parse_path_cmd(rest).map(|path| SlashCmd::File { path });
|
|
|
|
|
}
|
2026-09-10 14:37:43 -04:00
|
|
|
None
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:50:01 -04:00
|
|
|
fn parse_path_cmd(rest: &str) -> Option<String> {
|
|
|
|
|
let path = rest.trim();
|
|
|
|
|
if path.is_empty() {
|
|
|
|
|
None
|
|
|
|
|
} else {
|
|
|
|
|
Some(path.to_string())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:37:43 -04:00
|
|
|
fn parse_amount_cmd(rest: &str) -> Option<(String, String)> {
|
|
|
|
|
let rest = rest.trim();
|
|
|
|
|
if rest.is_empty() {
|
|
|
|
|
return None;
|
2026-09-10 14:25:31 -04:00
|
|
|
}
|
2026-09-10 14:37:43 -04:00
|
|
|
let mut parts = rest.splitn(2, char::is_whitespace);
|
|
|
|
|
let amount = parts.next()?.trim();
|
|
|
|
|
let memo = parts.next().unwrap_or("").trim().to_string();
|
|
|
|
|
let atomic = crate::pay::xmr_to_atomic(amount).ok()?;
|
|
|
|
|
Some((atomic, memo))
|
2026-09-10 14:25:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn parse_slash(raw: &str) -> Option<WipeKind> {
|
|
|
|
|
match parse_cmd(raw) {
|
|
|
|
|
Some(SlashCmd::Wipe(k)) => Some(k),
|
2026-09-10 02:49:42 -04:00
|
|
|
_ => None,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn wipe_screen_text(kind: WipeKind) -> &'static str {
|
|
|
|
|
match kind {
|
|
|
|
|
WipeKind::Messages => {
|
2026-09-10 20:22:31 -04:00
|
|
|
"Wipe chat and payments history?\n\
|
2026-09-10 02:49:42 -04:00
|
|
|
Identity key and friends stay.\n\
|
2026-09-10 20:22:31 -04:00
|
|
|
Not a forensic erase.\n\
|
2026-09-10 02:49:42 -04:00
|
|
|
Type WIPE to confirm Esc to cancel"
|
|
|
|
|
}
|
|
|
|
|
WipeKind::All => {
|
|
|
|
|
"Wipe ALL local data?\n\
|
|
|
|
|
This deletes your identity key. You become a new person.\n\
|
|
|
|
|
Type WIPEALL to confirm Esc to cancel"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub struct WipePrompt {
|
|
|
|
|
expected: &'static str,
|
|
|
|
|
buf: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl WipePrompt {
|
|
|
|
|
pub fn messages() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
expected: "WIPE",
|
|
|
|
|
buf: String::new(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn all() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
expected: "WIPEALL",
|
|
|
|
|
buf: String::new(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn on_esc(&self) -> WipeDecision {
|
|
|
|
|
WipeDecision::Cancel
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn on_char(&mut self, c: char) -> WipeDecision {
|
|
|
|
|
if c == '\n' {
|
|
|
|
|
return WipeDecision::Pending;
|
|
|
|
|
}
|
|
|
|
|
if c == '\u{8}' {
|
|
|
|
|
self.buf.pop();
|
|
|
|
|
return WipeDecision::Pending;
|
|
|
|
|
}
|
|
|
|
|
if !c.is_ascii_alphabetic() {
|
|
|
|
|
return WipeDecision::Pending;
|
|
|
|
|
}
|
|
|
|
|
self.buf.push(c);
|
|
|
|
|
if self.buf == self.expected {
|
|
|
|
|
WipeDecision::Confirm
|
|
|
|
|
} else {
|
|
|
|
|
WipeDecision::Pending
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn typed(&self) -> &str {
|
|
|
|
|
&self.buf
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 02:43:45 -04:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
pub enum RotateDecision {
|
|
|
|
|
Pending,
|
|
|
|
|
Confirm,
|
|
|
|
|
Cancel,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Default)]
|
|
|
|
|
pub struct RotatePrompt {
|
|
|
|
|
buf: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl RotatePrompt {
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
Self::default()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn on_esc(&self) -> RotateDecision {
|
|
|
|
|
RotateDecision::Cancel
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn on_char(&mut self, c: char) -> RotateDecision {
|
|
|
|
|
if c == '\n' {
|
|
|
|
|
return RotateDecision::Pending;
|
|
|
|
|
}
|
|
|
|
|
if c == '\u{8}' {
|
|
|
|
|
self.buf.pop();
|
|
|
|
|
return RotateDecision::Pending;
|
|
|
|
|
}
|
|
|
|
|
if !c.is_ascii_alphabetic() {
|
|
|
|
|
return RotateDecision::Pending;
|
|
|
|
|
}
|
|
|
|
|
self.buf.push(c);
|
|
|
|
|
if self.buf == "ROTATE" {
|
|
|
|
|
RotateDecision::Confirm
|
|
|
|
|
} else {
|
|
|
|
|
RotateDecision::Pending
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn typed(&self) -> &str {
|
|
|
|
|
&self.buf
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 17:19:50 -04:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
pub enum QuitDecision {
|
|
|
|
|
Pending,
|
|
|
|
|
ClearAndQuit,
|
|
|
|
|
Quit,
|
|
|
|
|
Cancel,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Default)]
|
|
|
|
|
pub struct QuitPrompt {
|
|
|
|
|
buf: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl QuitPrompt {
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
Self::default()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn on_esc(&self) -> QuitDecision {
|
|
|
|
|
QuitDecision::Cancel
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn on_char(&mut self, c: char) -> QuitDecision {
|
|
|
|
|
if c == '\n' {
|
|
|
|
|
return match self.buf.as_str() {
|
|
|
|
|
"CLEAR" => QuitDecision::ClearAndQuit,
|
|
|
|
|
"QUIT" => QuitDecision::Quit,
|
|
|
|
|
_ => QuitDecision::Pending,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
if c == '\u{8}' {
|
|
|
|
|
self.buf.pop();
|
|
|
|
|
return QuitDecision::Pending;
|
|
|
|
|
}
|
|
|
|
|
if !c.is_ascii_alphabetic() {
|
|
|
|
|
return QuitDecision::Pending;
|
|
|
|
|
}
|
|
|
|
|
self.buf.push(c);
|
|
|
|
|
QuitDecision::Pending
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn typed(&self) -> &str {
|
|
|
|
|
&self.buf
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:50:01 -04:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
pub enum BackupKind {
|
|
|
|
|
Backup,
|
|
|
|
|
Restore,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
pub enum BackupDecision {
|
|
|
|
|
Pending,
|
|
|
|
|
Confirm,
|
|
|
|
|
Cancel,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub struct BackupPrompt {
|
|
|
|
|
expected: &'static str,
|
|
|
|
|
buf: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl BackupPrompt {
|
|
|
|
|
pub fn backup() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
expected: "BACKUP",
|
|
|
|
|
buf: String::new(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn restore() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
expected: "RESTORE",
|
|
|
|
|
buf: String::new(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn on_esc(&self) -> BackupDecision {
|
|
|
|
|
BackupDecision::Cancel
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn on_char(&mut self, c: char) -> BackupDecision {
|
|
|
|
|
if c == '\n' {
|
|
|
|
|
return BackupDecision::Pending;
|
|
|
|
|
}
|
|
|
|
|
if c == '\u{8}' {
|
|
|
|
|
self.buf.pop();
|
|
|
|
|
return BackupDecision::Pending;
|
|
|
|
|
}
|
|
|
|
|
if !c.is_ascii_alphabetic() {
|
|
|
|
|
return BackupDecision::Pending;
|
|
|
|
|
}
|
|
|
|
|
self.buf.push(c);
|
|
|
|
|
if self.buf == self.expected {
|
|
|
|
|
BackupDecision::Confirm
|
|
|
|
|
} else {
|
|
|
|
|
BackupDecision::Pending
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn typed(&self) -> &str {
|
|
|
|
|
&self.buf
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn backup_screen_text() -> &'static str {
|
|
|
|
|
"Write encrypted identity backup?\n\
|
|
|
|
|
This file is your identity secret. Treat it like the database.\n\
|
|
|
|
|
Onion (locator) is not included.\n\
|
|
|
|
|
Type BACKUP to confirm Esc to cancel"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn restore_screen_text() -> &'static str {
|
|
|
|
|
"Restore identity from backup?\n\
|
|
|
|
|
This overwrites your self keys. It does not rewrite the roster.\n\
|
|
|
|
|
You may become a different person with old friends.\n\
|
|
|
|
|
Type RESTORE to confirm Esc to cancel"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn restore_terminal() {
|
|
|
|
|
ratatui::restore();
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
pub fn run(node: Arc<Node>, rt: tokio::runtime::Handle) -> Result<AppExit, String> {
|
2026-09-10 14:50:01 -04:00
|
|
|
let prev = std::panic::take_hook();
|
|
|
|
|
std::panic::set_hook(Box::new(move |info| {
|
|
|
|
|
restore_terminal();
|
|
|
|
|
prev(info);
|
|
|
|
|
}));
|
2026-09-10 02:43:45 -04:00
|
|
|
let mut app = App::new(node, rt)?;
|
2026-09-10 01:54:19 -04:00
|
|
|
let mut terminal = ratatui::init();
|
|
|
|
|
let result = app.run(&mut terminal);
|
2026-09-10 14:50:01 -04:00
|
|
|
restore_terminal();
|
2026-09-10 01:54:19 -04:00
|
|
|
result
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct App {
|
2026-09-10 02:43:45 -04:00
|
|
|
node: Arc<Node>,
|
|
|
|
|
rt: tokio::runtime::Handle,
|
2026-09-10 01:54:19 -04:00
|
|
|
screen: Screen,
|
|
|
|
|
friends: Vec<Friend>,
|
|
|
|
|
selected: usize,
|
|
|
|
|
me_fp: String,
|
|
|
|
|
me_onion: String,
|
2026-09-10 02:07:40 -04:00
|
|
|
alert: Option<String>,
|
2026-09-10 02:43:45 -04:00
|
|
|
status_note: Option<String>,
|
2026-09-10 02:49:42 -04:00
|
|
|
composer: String,
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
focus: Pane,
|
|
|
|
|
help_open: bool,
|
2026-09-10 14:25:31 -04:00
|
|
|
who_open: bool,
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
chat_scroll: u16,
|
2026-09-11 22:33:55 -04:00
|
|
|
job_rx: Option<mpsc::Receiver<String>>,
|
2026-09-10 01:54:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum Screen {
|
|
|
|
|
Main,
|
2026-09-10 14:50:01 -04:00
|
|
|
Share {
|
|
|
|
|
payload: String,
|
|
|
|
|
},
|
|
|
|
|
Paste {
|
|
|
|
|
buf: String,
|
|
|
|
|
err: Option<String>,
|
|
|
|
|
},
|
|
|
|
|
Approve {
|
|
|
|
|
payload: QrPayload,
|
|
|
|
|
},
|
|
|
|
|
Rotate {
|
|
|
|
|
prompt: RotatePrompt,
|
|
|
|
|
},
|
|
|
|
|
Wipe {
|
|
|
|
|
kind: WipeKind,
|
|
|
|
|
prompt: WipePrompt,
|
|
|
|
|
},
|
|
|
|
|
Profile {
|
|
|
|
|
editor: ProfileEditor,
|
|
|
|
|
},
|
|
|
|
|
ConfirmKeys {
|
|
|
|
|
kind: BackupKind,
|
|
|
|
|
path: String,
|
|
|
|
|
prompt: BackupPrompt,
|
|
|
|
|
},
|
|
|
|
|
Passphrase {
|
|
|
|
|
kind: BackupKind,
|
|
|
|
|
path: String,
|
|
|
|
|
first: Option<String>,
|
|
|
|
|
buf: String,
|
|
|
|
|
},
|
2026-09-10 17:19:50 -04:00
|
|
|
Quit {
|
|
|
|
|
prompt: QuitPrompt,
|
|
|
|
|
},
|
2026-09-10 01:54:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl App {
|
2026-09-10 02:43:45 -04:00
|
|
|
fn new(node: Arc<Node>, rt: tokio::runtime::Handle) -> Result<Self, String> {
|
|
|
|
|
let friends = node.list_friends()?;
|
2026-09-10 01:54:19 -04:00
|
|
|
Ok(Self {
|
2026-09-10 02:43:45 -04:00
|
|
|
me_fp: to_hex(&node.identity_pk()),
|
|
|
|
|
me_onion: node.onion(),
|
|
|
|
|
node,
|
|
|
|
|
rt,
|
2026-09-10 01:54:19 -04:00
|
|
|
screen: Screen::Main,
|
|
|
|
|
friends,
|
|
|
|
|
selected: 0,
|
2026-09-10 02:07:40 -04:00
|
|
|
alert: None,
|
2026-09-10 02:43:45 -04:00
|
|
|
status_note: None,
|
2026-09-10 02:49:42 -04:00
|
|
|
composer: String::new(),
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
focus: Pane::Composer,
|
|
|
|
|
help_open: false,
|
2026-09-10 14:25:31 -04:00
|
|
|
who_open: false,
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
chat_scroll: 0,
|
2026-09-11 22:33:55 -04:00
|
|
|
job_rx: None,
|
2026-09-10 01:54:19 -04:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
fn run(&mut self, terminal: &mut DefaultTerminal) -> Result<AppExit, String> {
|
2026-09-10 01:54:19 -04:00
|
|
|
loop {
|
2026-09-11 22:33:55 -04:00
|
|
|
self.drain_job();
|
2026-09-10 01:54:19 -04:00
|
|
|
terminal.draw(|f| self.draw(f)).map_err(|e| e.to_string())?;
|
2026-09-11 22:33:55 -04:00
|
|
|
if !event::poll(TUI_POLL).map_err(io_err)? {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2026-09-10 01:54:19 -04:00
|
|
|
let Event::Key(key) = event::read().map_err(io_err)? else {
|
|
|
|
|
continue;
|
|
|
|
|
};
|
|
|
|
|
if key.kind != KeyEventKind::Press {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if key.code == KeyCode::Char('q') && key.modifiers.contains(KeyModifiers::CONTROL) {
|
2026-09-10 17:19:50 -04:00
|
|
|
if !matches!(self.screen, Screen::Quit { .. }) {
|
|
|
|
|
self.screen = Screen::Quit {
|
|
|
|
|
prompt: QuitPrompt::new(),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
continue;
|
2026-09-10 02:49:42 -04:00
|
|
|
}
|
|
|
|
|
if let Some(exit) = self.handle_key(key)? {
|
|
|
|
|
return Ok(exit);
|
2026-09-10 01:54:19 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
fn handle_key(&mut self, key: KeyEvent) -> Result<Option<AppExit>, String> {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
if self.help_open {
|
|
|
|
|
match key.code {
|
|
|
|
|
KeyCode::Esc | KeyCode::Char('?') => self.help_open = false,
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
|
|
|
|
return Ok(None);
|
|
|
|
|
}
|
2026-09-10 14:25:31 -04:00
|
|
|
if self.who_open {
|
|
|
|
|
match key.code {
|
|
|
|
|
KeyCode::Esc | KeyCode::F(5) => self.who_open = false,
|
|
|
|
|
KeyCode::Char('?') => {
|
|
|
|
|
self.who_open = false;
|
|
|
|
|
self.help_open = true;
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
|
|
|
|
return Ok(None);
|
|
|
|
|
}
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
if key.code == KeyCode::Char('?') && !matches!(self.screen, Screen::Paste { .. }) {
|
|
|
|
|
self.help_open = true;
|
|
|
|
|
return Ok(None);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
let mut wipe_confirm = None;
|
2026-09-10 17:19:50 -04:00
|
|
|
let mut quit_clear = None;
|
2026-09-10 14:25:31 -04:00
|
|
|
let mut profile_save = None;
|
|
|
|
|
let mut open_profile = false;
|
2026-09-10 14:37:43 -04:00
|
|
|
let mut pay_cmd = None;
|
|
|
|
|
let mut tip_cmd = None;
|
2026-09-10 23:32:06 -04:00
|
|
|
let mut file_cmd = None;
|
2026-09-10 23:07:22 -04:00
|
|
|
let mut chat_send = None;
|
2026-09-10 01:54:19 -04:00
|
|
|
match &mut self.screen {
|
|
|
|
|
Screen::Main => match key.code {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
KeyCode::Tab => self.focus = self.focus.next(),
|
|
|
|
|
KeyCode::BackTab => self.focus = self.focus.prev(),
|
|
|
|
|
KeyCode::Up => self.nav_up(),
|
|
|
|
|
KeyCode::Down => self.nav_down(),
|
2026-09-10 01:54:19 -04:00
|
|
|
KeyCode::F(2) => self.open_share()?,
|
|
|
|
|
KeyCode::F(3) => {
|
|
|
|
|
self.screen = Screen::Paste {
|
|
|
|
|
buf: String::new(),
|
|
|
|
|
err: None,
|
|
|
|
|
};
|
|
|
|
|
}
|
2026-09-10 02:43:45 -04:00
|
|
|
KeyCode::F(4) => {
|
|
|
|
|
self.screen = Screen::Rotate {
|
|
|
|
|
prompt: RotatePrompt::new(),
|
|
|
|
|
};
|
|
|
|
|
}
|
2026-09-10 14:25:31 -04:00
|
|
|
KeyCode::F(5) => self.who_open = true,
|
2026-09-10 02:49:42 -04:00
|
|
|
KeyCode::Esc => self.composer.clear(),
|
|
|
|
|
KeyCode::Backspace => {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
if self.focus == Pane::Composer {
|
|
|
|
|
self.composer.pop();
|
|
|
|
|
}
|
2026-09-10 02:49:42 -04:00
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
KeyCode::Enter => match composer_enter(&self.composer) {
|
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Wipe(kind))) => {
|
2026-09-10 02:49:42 -04:00
|
|
|
self.composer.clear();
|
|
|
|
|
let prompt = match kind {
|
|
|
|
|
WipeKind::Messages => WipePrompt::messages(),
|
|
|
|
|
WipeKind::All => WipePrompt::all(),
|
|
|
|
|
};
|
|
|
|
|
self.screen = Screen::Wipe { kind, prompt };
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Profile)) => {
|
2026-09-10 14:25:31 -04:00
|
|
|
self.composer.clear();
|
|
|
|
|
open_profile = true;
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Who)) => {
|
2026-09-10 14:25:31 -04:00
|
|
|
self.composer.clear();
|
|
|
|
|
self.who_open = true;
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Pay { atomic, memo })) => {
|
2026-09-10 14:37:43 -04:00
|
|
|
self.composer.clear();
|
|
|
|
|
pay_cmd = Some((atomic, memo));
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Tip { atomic, memo })) => {
|
2026-09-10 14:37:43 -04:00
|
|
|
self.composer.clear();
|
|
|
|
|
tip_cmd = Some((atomic, memo));
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Backup { path })) => {
|
2026-09-10 14:50:01 -04:00
|
|
|
self.composer.clear();
|
|
|
|
|
self.screen = Screen::ConfirmKeys {
|
|
|
|
|
kind: BackupKind::Backup,
|
|
|
|
|
path,
|
|
|
|
|
prompt: BackupPrompt::backup(),
|
|
|
|
|
};
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Restore { path })) => {
|
2026-09-10 14:50:01 -04:00
|
|
|
self.composer.clear();
|
|
|
|
|
self.screen = Screen::ConfirmKeys {
|
|
|
|
|
kind: BackupKind::Restore,
|
|
|
|
|
path,
|
|
|
|
|
prompt: BackupPrompt::restore(),
|
|
|
|
|
};
|
|
|
|
|
}
|
2026-09-10 23:32:06 -04:00
|
|
|
Some(ComposerAction::Cmd(SlashCmd::File { path })) => {
|
|
|
|
|
self.composer.clear();
|
|
|
|
|
file_cmd = Some(path);
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
Some(ComposerAction::Send(text)) => {
|
|
|
|
|
self.composer.clear();
|
|
|
|
|
chat_send = Some(text);
|
|
|
|
|
}
|
|
|
|
|
Some(ComposerAction::UnknownSlash(cmd)) => {
|
|
|
|
|
self.composer.clear();
|
|
|
|
|
self.status_note = Some(format!("unknown command {cmd}"));
|
|
|
|
|
}
|
2026-09-10 14:25:31 -04:00
|
|
|
None => {}
|
|
|
|
|
},
|
2026-09-10 02:49:42 -04:00
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
self.handle_main_char(c);
|
2026-09-10 02:49:42 -04:00
|
|
|
}
|
2026-09-10 01:54:19 -04:00
|
|
|
_ => {}
|
|
|
|
|
},
|
|
|
|
|
Screen::Share { .. } => {
|
|
|
|
|
if key.code == KeyCode::Esc {
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Screen::Paste { buf, err } => match key.code {
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
KeyCode::Enter => {
|
|
|
|
|
let raw = buf.clone();
|
|
|
|
|
self.submit_paste(&raw)?;
|
|
|
|
|
}
|
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
buf.pop();
|
|
|
|
|
*err = None;
|
|
|
|
|
}
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
buf.push(c);
|
|
|
|
|
*err = None;
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
},
|
|
|
|
|
Screen::Approve { payload } => match key.code {
|
|
|
|
|
KeyCode::Char('y') | KeyCode::Enter => {
|
|
|
|
|
let p = payload.clone();
|
|
|
|
|
self.accept_friend(&p)?;
|
|
|
|
|
}
|
|
|
|
|
KeyCode::Char('n') | KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
_ => {}
|
|
|
|
|
},
|
2026-09-10 02:43:45 -04:00
|
|
|
Screen::Rotate { prompt } => match key.code {
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
if prompt.on_char(c) == RotateDecision::Confirm {
|
|
|
|
|
self.confirm_rotate()?;
|
|
|
|
|
}
|
2026-09-10 01:54:19 -04:00
|
|
|
}
|
2026-09-10 02:43:45 -04:00
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
prompt.on_char('\u{8}');
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
},
|
2026-09-10 02:49:42 -04:00
|
|
|
Screen::Wipe { kind, prompt } => {
|
|
|
|
|
let kind = *kind;
|
|
|
|
|
match key.code {
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
if prompt.on_char(c) == WipeDecision::Confirm {
|
|
|
|
|
wipe_confirm = Some(kind);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
prompt.on_char('\u{8}');
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-09-10 14:25:31 -04:00
|
|
|
Screen::Profile { editor } => match key.code {
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
KeyCode::Tab => editor.on_tab(),
|
|
|
|
|
KeyCode::BackTab => editor.on_backtab(),
|
|
|
|
|
KeyCode::Backspace => editor.on_backspace(),
|
|
|
|
|
KeyCode::Enter => profile_save = Some(editor.on_enter()),
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
editor.on_char(c);
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
},
|
2026-09-10 14:50:01 -04:00
|
|
|
Screen::ConfirmKeys { kind, path, prompt } => {
|
|
|
|
|
let kind = *kind;
|
|
|
|
|
match key.code {
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
if prompt.on_char(c) == BackupDecision::Confirm {
|
|
|
|
|
self.screen = Screen::Passphrase {
|
|
|
|
|
kind,
|
|
|
|
|
path: path.clone(),
|
|
|
|
|
first: None,
|
|
|
|
|
buf: String::new(),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
prompt.on_char('\u{8}');
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Screen::Passphrase {
|
|
|
|
|
kind,
|
|
|
|
|
path,
|
|
|
|
|
first,
|
|
|
|
|
buf,
|
|
|
|
|
} => match key.code {
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
buf.pop();
|
|
|
|
|
}
|
|
|
|
|
KeyCode::Enter => {
|
|
|
|
|
let kind = *kind;
|
|
|
|
|
let path = path.clone();
|
|
|
|
|
let first = first.clone();
|
|
|
|
|
let pass = buf.clone();
|
|
|
|
|
self.submit_passphrase(kind, &path, first.as_deref(), &pass)?;
|
|
|
|
|
}
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
buf.push(c);
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
},
|
2026-09-10 17:19:50 -04:00
|
|
|
Screen::Quit { prompt } => match key.code {
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
KeyCode::Enter => match prompt.on_char('\n') {
|
|
|
|
|
QuitDecision::ClearAndQuit => quit_clear = Some(true),
|
|
|
|
|
QuitDecision::Quit => quit_clear = Some(false),
|
|
|
|
|
_ => {}
|
|
|
|
|
},
|
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
prompt.on_char('\u{8}');
|
|
|
|
|
}
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
prompt.on_char(c);
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
},
|
2026-09-10 02:49:42 -04:00
|
|
|
}
|
|
|
|
|
if let Some(kind) = wipe_confirm {
|
|
|
|
|
return self.confirm_wipe(kind);
|
|
|
|
|
}
|
2026-09-10 17:19:50 -04:00
|
|
|
if let Some(clear) = quit_clear {
|
|
|
|
|
if clear {
|
|
|
|
|
self.node.wipe_messages()?;
|
|
|
|
|
}
|
|
|
|
|
return Ok(Some(AppExit::Quit));
|
|
|
|
|
}
|
2026-09-10 14:25:31 -04:00
|
|
|
if open_profile {
|
|
|
|
|
self.open_profile()?;
|
|
|
|
|
}
|
|
|
|
|
if let Some(draft) = profile_save {
|
|
|
|
|
self.save_profile(draft)?;
|
|
|
|
|
}
|
2026-09-10 14:37:43 -04:00
|
|
|
if let Some((atomic, memo)) = pay_cmd {
|
|
|
|
|
self.send_pay(&atomic, &memo)?;
|
|
|
|
|
}
|
|
|
|
|
if let Some((atomic, memo)) = tip_cmd {
|
|
|
|
|
self.send_tip(&atomic, &memo)?;
|
|
|
|
|
}
|
2026-09-10 23:32:06 -04:00
|
|
|
if let Some(path) = file_cmd {
|
|
|
|
|
self.send_file(&path)?;
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
if let Some(text) = chat_send {
|
|
|
|
|
self.send_chat(&text)?;
|
|
|
|
|
}
|
2026-09-10 02:49:42 -04:00
|
|
|
Ok(None)
|
|
|
|
|
}
|
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
fn handle_main_char(&mut self, c: char) {
|
|
|
|
|
if self.focus != Pane::Composer {
|
|
|
|
|
match c {
|
|
|
|
|
'1' => self.focus = Pane::Roster,
|
|
|
|
|
'2' => self.focus = Pane::Chat,
|
|
|
|
|
'3' => self.focus = Pane::Composer,
|
|
|
|
|
'j' => self.nav_down(),
|
|
|
|
|
'k' => self.nav_up(),
|
|
|
|
|
'g' => self.nav_top(),
|
|
|
|
|
'G' => self.nav_bottom(),
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
self.composer.push(c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn nav_up(&mut self) {
|
|
|
|
|
match self.focus {
|
|
|
|
|
Pane::Roster => {
|
|
|
|
|
self.selected = self.selected.saturating_sub(1);
|
|
|
|
|
self.chat_scroll = u16::MAX;
|
|
|
|
|
}
|
|
|
|
|
Pane::Chat => {
|
|
|
|
|
self.chat_scroll = self.chat_scroll.saturating_sub(1);
|
|
|
|
|
}
|
|
|
|
|
Pane::Composer => {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn nav_down(&mut self) {
|
|
|
|
|
match self.focus {
|
|
|
|
|
Pane::Roster => {
|
|
|
|
|
if !self.friends.is_empty() {
|
|
|
|
|
self.selected = (self.selected + 1).min(self.friends.len() - 1);
|
|
|
|
|
self.chat_scroll = u16::MAX;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Pane::Chat => {
|
|
|
|
|
self.chat_scroll = self.chat_scroll.saturating_add(1);
|
|
|
|
|
}
|
|
|
|
|
Pane::Composer => {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn nav_top(&mut self) {
|
|
|
|
|
match self.focus {
|
|
|
|
|
Pane::Roster => {
|
|
|
|
|
self.selected = 0;
|
|
|
|
|
self.chat_scroll = u16::MAX;
|
|
|
|
|
}
|
|
|
|
|
Pane::Chat => self.chat_scroll = 0,
|
|
|
|
|
Pane::Composer => {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn nav_bottom(&mut self) {
|
|
|
|
|
match self.focus {
|
|
|
|
|
Pane::Roster => {
|
|
|
|
|
if !self.friends.is_empty() {
|
|
|
|
|
self.selected = self.friends.len() - 1;
|
|
|
|
|
self.chat_scroll = u16::MAX;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Pane::Chat => self.chat_scroll = u16::MAX,
|
|
|
|
|
Pane::Composer => {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
fn confirm_wipe(&mut self, kind: WipeKind) -> Result<Option<AppExit>, String> {
|
|
|
|
|
match kind {
|
|
|
|
|
WipeKind::Messages => {
|
|
|
|
|
self.node.wipe_messages()?;
|
|
|
|
|
self.status_note = Some("wiped messages".into());
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
Ok(None)
|
|
|
|
|
}
|
|
|
|
|
WipeKind::All => Ok(Some(AppExit::WipeAll)),
|
2026-09-10 01:54:19 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:50:01 -04:00
|
|
|
fn submit_passphrase(
|
|
|
|
|
&mut self,
|
|
|
|
|
kind: BackupKind,
|
|
|
|
|
path: &str,
|
|
|
|
|
first: Option<&str>,
|
|
|
|
|
pass: &str,
|
|
|
|
|
) -> Result<(), String> {
|
|
|
|
|
match kind {
|
|
|
|
|
BackupKind::Backup => {
|
|
|
|
|
if let Some(first) = first {
|
|
|
|
|
if first != pass {
|
|
|
|
|
self.alert = Some("passphrases do not match".into());
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
return Ok(());
|
|
|
|
|
}
|
|
|
|
|
match self.node.write_backup(path, pass) {
|
|
|
|
|
Ok(()) => {
|
|
|
|
|
self.status_note = Some(format!("backup written {path}"));
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
}
|
|
|
|
|
Err(e) => {
|
|
|
|
|
self.alert = Some(e);
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
self.screen = Screen::Passphrase {
|
|
|
|
|
kind,
|
|
|
|
|
path: path.to_string(),
|
|
|
|
|
first: Some(pass.to_string()),
|
|
|
|
|
buf: String::new(),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BackupKind::Restore => match self.node.restore_backup(path, pass) {
|
|
|
|
|
Ok(()) => {
|
|
|
|
|
self.me_fp = to_hex(&self.node.identity_pk());
|
|
|
|
|
self.status_note = Some("identity restored — roster unchanged".into());
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
}
|
|
|
|
|
Err(e) => {
|
|
|
|
|
self.alert = Some(e);
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 02:43:45 -04:00
|
|
|
fn confirm_rotate(&mut self) -> Result<(), String> {
|
|
|
|
|
let node = Arc::clone(&self.node);
|
|
|
|
|
match self.rt.block_on(node.rotate()) {
|
|
|
|
|
Ok(outcome) => {
|
|
|
|
|
self.me_onion = node.onion();
|
|
|
|
|
self.status_note = Some(format!(
|
|
|
|
|
"rotated · notified {}/{} friends",
|
|
|
|
|
outcome.notified, outcome.friends
|
|
|
|
|
));
|
|
|
|
|
self.open_share()
|
|
|
|
|
}
|
|
|
|
|
Err(e) => {
|
|
|
|
|
self.alert = Some(e);
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 01:54:19 -04:00
|
|
|
fn open_share(&mut self) -> Result<(), String> {
|
2026-09-10 02:43:45 -04:00
|
|
|
let payload = self.node.qr_payload()?;
|
2026-09-10 16:53:03 -04:00
|
|
|
self.screen = Screen::Share { payload };
|
2026-09-10 01:54:19 -04:00
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn submit_paste(&mut self, raw: &str) -> Result<(), String> {
|
|
|
|
|
match qr::decode(raw.trim()) {
|
|
|
|
|
Err(e) => {
|
|
|
|
|
self.screen = Screen::Paste {
|
|
|
|
|
buf: raw.to_string(),
|
|
|
|
|
err: Some(e.to_string()),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
Ok(payload) => {
|
2026-09-10 02:43:45 -04:00
|
|
|
let known = self.node.get_friend(&payload.pubkey)?.is_some();
|
2026-09-10 01:54:19 -04:00
|
|
|
if known {
|
|
|
|
|
self.accept_friend(&payload)?;
|
|
|
|
|
} else {
|
|
|
|
|
self.screen = Screen::Approve { payload };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn accept_friend(&mut self, payload: &QrPayload) -> Result<(), String> {
|
2026-09-10 02:43:45 -04:00
|
|
|
self.node.add_friend_payload(payload)?;
|
2026-09-10 01:54:19 -04:00
|
|
|
self.reload_friends()?;
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn reload_friends(&mut self) -> Result<(), String> {
|
2026-09-10 02:43:45 -04:00
|
|
|
self.friends = self.node.list_friends()?;
|
2026-09-10 01:54:19 -04:00
|
|
|
if self.friends.is_empty() {
|
|
|
|
|
self.selected = 0;
|
|
|
|
|
} else {
|
|
|
|
|
self.selected = self.selected.min(self.friends.len() - 1);
|
|
|
|
|
}
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
self.chat_scroll = u16::MAX;
|
2026-09-10 01:54:19 -04:00
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:25:31 -04:00
|
|
|
fn open_profile(&mut self) -> Result<(), String> {
|
|
|
|
|
let p = self.node.self_profile()?;
|
|
|
|
|
self.screen = Screen::Profile {
|
|
|
|
|
editor: ProfileEditor::new(&p.display_name, &p.bio, &p.xmr_addr),
|
|
|
|
|
};
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn save_profile(&mut self, draft: ProfileDraft) -> Result<(), String> {
|
|
|
|
|
if let Err(e) = self
|
|
|
|
|
.node
|
|
|
|
|
.set_self_profile(&draft.display_name, &draft.bio, &draft.xmr_addr)
|
|
|
|
|
{
|
|
|
|
|
self.alert = Some(e);
|
|
|
|
|
return Ok(());
|
|
|
|
|
}
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
if let Some(friend) = self.friends.get(self.selected) {
|
|
|
|
|
let pk = friend.pubkey.clone();
|
|
|
|
|
match self.rt.block_on(self.node.push_self_profile(&pk)) {
|
|
|
|
|
Ok(()) => self.status_note = Some("profile saved · sent".into()),
|
|
|
|
|
Err(e) => self.status_note = Some(format!("profile send failed: {e}")),
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
self.status_note = Some("profile saved".into());
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:37:43 -04:00
|
|
|
fn send_pay(&mut self, atomic: &str, memo: &str) -> Result<(), String> {
|
|
|
|
|
let Some(friend) = self.friends.get(self.selected) else {
|
|
|
|
|
self.status_note = Some("no friend selected".into());
|
|
|
|
|
return Ok(());
|
|
|
|
|
};
|
|
|
|
|
let pk = friend.pubkey.clone();
|
|
|
|
|
match self.rt.block_on(self.node.pay_invoice(&pk, atomic, memo)) {
|
|
|
|
|
Ok(()) => self.status_note = Some("invoice sent".into()),
|
|
|
|
|
Err(e) => self.status_note = Some(e),
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn send_tip(&mut self, atomic: &str, memo: &str) -> Result<(), String> {
|
|
|
|
|
let Some(friend) = self.friends.get(self.selected) else {
|
|
|
|
|
self.status_note = Some("no friend selected".into());
|
|
|
|
|
return Ok(());
|
|
|
|
|
};
|
|
|
|
|
let pk = friend.pubkey.clone();
|
|
|
|
|
match self.rt.block_on(self.node.tip(&pk, atomic, memo)) {
|
|
|
|
|
Ok(()) => self.status_note = Some("tip sent".into()),
|
|
|
|
|
Err(e) => self.status_note = Some(e),
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 23:32:06 -04:00
|
|
|
fn send_file(&mut self, path: &str) -> Result<(), String> {
|
|
|
|
|
let Some(friend) = self.friends.get(self.selected) else {
|
|
|
|
|
self.status_note = Some("no friend selected".into());
|
|
|
|
|
return Ok(());
|
|
|
|
|
};
|
|
|
|
|
let pk = friend.pubkey.clone();
|
|
|
|
|
self.status_note = Some("sending".into());
|
|
|
|
|
match self
|
|
|
|
|
.rt
|
|
|
|
|
.block_on(self.node.send_file(&pk, std::path::Path::new(path)))
|
|
|
|
|
{
|
|
|
|
|
Ok(name) => self.status_note = Some(format!("sent file {name}")),
|
|
|
|
|
Err(e) => self.status_note = Some(format!("send failed: {e}")),
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 23:07:22 -04:00
|
|
|
fn send_chat(&mut self, text: &str) -> Result<(), String> {
|
|
|
|
|
let Some(friend) = self.friends.get(self.selected) else {
|
|
|
|
|
self.status_note = Some("no friend selected".into());
|
|
|
|
|
return Ok(());
|
|
|
|
|
};
|
2026-09-11 22:33:55 -04:00
|
|
|
if self.job_rx.is_some() {
|
|
|
|
|
self.status_note = Some("already sending".into());
|
|
|
|
|
return Ok(());
|
2026-09-10 23:07:22 -04:00
|
|
|
}
|
2026-09-11 22:33:55 -04:00
|
|
|
let pk = friend.pubkey.clone();
|
|
|
|
|
let body = text.as_bytes().to_vec();
|
|
|
|
|
let node = Arc::clone(&self.node);
|
|
|
|
|
let (tx, rx) = mpsc::channel();
|
|
|
|
|
self.status_note = Some("sending".into());
|
|
|
|
|
std::mem::drop(self.rt.spawn(async move {
|
feat(outbox): local retry queue for chat sends
Queue a chat send locally when the peer's v3 onion is unreachable and retry
it with exponential backoff (30s doubling, capped at 30 min, 8 attempts then
terminal Failed). Still peer-to-peer: no server, no store-and-forward relay,
no new frame prefix — every attempt is a fresh Noise IK handshake.
- src/outbox.rs: Outbox + Deliverer + ArtiDeliverer, pure backoff_secs(),
is_permanent_send_error(), background worker (15s scan).
- store: `outbox` table (no body column — the body is read from the joined
messages row, under that row's existing AEAD + AAD), append_message_id(),
queue/due/pending/mark_* helpers, reset_sending_outbox(), wipe.
- Node::send() returns Result<OutboxStatus, String> (Sent/Queued) instead of
Err on transport failure; protocol errors still fail immediately and are
never queued.
- Retry triggers: timer, unlock/foreground (spawn_flush_all), and "that peer
was just seen" (handshake or connect_onion -> spawn_flush_friend).
- File transfer and payment/rcp frames stay fail-closed.
- docs/PROTOCOL.md + docs/THREAT_MODEL.md: replace the no-queue statements;
add the seizure/cadence delta to the threat model.
src/tui.rs gets one forced arm change (Ok(()) -> Ok(_)); UI surfacing is
child card t_d9a5b065.
2026-09-12 13:35:10 -04:00
|
|
|
// send() now reports `Sent`/`Queued`; surfacing `queued` in the
|
|
|
|
|
// footer is a follow-up card, so this arm keeps today's wording.
|
2026-09-11 22:33:55 -04:00
|
|
|
let note = match node.send(&pk, &body).await {
|
feat(outbox): local retry queue for chat sends
Queue a chat send locally when the peer's v3 onion is unreachable and retry
it with exponential backoff (30s doubling, capped at 30 min, 8 attempts then
terminal Failed). Still peer-to-peer: no server, no store-and-forward relay,
no new frame prefix — every attempt is a fresh Noise IK handshake.
- src/outbox.rs: Outbox + Deliverer + ArtiDeliverer, pure backoff_secs(),
is_permanent_send_error(), background worker (15s scan).
- store: `outbox` table (no body column — the body is read from the joined
messages row, under that row's existing AEAD + AAD), append_message_id(),
queue/due/pending/mark_* helpers, reset_sending_outbox(), wipe.
- Node::send() returns Result<OutboxStatus, String> (Sent/Queued) instead of
Err on transport failure; protocol errors still fail immediately and are
never queued.
- Retry triggers: timer, unlock/foreground (spawn_flush_all), and "that peer
was just seen" (handshake or connect_onion -> spawn_flush_friend).
- File transfer and payment/rcp frames stay fail-closed.
- docs/PROTOCOL.md + docs/THREAT_MODEL.md: replace the no-queue statements;
add the seizure/cadence delta to the threat model.
src/tui.rs gets one forced arm change (Ok(()) -> Ok(_)); UI surfacing is
child card t_d9a5b065.
2026-09-12 13:35:10 -04:00
|
|
|
Ok(_) => "sent".to_string(),
|
2026-09-11 22:33:55 -04:00
|
|
|
Err(e) => format!("send failed: {e}"),
|
|
|
|
|
};
|
|
|
|
|
let _ = tx.send(note);
|
|
|
|
|
}));
|
|
|
|
|
self.job_rx = Some(rx);
|
2026-09-10 23:07:22 -04:00
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-11 22:33:55 -04:00
|
|
|
fn drain_job(&mut self) {
|
|
|
|
|
let Some(note) = self.job_rx.as_ref().and_then(take_job_result) else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
self.status_note = Some(note);
|
|
|
|
|
self.job_rx = None;
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:25:31 -04:00
|
|
|
fn who_body(&self) -> String {
|
|
|
|
|
let Some(friend) = self.friends.get(self.selected) else {
|
|
|
|
|
return "no friend selected\n\nEsc closes".into();
|
|
|
|
|
};
|
|
|
|
|
let profile = self.node.friend_profile(&friend.pubkey).ok().flatten();
|
|
|
|
|
who_overlay_text(&friend.fingerprint, &friend.onion, profile.as_ref())
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 01:54:19 -04:00
|
|
|
fn draw(&self, f: &mut Frame) {
|
|
|
|
|
match &self.screen {
|
|
|
|
|
Screen::Main => self.draw_main(f),
|
2026-09-10 16:53:03 -04:00
|
|
|
Screen::Share { payload } => draw_share(f, payload),
|
2026-09-10 01:54:19 -04:00
|
|
|
Screen::Paste { buf, err } => draw_paste(f, buf, err.as_deref()),
|
|
|
|
|
Screen::Approve { payload } => draw_approve(f, payload),
|
2026-09-10 02:43:45 -04:00
|
|
|
Screen::Rotate { prompt } => draw_rotate(f, prompt.typed()),
|
2026-09-10 02:49:42 -04:00
|
|
|
Screen::Wipe { kind, prompt } => draw_wipe(f, *kind, prompt.typed()),
|
2026-09-10 14:25:31 -04:00
|
|
|
Screen::Profile { editor } => draw_profile(f, editor),
|
2026-09-10 14:50:01 -04:00
|
|
|
Screen::ConfirmKeys { kind, prompt, .. } => draw_confirm_keys(f, *kind, prompt.typed()),
|
|
|
|
|
Screen::Passphrase {
|
|
|
|
|
kind, first, buf, ..
|
|
|
|
|
} => draw_passphrase(f, *kind, first.is_some(), buf),
|
2026-09-10 17:19:50 -04:00
|
|
|
Screen::Quit { prompt } => draw_quit(f, prompt.typed()),
|
2026-09-10 01:54:19 -04:00
|
|
|
}
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
if self.help_open {
|
2026-09-10 14:25:31 -04:00
|
|
|
draw_text_overlay(f, "? help", help_overlay_text());
|
|
|
|
|
} else if self.who_open {
|
|
|
|
|
draw_text_overlay(f, "/who", &self.who_body());
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
}
|
2026-09-10 01:54:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn draw_main(&self, f: &mut Frame) {
|
|
|
|
|
let area = f.area();
|
2026-09-12 00:15:19 -04:00
|
|
|
let header = main_header_line(area.width, &self.me_fp, &self.me_onion);
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
let alert_h = u16::from(self.alert.is_some());
|
2026-09-10 02:49:42 -04:00
|
|
|
let cols = Layout::vertical([
|
2026-09-12 00:15:19 -04:00
|
|
|
Constraint::Length(1),
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
Constraint::Length(alert_h),
|
|
|
|
|
Constraint::Min(3),
|
|
|
|
|
Constraint::Length(3),
|
2026-09-10 02:49:42 -04:00
|
|
|
Constraint::Length(1),
|
|
|
|
|
])
|
|
|
|
|
.split(area);
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
f.render_widget(Paragraph::new(header).style(style_accent()), cols[0]);
|
2026-09-10 02:07:40 -04:00
|
|
|
if let Some(msg) = &self.alert {
|
2026-09-12 00:54:16 -04:00
|
|
|
let text = alert_line(msg, area.width);
|
2026-09-12 00:15:19 -04:00
|
|
|
f.render_widget(Paragraph::new(text).style(style_alert()), cols[1]);
|
2026-09-10 02:07:40 -04:00
|
|
|
}
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
let roster_w = roster_col_width(area.width).min(cols[2].width.saturating_sub(10));
|
2026-09-10 01:54:19 -04:00
|
|
|
let panes =
|
2026-09-12 00:15:19 -04:00
|
|
|
Layout::horizontal([Constraint::Length(roster_w), Constraint::Min(10)]).split(cols[2]);
|
|
|
|
|
let inner_roster = panes[0].width.saturating_sub(2);
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
|
|
|
|
let stale_n = self.friends.iter().filter(|fr| !fr.last_connect_ok).count();
|
|
|
|
|
let roster_title = if stale_n > 0 {
|
|
|
|
|
format!("roster {} {stale_n} stale", self.friends.len())
|
|
|
|
|
} else {
|
|
|
|
|
format!("roster {}", self.friends.len())
|
|
|
|
|
};
|
2026-09-10 01:54:19 -04:00
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
let items: Vec<ListItem> = if self.friends.is_empty() {
|
|
|
|
|
vec![ListItem::new("no friends").style(style_dim())]
|
|
|
|
|
} else {
|
|
|
|
|
self.friends
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|friend| {
|
|
|
|
|
let raw = friend.petname.as_deref().unwrap_or(&friend.fingerprint);
|
|
|
|
|
let name = sanitize::display_text(raw.as_bytes());
|
|
|
|
|
let line = roster_row_text(
|
|
|
|
|
&name,
|
|
|
|
|
&friend.fingerprint,
|
|
|
|
|
!friend.last_connect_ok,
|
|
|
|
|
inner_roster,
|
|
|
|
|
);
|
|
|
|
|
let style = if friend.last_connect_ok {
|
|
|
|
|
style_text()
|
|
|
|
|
} else {
|
|
|
|
|
style_stale()
|
|
|
|
|
};
|
|
|
|
|
ListItem::new(line).style(style)
|
|
|
|
|
})
|
|
|
|
|
.collect()
|
|
|
|
|
};
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
let roster = List::new(items)
|
2026-09-12 00:15:19 -04:00
|
|
|
.highlight_style(style_highlight())
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
.highlight_symbol("> ")
|
|
|
|
|
.block(self.pane_block(&roster_title, Pane::Roster));
|
|
|
|
|
let mut roster_state = ListState::default();
|
|
|
|
|
if !self.friends.is_empty() {
|
|
|
|
|
roster_state.select(Some(self.selected));
|
|
|
|
|
}
|
|
|
|
|
f.render_stateful_widget(roster, panes[0], &mut roster_state);
|
|
|
|
|
|
|
|
|
|
let chat_lines = self.chat_lines();
|
|
|
|
|
let inner_h = panes[1].height.saturating_sub(2);
|
|
|
|
|
let nlines = chat_lines.len();
|
|
|
|
|
let max_scroll = nlines.saturating_sub(inner_h as usize) as u16;
|
|
|
|
|
let scroll = self.chat_scroll.min(max_scroll);
|
|
|
|
|
let overflow = nlines > inner_h as usize && inner_h > 0;
|
|
|
|
|
let chat_title = {
|
|
|
|
|
let name = self.friends.get(self.selected).map(|friend| {
|
|
|
|
|
friend
|
|
|
|
|
.petname
|
|
|
|
|
.as_deref()
|
|
|
|
|
.unwrap_or(&friend.fingerprint)
|
|
|
|
|
.to_string()
|
|
|
|
|
});
|
|
|
|
|
let mut t = match name {
|
|
|
|
|
Some(n) => format!("chat {n}"),
|
|
|
|
|
None => "chat".to_string(),
|
|
|
|
|
};
|
|
|
|
|
if overflow {
|
|
|
|
|
let end = (scroll as usize + inner_h as usize).min(nlines);
|
|
|
|
|
t.push_str(&format!(" {}-{end}/{nlines}", scroll as usize + 1));
|
|
|
|
|
}
|
2026-09-12 00:15:19 -04:00
|
|
|
let mark = if self.focus == Pane::Chat { "> " } else { " " };
|
|
|
|
|
format!("{mark}{t}")
|
2026-09-10 01:54:19 -04:00
|
|
|
};
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
let chat_text = chat_lines.join("\n");
|
2026-09-10 01:54:19 -04:00
|
|
|
let chat = Paragraph::new(chat_text)
|
2026-09-12 00:15:19 -04:00
|
|
|
.style(style_text())
|
2026-09-10 01:54:19 -04:00
|
|
|
.wrap(Wrap { trim: false })
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
.scroll((scroll, 0))
|
|
|
|
|
.block(self.pane_block(&chat_title, Pane::Chat));
|
2026-09-10 01:54:19 -04:00
|
|
|
f.render_widget(chat, panes[1]);
|
|
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
let mark = if self.focus == Pane::Composer {
|
|
|
|
|
"> "
|
2026-09-10 02:49:42 -04:00
|
|
|
} else {
|
2026-09-12 00:15:19 -04:00
|
|
|
" "
|
2026-09-10 02:49:42 -04:00
|
|
|
};
|
2026-09-12 00:15:19 -04:00
|
|
|
let (cmd, cmd_style) = if self.composer.is_empty() {
|
|
|
|
|
(format!("{mark}message"), style_dim())
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
} else {
|
2026-09-12 00:15:19 -04:00
|
|
|
let style = if self.focus == Pane::Composer {
|
|
|
|
|
style_text().add_modifier(Modifier::BOLD)
|
|
|
|
|
} else {
|
|
|
|
|
style_text()
|
|
|
|
|
};
|
|
|
|
|
(format!("{mark}{}", self.composer), style)
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
};
|
|
|
|
|
f.render_widget(
|
|
|
|
|
Paragraph::new(cmd)
|
|
|
|
|
.style(cmd_style)
|
2026-09-12 00:15:19 -04:00
|
|
|
.wrap(Wrap { trim: false }),
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
cols[3],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let footer = self.footer_line(area.width);
|
2026-09-12 00:15:19 -04:00
|
|
|
f.render_widget(Paragraph::new(footer).style(style_dim()), cols[4]);
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn footer_line(&self, width: u16) -> String {
|
|
|
|
|
status_footer(
|
|
|
|
|
width,
|
|
|
|
|
&self.me_fp,
|
|
|
|
|
&self.me_onion,
|
|
|
|
|
self.status_note.as_deref(),
|
|
|
|
|
footer_hints(&self.screen),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn chat_lines(&self) -> Vec<String> {
|
|
|
|
|
let Some(friend) = self.friends.get(self.selected) else {
|
2026-09-10 17:19:50 -04:00
|
|
|
return vec![
|
|
|
|
|
"no friends yet".into(),
|
|
|
|
|
"F3 paste an invite to add one".into(),
|
|
|
|
|
];
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
};
|
|
|
|
|
match self.node.list_messages(&friend.pubkey) {
|
2026-09-12 00:54:16 -04:00
|
|
|
Ok(msgs) if msgs.is_empty() => empty_friend_chat_text()
|
|
|
|
|
.lines()
|
|
|
|
|
.map(str::to_string)
|
|
|
|
|
.collect(),
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
Ok(msgs) => msgs
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|m| {
|
|
|
|
|
let side = if m.dir == "out" { "you" } else { "them" };
|
2026-09-11 23:42:48 -04:00
|
|
|
format!("{side}: {}", sanitize::display_text(&m.plaintext))
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
})
|
|
|
|
|
.collect(),
|
|
|
|
|
Err(e) => vec![e],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn pane_block<'a>(&self, title: &'a str, pane: Pane) -> Block<'a> {
|
|
|
|
|
let focused = self.focus == pane;
|
2026-09-12 00:15:19 -04:00
|
|
|
let border = if focused {
|
|
|
|
|
style_accent()
|
|
|
|
|
} else {
|
|
|
|
|
style_border()
|
|
|
|
|
};
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
let title_style = if focused {
|
2026-09-12 00:15:19 -04:00
|
|
|
style_accent().add_modifier(Modifier::BOLD)
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
} else {
|
2026-09-12 00:15:19 -04:00
|
|
|
style_dim()
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
};
|
2026-09-12 00:54:16 -04:00
|
|
|
apply_chrome_borders(Block::default())
|
2026-09-12 00:15:19 -04:00
|
|
|
.border_style(border)
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
.title(title)
|
|
|
|
|
.title_style(title_style)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
/// Status bar: never drop a non-empty `status_note`. Always keep `TOR`, `me:`, `? help`.
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
pub fn status_footer(
|
|
|
|
|
width: u16,
|
|
|
|
|
me_fp: &str,
|
|
|
|
|
me_onion: &str,
|
|
|
|
|
status_note: Option<&str>,
|
|
|
|
|
hints: &str,
|
|
|
|
|
) -> String {
|
|
|
|
|
let w = width as usize;
|
2026-09-12 00:15:19 -04:00
|
|
|
let gap = if w >= 120 { " " } else { " " };
|
|
|
|
|
let help = "? help";
|
|
|
|
|
let me = format!("TOR me:{}", truncate_fp(me_fp));
|
|
|
|
|
let mut note = status_note.unwrap_or("").trim().to_string();
|
|
|
|
|
if !note.is_empty()
|
|
|
|
|
&& color_mode() == ColorMode::None
|
|
|
|
|
&& (note.starts_with("send failed") || note == "fingerprint mismatch")
|
|
|
|
|
&& !note.starts_with("! ")
|
|
|
|
|
{
|
|
|
|
|
note = format!("! {note}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let onion_full = if me_onion.is_empty() {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
"unset".to_string()
|
2026-09-12 00:15:19 -04:00
|
|
|
} else {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
me_onion.to_string()
|
2026-09-12 00:15:19 -04:00
|
|
|
};
|
|
|
|
|
let onion_short = if me_onion.is_empty() {
|
|
|
|
|
"unset".to_string()
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
} else {
|
|
|
|
|
truncate_fp(me_onion)
|
|
|
|
|
};
|
2026-09-12 00:15:19 -04:00
|
|
|
|
|
|
|
|
if !note.is_empty() {
|
|
|
|
|
let fixed = char_len(&me) + char_len(help) + 2 * gap.len();
|
|
|
|
|
let budget = w.saturating_sub(fixed);
|
|
|
|
|
if char_len(¬e) > budget {
|
|
|
|
|
note = truncate_chars(¬e, budget.max(12));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let mut parts: Vec<String> = Vec::new();
|
|
|
|
|
if !note.is_empty() {
|
|
|
|
|
parts.push(note);
|
|
|
|
|
}
|
|
|
|
|
parts.push(me);
|
|
|
|
|
|
|
|
|
|
let onion_full_part = format!("onion:{onion_full}");
|
|
|
|
|
let onion_short_part = format!("onion:{onion_short}");
|
|
|
|
|
let try_full = width >= 110;
|
|
|
|
|
if try_full && footer_fits(&parts, &[&onion_full_part], help, gap, w) {
|
|
|
|
|
parts.push(onion_full_part);
|
|
|
|
|
} else if footer_fits(&parts, &[&onion_short_part], help, gap, w) {
|
|
|
|
|
parts.push(onion_short_part);
|
|
|
|
|
}
|
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
let extra = hints.replace("? help", "");
|
2026-09-12 00:15:19 -04:00
|
|
|
let mut hint_tokens: Vec<&str> = extra.split_whitespace().collect();
|
|
|
|
|
while !hint_tokens.is_empty() {
|
|
|
|
|
let hint_str = hint_tokens.join(" ");
|
|
|
|
|
if footer_fits(&parts, &[&hint_str], help, gap, w) {
|
|
|
|
|
parts.push(hint_str);
|
|
|
|
|
break;
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
}
|
2026-09-12 00:15:19 -04:00
|
|
|
hint_tokens.remove(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parts.push(help.to_string());
|
|
|
|
|
let line = parts.join(gap);
|
|
|
|
|
if char_len(&line) <= w {
|
|
|
|
|
line
|
|
|
|
|
} else {
|
|
|
|
|
truncate_chars(&line, w)
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
fn footer_fits(parts: &[String], extra: &[&str], help: &str, gap: &str, w: usize) -> bool {
|
|
|
|
|
let mut all: Vec<&str> = parts.iter().map(String::as_str).collect();
|
|
|
|
|
all.extend(extra.iter().copied());
|
|
|
|
|
all.push(help);
|
|
|
|
|
char_len(&all.join(gap)) <= w
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Main-screen key hints. Kept short so width 80 still shows TOR + identity + `? help`.
|
|
|
|
|
pub fn main_footer_hints() -> &'static str {
|
2026-09-10 14:25:31 -04:00
|
|
|
"Tab F2 F3 F4 F5 ? help Ctrl-Q"
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn footer_hints(screen: &Screen) -> &'static str {
|
|
|
|
|
match screen {
|
|
|
|
|
Screen::Main => main_footer_hints(),
|
|
|
|
|
Screen::Share { .. } => "Esc back ? help",
|
|
|
|
|
Screen::Paste { .. } => "Enter submit Esc back ? help",
|
|
|
|
|
Screen::Approve { .. } => "y accept n reject ? help",
|
|
|
|
|
Screen::Rotate { .. } => "type ROTATE Esc cancel ? help",
|
|
|
|
|
Screen::Wipe { kind, .. } => match kind {
|
|
|
|
|
WipeKind::Messages => "type WIPE Esc cancel ? help",
|
|
|
|
|
WipeKind::All => "type WIPEALL Esc cancel ? help",
|
|
|
|
|
},
|
2026-09-10 14:25:31 -04:00
|
|
|
Screen::Profile { .. } => "Enter save Tab field Esc cancel ? help",
|
2026-09-10 14:50:01 -04:00
|
|
|
Screen::ConfirmKeys { kind, .. } => match kind {
|
|
|
|
|
BackupKind::Backup => "type BACKUP Esc cancel ? help",
|
|
|
|
|
BackupKind::Restore => "type RESTORE Esc cancel ? help",
|
|
|
|
|
},
|
|
|
|
|
Screen::Passphrase { .. } => "Enter submit Esc cancel ? help",
|
2026-09-10 17:19:50 -04:00
|
|
|
Screen::Quit { .. } => "CLEAR or QUIT then Enter Esc cancel ? help",
|
2026-09-10 01:54:19 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-12 00:54:16 -04:00
|
|
|
fn apply_chrome_borders(block: Block<'_>) -> Block<'_> {
|
|
|
|
|
let block = block.borders(Borders::ALL);
|
|
|
|
|
if ascii_chrome() {
|
|
|
|
|
block.border_set(ASCII_BORDERS)
|
|
|
|
|
} else {
|
|
|
|
|
block
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
fn themed_block(title: &str) -> Block<'_> {
|
2026-09-12 00:54:16 -04:00
|
|
|
apply_chrome_borders(Block::default())
|
2026-09-12 00:15:19 -04:00
|
|
|
.border_style(style_accent())
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
.title(title)
|
2026-09-12 00:15:19 -04:00
|
|
|
.title_style(style_accent().add_modifier(Modifier::BOLD))
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
}
|
|
|
|
|
|
2026-09-10 16:53:03 -04:00
|
|
|
pub fn draw_share(f: &mut Frame, payload: &str) {
|
|
|
|
|
let (fp, onion) = match qr::decode(payload) {
|
|
|
|
|
Ok(p) => (truncate_fp(&to_hex(&p.pubkey)), p.onion),
|
|
|
|
|
Err(_) => ("?".into(), "?".into()),
|
|
|
|
|
};
|
2026-09-12 00:54:16 -04:00
|
|
|
let inner = f.area().width.saturating_sub(2) as usize;
|
|
|
|
|
let invite = wrap_invite(payload, inner.max(1));
|
2026-09-10 16:53:03 -04:00
|
|
|
let body = format!(
|
2026-09-12 00:54:16 -04:00
|
|
|
"give this string to a friend; they F3 paste it\n\nfp {fp}\nonion {onion}\n\n{invite}"
|
2026-09-10 16:53:03 -04:00
|
|
|
);
|
2026-09-10 01:54:19 -04:00
|
|
|
f.render_widget(
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
.style(style_text())
|
2026-09-10 01:54:19 -04:00
|
|
|
.wrap(Wrap { trim: false })
|
2026-09-10 16:53:03 -04:00
|
|
|
.block(themed_block("(o) invite")),
|
2026-09-10 01:54:19 -04:00
|
|
|
f.area(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn draw_paste(f: &mut Frame, buf: &str, err: Option<&str>) {
|
2026-09-12 00:54:16 -04:00
|
|
|
let inner = f.area().width.saturating_sub(2) as usize;
|
|
|
|
|
let shown = wrap_invite(buf, inner.max(1));
|
|
|
|
|
let body = paste_screen_text(&shown, err);
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
let style = if err.is_some() {
|
2026-09-12 00:15:19 -04:00
|
|
|
style_alert()
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
} else {
|
2026-09-12 00:15:19 -04:00
|
|
|
style_text()
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
};
|
2026-09-10 01:54:19 -04:00
|
|
|
f.render_widget(
|
|
|
|
|
Paragraph::new(body)
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
.style(style)
|
2026-09-10 01:54:19 -04:00
|
|
|
.wrap(Wrap { trim: false })
|
2026-09-10 16:53:03 -04:00
|
|
|
.block(themed_block("(o) paste invite")),
|
2026-09-10 01:54:19 -04:00
|
|
|
f.area(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn draw_approve(f: &mut Frame, payload: &QrPayload) {
|
|
|
|
|
let fp = to_hex(&payload.pubkey);
|
|
|
|
|
let body = format!(
|
|
|
|
|
"Unknown key. Add this friend?\n\nfp {}\nonion {}\n\ny accept n / Esc reject",
|
|
|
|
|
truncate_fp(&fp),
|
|
|
|
|
payload.onion
|
|
|
|
|
);
|
|
|
|
|
f.render_widget(
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
.style(style_text())
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
.block(themed_block("(o) approve")),
|
2026-09-10 01:54:19 -04:00
|
|
|
f.area(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 02:43:45 -04:00
|
|
|
fn draw_rotate(f: &mut Frame, typed: &str) {
|
|
|
|
|
let body = format!("{}\n\n{typed}", rotate_screen_text());
|
2026-09-10 01:54:19 -04:00
|
|
|
f.render_widget(
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
.style(style_text())
|
2026-09-10 01:54:19 -04:00
|
|
|
.wrap(Wrap { trim: false })
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
.block(themed_block("(o) rotate locator")),
|
2026-09-10 01:54:19 -04:00
|
|
|
f.area(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
fn draw_wipe(f: &mut Frame, kind: WipeKind, typed: &str) {
|
|
|
|
|
let title = match kind {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
WipeKind::Messages => "(o) wipe",
|
|
|
|
|
WipeKind::All => "(o) wipe all",
|
2026-09-10 02:49:42 -04:00
|
|
|
};
|
|
|
|
|
let body = format!("{}\n\n{typed}", wipe_screen_text(kind));
|
|
|
|
|
f.render_widget(
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
.style(style_text())
|
2026-09-10 02:49:42 -04:00
|
|
|
.wrap(Wrap { trim: false })
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
.block(themed_block(title)),
|
2026-09-10 02:49:42 -04:00
|
|
|
f.area(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 17:19:50 -04:00
|
|
|
fn draw_quit(f: &mut Frame, typed: &str) {
|
|
|
|
|
let body = format!("{}\n\n{typed}", quit_screen_text());
|
|
|
|
|
f.render_widget(
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
.style(style_text())
|
2026-09-10 17:19:50 -04:00
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
.block(themed_block("(o) quit")),
|
|
|
|
|
f.area(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:25:31 -04:00
|
|
|
fn draw_profile(f: &mut Frame, editor: &ProfileEditor) {
|
|
|
|
|
let labels = ["name", "bio", "xmr"];
|
|
|
|
|
let values = [editor.display_name(), editor.bio(), editor.xmr_addr()];
|
|
|
|
|
let mut body = String::from(
|
|
|
|
|
"Your profile (friend-visible)\nEnter saves Esc cancels Tab next field\n",
|
|
|
|
|
);
|
|
|
|
|
for (i, (label, value)) in labels.iter().zip(values).enumerate() {
|
|
|
|
|
let mark = if editor.field() == i { ">" } else { " " };
|
|
|
|
|
body.push_str(&format!("\n{mark} {label}: {value}"));
|
|
|
|
|
}
|
|
|
|
|
f.render_widget(
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
.style(style_text())
|
2026-09-10 14:25:31 -04:00
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
.block(themed_block("(o) profile")),
|
|
|
|
|
f.area(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:50:01 -04:00
|
|
|
fn draw_confirm_keys(f: &mut Frame, kind: BackupKind, typed: &str) {
|
|
|
|
|
let (title, text) = match kind {
|
|
|
|
|
BackupKind::Backup => ("(o) backup", backup_screen_text()),
|
|
|
|
|
BackupKind::Restore => ("(o) restore", restore_screen_text()),
|
|
|
|
|
};
|
|
|
|
|
let body = format!("{text}\n\n{typed}");
|
|
|
|
|
f.render_widget(
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
.style(style_text())
|
2026-09-10 14:50:01 -04:00
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
.block(themed_block(title)),
|
|
|
|
|
f.area(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn draw_passphrase(f: &mut Frame, kind: BackupKind, second: bool, buf: &str) {
|
|
|
|
|
let stars: String = buf.chars().map(|_| '*').collect();
|
|
|
|
|
let hint = match (kind, second) {
|
|
|
|
|
(BackupKind::Backup, false) => "Enter passphrase",
|
|
|
|
|
(BackupKind::Backup, true) => "Re-enter passphrase",
|
|
|
|
|
(BackupKind::Restore, _) => "Enter passphrase",
|
|
|
|
|
};
|
|
|
|
|
let body = format!("{hint}\n\n{stars}\n\nEnter submit Esc cancel");
|
|
|
|
|
f.render_widget(
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
.style(style_text())
|
2026-09-10 14:50:01 -04:00
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
.block(themed_block("(o) passphrase")),
|
|
|
|
|
f.area(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
pub fn draw_text_overlay(f: &mut Frame, title: &str, text: &str) {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
let area = f.area();
|
2026-09-12 00:15:19 -04:00
|
|
|
let popup = if area.height < 28 {
|
|
|
|
|
area
|
|
|
|
|
} else {
|
|
|
|
|
let lines = text.lines().count() as u16 + 2;
|
|
|
|
|
let text_w = text
|
|
|
|
|
.lines()
|
|
|
|
|
.map(|l| l.chars().count() as u16)
|
|
|
|
|
.max()
|
|
|
|
|
.unwrap_or(40)
|
|
|
|
|
.saturating_add(4);
|
|
|
|
|
let width = text_w.min(area.width).max(10);
|
|
|
|
|
let height = lines.min(area.height).max(3);
|
|
|
|
|
Rect {
|
|
|
|
|
x: area.x + (area.width.saturating_sub(width)) / 2,
|
|
|
|
|
y: area.y + (area.height.saturating_sub(height)) / 2,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
}
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
};
|
2026-09-12 00:15:19 -04:00
|
|
|
f.render_widget(Clear, area);
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
f.render_widget(Clear, popup);
|
2026-09-12 00:15:19 -04:00
|
|
|
let inner_w = popup.width.saturating_sub(2).max(1);
|
|
|
|
|
let inner_h = popup.height.saturating_sub(2);
|
|
|
|
|
let wrapped: u16 = text
|
|
|
|
|
.lines()
|
|
|
|
|
.map(|l| {
|
|
|
|
|
let n = char_len(l) as u16;
|
|
|
|
|
if n == 0 { 1 } else { n.div_ceil(inner_w) }
|
|
|
|
|
})
|
|
|
|
|
.sum();
|
|
|
|
|
let scroll = wrapped.saturating_sub(inner_h);
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
f.render_widget(
|
|
|
|
|
Paragraph::new(text)
|
2026-09-12 00:15:19 -04:00
|
|
|
.style(style_text())
|
|
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
.scroll((scroll, 0))
|
2026-09-10 14:25:31 -04:00
|
|
|
.block(themed_block(title)),
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
popup,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 01:54:19 -04:00
|
|
|
fn truncate_fp(fp: &str) -> String {
|
|
|
|
|
let s: String = fp.chars().take(8).collect();
|
2026-09-12 00:15:19 -04:00
|
|
|
format!("{s}{}", ellipsis())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn roster_row_text(name: &str, fingerprint: &str, stale: bool, inner_width: u16) -> String {
|
|
|
|
|
let budget = (inner_width as usize).saturating_sub(2);
|
|
|
|
|
let fp = truncate_fp(fingerprint);
|
|
|
|
|
let fp_part = format!(" {fp}");
|
|
|
|
|
let mut stale_s = if stale { " stale" } else { "" }.to_string();
|
|
|
|
|
let suffix_len = char_len(&fp_part) + char_len(&stale_s);
|
|
|
|
|
let mut name_budget = budget.saturating_sub(suffix_len);
|
|
|
|
|
if name_budget < 1 && stale {
|
|
|
|
|
stale_s = " s".into();
|
|
|
|
|
name_budget = budget.saturating_sub(char_len(&fp_part) + char_len(&stale_s));
|
|
|
|
|
}
|
|
|
|
|
let shown = if name_budget == 0 {
|
|
|
|
|
String::new()
|
|
|
|
|
} else {
|
|
|
|
|
truncate_chars(name, name_budget)
|
|
|
|
|
};
|
|
|
|
|
let line = format!("{shown}{fp_part}{stale_s}");
|
|
|
|
|
if char_len(&line) > budget {
|
|
|
|
|
truncate_chars(&line, budget)
|
|
|
|
|
} else {
|
|
|
|
|
line
|
|
|
|
|
}
|
2026-09-10 01:54:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn to_hex(bytes: &[u8]) -> String {
|
|
|
|
|
bytes.iter().map(|b| format!("{b:02x}")).collect()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn io_err(e: io::Error) -> String {
|
|
|
|
|
e.to_string()
|
|
|
|
|
}
|