gh-90092: Support multiple terminals in the curses module#151748
Open
serhiy-storchaka wants to merge 2 commits into
Open
gh-90092: Support multiple terminals in the curses module#151748serhiy-storchaka wants to merge 2 commits into
serhiy-storchaka wants to merge 2 commits into
Conversation
Add the X/Open Curses SCREEN API for driving more than one terminal: newterm() and set_term(), plus the ncurses extension new_prescr(). A new screen object wraps the C SCREEN. It exposes the terminal's standard window as screen.stdscr. Each window keeps a reference to its screen (like a subwindow does to its parent window), so the screen is deleted automatically once it and all of its windows are unreferenced. The ncurses use_screen()/use_window() locking helpers are exposed as the screen.use() and window.use() methods. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Documentation build overview
|
| that can be used to call functions that affect global state | ||
| before :func:`initscr` or :func:`newterm` is called. | ||
|
|
||
| Availability: if the underlying curses library provides ``new_prescr()``. |
Member
There was a problem hiding this comment.
Should we not be using the directive?
Member
Author
There was a problem hiding this comment.
No, it only supports limited set of OS names.
Member
Author
|
Doc failures require merging #151643 first. |
ScreenTests drives curses over a pseudo-terminal whose master was never read. On macOS (and other BSD-derived platforms) the tcdrain() that curses performs inside endwin() blocks until the master side is read, so the test hung until the timeout; Linux does not block there. Drain each pty master in a background daemon thread, joined (with a timeout) once both ends are closed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add the X/Open Curses SCREEN API for driving more than one terminal:
curses.newterm()andcurses.set_term(), plus the ncurses extensioncurses.new_prescr().A new
screenobject wraps the CSCREENand exposes the terminal's standard window asscreen.stdscr. Each window keeps a reference to its screen (like a subwindow does to its parent window), so a screen is freed automatically once it and all of its windows are unreferenced.delscreen()is deferred to the screen object's deallocation rather than itstp_clear, so it runs only after the screen's windows — and any panels built on them — are gone.The ncurses
use_screen()/use_window()locking helpers are exposed as thescreen.use()andwindow.use()methods, forwarding*argsand**kwargsto the callable.ScreenTestsnow run in-process over pseudo-terminals instead of subprocesses, andTestCursesdrives anewterm()screen, so the new API is exercised without needing a second real terminal.🤖 Generated with Claude Code