STINNER Victor <victor.stin...@haypocalc.com> added the comment: > I noticed that bash uses $LINES, not $ROWS. I have renamed rows to lines > everywhere, to follow existing convention.
The stty program has "rows" and "columns" commands to set the terminal size. The tput programs has "cols" and "lines" commands to get the terminal size. The curses library uses (y, x), e.g. it has a getmaxyx() function. I don't know the most common term, lines or rows. Extract of http://stackoverflow.com/questions/1780483/lines-and-columns-environmental-variables-lost-in-a-script "The variables $LINES and $COLUMNS are shell variables, not environmental variables, and thus are not exported to the child process (...)" If I understood correctly, LINES and COLUMNS environment variables are only set by the user. In a bash script, these variables are wrapper to ioctl(). The tput program reads TERM environment variable to decide if LINES and COLUMNS are used or not: "-Ttype indicates the type of terminal. Normally this option is unnecessary, because the default is taken from the environment variable TERM. If -T is specified, then the shell variables LINES and COLUMNS will be ignored,and the operating system will not be queried for the actual screen size." Extract of http://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html : ------ COLUMNS A decimal integer > 0 used to indicate the user's preferred width in column positions for the terminal screen or window. (See column position .) If this variable is unset or null, the implementation determines the number of columns, appropriate for the terminal or window, in an unspecified manner. When COLUMNS is set, any terminal-width information implied by TERM will be overridden. Users and portable applications should not set COLUMNS unless they wish to override the system selection and produce output unrelated to the terminal characteristics. The default value for the number of column positions is unspecified because historical implementations use different methods to determine values corresponding to the size of the screen in which the utility is run. This size is typically known to the implementation through the value of TERM or by more elaborate methods such as extensions to the stty utility, or knowledge of how the user is dynamically resizing windows on a bit-mapped display terminal. Users should not need to set this variable in the environment unless there is a specific reason to override the implementation's default behaviour, such as to display data in an area arbitrarily smaller than the terminal or window. LINES A decimal integer > 0 used to indicate the user's preferred number of lines on a page or the vertical screen or window size in lines. A line in this case is a vertical measure large enough to hold the tallest character in the character set being displayed. If this variable is unset or null, the implementation determines the number of lines, appropriate for the terminal or window (size, terminal baud rate, and so forth), in an unspecified manner. When LINES is set, any terminal-height information implied by TERM will be overridden. Users and portable applications should not set LINES unless they wish to override the system selection and produce output unrelated to the terminal characteristics. The default value for the number of lines is unspecified because historical implementations use different methods to determine values corresponding to the size of the screen in which the utility is run. This size is typically known to the implementation through the value of TERM or by more elaborate methods such as extensions to the stty utility, or knowledge of how the user is dynamically resizing windows on a bit-mapped display terminal. Users should not need to set this variable in the environment unless there is a specific reason to override the implementation's default behaviour, such as to display data in an area arbitrarily smaller than the terminal or window. ------ > The big remaining question seems to be one function vs. two functions. Not exactly. I suggested to keep only the simple function in the os module, and add maybe a function with a higher level API (using environment variables) in another module (e.g. in shutil). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13609> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com