Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add curses window attribute get/set methods and WA_* constants #152219

Description

@serhiy-storchaka

Feature or enhancement

Feature or enhancement

The curses module wraps the legacy attron()/attroff()/attrset() functions, which take a chtype (where the color pair is packed into the value via COLOR_PAIR()), but it does not expose the X/Open attr_t-based family that passes the color pair as a separate argument:

  • wattr_get() / wattr_set()
  • wattr_on() / wattr_off()
  • wcolor_set()

These are the modern, recommended forms: they keep the attribute bits (A_* / WA_*) and the color pair separate, which is what cchar_t-based wide-character output (add_wch() etc.) already uses internally. The legacy functions also can't address color pairs above 255 without the pair number colliding with the attribute bits.

This issue proposes adding the corresponding window methods:

  • window.attr_get()(attributes, pair) — current attribute bits and color pair
  • window.attr_set(attr, pair=0) — set attribute bits and color pair
  • window.attr_on(attr) — turn attribute bits on
  • window.attr_off(attr) — turn attribute bits off
  • window.color_set(pair) — set just the color pair

and the associated WA_* attribute constants (WA_NORMAL, WA_BOLD, WA_UNDERLINE, WA_REVERSE, WA_BLINK, WA_DIM, WA_STANDOUT, WA_ALTCHARSET, WA_INVIS, WA_PROTECT, WA_ITALIC, WA_HORIZONTAL, WA_LEFT, WA_LOW, WA_RIGHT, WA_TOP, WA_VERTICAL, WA_ATTRIBUTES), each guarded by #ifdef for portability. On ncurses the WA_* values are bit-identical to the matching A_* values.

The color_set part overlaps with the long-standing gh-49618 (which also asks for the unrelated addchstr family); this issue scopes the attribute get/set surface specifically.

Linked PRs

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-featureA feature request or enhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions