summaryrefslogtreecommitdiffstats
path: root/lib/ttyutils.c
Commit message (Collapse)AuthorAgeFilesLines
* lib/ttyutils: avoid checking same thing twiceSami Kerola2019-07-011-8/+8
| | | | | | Check cols and lines are not NULL only once. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/ttyutils: introduce get_terminal_stdfd()Karel Zak2019-05-271-9/+18
| | | | | | Let's use separate function to detect what is the current terminal. Signed-off-by: Karel Zak <kzak@redhat.com>
* script: add more info to script headerKarel Zak2018-05-141-0/+7
| | | | | | | | | | | | | | | | This patch introduces [...] to store extra information about terminal to the typescript header. For example: Script started on 2018-05-14 12:52:32+02:00 [TERM="xterm-256color" TTY="/dev/pts/3" COLS="190" LINES="53"] or Script started on 2018-05-14 12:54:01+02:00 [<not executed on terminal>] if stdout is not terminal. Addresses: https://github.com/karelzak/util-linux/issues/583 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/ttyutils: return terminal lines tooKarel Zak2017-06-121-19/+49
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: use unique ifdefs for testsKarel Zak2017-01-041-2/+2
| | | | | | | Let's use unique TEST_PROGRAM_<NAME> ifdefs to make build system more robust. Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: fix ttyutils testKarel Zak2016-07-151-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: try to find tty in get_terminal_name()Sami Kerola2016-07-041-2/+13
| | | | | | | | Try all standard terminal input/output file descriptors when finding tty name in get_germinal_name(). This should make all invocations of the function as robust as they can get. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/ttyutils: use stdout for get_terminal_width()Karel Zak2016-06-021-2/+2
| | | | | | | | | We use the function to be sure with *output* width. Note that the current code (with STDIN) is broken because in some situations libsmartcols is not able to detect terminal width and fall back to default 80. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tty: Pass default width to get_terminal_width()Boris Egorov2016-01-061-25/+25
| | | | | | | | | | Almost any code calling get_terminal_width() checks returned width for non-positive values and sets it to some default value (say, 80). So, let's pass this default value directly to the function. [kzak@redhat.com: - get_terminal_width() refactoring] Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tty: fix get_terminal_name() usage, cleanup codeKarel Zak2013-05-281-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tty: don't hardcode terminal fd in get_terminal_name()Karel Zak2013-05-131-2/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include: cleanup copyright headersKarel Zak2013-01-081-1/+6
| | | | | | | We use the code from include/ and lib/ on many places, so use public domain if possible or LGPL for code copied from libs. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/ttyutils: add get_terminal_name()Karel Zak2012-11-221-2/+43
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/ttyutils: add test programKarel Zak2012-11-221-0/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/ttyutils: create .c fileKarel Zak2012-11-221-0/+39
Well, now all tty stuff are incline functions in include/ttyutils.h. It's seems more elegant to create regular lib/ttyutils.c for libcommon and write test program. Signed-off-by: Karel Zak <kzak@redhat.com>