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

Detecting NCKEY_RESIZE via Python Bindings #2817

Open
dcontiveros opened this issue Dec 13, 2024 · 0 comments
Open

Detecting NCKEY_RESIZE via Python Bindings #2817

dcontiveros opened this issue Dec 13, 2024 · 0 comments
Labels
userquestion not quite bugs--inquiries from users

Comments

@dcontiveros
Copy link

dcontiveros commented Dec 13, 2024

Hello,

Getting started with this library and running into some issues. I want to be able to capture NCKEY_RESIZE event in order to let my app know the terminal has been resized. My code does not appear to be working. I have simplified the code as follows:

import notcurses as nc
import sys

def main():
    nc_obj = nc.Notcurses()
    try:
        std_plane = nc_obj.stdplane()
        std_plane.putstr("Resize the terminal to see the event. Press any key to exit.")
        nc_obj.render()
        while True:
            # Wait for an event
            key_event = nc_obj.get(None)

            if key_event is not None:
                # Check if it's a resize event
                if key_event.id == nc.NCKEY_RESIZE:
                    std_plane.erase()
                    std_plane.putstr("Terminal resized! Press any key to exit.")
                    nc_obj.render()
                else:
                    # Exit on any other key press
                    break
    except:
        print("ERROR")
        sys.exit(0)

if __name__ == "__main__":
    main()

Intended behavior: I resize the terminal and see the Terminal resized! Press any key to exit. confirmation.

Observed behavior: Nothing happens

Please include the following data:

  • export | egrep 'LANG|LC_CTYPE|TERM'
COLORTERM=truecolor
LANG=en_US.UTF-8
TERM=xterm-kitty
TERMINFO=/Applications/kitty.app/Contents/Resources/kitty/terminfo
  • notcurses version (available from notcurses-demo i)
$ python 000-print-version.py 
3.0.11
  • terminal name + version
    Kitty Version 0.37.0 (0.37.0)
@dcontiveros dcontiveros added the userquestion not quite bugs--inquiries from users label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
userquestion not quite bugs--inquiries from users
Projects
None yet
Development

No branches or pull requests

1 participant