terminal-size: Get terminal window height and width

[ bsd3, library, system ] [ Propose Tags ]

Get terminal window height and width without ncurses dependency.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.1.0, 0.3.0, 0.3.1, 0.3.2, 0.3.2.1, 0.3.3, 0.3.4
Change log CHANGELOG.markdown
Dependencies base (>=4 && <5), ghc-prim, process, Win32 (>=2.13.2.0 && <2.14) [details]
License BSD-3-Clause
Author Andreas Hammar, Matvey Aksenov
Maintainer matvey.aksenov@gmail.com
Category System
Source repo head: git clone https://github.com/biegunka/terminal-size
this: git clone https://github.com/biegunka/terminal-size(tag 0.3.4)
Uploaded by MatveyAksenov at 2023-03-13T14:27:31Z
Distributions Arch:0.3.4, Debian:0.3.2.1, Fedora:0.3.4, LTSHaskell:0.3.4, NixOS:0.3.4, Stackage:0.3.4, openSUSE:0.3.4
Reverse Dependencies 41 direct, 264 indirect [details]
Downloads 43562 total (269 in the last 30 days)
Rating 2.5 (votes: 3) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-03-13 [all 1 reports]

Readme for terminal-size-0.3.4

[back to package description]

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