module
TermBuf::SizeDetector
Overview
Works out how big the terminal is, trying each source in turn and taking the first that answers.
The ioctl comes first because it is exact, free, and needs no cooperation from the terminal. Everything after it is a fallback for the cases where there is no controlling terminal to ask — a pipe, a pty without a size set, a terminal reached across a connection that did not forward one.
Extended Modules
Defined in:
termbuf/caps/screen_size.crConstant Summary
-
TIOCGWINSZ =
21523_u64
Instance Method Summary
-
#detect(fd : Int32 | Nil = nil, env : Hash(String, String) = ENV.to_h) : ScreenSize
In order: the kernel, the environment, then the shell utilities.
-
#from_commands : ScreenSize | Nil
sttyandtput, which reach the same ioctl by another route. -
#from_env(env : Hash(String, String)) : ScreenSize | Nil
COLUMNSandLINES, which a shell exports and which can be set by hand when nothing else knows. -
#from_ioctl(fd : Int32 | Nil = nil) : ScreenSize | Nil
TIOCGWINSZon the given descriptor, or on stdout, stdin, and stderr in turn when none is named.
Instance Method Detail
In order: the kernel, the environment, then the shell utilities.
stty and tput, which reach the same ioctl by another route. Worth
trying because they may find a controlling terminal this process cannot
see through its own descriptors.
COLUMNS and LINES, which a shell exports and which can be set by hand
when nothing else knows.
TIOCGWINSZ on the given descriptor, or on stdout, stdin, and stderr in
turn when none is named. A process with its output redirected often still
has a terminal on one of the others.