Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ or, from a checkout, `cargo build --release`, which writes
download a GGUF for you, smallest quantization first; set `HF_TOKEN` in
your environment for gated repositories.
3. Run `computearena`. In a terminal this opens the full-screen interface:
arrow keys move, Enter selects, Esc goes back, Ctrl+C leaves, and the
wheel or PgUp/PgDn scrolls long output. It asks which
arrow keys move, Enter selects, Esc goes back, Ctrl+C leaves, and
PgUp/PgDn scrolls long output. The terminal retains the mouse, so URLs can
be clicked and text can be selected and copied normally. It asks which
runtime to use only when the answer is not obvious — one installed, or the
one you used last — shows the executable it found (or offers to install
one), and opens a menu: run benchmarks, submit previous benchmarks, list
Expand Down
5 changes: 0 additions & 5 deletions crates/computearena-cli/src/tui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,11 +739,6 @@ impl App {

// ---- key handling ----------------------------------------------------

/// A wheel notch, or any other coarse scroll.
pub(crate) fn scroll(&mut self, delta: isize) {
self.move_cursor(delta);
}

pub(crate) fn on_key(&mut self, key: ratatui::crossterm::event::KeyEvent) -> Result<()> {
use ratatui::crossterm::event::{KeyCode, KeyModifiers};
if key.modifiers.contains(KeyModifiers::CONTROL) && matches!(key.code, KeyCode::Char('c')) {
Expand Down
12 changes: 4 additions & 8 deletions crates/computearena-cli/src/tui/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ fn header(frame: &mut Frame, area: Rect, app: &App) {
..bar
};
let name = wordmark("ComputeArena");
let links = format!(
"{} · {} ",
COMPUTEARENA_WEBSITE.trim_start_matches("https://"),
COMPUTEARENA_DISCORD.trim_start_matches("https://")
);
let links = format!("{} · {} ", COMPUTEARENA_WEBSITE, COMPUTEARENA_DISCORD);
frame.render_widget(
Paragraph::new(Line::from(Span::styled(
format!(" {name}"),
Expand Down Expand Up @@ -203,13 +199,13 @@ fn footer(frame: &mut Frame, area: Rect, app: &App) {
"↑/↓ move · Space tick · a all · Enter preview · Esc back"
}
Screen::Reports { .. } => "↑/↓ move · Enter verify · Esc back",
Screen::Preview { .. } => "↑/↓ or wheel scroll · Enter submit · Esc back",
Screen::Preview { .. } => "↑/↓ scroll · Enter submit · Esc back",
// While a job runs, Enter and Esc do nothing; once it is done, Enter
// is the way on, so the footer leads with it.
Screen::Running if app.job.as_ref().is_none_or(Job::finished) => {
"Enter continue · ↑/↓ or wheel scroll · PgUp/PgDn page · Esc back"
"Enter continue · ↑/↓ scroll · PgUp/PgDn page · Esc back"
}
Screen::Running => "↑/↓ or wheel scroll · PgUp/PgDn page · Ctrl+C quit",
Screen::Running => "↑/↓ scroll · PgUp/PgDn page · Ctrl+C quit",
Screen::Loading { .. } => "working…",
Screen::HubSearch { .. } => "type a search · Enter search · Esc back",
Screen::HubModels { .. } => "↑/↓ move · Enter list files · Esc back",
Expand Down
26 changes: 6 additions & 20 deletions crates/computearena-cli/src/tui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use crate::adapters::Runtime;
use crate::reports::Paths;
use anyhow::{Context, Result};
use app::App;
use ratatui::crossterm::event::{
self, DisableMouseCapture, EnableMouseCapture, Event, KeyEventKind, MouseEventKind,
};
use ratatui::crossterm::event::{self, Event, KeyEventKind};
use ratatui::crossterm::execute;
use ratatui::crossterm::terminal::{
disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen,
Expand All @@ -29,9 +27,6 @@ use std::time::Duration;
/// a duplicate of the terminal taken before any of that happens.
type Screen = Terminal<CrosstermBackend<std::fs::File>>;

/// Lines moved per wheel notch.
const SCROLL_LINES: isize = 3;

pub(crate) fn session(
runtime: Runtime,
choose_runtime: bool,
Expand Down Expand Up @@ -60,7 +55,7 @@ fn install_panic_hook() {
std::panic::set_hook(Box::new(move |info| {
let _ = disable_raw_mode();
if let Ok(mut file) = job::tty() {
let _ = ratatui::crossterm::execute!(file, DisableMouseCapture, LeaveAlternateScreen);
let _ = ratatui::crossterm::execute!(file, LeaveAlternateScreen);
}
previous(info);
}));
Expand All @@ -70,19 +65,15 @@ fn start() -> Result<Screen> {
install_panic_hook();
let mut file = job::tty()?;
enable_raw_mode()?;
// Mouse capture is what delivers wheel events; the terminal's own text
// selection still works with Shift held.
execute!(file, EnterAlternateScreen, EnableMouseCapture)?;
// Leave mouse events with the terminal so URLs are clickable and normal
// drag selection/copy works without requiring a modifier key.
execute!(file, EnterAlternateScreen)?;
Ok(Terminal::new(CrosstermBackend::new(file))?)
}

fn stop(terminal: &mut Screen) {
let _ = disable_raw_mode();
let _ = execute!(
terminal.backend_mut(),
DisableMouseCapture,
LeaveAlternateScreen
);
let _ = execute!(terminal.backend_mut(), LeaveAlternateScreen);
let _ = terminal.show_cursor();
let _ = terminal.backend_mut().flush();
}
Expand All @@ -96,11 +87,6 @@ fn run(terminal: &mut Screen, app: &mut App) -> Result<()> {
if event::poll(idle)? {
match event::read()? {
Event::Key(key) if key.kind == KeyEventKind::Press => app.on_key(key)?,
Event::Mouse(mouse) => match mouse.kind {
MouseEventKind::ScrollUp => app.scroll(-SCROLL_LINES),
MouseEventKind::ScrollDown => app.scroll(SCROLL_LINES),
_ => {}
},
Event::Resize(_, _) => {}
_ => {}
}
Expand Down
Loading