mirror of
https://github.com/ilyakooo0/vty.git
synced 2024-11-29 08:49:40 +03:00
Config: expose vtyConfigPath, vtyConfigFileEnvName
This commit is contained in:
parent
0bea225b6d
commit
f1b7839875
@ -68,9 +68,11 @@ module Graphics.Vty.Config
|
||||
, getTtyEraseChar
|
||||
, currentTerminalName
|
||||
|
||||
, vtyConfigPath
|
||||
, widthTableFilename
|
||||
, vtyDataDirectory
|
||||
, terminalWidthTablePath
|
||||
, vtyConfigFileEnvName
|
||||
)
|
||||
where
|
||||
|
||||
@ -197,12 +199,20 @@ instance Monoid Config where
|
||||
vtyDataDirectory :: IO FilePath
|
||||
vtyDataDirectory = getAppUserDataDirectory "vty"
|
||||
|
||||
-- | Load a configuration from @'getAppUserDataDirectory'/config@ and
|
||||
-- @$VTY_CONFIG_FILE@.
|
||||
vtyConfigPath :: IO FilePath
|
||||
vtyConfigPath = do
|
||||
dir <- vtyDataDirectory
|
||||
return $ dir </> "config"
|
||||
|
||||
vtyConfigFileEnvName :: String
|
||||
vtyConfigFileEnvName = "VTY_CONFIG_FILE"
|
||||
|
||||
-- | Load a configuration from 'vtyConfigPath' and @$VTY_CONFIG_FILE@.
|
||||
userConfig :: IO Config
|
||||
userConfig = do
|
||||
configFile <- (mappend <$> vtyDataDirectory <*> pure "/config") >>= parseConfigFile
|
||||
overrideConfig <- maybe (return defaultConfig) parseConfigFile =<< lookupEnv "VTY_CONFIG_FILE"
|
||||
configFile <- vtyConfigPath >>= parseConfigFile
|
||||
overrideConfig <- maybe (return defaultConfig) parseConfigFile =<<
|
||||
lookupEnv vtyConfigFileEnvName
|
||||
let base = configFile <> overrideConfig
|
||||
mappend base <$> overrideEnvConfig
|
||||
|
||||
|
@ -84,9 +84,10 @@ main = do
|
||||
putStrLn $ "\nOutput table written to " <> outputPath
|
||||
|
||||
Just tName <- currentTerminalName
|
||||
configPath <- vtyConfigPath
|
||||
putStrLn ""
|
||||
putStrLn "To configure your Vty-based applications to use this map, add"
|
||||
putStrLn "the following line to ~/.vty/config:"
|
||||
putStrLn "the following line to " <> configPath <> ":"
|
||||
putStrLn ""
|
||||
putStrLn $ " widthMap " <> show tName <> " " <> show outputPath
|
||||
putStrLn ""
|
||||
|
Loading…
Reference in New Issue
Block a user