feat: make month week start configurable

Add a Monday-default --week-start option for every weekday and carry it through domain layout, full and compact rendering, event query windows, print mode, and the interactive TUI.

Preserve byte-compatible Monday output and cover rotated headers, spill dates, invalid input, sanitizer behavior, and live terminal restoration.
This commit is contained in:
2026-07-18 09:58:27 +01:00
parent b524e6e33d
commit 989332ef9a
17 changed files with 430 additions and 23 deletions

View File

@@ -31,6 +31,8 @@ using YearMonth = std::chrono::year_month;
[[nodiscard]] Date first_day_of_month(YearMonth month);
[[nodiscard]] YearMonth following_month(YearMonth month);
[[nodiscard]] unsigned weekday_index(Date date,
std::chrono::weekday week_start);
[[nodiscard]] unsigned monday_first_weekday(Date date);
} // namespace nocal

View File

@@ -20,6 +20,7 @@ struct MonthLayout {
static constexpr std::size_t cell_count = rows * columns;
YearMonth month{std::chrono::year{1970} / std::chrono::January};
std::chrono::weekday week_start{std::chrono::Monday};
std::array<MonthCell, cell_count> cells{};
[[nodiscard]] const MonthCell& at(std::size_t row, std::size_t column) const;
@@ -28,6 +29,7 @@ struct MonthLayout {
[[nodiscard]] Date last_visible_date() const noexcept;
};
[[nodiscard]] MonthLayout make_month_layout(YearMonth month);
[[nodiscard]] MonthLayout make_month_layout(
YearMonth month, std::chrono::weekday week_start = std::chrono::Monday);
} // namespace nocal

View File

@@ -89,6 +89,7 @@ struct ScreenState {
std::chrono::year{1970}, std::chrono::month{1}, std::chrono::day{1}};
std::vector<AgendaItem> agenda_items;
std::size_t agenda_index{0};
std::chrono::weekday week_start{std::chrono::Monday};
};
// Render a complete frame. The result contains no cursor positioning, which

View File

@@ -26,8 +26,12 @@ public:
using SaveCallback = std::function<void(std::span<const Event>)>;
explicit TuiApp(std::vector<Event>& events, int input_fd = 0, int output_fd = 1);
TuiApp(std::vector<Event>& events, std::chrono::weekday week_start,
int input_fd = 0, int output_fd = 1);
TuiApp(std::vector<Event>& events, SaveCallback saver, int input_fd = 0,
int output_fd = 1);
TuiApp(std::vector<Event>& events, SaveCallback saver,
std::chrono::weekday week_start, int input_fd = 0, int output_fd = 1);
[[nodiscard]] ExitReason run();
void dispatch(Action action);