From 56372b760e1dd81e076e2e0297b89fad2c15cad7 Mon Sep 17 00:00:00 2001 From: Xiang Zhang Date: Thu, 27 Apr 2017 00:07:43 +0800 Subject: [PATCH 1/4] add missing curses cell attributes constants --- Doc/library/curses.rst | 28 +++++++++++++++++++++++++++- Modules/_cursesmodule.c | 8 +++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Doc/library/curses.rst b/Doc/library/curses.rst index 8e509d50e648d4..4a5f9e2d5a0f95 100644 --- a/Doc/library/curses.rst +++ b/Doc/library/curses.rst @@ -1271,11 +1271,15 @@ The :mod:`curses` module defines the following data members: A string representing the current version of the module. Also available as :const:`__version__`. -Several constants are available to specify character cell attributes: +Some constants are available to specify character cell attributes. +The exact constants available are system dependent. +------------------+-------------------------------+ | Attribute | Meaning | +==================+===============================+ +| ``A_ATTRIBUTES`` | Bit-mask to extract | +| | attributes | ++------------------+-------------------------------+ | ``A_ALTCHARSET`` | Alternate character set mode. | +------------------+-------------------------------+ | ``A_BLINK`` | Blink mode. | @@ -1286,6 +1290,16 @@ Several constants are available to specify character cell attributes: +------------------+-------------------------------+ | ``A_DIM`` | Dim mode. | +------------------+-------------------------------+ +| ``A_INVIS`` | Invisible or blank mode | ++------------------+-------------------------------+ +| ``A_PROTECT`` | Protected mode | ++------------------+-------------------------------+ +| ``A_CHARTEXT`` | Bit-mask to extract a | +| | character | ++------------------+-------------------------------+ +| ``A_COLOR`` | Bit-mask to extract | +| | color-pair field information | ++------------------+-------------------------------+ | ``A_NORMAL`` | Normal attribute. | +------------------+-------------------------------+ | ``A_REVERSE`` | Reverse background and | @@ -1295,6 +1309,18 @@ Several constants are available to specify character cell attributes: +------------------+-------------------------------+ | ``A_UNDERLINE`` | Underline mode. | +------------------+-------------------------------+ +| ``A_HORIZONTAL`` | Horizontal highlight | ++------------------+-------------------------------+ +| ``A_LEFT`` | Left highlight | ++------------------+-------------------------------+ +| ``A_LOW`` | Low highlight | ++------------------+-------------------------------+ +| ``A_RIGHT`` | Right highlight | ++------------------+-------------------------------+ +| ``A_TOP`` | Top highlight | ++------------------+-------------------------------+ +| ``A_VERTICAL`` | Vertical highlight | ++------------------+-------------------------------+ .. versionadded:: 3.7 ``A_ITALIC`` was added. diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index f278268e6702ab..5dc0865c1c4dda 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -3335,9 +3335,6 @@ PyInit__curses(void) SetDictInt("A_BLINK", A_BLINK); SetDictInt("A_DIM", A_DIM); SetDictInt("A_BOLD", A_BOLD); -#ifdef A_ITALIC - SetDictInt("A_ITALIC", A_ITALIC); -#endif SetDictInt("A_ALTCHARSET", A_ALTCHARSET); #if !defined(__NetBSD__) SetDictInt("A_INVIS", A_INVIS); @@ -3366,6 +3363,11 @@ PyInit__curses(void) SetDictInt("A_VERTICAL", A_VERTICAL); #endif + /* ncurses extension */ +#ifdef A_ITALIC + SetDictInt("A_ITALIC", A_ITALIC); +#endif + SetDictInt("COLOR_BLACK", COLOR_BLACK); SetDictInt("COLOR_RED", COLOR_RED); SetDictInt("COLOR_GREEN", COLOR_GREEN); From 06d308c9b56a6a20550d733116c84b1636924ede Mon Sep 17 00:00:00 2001 From: Xiang Zhang Date: Thu, 27 Apr 2017 01:31:34 +0800 Subject: [PATCH 2/4] group and reorder --- Doc/library/curses.rst | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Doc/library/curses.rst b/Doc/library/curses.rst index 4a5f9e2d5a0f95..324fcd21e4f3cb 100644 --- a/Doc/library/curses.rst +++ b/Doc/library/curses.rst @@ -1280,34 +1280,34 @@ The exact constants available are system dependent. | ``A_ATTRIBUTES`` | Bit-mask to extract | | | attributes | +------------------+-------------------------------+ -| ``A_ALTCHARSET`` | Alternate character set mode. | +| ``A_CHARTEXT`` | Bit-mask to extract a | +| | character | +------------------+-------------------------------+ -| ``A_BLINK`` | Blink mode. | +| ``A_COLOR`` | Bit-mask to extract | +| | color-pair field information | +------------------+-------------------------------+ -| ``A_BOLD`` | Bold mode. | +| ``A_ALTCHARSET`` | Alternate character set mode | +------------------+-------------------------------+ -| ``A_ITALIC`` | Italic mode. | +| ``A_BLINK`` | Blink mode | +------------------+-------------------------------+ -| ``A_DIM`` | Dim mode. | +| ``A_BOLD`` | Bold mode | +------------------+-------------------------------+ -| ``A_INVIS`` | Invisible or blank mode | +| ``A_DIM`` | Dim mode | +------------------+-------------------------------+ -| ``A_PROTECT`` | Protected mode | +| ``A_INVIS`` | Invisible or blank mode | +------------------+-------------------------------+ -| ``A_CHARTEXT`` | Bit-mask to extract a | -| | character | +| ``A_ITALIC`` | Italic mode | +------------------+-------------------------------+ -| ``A_COLOR`` | Bit-mask to extract | -| | color-pair field information | +| ``A_NORMAL`` | Normal attribute | +------------------+-------------------------------+ -| ``A_NORMAL`` | Normal attribute. | +| ``A_PROTECT`` | Protected mode | +------------------+-------------------------------+ | ``A_REVERSE`` | Reverse background and | -| | foreground colors. | +| | foreground colors | +------------------+-------------------------------+ -| ``A_STANDOUT`` | Standout mode. | +| ``A_STANDOUT`` | Standout mode | +------------------+-------------------------------+ -| ``A_UNDERLINE`` | Underline mode. | +| ``A_UNDERLINE`` | Underline mode | +------------------+-------------------------------+ | ``A_HORIZONTAL`` | Horizontal highlight | +------------------+-------------------------------+ From 56add73e6702ab7b362c18cb4cfa815b2f2a7380 Mon Sep 17 00:00:00 2001 From: Xiang Zhang Date: Thu, 27 Apr 2017 10:49:07 +0800 Subject: [PATCH 3/4] separate bit-masks --- Doc/library/curses.rst | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/Doc/library/curses.rst b/Doc/library/curses.rst index 324fcd21e4f3cb..2fd4329db1db81 100644 --- a/Doc/library/curses.rst +++ b/Doc/library/curses.rst @@ -1277,15 +1277,6 @@ The exact constants available are system dependent. +------------------+-------------------------------+ | Attribute | Meaning | +==================+===============================+ -| ``A_ATTRIBUTES`` | Bit-mask to extract | -| | attributes | -+------------------+-------------------------------+ -| ``A_CHARTEXT`` | Bit-mask to extract a | -| | character | -+------------------+-------------------------------+ -| ``A_COLOR`` | Bit-mask to extract | -| | color-pair field information | -+------------------+-------------------------------+ | ``A_ALTCHARSET`` | Alternate character set mode | +------------------+-------------------------------+ | ``A_BLINK`` | Blink mode | @@ -1321,10 +1312,29 @@ The exact constants available are system dependent. +------------------+-------------------------------+ | ``A_VERTICAL`` | Vertical highlight | +------------------+-------------------------------+ +| ``A_CHARTEXT`` | Bit-mask to extract a | +| | character | ++------------------+-------------------------------+ .. versionadded:: 3.7 ``A_ITALIC`` was added. +Several constants are available to extract corresponding attributes returned +by some methods. + ++------------------+-------------------------------+ +| Bit-mask | Meaning | ++==================+===============================+ +| ``A_ATTRIBUTES`` | Bit-mask to extract | +| | attributes | ++------------------+-------------------------------+ +| ``A_CHARTEXT`` | Bit-mask to extract a | +| | character | ++------------------+-------------------------------+ +| ``A_COLOR`` | Bit-mask to extract | +| | color-pair field information | ++------------------+-------------------------------+ + Keys are referred to by integer constants with names starting with ``KEY_``. The exact keycaps available are system dependent. From a0c8c454c29c30fe0824617cfc94444c4da169ea Mon Sep 17 00:00:00 2001 From: Xiang Zhang Date: Thu, 27 Apr 2017 10:51:14 +0800 Subject: [PATCH 4/4] add NEWS entry --- Misc/NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 71db0ee46b0dc4..ee8a833848c7dc 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -984,6 +984,8 @@ C API Documentation ------------- +- bpo-30176: Add missing attribute related constants in curses documentation. + - bpo-26985: Add missing info of code object in inspect documentation. - bpo-19824, bpo-20314, bpo-12518: Improve the documentation for, and links