prompt-toolkit / prompt-toolkit/python-prompt-toolkit

Resizing when the application is in a background thread

Open
#636 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

First of all, thanks for making prompt_toolkit available. It's been tremendously useful.

We are working on a small terminal-based full screen application. At the moment, our
app does not handle changes to the terminal size correctly. This appears (as far as I understand) to be because the prompt toolkit application runs in a background thread (source)
and prompt_toolkit only handles SIGWINCH signals if the application is running in the main thread.

Obviously, there are workarounds: we can handle SIGWINCH signals directly and just run app.invalidate(), but we aren't sure whether that's the right thing to do. We had the following questions:

  • Any reason why handling SIGWINCH by calling app.invalidate() would be a bad idea?
  • Why restrict handling resizes to when the application is in the main thread?
  • Should our application be running in the main thread?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading prompt_toolkit/application/application.py around the SIGWINCH handling cited in the issue, then compare it with the background-thread usage in sml_sync/ui.py. Check how app.invalidate() relates to terminal resize handling and determine the supported behavior for applications running outside the main thread. Done means the resize behavior and recommended approach are clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.