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

Textual leaves Kitty terminal broken #4779

Closed
ihabunek opened this issue Jul 19, 2024 · 3 comments · Fixed by #4781
Closed

Textual leaves Kitty terminal broken #4779

ihabunek opened this issue Jul 19, 2024 · 3 comments · Fixed by #4781

Comments

@ihabunek
Copy link

Running any Textual app in a Kitty terminal will leave it not fully functional.

Most obviously, less does not work, pressing down does not make text scroll. I used less some_long_file.txt to test.

To reproduce, run any textual app like this one:

from textual.app import App
from textual.widgets import Label


class ReproApp(App):
    def compose(self):
        yield Label("hello world")


if __name__ == "__main__":
    app = ReproApp()
    app.run()

Exit with Ctrl+C. Terminal is now broken. Running reset fixes the terminal.

Textual Diagnostics

Versions

Name Value
Textual 0.72.0
Rich 13.7.1

Python

Name Value
Version 3.12.4
Implementation CPython
Compiler GCC 14.1.1 20240607 (Red Hat 14.1.1-5)
Executable /home/ihabunek/.virtualenvs/pgtui/bin/python

Operating System

Name Value
System Linux
Release 6.9.5-200.fc40.x86_64
Version #1 SMP PREEMPT_DYNAMIC Sun Jun 16 15:47:09 UTC 2024

Terminal

Name Value
Terminal Application Kitty
TERM xterm-kitty
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=91, height=48
legacy_windows False
min_width 1
max_width 91
is_terminal False
encoding utf-8
max_height 48
justify None
overflow None
no_wrap False
highlight None
markup None
height None
Copy link

We found the following entries in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@TomJGooding
Copy link
Contributor

After running a few quick tests I suspect this may be related to the Kitty key protocol support added in #4631.

From https://sw.kovidgoyal.net/kitty/keyboard-protocol/:

Emit the escape sequence CSI < u at application exit if using the main screen or just before leaving alternate screen mode if using the alternate screen [emphasis mine]

Perhaps the fix is as simple as changing the order here?

# Alt screen false, show cursor
self.write("\x1b[?1049l")
self.write("\x1b[?25h")
self.write("\x1b[?1004l") # Disable FocusIn/FocusOut.
self.write(
"\x1b[<u"
) # Disable https://sw.kovidgoyal.net/kitty/keyboard-protocol/
self.flush()

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

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

Successfully merging a pull request may close this issue.

2 participants