TCGETWINSIZE(3)
πΈ tcgetwinsize, tcsetwinsize β get, set the size of a terminal window πΈ
okay bestie, this is TCGETWINSIZE(3) from the Library Functions Manual, and it's literally the page for getting and setting your terminal window size. no cap. π«Ά
π NAME π
tcgetwinsize, tcsetwinsize β get, set the size of a terminal window.
π LIBRARY π
Standard C Library (libc, -lc).
β¨ SYNOPSIS β¨
#include <termios.h>
struct winsize {
unsigned short ws_row; /* number of rows, in characters */
unsigned short ws_col; /* number of columns, in characters */
unsigned short ws_xpixel; /* horizontal size, in pixels */
unsigned short ws_ypixel; /* vertical size, in pixels */
};
int
tcgetwinsize(int fd, struct winsize *w);
int
tcsetwinsize(int fd, const struct winsize *w);
π DESCRIPTION π
tcgetwinsize() is the βread the roomβ function: it gets the terminal window size of the terminal of which fd is an open file descriptor and stores it in the winsize structure of which w is a pointer. π
tcsetwinsize() is the βset the vibeβ function: it sets the terminal window size of the terminal of which fd is an open file descriptor from the winsize structure referenced by w. The change occurs immediately. If the terminal window size of the terminal is changed successfully to have a value that is different from the value that it had before the tcsetwinsize() call, then the SIGWINCH signal is sent to all those members of the foreground process group of the terminal that have the terminal as their controlling terminal. periodt. π
The above declaration of struct winsize may not be literal. It is provided only to list the accessible members. Therefore, before calling tcsetwinsize(), the members of the winsize structure must be initialized by calling tcgetwinsize(). The information in a winsize structure is stored by the kernel in order to provide a consistent interface, but it is not used by the kernel. (The kernel is keeping receipts but not using them, iconic. π)
π RETURN VALUE π
tcgetwinsize() and tcsetwinsize() return the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. The terminal window size remains unchanged if tcsetwinsize() fails. π«Ά
π ERRORS π
The following are the possible failure conditions:
[EBADF]β thefdargument totcgetwinsize()or totcsetwinsize()is not a valid file descriptor.[ENOTTY]β thefdargument totcgetwinsize()or totcsetwinsize()is not associated with a character special device.[EINVAL]β thewargument totcsetwinsize()is not valid.[EFAULT]β thewargument totcgetwinsize()or totcsetwinsize()points outside the process's allocated address space.
π SEE ALSO π
stty(1), ioctl(2), sigaction(2), termios(4), tty(4)
π STANDARDS π
tcgetwinsize() and tcsetwinsize() are expected to conform to IEEE Std 1003.1 (βPOSIX.1β) Base Specifications, Issue 8. The ws_xpixel and ws_ypixel members of struct winsize are FreeBSD extensions. β¨
mwah π source/version says Debian, date says December 28, 2020, and the page is TCGETWINSIZE(3) β that's the tea, bestie. π΅π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2020 Soumendra Ganguly <soumendraganguly@gmail.com>
- Copyright (C) 2020 by the Institute of
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms