Skip to content

Commit

Permalink
Update to latest brick/vty version.
Browse files Browse the repository at this point in the history
  • Loading branch information
damianfral committed Apr 3, 2024
1 parent 9253f50 commit 1c10294
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies:
- time
- time-parsers
- vty
- vty-crossplatform
- word-wrap

library:
Expand All @@ -48,4 +49,4 @@ executables:
ghc-options:
- -rtsopts
- -threaded
- -with-rtsopts=-N
- -with-rtsopts=-N
30 changes: 16 additions & 14 deletions src/UI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

module UI (makeApp, AppConfig (..), AppState, loadJournalDirectory, getCurrentDay, customMain', makeKeyDispatcher, markdownHelp) where

import Brick
import Brick hiding (Down)
import Brick.BChan
import Brick.Keybindings
import Brick.Widgets.Border
Expand All @@ -24,6 +24,7 @@ import Data.Zipper
import Graphics.Vty
import qualified Graphics.Vty as V
import qualified Graphics.Vty as Vty
import Graphics.Vty.CrossPlatform (mkVty)
import Relude
import System.Directory (listDirectory)
import System.FilePath
Expand Down Expand Up @@ -66,16 +67,16 @@ draw appConfig appState@(AppState {..}) =

drawSideBar :: AppState -> Widget Resources
drawSideBar AppState {..} =
hLimit 13 $
withVScrollBars OnRight $
viewport SideBar Vertical $
padLeft (Pad 1) $
vBox $
mconcat
[ drawEntry <$> reverse (next entries),
[selected $ visible $ drawEntry $ current entries],
drawEntry <$> previous entries
]
hLimit 13
$ withVScrollBars OnRight
$ viewport SideBar Vertical
$ padLeft (Pad 1)
$ vBox
$ mconcat
[ drawEntry <$> reverse (next entries),
[selected $ visible $ drawEntry $ current entries],
drawEntry <$> previous entries
]

drawContent :: Day -> Text -> Widget Resources
drawContent day =
Expand Down Expand Up @@ -178,7 +179,7 @@ loadJournalDirectory appConfig@AppConfig {..} = do
today <- getCurrentDay
paths <- Relude.filter isMarkdownFile <$> listDirectory appConfigLogPath
let daysFromFiles = rights $ parseDay appConfigLogPath <$> paths
let days = case reverse $ sort daysFromFiles of
let days = case sortBy (comparing Down) daysFromFiles of
[] -> today :| []
mostRecentDay : rest ->
if mostRecentDay == today
Expand Down Expand Up @@ -212,11 +213,12 @@ readLogFile file = do
customMain' :: AppConfig -> KeyDispatcher Action AppEventM -> AppState -> BChan Day -> IO AppState
customMain' appConfig keyDispatcher' initialAppState chan = do
let buildVty = do
v <- mkVty =<< standardIOConfig
v <- mkVty defaultConfig
Vty.setMode (Vty.outputIface v) Vty.Mouse True
pure v
initialVty <- liftIO buildVty
customMain initialVty buildVty (Just chan) (makeApp appConfig keyDispatcher') initialAppState
let app = makeApp appConfig keyDispatcher'
customMain initialVty buildVty (Just chan) app initialAppState

makeKeyDispatcher :: AppConfig -> IO (KeyDispatcher Action (EventM Resources AppState))
makeKeyDispatcher appConfig = do
Expand Down

0 comments on commit 1c10294

Please sign in to comment.