picotui icon indicating copy to clipboard operation
picotui copied to clipboard

Add alternative path to retrieve terminal size if available

Open arcivanov opened this issue 3 years ago • 4 comments

Use os.get_terminal_size if it is available Maintain original path if not

related to #48

arcivanov avatar Jan 30 '21 21:01 arcivanov

Thanks, but the whole purpose of picotui's existence is to oppose such programming style. Picotui is a thin layer above terminal escape sequences, not a patch-mess of #ifdef's like that.

If some terminal escape sequence doesn't work with a particular terminal emulator, I'd be interested to investigate why, and if possible, fix that.

pfalcon avatar Jan 30 '21 21:01 pfalcon

@pfalcon The os.get_terminal_size uses either IOCTL or conio, depending on how it's compiled, i.e. you'd need to look at conio source for all the possible options. If it's IOCTL then it's not replicable without actually doing ioctl.

https://github.com/python/cpython/blob/master/Modules/posixmodule.c#L13056

arcivanov avatar Jan 31 '21 16:01 arcivanov

picotui is intended to work with following terminals: a) VT100, which is a "dumb" terminal with hardcoded size 80x24; b) Xterm, which is a smarter terminal, and offers capability to query the screen size. picotui is intended to run on remote systems which don't have ioctl, conio, or any mess like that. The only requirement for picoui is stdin and stdout, and smart (ideally) terminal on the other end of those.

pfalcon avatar Jan 31 '21 16:01 pfalcon

And to explicate the topic of the discussion: I'm explaining why I don't jump to merging this patch right away. I consider it a workaround, and the real issue being that Konsole doesn't seem to respond to Xterm "query screen size" escape sequence, like Gnome Terminal does. I'd like to investigate that issue first, which may render this patch unneeded.

Or vice-versa, it may turn out to be still useful. But so far, more investigation for the Konsole issue is needed.

pfalcon avatar Jan 31 '21 16:01 pfalcon