terminal-size

Get terminal window height and width

LTS Haskell 22.17:0.3.4
Stackage Nightly 2024-04-18:0.3.4
Latest on Hackage:0.3.4

See all snapshots terminal-size appears in

BSD-3-Clause licensed by Andreas Hammar, Matvey Aksenov
Maintained by [email protected]
This version can be pinned in stack with:terminal-size-0.3.4@sha256:f0318c54273d04afb65109683b442792dcb67af1ad01ab5ec64423a28bb97715,1291

Module documentation for 0.3.4

terminal-size

Hackage Build Status

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

Changes

0.3.4

0.3.3

0.3.2.1

0.3.2

0.3.1

  • Typeable, Data, Generic, and Generic1 instances for Window.

0.3.0