packages feed

gotta-go-fast 0.1.2.0 → 0.1.3.0

raw patch · 3 files changed

+23/−11 lines, 3 filesdep ~base

Dependency ranges changed: base

Files

gotta-go-fast.cabal view
@@ -1,5 +1,5 @@ name:                gotta-go-fast-version:             0.1.2.0+version:             0.1.3.0 synopsis:            A command line utility for practicing typing description:   A command line utility for practicing typing and measuring your WPM and accuracy. See the project <https://github.com/hot-leaf-juice/gotta-go-fast/blob/master/README.md README> for details.@@ -20,7 +20,7 @@                      , FormatCode   main-is:             Main.hs   ghc-options:         -threaded-  build-depends:       base >=4.9 && <4.10+  build-depends:       base >=4.9 && <4.11                      , brick                      , cmdargs                      , directory
src/Main.hs view
@@ -2,6 +2,7 @@  module Main where +import Data.Word (Word8) import Control.Monad (filterM) import System.Console.CmdArgs   (Data, Typeable, args, cmdArgs, def, help, program, summary, typ, (&=))@@ -16,6 +17,8 @@   , width :: Int   , tab :: Int   , files :: [FilePath]+  , fg_empty :: Word8+  , fg_error :: Word8   } deriving (Show, Data, Typeable)  config :: Config@@ -26,9 +29,13 @@     help "The width at which to wrap lines (default: 80)"   , tab = 4 &= typ "SIZE" &=     help "The size of a tab in spaces (default: 4)"+  , fg_empty = 8 &= typ "COLOUR" &=+    help "The ISO colour code for empty (not yet typed) characters (default: 8)"+  , fg_error = 1 &= typ "COLOUR" &=+    help "The ISO colour code for errors (default: 1)"   , files = def &= args &= typ "FILES"   }-  &= summary "Gotta Go Fast 0.1.2.0"+  &= summary "Gotta Go Fast 0.1.3.0"   &= help "Practice typing and measure your WPM and accuracy"   &= program "gotta-go-fast" @@ -51,4 +58,4 @@       r <- randomRIO (0, length fs - 1)       file <- readFile $ fs !! r       sampled <- sample c file-      run sampled+      run (fg_empty c) (fg_error c) sampled
src/UI.hs view
@@ -1,5 +1,7 @@ module UI (run) where +import Data.Word (Word8)+ import Brick   ( App(..), AttrName, BrickEvent(..), EventM, Location(..), Next, Widget   , attrMap, attrName, continue, defaultMain, emptyWidget, fg, halt, padAll@@ -10,7 +12,7 @@ import Control.Monad.IO.Class (liftIO) import Data.Time (getCurrentTime) import Graphics.Vty-  (Event(..), Key(..), Modifier(..), brightBlack, defAttr, red)+  (Attr, Color(..), Event(..), Key(..), Modifier(..), defAttr, withStyle)  import GottaGoFast @@ -85,17 +87,20 @@     _ -> continue s handleEvent s _ = continue s -app :: App State e ()-app = App+app :: Attr -> Attr -> App State e ()+app fgEmpty fgError = App   { appDraw = draw   , appChooseCursor = showFirstCursor   , appHandleEvent = handleEvent   , appStartEvent = return   , appAttrMap = const $ attrMap defAttr-    [(emptyAttr, fg brightBlack), (missAttr, fg red), (borderAttr, fg red)]+    [(emptyAttr, fgEmpty), (missAttr, fgError), (borderAttr, fgError)]   } -run :: String -> IO ()-run t = do-  _ <- defaultMain app $ initialState t+run :: Word8 -> Word8 -> String -> IO ()+run fgEmptyCode fgErrorCode t = do+  _ <- defaultMain (app fgEmpty fgError) $ initialState t   return ()+    where+      fgEmpty = fg $ ISOColor fgEmptyCode+      fgError = fg $ ISOColor fgErrorCode