diff options
| author | 2026-03-07 11:56:03 -0500 | |
|---|---|---|
| committer | 2026-03-07 11:56:03 -0500 | |
| commit | 35dc12880737ecfff26789f0085de93780e3fa71 (patch) | |
| tree | 8e3e97784a46a270385122f4f2ff3ccf8eb63523 /src/tui/ui.rs | |
| parent | initial commit (diff) | |
a bunch of client cleanup
Diffstat (limited to 'src/tui/ui.rs')
| -rw-r--r-- | src/tui/ui.rs | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/tui/ui.rs b/src/tui/ui.rs index a38834a..4a243ad 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -90,37 +90,25 @@ fn draw_center(f: &mut Frame, area: Rect, state: &AppState) { } fn draw_chat_log(f: &mut Frame, area: Rect, state: &AppState) { - let inner_height = area.height.saturating_sub(2) as usize; // subtract borders - - // Build all rendered lines first so we can scroll from the bottom let lines: Vec<Line> = state .messages .iter() .map(|msg| render_chat_line(msg)) .collect(); - // Apply scroll offset - // scroll=0 means pinned to bottom (newest). scroll=N means N lines back from bottom. - let total = lines.len(); - let max_scroll = total.saturating_sub(inner_height); - let scroll = state.scroll.min(max_scroll); - let visible_start = total.saturating_sub(inner_height + scroll); - let visible: Vec<Line> = lines - .into_iter() - .skip(visible_start) - .take(inner_height) - .collect(); - let block = Block::default() .borders(Borders::ALL) .border_type(BorderType::Plain) .border_style(Style::default().fg(ORANGE)) .style(Style::default().bg(BG)); + let inner_height = area.height.saturating_sub(2) as usize; + let scroll = lines.len().saturating_sub(inner_height); f.render_widget( - Paragraph::new(Text::from(visible)) + Paragraph::new(Text::from(lines)) .block(block) - .wrap(Wrap { trim: false }), + .wrap(Wrap { trim: false }) + .scroll((scroll as u16, 0)), area, ); } @@ -232,7 +220,7 @@ fn draw_statusbar(f: &mut Frame, area: Rect, state: &AppState) { Span::styled(" │ ", Style::default().fg(FG)), Span::styled(&state.status, Style::default().fg(FG)), Span::styled(" │ ", Style::default().fg(FG)), - Span::styled("PgUp/Dn scroll Ctrl-C quit", Style::default().fg(FG)), + Span::styled("Ctrl-C quit", Style::default().fg(FG)), ]); f.render_widget(Paragraph::new(line).style(Style::default()), area); |
