Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KDE Konsole doesn't seem to respond to "get screen size" escape sequence #48

Open
arcivanov opened this issue Jan 30, 2021 · 14 comments
Open
Labels

Comments

@arcivanov
Copy link

arcivanov commented Jan 30, 2021

X11 Konsole/bash on Fedora 33 with Python 3.9.1

Firstly, thank you for the project, it reminds me of the good-old Borland Turbo Vision, which was absolutely epic.

However, I just started writing a prototype and the most basic features seem not to work. I guess it's something specific with my setup (Python 3.9?), but I'm still going to report it in case the problem is unknown and global.

Just for the reference, other console tools like bpytop and s-tui work perfectly.

  1. Mouse is not working at all.
  2. TTY size is not retrieved.

I suspect it's all related to console comms but it's hard to say what's going on.

As far as TTY size I always end up going this route with res being []:

picotui/picotui/screen.py

Lines 144 to 146 in 7a26e62

res = select.select([0], [], [], 0.2)[0]
if not res:
return (80, 24)

bpytop uses os.get_terminal_size() which seems to work perfectly:
https://github.com/aristocratos/bpytop/blob/2fbdc35125ad5d9a9f613736f194a33ec69bb14b/bpytop.py#L651

Anybody else has issues with basic functionality like that? I'm running code virtually identical to the https://github.com/pfalcon/picotui/blob/master/example_menu.py

@pfalcon
Copy link
Owner

pfalcon commented Jan 30, 2021

I suspect it's all related to console comms but it's hard to say what's going on.

Exactly, as you don't say what you use, it's hard to say what's going on. Please see https://www.chiark.greenend.org.uk/~sgtatham/bugs.html .

@arcivanov
Copy link
Author

arcivanov commented Jan 30, 2021

First of all, it's not even a bug report (yet). I'm trying to gauge whether there are other people that might have the same massive issue of "nothing working right". Maybe there is a common quirk that is known to all, as in maybe everybody knows that the project doesn't work on 3.9 or that the examples in project root are broken and only the examples in the examples directory do, or something else along those lines. There is no documentation to speak of, hence the broad question.

Secondly, "you don't say what you use" is not true. I said I'm on Fedora 33, Python 3.9.1, KDE Konsole over X11 and bash (over actual tty). I am using the latest version of picotui.

Thirdly, I even posted specific lines in terminal size query code that fail, returning default terminal size path. That, generally, shouldn't happen (ever?), so there must be something fundamentally wrong.

@arcivanov
Copy link
Author

arcivanov commented Jan 30, 2021

So this monkey-patching workaround for the terminal sizing fixes things somewhat:

from picotui import screen


class Screen(screen.Screen):
    @classmethod
    def screen_size(cls):
        return os.get_terminal_size(sys.stdout.fileno())


screen.Screen = Screen

from picotui.context import Context
from picotui.menu import (C_WHITE,
                          C_BLUE,
                          C_B_WHITE,
                          C_BLACK,
                          ACTION_CANCEL,
                          KEY_F9,
                          ACTION_OK,
                          WMenuBox, WMenuBar, Screen)
from picotui.widgets import Dialog, WButton, WLabel, WListBox, WDropDown
...

@pfalcon
Copy link
Owner

pfalcon commented Jan 30, 2021

said I'm on Fedora 33, Python 3.9.1, KDE Konsole over X11

Right, please consider a brain-fart. But for modern short attention-span humans, like myself, I'm going to edit the actual description to contain that info.

@pfalcon
Copy link
Owner

pfalcon commented Jan 30, 2021

As a quick reply, my work environment is Ubuntu MATE with MATE Terminal (1.24 as of now, but different version over last few years). Also tested with Gnome Terminal (of which MATE Terminal is a fork). I'll try KDE Konsole as time permits. In the meantime, please post what you get in it with:

$ env|grep TERM
COLORTERM=truecolor
TERM=xterm-256color

@pfalcon
Copy link
Owner

pfalcon commented Jan 30, 2021

maybe everybody knows that the project doesn't work on 3.9

I wouldn't err on the side of the of Python version, I'd err on what terminal setup you and/or in which terminal emulator. Just to confirm, I quick ran example_widgets.py with:

$ python3.9 --version
Python 3.9.1

and don't see any issues.

or that the examples in project root are broken and only the examples in the examples directory do, or something else along those lines.

Chances are that situation would be opposite - examples in the root is tried all the time, while stuff at examples/ might bitrot.

Thirdly, I even posted specific lines in terminal size query code that fail, returning default terminal size path. That, generally, shouldn't happen (ever?)

Terminal size querying relies on the particular Xterm escape sequence. MATE Terminal handles that sequence in a way compatible with picotui (speaking conservatively).

@pfalcon
Copy link
Owner

pfalcon commented Jan 30, 2021

So this monkey-patching workaround for the terminal sizing fixes things somewhat:

That doesn't tell me much, I would need to see a diff.

@pfalcon
Copy link
Owner

pfalcon commented Jan 30, 2021

Confirming Xterm mouse not working with Konsole 19.12.3.

@pfalcon
Copy link
Owner

pfalcon commented Jan 30, 2021

Screen size detection also doesn't seem to work, yeah.

@pfalcon
Copy link
Owner

pfalcon commented Jan 30, 2021

My guess is that Konsole wants some escape sequence to enable all the "extra" features like mouse input and size reporting...

arcivanov added a commit to arcivanov/picotui that referenced this issue Jan 30, 2021
Use os.get_terminal_size if it is available
Maintain original path if not

related to pfalcon#48
arcivanov added a commit to arcivanov/picotui that referenced this issue Jan 30, 2021
Use `os.get_terminal_size` if it is available
Maintain original path if not

related to pfalcon#48
@arcivanov
Copy link
Author

Please see #49 for terminal size fix/workaround. The call is available in all versions of Python that aren't EOLed. I maintained the alternative for all platforms where it's not available.

@pfalcon
Copy link
Owner

pfalcon commented Feb 1, 2021

Ok, mouse is working in Konsole in the latest master.

@pfalcon pfalcon added the triaged label Feb 2, 2021
@pfalcon pfalcon changed the title Broken mouse, can't get terminal size on X11 Konsole/bash on Fedora 33 with Python 3.9.1 KDE Konsole doesn't seem to respond to "get screen size" escape sequence Feb 4, 2021
@pfalcon
Copy link
Owner

pfalcon commented Feb 4, 2021

Suggested further plan re: screen size issue:

  1. Review https://www.x.org/docs/xterm/ctlseqs.pdf and compare with what picotui sends.
  2. If everything's ok on picotui side, figure out why Konsole doesn't respond to that escape. There're multiple ways to do that, the ultimate is to look at the source.
  3. Imagining that Konsole simply doesn't implement it, submit an upstream issue on it ("Konsole doesn't conform to Xterm terminal spec it advertises as implementing").
  4. Only after that can consider workarounds on picotui side.

@ethael
Copy link

ethael commented Jul 7, 2021

The same "resize" problem exists when using "st" simple terminal from suckless: https://st.suckless.org
Proposed patch does resolve the problem on "st" too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants