module UI.Draw.Main where
import Brick.Types (Padding(..), Widget)
import Brick.Widgets.Core (fill, txt, vLimit, padRight, (<+>), withAttr)
import qualified Brick.Widgets.Edit as E
import qualified Data.Text as T
import Types
import Config.Main (editorLabelAttr, editorAttr, editorFocusedAttr)
fillLine :: Widget Name
fillLine = vLimit 1 (fill ' ')
editorDrawContent :: [T.Text] -> Widget Name
editorDrawContent st = txt $ T.unlines st
renderEditorWithLabel :: T.Text
-> Bool
-> E.Editor T.Text Name
-> Widget Name
renderEditorWithLabel label hasFocus e =
let inputW = E.renderEditor editorDrawContent hasFocus e
labelW = withAttr editorLabelAttr $ padRight (Pad 1) $ txt label
eAttr = if hasFocus then editorFocusedAttr else editorAttr
in labelW <+> withAttr eAttr (vLimit 1 inputW)