⭐
Log in to mark this repository.
tui: lay the calendar out as four months by three rows
dea84dc · Gabriel Morell · 2026-10-19 16:11
✓
Rust CI and Docker Build / Create Release (push)
✓
Rust CI and Docker Build / Release (7z a, .exe, ppl-x86_64-windows.zip, windows-latest, windows-latest, 1.92) (push)
✓
Rust CI and Docker Build / Release (tar -czf, , ppl-aarch64-linux-gnu.tar.gz, ubuntu-24.04-arm, ubuntu-24.04-arm, 1.92) (push)
✓
Rust CI and Docker Build / Release (tar -czf, , ppl-aarch64-macos.tar.gz, macos-latest, macos-latest, 1.92) (push)
✓
Rust CI and Docker Build / Release (tar -czf, , ppl-x86_64-linux-gnu.tar.gz, ubuntu-latest, arc-runner-set, 1.92) (push)
✗
Rust CI and Docker Build / build (aarch64, ubuntu-24.04-arm) (push)
✓
Rust CI and Docker Build / build (x86_64, arc-runner-set) (push)
Message
{commit_body(@commit)}
Files changed
modified
src/do_tui.rs
+12
−3
@@ -18,6 +18,7 @@ use crossterm::event;
| 18 | 18 | use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind}; |
| 19 | 19 | use enum_iterator::{next, Sequence}; |
| 20 | 20 | use itertools::Itertools; |
| 21 | +use ratatui::layout::Flex; | |
| 21 | 22 | use ratatui::prelude::{Constraint, Direction, Layout, Line, Modifier, Span, Style, Stylize, Text}; |
| 22 | 23 | use ratatui::style::palette::material::AMBER; |
| 23 | 24 | use ratatui::style::palette::tailwind::{GREEN, ORANGE, PINK, SLATE, WHITE}; |
@@ -1614,15 +1615,23 @@ fn render(f: &mut Frame, app: &mut Tui) {
| 1614 | 1615 | // ); |
| 1615 | 1616 | // }); |
| 1616 | 1617 | |
| 1617 | − let rows = Layout::vertical([Constraint::Ratio(1, 2); 2]).split(layout_cal[1]); | |
| 1618 | + // Three rows of four months, each month centred in its cell | |
| 1619 | + let rows = Layout::vertical([Constraint::Ratio(1, 3); 3]).split(layout_cal[1]); | |
| 1618 | 1620 | let cols = rows.iter().flat_map(|row| { |
| 1619 | − Layout::horizontal([Constraint::Ratio(1, 6); 6]) | |
| 1621 | + Layout::horizontal([Constraint::Ratio(1, 4); 4]) | |
| 1620 | 1622 | .split(*row) |
| 1621 | 1623 | .to_vec() |
| 1622 | 1624 | }); |
| 1623 | 1625 | for col in cols { |
| 1626 | + // A month is 7 days of 3 columns wide, and a header plus up to 6 weeks tall | |
| 1627 | + let [cell] = Layout::horizontal([Constraint::Length(21)]) | |
| 1628 | + .flex(Flex::Center) | |
| 1629 | + .areas(col); | |
| 1630 | + let [cell] = Layout::vertical([Constraint::Length(7)]) | |
| 1631 | + .flex(Flex::Center) | |
| 1632 | + .areas(cell); | |
| 1624 | 1633 | let cal = get_cal(start, &event_list); |
| 1625 | − f.render_widget(cal, col); | |
| 1634 | + f.render_widget(cal, cell); | |
| 1626 | 1635 | start = start.replace_month(start.month().next()).unwrap_or(start); |
| 1627 | 1636 | } |
| 1628 | 1637 |
Parents: 9acf634