Skip to content

Commit 90db9bb

Browse files
gh-138071: Clarify curses.color_pair doc about style vs extraction masks
1 parent 3706ef6 commit 90db9bb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Doc/library/curses.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,15 @@ The module :mod:`curses` defines the following functions:
122122
.. function:: color_pair(pair_number)
123123

124124
Return the attribute value for displaying text in the specified color pair.
125-
Only the first 256 color pairs are supported. This
126-
attribute value can be combined with :const:`A_STANDOUT`, :const:`A_REVERSE`,
127-
and the other :const:`!A_\*` attributes. :func:`pair_number` is the counterpart
128-
to this function.
125+
Only the first 256 color pairs are supported. The value returned by
126+
``color_pair(n)`` is an attribute mask. It can be combined (using bitwise OR, ``|``)
127+
with other style attributes such as :const:`A_BOLD`, :const:`A_REVERSE`,
128+
:const:`A_UNDERLINE`, etc. Note that :const:`A_COLOR`, :const:`A_ATTRIBUTES`,
129+
and :const:`A_CHARTEXT` are extraction masks used with bitwise AND (``&``) on
130+
values returned from functions like :meth:`window.inch`. They are not style
131+
attributes and must not be combined with :func:`color_pair`. :func:`pair_number`
132+
is the counterpart to this function.
133+
129134

130135

131136
.. function:: curs_set(visibility)

0 commit comments

Comments
 (0)