gh-152219: Add curses window attribute get/set methods and WA_* constants#152221
Open
serhiy-storchaka wants to merge 1 commit into
Open
gh-152219: Add curses window attribute get/set methods and WA_* constants#152221serhiy-storchaka wants to merge 1 commit into
serhiy-storchaka wants to merge 1 commit into
Conversation
… constants Add the window methods attr_get(), attr_set(), attr_on(), attr_off() and color_set(), wrapping wattr_get(), wattr_set(), wattr_on(), wattr_off() and wcolor_set(). Unlike the legacy attron()/attroff()/attrset() methods, these pass the color pair as a separate argument instead of packing it into the attribute value. Also add the corresponding WA_* attribute constants. Add an attr_converter that range-checks the attr_t attribute argument and raises OverflowError instead of silently truncating it; apply it to attr_set(), attr_on(), attr_off() and chgat(). Co-Authored-By: Claude Opus 4.8 <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.
Add the
curseswindow methodsattr_get(),attr_set(),attr_on(),attr_off()andcolor_set(), wrappingwattr_get(),wattr_set(),wattr_on(),wattr_off()andwcolor_set().Unlike the legacy
attron()/attroff()/attrset()methods, which take achtypewith the color pair packed in viaCOLOR_PAIR(), these pass the color pair as a separate argument. This is the form used internally by thecchar_t-based wide-character output, and it can address color pairs beyond 255 without colliding with the attribute bits.Also add the corresponding
WA_*attribute constants (WA_NORMAL,WA_BOLD,WA_UNDERLINE,WA_REVERSE,WA_BLINK,WA_DIM,WA_STANDOUT,WA_ALTCHARSET,WA_INVIS,WA_PROTECT,WA_ITALICand the placement constants), each guarded by#ifdef. On ncurses they are bit-identical to the matchingA_*values.This PR adds an
attr_converterthat range-checks theattr_targument and raisesOverflowErrorinstead of silently truncating; it is applied toattr_set(),attr_on(),attr_off()andchgat(). A converter for thechtype-style methods (addch,bkgd,hline, etc.) is left for a separate issue.