From c1596baaeb1bbc4e1e714a97bb69af28b2e3b59d Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 18 Mar 2018 14:46:24 +0000 Subject: [PATCH] Move some UI stuff --- app/Main.hs | 19 ++++--------------- src/TaskMachine/UI.hs | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 src/TaskMachine/UI.hs diff --git a/app/Main.hs b/app/Main.hs index bbbadff..9e9dcca 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -9,21 +9,10 @@ module Main where import Control.Monad import Data.Monoid -import qualified Brick as B -import qualified Graphics.Vty as VTY +import qualified Brick as B +import qualified Brick.Themes as B -myAttrMap :: B.AttrMap -myAttrMap = B.attrMap VTY.defAttr - [ ("taskList" <> "normal", withStyle VTY.bold $ B.fg VTY.cyan) - , ("taskList" <> "highlight", withStyle VTY.bold $ B.bg VTY.cyan) - , ("taskList" <> "urgent" <> "normal", withStyle VTY.bold $ B.fg VTY.yellow) - , ("taskList" <> "urgent" <> "highlight", withStyle VTY.bold $ B.bg VTY.yellow) - , ("taskList" <> "veryUrgent" <> "normal", withStyle VTY.bold $ B.fg VTY.red) - , ("taskList" <> "veryUrgent" <> "highlight", withStyle VTY.bold $ B.bg VTY.red) - , ("taskList" <> "overdue" <> "normal", withStyle VTY.bold $ B.fg VTY.magenta) - , ("taskList" <> "overdue" <> "highlight", withStyle VTY.bold $ B.bg VTY.magenta) - ] - where withStyle = flip VTY.withStyle +import qualified TaskMachine.UI as TM data ResourceName = Asdf deriving (Eq, Ord) @@ -34,7 +23,7 @@ myApp = B.App , B.appHandleEvent = B.resizeOrQuit , B.appStartEvent = \s -> return s , B.appChooseCursor = B.neverShowCursor - , B.appAttrMap = \_ -> myAttrMap + , B.appAttrMap = const $ B.themeToAttrMap TM.defaultTheme } where myTestWidget = normal B.<=> urgent B.<=> veryUrgent B.<=> overdue diff --git a/src/TaskMachine/UI.hs b/src/TaskMachine/UI.hs new file mode 100644 index 0000000..d4af79d --- /dev/null +++ b/src/TaskMachine/UI.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE OverloadedStrings #-} + +module TaskMachine.UI + ( defaultTheme + ) where + +import Data.Monoid + +import qualified Brick as B +import qualified Brick.Themes as B +import qualified Graphics.Vty as VTY + +defaultTheme :: B.Theme +defaultTheme = B.newTheme VTY.defAttr + [ ("taskList" <> "normal", withStyle VTY.bold $ B.fg VTY.cyan) + , ("taskList" <> "highlight", withStyle VTY.bold $ B.bg VTY.cyan) + , ("taskList" <> "urgent" <> "normal", withStyle VTY.bold $ B.fg VTY.yellow) + , ("taskList" <> "urgent" <> "highlight", withStyle VTY.bold $ B.bg VTY.yellow) + , ("taskList" <> "veryUrgent" <> "normal", withStyle VTY.bold $ B.fg VTY.red) + , ("taskList" <> "veryUrgent" <> "highlight", withStyle VTY.bold $ B.bg VTY.red) + , ("taskList" <> "overdue" <> "normal", withStyle VTY.bold $ B.fg VTY.magenta) + , ("taskList" <> "overdue" <> "highlight", withStyle VTY.bold $ B.bg VTY.magenta) + ] + where withStyle = flip VTY.withStyle