Skip to content

Commit

Permalink
fix: empty screen on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaDucak committed Nov 28, 2024
1 parent 62bae33 commit 3313943
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion source/view/annual_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()(); }

Expand Down
6 changes: 5 additions & 1 deletion source/view/calendar_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "view/ftxui_ext/extended_containers.hpp"

#include <ftxui/screen/screen.hpp>
#include <ftxui/screen/terminal.hpp>

namespace caps_log::view {
using namespace ftxui;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3313943

Please sign in to comment.