@@ -1,5 +1,6 @@
1{-# LANGUAGE FlexibleContexts #-}
1{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE NoMonomorphismRestriction #-}
2{-# LANGUAGE NoMonomorphismRestriction #-}
3+{-# LANGUAGE KindSignatures #-}
3-- | A 'Config' can be provided to mkVty to customize the applications use of vty. A config file can
4-- | A 'Config' can be provided to mkVty to customize the applications use of vty. A config file can
4-- be used to customize vty for a user's system.
5-- be used to customize vty for a user's system.
@@ -173,6 +174,9 @@ configLanguage = LanguageDef
173configLexer :: Stream s m Char => P.GenTokenParser s u m
174configLexer :: Stream s m Char => P.GenTokenParser s u m
174configLexer = P.makeTokenParser configLanguage
175configLexer = P.makeTokenParser configLanguage
177+mapDecl :: forall s u (m :: * -> *).
178+ (Monad m, Stream s (WriterT Config m) Char) =>
179+ ParsecT s u (WriterT Config m) ()
176mapDecl = do
180mapDecl = do
177 void $ string "map"
181 void $ string "map"
178 P.whiteSpace configLexer
182 P.whiteSpace configLexer
@@ -185,6 +189,9 @@ mapDecl = do
186-- TODO: Generated by a vim macro. There is a better way here. Derive parser? Use Read
190-- TODO: Generated by a vim macro. There is a better way here. Derive parser? Use Read
187-- instance? Generics?
191-- instance? Generics?
192+parseKey :: forall s u (m :: * -> *).
188parseKey = do
195parseKey = do
189 key <- P.identifier configLexer
196 key <- P.identifier configLexer
190 case key of
197 case key of
@@ -215,8 +222,14 @@ parseKey = do
215 "KMenu" -> return KMenu
222 "KMenu" -> return KMenu
216 _ -> fail $ key ++ " is not a valid key identifier"
223 _ -> fail $ key ++ " is not a valid key identifier"
225+parseModifiers :: forall s u (m :: * -> *).
227+ ParsecT s u m [Modifier]
218parseModifiers = P.brackets configLexer (parseModifier `sepBy` P.symbol configLexer ",")
228parseModifiers = P.brackets configLexer (parseModifier `sepBy` P.symbol configLexer ",")
230+parseModifier :: forall s u (m :: * -> *).
232+ ParsecT s u m Modifier
220parseModifier = do
233parseModifier = do
221 m <- P.identifier configLexer
234 m <- P.identifier configLexer
222 case m of
235 case m of
@@ -226,14 +239,22 @@ parseModifier = do
226 "MAlt" -> return MAlt
239 "MAlt" -> return MAlt
227 _ -> fail $ m ++ " is not a valid modifier identifier"
240 _ -> fail $ m ++ " is not a valid modifier identifier"
242+debugLogDecl :: forall s u (m :: * -> *).
243+ (Monad m, Stream s (WriterT Config m) Char) =>
244+ ParsecT s u (WriterT Config m) ()
229debugLogDecl = do
245debugLogDecl = do
230 void $ string "debugLog"
246 void $ string "debugLog"
231 P.whiteSpace configLexer
247 P.whiteSpace configLexer
232 path <- P.stringLiteral configLexer
248 path <- P.stringLiteral configLexer
233 lift $ tell $ def { debugLog = Just path }
249 lift $ tell $ def { debugLog = Just path }
251+ignoreLine :: forall s u (m :: * -> *).
252+ Stream s m Char => ParsecT s u m ()
235ignoreLine = void $ manyTill anyChar newline
253ignoreLine = void $ manyTill anyChar newline
255+parseConfig :: forall s u (m :: * -> *).
256+ (Monad m, Stream s (WriterT Config m) Char) =>
257+ ParsecT s u (WriterT Config m) ()
237parseConfig = void $ many $ do
258parseConfig = void $ many $ do
238 P.whiteSpace configLexer
259 P.whiteSpace configLexer
239 let directives = [mapDecl, debugLogDecl]
260 let directives = [mapDecl, debugLogDecl]