on master help sign in
Graphics.Vty.Config haddock pass
commit12ec53c97fc3d12c590926d9b8c95ffc95cdde12 authorJonathan Daugherty <cygnus@foobox.com> dateSun 22 Jan 2017, 12:55 (10 years ago) parentb0f7cbe
1 file changed+12−26
src/Graphics/Vty/Config.hs+12−26
src/Graphics/Vty/Config.hs+12−26
@@ -2,23 +2,12 @@
22{-# LANGUAGE FlexibleContexts, FlexibleInstances #-}
33{-# LANGUAGE TypeOperators #-}
44{-# LANGUAGE ScopedTypeVariables #-}
5−-- | A 'Config' can be provided to mkVty to customize the applications
6−-- use of vty. A config file can be used to customize vty for a user's
7−-- system.
8−--
9−-- The 'Config' provided is mappend'd to 'Config's loaded from
10−-- @'getAppUserDataDirectory'/config@ and @$VTY_CONFIG_FILE@. The
11−-- @$VTY_CONFIG_FILE@ takes precedence over the @config@ file or the
12−-- application provided 'Config'.
5+-- | Vty supports a configuration file format and associated 'Config'
6+-- data type. The 'Config' can be provided to 'mkVty' to customize the
7+-- application's use of Vty.
138--
149-- Lines in config files that fail to parse are ignored. Later entries
15−-- take precedence over earlier.
16−--
17−-- For all directives:
18−--
19−-- @
20−-- string := \"\\\"\" chars+ \"\\\"\"
21−-- @
10+-- take precedence over earlier ones.
2211--
2312-- = Debug
2413--
@@ -48,7 +37,7 @@
4837-- term := "_" | string
4938-- @
5039--
51−-- EG: If the contents are
40+-- E.g., if the contents are
5241--
5342-- @
5443-- map _ \"\\ESC[B\" KUp []
@@ -62,11 +51,9 @@
6251-- result in the KLeft event when @TERM@ is @xterm@.
6352--
6453-- If a debug log is requested then vty will output the current input
65−-- table to the log in the above format.
66−--
67−-- Set VTY_DEBUG_LOG. Run vty. Check debug log for incorrect mappings.
68−-- Add corrected mappings to .vty/config
69−--
54+-- table to the log in the above format. A workflow for using this is
55+-- to set @VTY_DEBUG_LOG@. Run the application. Check the debug log for
56+-- incorrect mappings. Add corrected mappings to @$HOME/.vty/config@.
7057module Graphics.Vty.Config
7158 ( InputMap
7259 , Config(..)
@@ -117,6 +104,7 @@ instance Exception VtyConfigurationError where
117104-- have the same byte string.
118105type InputMap = [(Maybe String, String, Event)]
119106
107+-- | A Vty configuration.
120108data Config = Config
121109 {
122110 -- | The default is 1 character.
@@ -174,8 +162,8 @@ instance Monoid Config where
174162 , termName = termName c1 <|> termName c0
175163 }
176164
177−-- | Config from @'getAppUserDataDirectory'/config@ and
178−-- @$VTY_CONFIG_FILE@
165+-- | Load a configuration from @'getAppUserDataDirectory'/config@ and
166+-- @$VTY_CONFIG_FILE@.
179167userConfig :: IO Config
180168userConfig = do
181169 configFile <- (mappend <$> getAppUserDataDirectory "vty" <*> pure "/config") >>= parseConfigFile
@@ -188,7 +176,7 @@ overrideEnvConfig = do
188176 d <- getEnv "VTY_DEBUG_LOG"
189177 return $ defaultConfig { debugLog = d }
190178
191−-- | Configures VTY using defaults suitable for terminals. This action
179+-- | Configures VTY using defaults suitable for terminals. This function
192180-- can raise 'VtyConfigurationError'.
193181standardIOConfig :: IO Config
194182standardIOConfig = do
@@ -221,8 +209,6 @@ runParseConfig name cfgTxt =
221209
222210type Parser = Parsec BS.ByteString ()
223211
224−-- I tried to use the haskellStyle here but that was specialized
225−-- (without requirement?) to the String stream type.
226212configLanguage :: Monad m => P.GenLanguageDef BS.ByteString () m
227213configLanguage = LanguageDef
228214 { commentStart = "{-"