on master help sign in
Graphics.Vty.Config: add and export currentTerminalName function
e882198Jonathan Daugherty
src/Graphics/Vty/Config.hs+9−2
@@ -66,6 +66,7 @@ module Graphics.Vty.Config
66 , parseConfigFile
66 , parseConfigFile
67 , defaultConfig
67 , defaultConfig
68 , getTtyEraseChar
68 , getTtyEraseChar
69+ , currentTerminalName
69
70
70 , widthTableFilename
71 , widthTableFilename
71 , vtyDataDirectory
72 , vtyDataDirectory
@@ -195,10 +196,16 @@ userConfig = do
195widthTableFilename :: String -> String
196widthTableFilename :: String -> String
196widthTableFilename term = "width_table_" <> term <> ".dat"
197widthTableFilename term = "width_table_" <> term <> ".dat"
197
198
199+termVariable :: String
200+termVariable = "TERM"
201+
202+currentTerminalName :: IO (Maybe String)
203+currentTerminalName = lookupEnv termVariable
204+
198terminalWidthTablePath :: IO (Maybe FilePath)
205terminalWidthTablePath :: IO (Maybe FilePath)
199terminalWidthTablePath = do
206terminalWidthTablePath = do
200 dataDir <- vtyDataDirectory
207 dataDir <- vtyDataDirectory
201− result <- lookupEnv "TERM"
208+ result <- lookupEnv termVariable
202 case result of
209 case result of
203 Nothing -> return Nothing
210 Nothing -> return Nothing
204 Just term -> do
211 Just term -> do
@@ -213,7 +220,7 @@ overrideEnvConfig = do
213-- can raise 'VtyConfigurationError'.
220-- can raise 'VtyConfigurationError'.
214standardIOConfig :: IO Config
221standardIOConfig :: IO Config
215standardIOConfig = do
222standardIOConfig = do
216− mb <- lookupEnv "TERM"
223+ mb <- lookupEnv termVariable
217 case mb of
224 case mb of
218 Nothing -> throwIO VtyMissingTermEnvVar
225 Nothing -> throwIO VtyMissingTermEnvVar
219 Just t ->
226 Just t ->