diff --git a/source/view/annual_view.cpp b/source/view/annual_view.cpp index 1ac412b..ce3c4a6 100644 --- a/source/view/annual_view.cpp +++ b/source/view/annual_view.cpp @@ -33,7 +33,11 @@ AnnualView::AnnualView(const std::chrono::year_month_day &today, bool sundayStar m_tagsMenu{makeTagsMenu()}, m_sectionsMenu{makeSectionsMenu()}, m_rootComponent{makeFullUIComponent()}, m_recentEventsWindow{recentEventsWindow} {} -void AnnualView::run() { m_screen.Loop(m_rootComponent); } +void AnnualView::run() { + // Caps-log expects the terminal to be at least 80x24 + Terminal::SetFallbackSize(Dimensions{/*dimx=*/80, /*dimy=*/24}); + m_screen.Loop(m_rootComponent); +} void AnnualView::stop() { m_screen.ExitLoopClosure()(); } diff --git a/source/view/calendar_component.cpp b/source/view/calendar_component.cpp index a321359..6366611 100644 --- a/source/view/calendar_component.cpp +++ b/source/view/calendar_component.cpp @@ -5,6 +5,7 @@ #include "view/ftxui_ext/extended_containers.hpp" #include +#include namespace caps_log::view { using namespace ftxui; @@ -41,7 +42,10 @@ class MonthComponentArranger { * @brief Computes the number of months that can be displayed in a row. */ static int computeNumberOfMonthsPerRow(const Screen &screen) { - int availableMonthColumns = screen.dimx() / kCharsPerMonthComponet; + // Caps log runs only in fullscreen mode so we can safely assume the terminal size + // is the screen size + const auto terminal_size = Terminal::Size(); + int availableMonthColumns = terminal_size.dimx / kCharsPerMonthComponet; // prevent spliting 12 months into 2 rows of unequal elements if (availableMonthColumns == 5) { // NOLINT availableMonthColumns = 4;