HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleterminal-size-0.3.4Haskell2010

System.Console.Terminal.Size

Get terminal window height and width without ncurses dependency

Based on answer by Andreas Hammar at http://stackoverflow.com/a/12807521/972985

  • 1 type
  • 3 values
datadata Window a
#

Terminal window width and height

Constructors

Instances11Functor, Foldable, Traversable, Generic1, Eq, Data, …
valuesize :: Integral n => IO (Maybe (Window n))
#

Get terminal window width and height for stdout.

Example2 expressions
import System.Console.Terminal.SizesizeJust (Window {height = 60, width = 112})
valuefdSize :: Integral n => Fd -> IO (Maybe (Window n))
#

Not available on Windows: Get terminal window width and height for a specified file descriptor. If it's not attached to a terminal then Nothing is returned.

Example5 expressions
import System.Console.Terminal.Sizeimport System.PosixfdSize stdOutputJust (Window {height = 56, width = 85})fd <- openFd "foo" ReadWrite (Just stdFileMode) defaultFileFlagsfdSize fdNothing
valuehSize :: Integral n => Handle -> IO (Maybe (Window n))
#

Same as fdSize, but takes Handle instead of Fd (file descriptor).

Note that on Windows with shells that use the native console API (cmd.exe, PowerShell) this works only for output handles like stdout and stderr; for input handles like stdin it always returns Nothing.

Example3 expressions
import System.Console.Terminal.Sizeimport System.IOhSize stdoutJust (Window {height = 56, width = 85})