@@ -7,11 +7,17 @@
7module Graphics.Vty.Config where
7module Graphics.Vty.Config where
9import Data.Default
9import Data.Default
10+import Data.Either (either)
11import Graphics.Vty.Input.Events
13import Graphics.Vty.Input.Events
13import System.FilePath
15import System.FilePath
18+import qualified Text.Parsec.Token as P
19+import Text.Parsec.Language (haskellDef)
15data Config = Config
21data Config = Config
16 { singleEscPeriod :: Int -- ^ AKA VTIME. The default is 100000 microseconds or 0.1 seconds.
22 { singleEscPeriod :: Int -- ^ AKA VTIME. The default is 100000 microseconds or 0.1 seconds.
17 -- | Debug information about the input process is appended to the file.
23 -- | Debug information about the input process is appended to the file.
@@ -26,5 +32,22 @@ instance Default Config where
26 , inputOverrides = []
32 , inputOverrides = []
35+-- not a proper monoid but useful as one.
36+instance Monoid Config where
38+ mappend c0 c1 = c1 { inputOverrides = inputOverrides c0 <> inputOverrides c1 }
29parseConfigFile :: FilePath -> IO Config
40parseConfigFile :: FilePath -> IO Config
30−parseConfigFile path = return def
41+parseConfigFile path = either (const def) id <$> parseFromFile parseConfig path
44+ let lexer = P.makeTokenParser haskellDef
49+ bytes <- P.stringLiteral
51+ modifier <- parseModifier
52+ _ <- manyTill space newline
53+ overrides <- many $ try parseOverride <|> ignoreOverride