hxbrief: Respect lines/columns env var even if ansi fails
parent
ad1e8a0b12
commit
8955a9ca75
|
@ -7,6 +7,7 @@ module Main
|
||||||
where
|
where
|
||||||
|
|
||||||
|
|
||||||
|
import Control.Applicative ( (<|>) )
|
||||||
import Control.Concurrent ( threadDelay )
|
import Control.Concurrent ( threadDelay )
|
||||||
import qualified Control.Concurrent.Async as A
|
import qualified Control.Concurrent.Async as A
|
||||||
import Control.Concurrent.MVar
|
import Control.Concurrent.MVar
|
||||||
|
@ -740,12 +741,12 @@ main = B.mainFromCmdParser $ do
|
||||||
-- restore $ System.IO.hSetEncoding System.IO.stderr GHC.IO.Encoding.utf8
|
-- restore $ System.IO.hSetEncoding System.IO.stderr GHC.IO.Encoding.utf8
|
||||||
termSizeMay <- restore $ do
|
termSizeMay <- restore $ do
|
||||||
support <- Ansi.hSupportsANSI System.IO.stdin
|
support <- Ansi.hSupportsANSI System.IO.stdin
|
||||||
if support
|
viaAnsi <- if support then Ansi.getTerminalSize else pure Nothing
|
||||||
then Ansi.getTerminalSize
|
viaEnv <- do
|
||||||
else do
|
|
||||||
envLines <- System.Environment.lookupEnv "LINES"
|
envLines <- System.Environment.lookupEnv "LINES"
|
||||||
envCols <- System.Environment.lookupEnv "COLUMNS"
|
envCols <- System.Environment.lookupEnv "COLUMNS"
|
||||||
pure $ (,) <$> (envLines >>= readMaybe) <*> (envCols >>= readMaybe)
|
pure $ (,) <$> (envLines >>= readMaybe) <*> (envCols >>= readMaybe)
|
||||||
|
pure (viaAnsi <|> viaEnv)
|
||||||
let stdoutCheckCount = length $ [ () | keepStdout || keepBoth ] ++ [ () | conflateStdout || conflateBoth ] ++ [ () | dropStdout || dropBoth ]
|
let stdoutCheckCount = length $ [ () | keepStdout || keepBoth ] ++ [ () | conflateStdout || conflateBoth ] ++ [ () | dropStdout || dropBoth ]
|
||||||
let stderrCheckCount = length $ [ () | keepStderr || keepBoth ] ++ [ () | conflateStderr || conflateBoth ] ++ [ () | dropStderr || dropBoth ]
|
let stderrCheckCount = length $ [ () | keepStderr || keepBoth ] ++ [ () | conflateStderr || conflateBoth ] ++ [ () | dropStderr || dropBoth ]
|
||||||
adjustedNumLines <- case termSizeMay of
|
adjustedNumLines <- case termSizeMay of
|
||||||
|
|
Loading…
Reference in New Issue