Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
System.Console.Terminal.Size
Description
Get terminal window height and width without ncurses dependency
Based on answer by Andreas Hammar at http://stackoverflow.com/a/12807521/972985
Documentation
Terminal window width and height
Instances
Functor Window Source # | |
Foldable Window Source # | |
Traversable Window Source # | |
Eq a => Eq (Window a) Source # | |
Data a => Data (Window a) Source # | |
Read a => Read (Window a) Source # | |
Show a => Show (Window a) Source # | |
Generic (Window a) Source # | |
Generic1 * Window Source # | |
type Rep (Window a) Source # | |
type Rep1 * Window Source # | |
size :: Integral n => IO (Maybe (Window n)) Source #
Get terminal window width and height for stdout
.
>>>
import System.Console.Terminal.Size
>>>
size
Just (Window {height = 60, width = 112})
fdSize :: Integral n => Fd -> IO (Maybe (Window n)) Source #
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.
>>>
import System.Console.Terminal.Size
>>>
import System.Posix
>>>
fdSize stdOutput
Just (Window {height = 56, width = 85})>>>
fd <- openFd "foo" ReadWrite (Just stdFileMode) defaultFileFlags
>>>
fdSize fd
Nothing