Python Forum
shutils.get_terminal_size()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
shutils.get_terminal_size()
#10
(Dec-04-2018, 12:33 PM)DeaD_EyE Wrote: Just google for it how many terminal emulators does exits. Count how many shells (sh, bash, csh, zsh, ...) we do have. And count all distributions.

Then you can calculate the possible combinations of everything:
terminals * shells * distros = many different standards

I guess it's nearly impossible to do it right, because there is no clear strict definition of only one standard.
We have many standards and the libraries have to handle this correct.

So every time, when your problem was solved by another programmer, you should give him a hug.
Ok, you can stop :-D

then no code should depend on anything besides the controlling tty attributes. so i guess i need to revise my code, yet, again, to do this based only on the controlling tty attributes, which is how i did it when i first coded it.

the screen command has a means to start a detached screen session. but you have very little control over the screen size of that session. i have implemented, in Python, a means to create a detached screen session of the specific size you want (up to the implementation maximum, which appears to be 1023x1023 in amd64 Linux). it is likely doable in almost any language that can call the system exec* syscalls. i used the stty command to perform the actual setting and a bit of juggling with screen and bash to be sure it recognized that size. setting the terminal size did not set any environment variables. bash does set some as it initializes an interactive shell. my own .bashrc code than sets the other common ones. but i must not assume everyone uses bash, my .bashrc code, or even amd64 Linux. that means using the controlling tty attributes, if there is a controlling tty.

i use detached screen sessions to run long running work in the background. for that i implemented commands to ...

1. create a detached screen session with whatever virtual terminal size is desired (defaulting to what is set, currently).

2. stuff input, with conversion from many escape sequences, into the detached screen session.

3. obtain the current output screen contents and output it to stdout.

4. attach to an existing detached screen session.

that is the current reason i have been examining this issue. but i tend to make functions to do many of the various things i do. i have a collection of over 100 Python functions.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
shutils.get_terminal_size() - by Skaperen - Nov-28-2018, 10:01 PM
RE: shutils.get_terminal_size() - by Gribouillis - Nov-28-2018, 10:21 PM
RE: shutils.get_terminal_size() - by nilamo - Nov-28-2018, 10:22 PM
RE: shutils.get_terminal_size() - by wavic - Nov-29-2018, 12:37 AM
RE: shutils.get_terminal_size() - by Skaperen - Nov-29-2018, 01:32 AM
RE: shutils.get_terminal_size() - by wavic - Nov-29-2018, 08:35 AM
RE: shutils.get_terminal_size() - by nilamo - Nov-29-2018, 03:40 PM
RE: shutils.get_terminal_size() - by Skaperen - Dec-04-2018, 08:48 AM
RE: shutils.get_terminal_size() - by DeaD_EyE - Dec-04-2018, 12:33 PM
RE: shutils.get_terminal_size() - by Skaperen - Dec-07-2018, 03:46 AM
RE: shutils.get_terminal_size() - by Skaperen - Dec-10-2018, 05:37 AM
RE: shutils.get_terminal_size() - by DeaD_EyE - Dec-10-2018, 08:30 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020