gh-151774: Add curses dynamic color-pair functions#151775
Open
serhiy-storchaka wants to merge 1 commit into
Open
gh-151774: Add curses dynamic color-pair functions#151775serhiy-storchaka wants to merge 1 commit into
serhiy-storchaka wants to merge 1 commit into
Conversation
Add alloc_pair(), find_pair(), free_pair() and reset_color_pairs(), wrapping the ncurses extended-color dynamic pair management. They are available only when built against a wide-character ncurses with extended-color support. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Documentation build overview
|
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.
Wrap the ncurses extended-color dynamic color-pair management, which the standard :mod:
cursesfunctions cannot express:curses.alloc_pair(fg, bg)allocates a color pair for the given foreground and background colors and returns its number, reusing an existing pair for the same combination. Unlikeinit_pair(), the caller does not choose the pair number.curses.find_pair(fg, bg)returns the number of an already-allocated pair for the given colors, or-1if none has been allocated (the inverse ofpair_content()).curses.free_pair(pair)releases a pair previously allocated byalloc_pair().curses.reset_color_pairs()discards all color-pair definitions at once.All four are available only when Python is built against a wide-character ncurses with extended-color support (the same condition as
curses.has_extended_color_support()).The already-wrapped
init_color/init_pair/color_content/pair_contentalready route to the*_extended_*variants internally, so those extended functions are not exposed under separate names; only the dynamic pair-management functions above add new capability.🤖 Generated with Claude Code