Skip to content

Commit d831a69

Browse files
gh-87881: Document the result of curses inch() and getbkgd() (GH-152488)
Explain the character/attribute bit layout and how to extract the parts (A_CHARTEXT and A_ATTRIBUTES bit-masks, pair_number() for the color pair), or use in_wch() to get a complexchar. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 499d31f commit d831a69

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Doc/library/curses.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,7 @@ Window objects
13321332
.. method:: window.getbkgd()
13331333

13341334
Return the given window's current background character/attribute pair.
1335+
Its components can be extracted like those of :meth:`inch`.
13351336
It cannot represent a background set with a wide character or with a color
13361337
pair outside the :func:`color_pair` range; use :meth:`getbkgrnd` for those.
13371338

@@ -1486,11 +1487,13 @@ Window objects
14861487

14871488
.. method:: window.inch([y, x])
14881489

1489-
Return the character at the given position in the window. The bottom 8 bits are
1490-
the character proper, and upper bits are the attributes.
1490+
Return the character at the given position in the window.
1491+
The bottom 8 bits are the character proper and the upper bits are the attributes;
1492+
extract them with the :data:`A_CHARTEXT` and :data:`A_ATTRIBUTES` bit-masks,
1493+
and the color pair with :func:`pair_number`.
14911494
It cannot represent a cell holding combining characters, a character that does
14921495
not fit in a single byte, or a color pair outside the :func:`color_pair`
1493-
range; use :meth:`in_wch` for those.
1496+
range; use :meth:`in_wch` for those, which returns it as a :class:`complexchar`.
14941497

14951498

14961499
.. method:: window.in_wch([y, x])

0 commit comments

Comments
 (0)