11{-# LANGUAGE BlockArguments #-}
22{-# LANGUAGE ImportQualifiedPost #-}
33{-# LANGUAGE OverloadedLabels #-}
4+ {-# LANGUAGE OverloadedStrings #-}
45
56import Brick (
67 AttrMap ,
@@ -15,7 +16,7 @@ import Brick (
1516 halt ,
1617 neverShowCursor ,
1718 on ,
18- str ,
19+ txt ,
1920 viewport ,
2021 withAttr ,
2122 withHScrollBars ,
@@ -39,6 +40,8 @@ import Control.Monad (void)
3940import Data.Foldable (toList )
4041import Data.Function ((&) )
4142import Data.Generics.Labels ()
43+ import Data.Text (Text )
44+ import Data.Text qualified as Text
4245import Data.Vector qualified as Vector
4346import GHC.Generics (Generic )
4447import Graphics.Vty (
@@ -125,25 +128,25 @@ appDraw Model{notes, openNoteM} = [mainWidget <=> keysHelpLine]
125128
126129 agenda =
127130 borderWithLabel
128- (str " Agenda " )
131+ (txt " Agenda " )
129132 (renderList renderListItem True notes & withVScrollBars OnRight )
130133
131134 openNoteWidget = do
132135 Entity {entityVal = Note {note_text}} <- openNoteM
133- let text = fromRgaM note_text
134- pure $
135- borderWithLabel (str " Note " ) $
136- viewport OpenNoteViewport Both (str text )
136+ let noteText = Text. pack $ fromRgaM note_text
137+ Just $
138+ borderWithLabel (txt " Note " ) $
139+ viewport OpenNoteViewport Both (txt noteText )
137140 & withVScrollBars OnRight
138141 & withHScrollBars OnBottom
139142
140143 keysHelpLine =
141- withAttr highlightAttr (str " Esc" )
142- <+> str " "
143- <+> withAttr highlightAttr (str " q" )
144- <+> str " exit "
145- <+> withAttr highlightAttr (str " Enter" )
146- <+> str " open"
144+ withAttr highlightAttr (txt " Esc" )
145+ <+> txt " "
146+ <+> withAttr highlightAttr (txt " q" )
147+ <+> txt " exit "
148+ <+> withAttr highlightAttr (txt " Enter" )
149+ <+> txt " open"
147150
148151highlightAttr :: AttrName
149152highlightAttr = attrName " highlight"
@@ -164,11 +167,14 @@ appHandleVtyEvent = \case
164167 e -> zoom # notes $ handleListEvent e
165168
166169renderListItem :: Bool -> EntityDoc Note -> Widget
167- renderListItem _isSelected Entity {entityVal} = str $ noteTitle entityVal
170+ renderListItem _isSelected Entity {entityVal} = txt $ noteTitle entityVal
168171
169- noteTitle :: Note -> String
172+ noteTitle :: Note -> Text
170173noteTitle Note {note_text} =
171- case filter ( not . null ) $ lines $ fromRgaM note_text of
174+ case textLines of
172175 [] -> " ..."
173176 [singleLine] -> singleLine
174177 firstLine : _ -> firstLine <> " ..."
178+ where
179+ textLines =
180+ filter (not . Text. null ) $ Text. lines $ Text. pack $ fromRgaM note_text
0 commit comments