From 59056530f9fbaa15b7deb2f6d4ba42ec5d06c8e2 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Wed, 21 Sep 2022 06:13:03 -0400 Subject: abbreviated display of "Next" calendar entry --- countdown.hs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/countdown.hs b/countdown.hs index 70ecc99..5a5d718 100755 --- a/countdown.hs +++ b/countdown.hs @@ -217,7 +217,8 @@ countdownWidget showConversion isSimulated t = hCenter (hBox [ -- TODO: accumulate all entries on today's date into one vBox if currentEntryIsCurrent then - borderWithLabel (txt "Now on the Cosmic Calendar") currentEntry + (borderWithLabel (txt "Now on the Cosmic Calendar") currentEntry) <=> + (fromMaybe (str "") $ fmap (borderWithLabel (txt "Next on the Cosmic Calendar")) nextEntryShort) else borderWithLabel (txt "Next on the Cosmic Calendar") nextEntry, -- vBox [ cosmicCalendarCurrent, txt "\n", cosmicCalendarNext ], @@ -240,10 +241,11 @@ countdownWidget showConversion isSimulated t = (LocalTime entryDay _) <- (`addLocalTime` yearStart t) . calBeginTime <$> getCurrentCalendarEntry t let (LocalTime nowDay _) = t return $ entryDay == nowDay - currentEntry = fromMaybe (str "none") $ calendarWidget <$> getCurrentCalendarEntry t - nextEntry = fromMaybe (str "none") $ calendarWidget <$> getNextCalendarEntry t + currentEntry = fromMaybe (str "none") $ calendarWidget False <$> getCurrentCalendarEntry t + nextEntry = fromMaybe (str "none") $ calendarWidget False <$> getNextCalendarEntry t + nextEntryShort = fmap (str "\n" <=>) (calendarWidget True <$> getNextCalendarEntry t) - calendarWidget CalendarEntry{..} = box -- vBox [eventCountdown, str "\n", box] + calendarWidget short CalendarEntry{..} = box -- vBox [eventCountdown, str "\n", box] where timeUntilActive = (calBeginTime `addLocalTime` yearStart t) `diffLocalTime` t eventCountdown = if timeUntilActive >= 0 then @@ -254,7 +256,7 @@ countdownWidget showConversion isSimulated t = padLeft Max $ str $ showCosmicTime (-timeUntilActive) ++ " ago"] years = fromRational $ toCosmicTime calBeginTime box = vBox [ - if currentEntryIsCurrent + if currentEntryIsCurrent && not short then str "\n" else eventCountdown <=> str "\n", hCenter $ txt calTitle, @@ -269,8 +271,12 @@ countdownWidget showConversion isSimulated t = ], -- str $ printf "%s years ago" (commas $ ageOfUniverseInYears - floor years), str $ printf "%s years ago" $ showLarge $ realToFrac (ageOfUniverseInYears - floor years), - str "\n", - txtWrap calDescription + if not short + then + str "\n" <=> + txtWrap calDescription + else + str "" ] countdownBox = -- cgit v1.2.3