@hackage terminal-size0.3.4
Get terminal window height and width
Categories
License
BSD-3-Clause
Maintainer
matvey.aksenov@gmail.com
Links
Versions
Installation
Dependencies (4)
Dependents (57)
@hackage/cmt, @hackage/cheapskate-terminal, @hackage/swarm, @hackage/cli-extras, @hackage/android-lint-summary, @hackage/futhark, Show all…
terminal-size
Get terminal window width and height
Usage
>>> import System.Console.Terminal.Size
>>> size
Just (Window {height = 60, width = 112})
Test
Compile test.hs and run it in a terminal. Here is what I get on Linux:
> ghc test.hs
> ./test
With redirected stdin
hSize stdin = Nothing
hSize stdout = Just (Window {height = 19, width = 87})
hSize stderr = Just (Window {height = 19, width = 87})
With redirected stdout
hSize stdin = Just (Window {height = 19, width = 87})
hSize stdout = Nothing
hSize stderr = Just (Window {height = 19, width = 87})
With redirected stderr
hSize stdin = Just (Window {height = 19, width = 87})
hSize stdout = Just (Window {height = 19, width = 87})
hSize stderr = Nothing
On MINGW/MSYS the output is the same.
On Windows with cmd.exe I get
With redirected stdin
hSize stdin = Nothing
hSize stdout = Just (Window {height = 40, width = 164})
hSize stderr = Just (Window {height = 40, width = 164})
With redirected stdout
hSize stdin = Nothing
hSize stdout = Nothing
hSize stderr = Just (Window {height = 40, width = 164})
With redirected stderr
hSize stdin = Nothing
hSize stdout = Just (Window {height = 40, width = 164})
hSize stderr = Nothing