@@ -146,6 +146,8 @@ data Config = Config
146146 -- | The terminal name used to look up terminfo capabilities.
147147 -- The default is the value of the TERM environment variable.
148148 , termName :: Maybe String
149+ -- | Terminal width map files.
150+ , termWidthMaps :: [(String, FilePath)]
149151 } deriving (Show, Eq)
150152
151153defaultConfig :: Config
@@ -163,6 +165,7 @@ instance Semigroup Config where
163165 , inputFd = inputFd c1 <|> inputFd c0
164166 , outputFd = outputFd c1 <|> outputFd c0
165167 , termName = termName c1 <|> termName c0
168+ , termWidthMaps = termWidthMaps c1 <|> termWidthMaps c0
166169 }
167170
168171instance Monoid Config where
@@ -176,6 +179,7 @@ instance Monoid Config where
176179 , inputFd = Nothing
177180 , outputFd = Nothing
178181 , termName = Nothing
182+ , termWidthMaps = []
179183 }
180184#if !(MIN_VERSION_base(4,11,0))
181185 mappend = (<>)
@@ -283,13 +287,20 @@ debugLogDecl = do
283287 path <- P.stringLiteral configLexer
284288 return defaultConfig { debugLog = Just path }
285289
290+widthMapDecl :: Parser Config
291+widthMapDecl = do
292+ "widthMap" <- P.identifier configLexer
293+ tName <- P.stringLiteral configLexer
294+ path <- P.stringLiteral configLexer
295+ return defaultConfig { termWidthMaps = [(tName, path)] }
296+
286297ignoreLine :: Parser ()
287298ignoreLine = void $ manyTill anyChar newline
288299
289300parseConfig :: Parser Config
290301parseConfig = liftM mconcat $ many $ do
291302 P.whiteSpace configLexer
292− let directives = [try mapDecl, try debugLogDecl]
303+ let directives = [try mapDecl, try debugLogDecl, try widthMapDecl]
293304 choice directives <|> (ignoreLine >> return defaultConfig)
294305
295306class Parse a where parseValue :: Parser a