Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
e1d4001
Use new test.support helper submodules in tests
shihai1991 Jul 12, 2020
104060d
remove unused module
shihai1991 Jul 12, 2020
62a6061
Merge branch 'master' into bpo_40275_helper_replace_13
shihai1991 Jul 12, 2020
bc385bc
bpo-20181: Convert the readline module to the Argument Clinic (#14326)
ZackerySpytz Jul 12, 2020
bc3d804
bpo-20175: Convert Modules/_multiprocessing to the Argument Clinic (G…
ZackerySpytz Jul 12, 2020
c2819d3
bpo-41146: Convert signal.default_int_handler() to Argument Clinic (G…
serhiy-storchaka Jul 12, 2020
26c9c70
bpo-41288: Fix a crash in unpickling invalid NEWOBJ_EX. (GH-21458)
serhiy-storchaka Jul 13, 2020
56c4331
bpo-32192: A basic lazy importer example (GH-21330)
nanjekyejoannah Jul 13, 2020
170a8a8
Fix repeated words in Classes tutorial (GH-21455)
PaulMcMillan Jul 14, 2020
b3aef83
bpo-32528: Document the change in inheritance of asyncio.CancelledErr…
JustAnotherArchivist Jul 14, 2020
a2d9d5d
bpo-41273: asyncio's proactor read transport's better performance by …
tontinton Jul 14, 2020
0675e5f
bpo-20183: Convert _locale to the Argument Clinic (GH-14201)
ZackerySpytz Jul 15, 2020
3c3411b
bpo-39017: Avoid infinite loop in the tarfile module (GH-21454)
rishi93 Jul 15, 2020
f25bfa2
bpo-41302: Fix build with system libmpdec (GH-21481)
felixonmars Jul 15, 2020
bde9b72
Fix -Wstrict-prototypes warning in thread_pthread.h. (GH-21477)
benjaminp Jul 15, 2020
cddbe8e
Fix -Wstring-prototypes warnings in _zoneinfo.c. (GH-21478)
benjaminp Jul 15, 2020
6d537b4
bpo-40150: Fix mismatched argument in RegisterWaitForSingleObject() c…
ZackerySpytz Jul 15, 2020
9f11bcc
bpo-41304: Ensure python3x._pth is loaded on Windows (GH-21495)
zooba Jul 15, 2020
5303bf8
bpo-31844: Remove _markupbase.ParserBase.error() (GH-8562)
berkerpeksag Jul 16, 2020
6ecd55a
bpo-31844: Move whatsnew note to 3.10.rst (GH-21504)
berkerpeksag Jul 16, 2020
4b9dfef
Remove unnecessary spaces in code blocks in urllib.parse.rst (GH-21500)
chrisyeh96 Jul 16, 2020
f2197cb
Fix possibly-unitialized warning in string_parser.c. (GH-21503)
benjaminp Jul 16, 2020
e57f75d
Fix trivial typo in the PEG string parser (GH-21508)
ericvsmith Jul 16, 2020
1349c97
bpo-41300: IDLE - save files with non-ascii chars (GH-21512)
terryjreedy Jul 16, 2020
ee26dc3
bpo-41195: Add getter for Openssl security level (GH-21282)
matthewhughes934 Jul 17, 2020
4134617
bpo-40941: Unify implicit and explicit state in the frame and generat…
markshannon Jul 17, 2020
d9f6d8b
bpo-43104: Update NEWS to include CVE-2020-15801 reference (GH-21521)
zooba Jul 17, 2020
19141a1
Fix a small grammatical mistake in a comment (GH-21526)
brettcannon Jul 17, 2020
61feac4
bpo-41288: Refactor of unpickling NEWOBJ and NEWOBJ_EX opcodes. (GH-2…
serhiy-storchaka Jul 18, 2020
77c28b1
bpo-41262: Convert memoryview to Argument Clinic. (GH-21421)
serhiy-storchaka Jul 18, 2020
5837652
bpo-41325: Add version note for args and kwargs property in call obje…
uSpike Jul 18, 2020
d6258af
bpo-39603: Prevent header injection in http methods (GH-18485)
amiremohamadi Jul 18, 2020
f0d0237
bpo-41295: Reimplement the Carlo Verre "hackcheck" (GH-21528)
scoder Jul 18, 2020
6f297a3
bpo-41333: Convert OrderedDict.pop() to Argument Clinic (GH-21534)
serhiy-storchaka Jul 19, 2020
de846a1
bpo-41205: Document Decimal power 0 to the 0 (GH-21386)
srinivasreddy Jul 19, 2020
ebbe4cf
bpo-38169: Increase code coverage for SharedMemory and ShareableList …
vinay0410 Jul 19, 2020
36a8204
bpo-41338: Fix DeprecationWarning in tests (GH-21542)
methane Jul 20, 2020
fed528f
bpo-40741: Update macOS installer to use SQLite 3.32.3 (GH-20979)
Jul 20, 2020
9264f19
Doc: fix import of asdl.py when called from outside Doc/. (GH-21529)
JulienPalard Jul 20, 2020
a2425a2
bpo-37703: improve asyncio.gather documentation regarding cancellatio…
vinay0410 Jul 20, 2020
833cd79
Simple Documentation fix: Missing link to return type class. (GH-21291)
Volker-Weissmann Jul 20, 2020
185ac7d
bpo-41336: Fix the error handling in zoneinfo_new_instance() (GH-21546)
ZackerySpytz Jul 20, 2020
ca8d63e
bpo-41343: Convert methods of complex to Argument Clinic (GH-21550)
corona10 Jul 20, 2020
93ccf70
bpo-41334: Convert constructors of str, bytes and bytearray to Argume…
serhiy-storchaka Jul 20, 2020
a597f0a
bpo-41342: Convert int.__round__ to Argument Clinic (GH-21549)
serhiy-storchaka Jul 20, 2020
ccbc2bc
bpo-40741: Update Windows build to include SQLite 3.32.3 (GH-21570)
zooba Jul 20, 2020
1bf47e5
bpo-41283: Fix mismatched argument name for imghdr.what (GH-21501)
ammaraskar Jul 21, 2020
808203d
bpo-41364: Reduce import overhead of uuid module (GH-21586)
zooba Jul 21, 2020
f766adc
bpo-41341: Recursive evaluation of ForwardRef in get_type_hints (#21553)
wyfo Jul 22, 2020
4ce1885
bpo-41369 Update to libmpdec-2.5.1: new features (GH-21593)
skrah Jul 22, 2020
e45c083
Stick with the phrase "default parameter value" (GH-21590)
andresdelfino Jul 22, 2020
b1bac9c
bpo-41182 selector: use DefaultSelector based upon implementation (GH…
Akasurde Jul 23, 2020
b5ffc5c
bpo-4630: Fix errors in Lib/idlelib/NEWS.txt (GH-21594)
ZackerySpytz Jul 23, 2020
5a7e588
bpo-41366: Fix clang warning for sign conversion (GH-21592)
henryiii Jul 23, 2020
e89752d
bpo-41317: Remove reader on cancellation in asyncio.loop.sock_accept(…
agronholm Jul 23, 2020
aaac3b5
bpo-41373: IDLE: Fix saving files loaded with no newlines or mixed ne…
serhiy-storchaka Jul 25, 2020
0454fd7
bpo-37309: NEWS for #41373 (GH-21612)
terryjreedy Jul 25, 2020
b9063e5
bpo-38731: Add --quiet option to py_compile CLI (GH-17134)
gvsheva Jul 25, 2020
1ca7578
bpo-41314: fixed annotations __future__ version (GH-21616)
YoSTEALTH Jul 25, 2020
004e82b
bpo-39868: Add documentation for Assignment Expressions (walrus, PEP …
shankarj67 Jul 25, 2020
d481884
bpo-41385: Fix test_executable_without_cwd on Windows (GH-21608)
serhiy-storchaka Jul 26, 2020
3b83635
Delete remaining references to Grammar/Grammar from docs (#21624)
gvanrossum Jul 26, 2020
505d16d
Fix atexitmodule doc (GH-21456)
linchiwei123 Jul 26, 2020
36457bb
bpo-41384: Raise TclError in tkinter.OptionMenu (GH-21601)
Akuli Jul 27, 2020
e93448a
bpo-41340: Removed fallback implementation for strdup (GH-21634)
Jul 27, 2020
d2b0cab
bpo-31904: Fix test_ftplib failures for VxWorks RTOS (GH-19447)
pxinwr Jul 27, 2020
aa7c22e
bpo-41401: Fix test_fspath_support in test_io. (GH-21640)
serhiy-storchaka Jul 27, 2020
ae085b1
bpo-40939: Use the new grammar for the grammar specification document…
pablogsal Jul 27, 2020
dbdeaa2
bpo-40939: Remove even more references to the old parser (GH-21642)
lysnikolaou Jul 27, 2020
68732c1
bpo-41045: Document debug feature of f-strings ('=') (GH-21509)
amaajemyfren Jul 27, 2020
d00400d
Validate the AST produced by the parser in debug mode (GH-21643)
pablogsal Jul 27, 2020
f45a004
bpo-35328: Set VIRTUAL_ENV_PROMPT at venv activation (GH-21587)
ZackerySpytz Jul 28, 2020
7655ae8
bpo-41328: Replace mention of Hudson CI with Travis CI and AppVeyor (…
Jul 28, 2020
97ac216
bpo-41412 and bpo-40948: Windows installer updates (GH-21656)
zooba Jul 28, 2020
7fff0da
Fix `List_Append` description, list is extracted at TOS1[-i] (GH-21465)
zhangyangyu Jul 28, 2020
fa966e2
Remove incorrect mention of method.__class__ in descriptor docs (GH-2…
Jongy Jul 28, 2020
744a9c5
closes bpo-38156: Always handle interrupts in PyOS_StdioReadline. (GH…
benjaminp Jul 29, 2020
953733b
bpo-41426 Fix grammar in curses.getmouse() documentation (GH-21677)
s3bw Jul 29, 2020
2c6db7b
bpo-41323: Perform 'peephole' optimizations directly on the CFG. (GH-…
markshannon Jul 30, 2020
88c59f6
bpo-40360: Handle PendingDeprecationWarning in test_lib2to3. (GH-21694)
tirkarthi Jul 31, 2020
b9c5c17
bpo-41421: Algebraic simplification for random.paretovariate() (GH-21…
rhettinger Aug 1, 2020
577fbbd
random module: Convert a "while 1" to "while True (GH-21700)
rhettinger Aug 2, 2020
51a9b9e
bpo-40979: refactored typing.rst; (mostly) same content, new sub-sect…
ramalho Aug 2, 2020
dd7378e
bpo-41424: Remove extra words in Tkinter-Packer documentation (GH-21707)
nmaynes Aug 3, 2020
78aeea9
bpo-41425: Make tkinter doc example runnable (GH-21706)
nerandell Aug 3, 2020
2edc37a
A (very) slight speed improvement for iterating over bytes (#21705)
gvanrossum Aug 3, 2020
d23a13f
bpo-40275: Use new test.support helper submodules in tests (GH-21449)
shihai1991 Aug 3, 2020
f491296
bpo-40275: Use new test.support helper submodules in tests (GH-21451)
shihai1991 Aug 3, 2020
7ad643a
bpo-40275: Use new test.support helper submodules in tests (GH-21448)
shihai1991 Aug 3, 2020
4c461ad
bpo-38912: regrtest logs unraisable exception into sys.__stderr__ (GH…
vstinner Aug 3, 2020
587f073
bpo-38156: Fix compiler warning in PyOS_StdioReadline() (GH-21721)
vstinner Aug 4, 2020
11c2ff2
bpo-41467: Fix asyncio recv_into() on Windows (GH-21720)
vstinner Aug 4, 2020
58220f0
bpo-41431: Optimize dict_merge for copy (GH-21674)
methane Aug 4, 2020
b568ebb
bpo-36982: Add support for extended color functions in ncurses 6.1 (G…
hpjansson Aug 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
bpo-36982: Add support for extended color functions in ncurses 6.1 (G…
…H-17536)

Co-authored-by: Jeffrey Kintscher <websurfer@surf2c.net>
  • Loading branch information
2 people authored and shihai1991 committed Aug 4, 2020
commit b568ebbbca9276bd3906c7fdedfea63d05729f2f
9 changes: 9 additions & 0 deletions Doc/library/curses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ The module :mod:`curses` defines the following functions:

Return ``True`` if the terminal can display colors; otherwise, return ``False``.

.. function:: has_extended_color_support()

Return ``True`` if the module supports extended colors; otherwise, return
``False``. Extended color support allows more than 256 color pairs for
terminals that support more than 16 colors (e.g. xterm-256color).

Extended color support requires ncurses version 6.1 or later.

.. versionadded:: 3.10

.. function:: has_ic()

Expand Down
10 changes: 10 additions & 0 deletions Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ New Modules
Improved Modules
================

curses
------

The extended color functions added in ncurses 6.1 will be used transparently
by :func:`curses.color_content`, :func:`curses.init_color`,
:func:`curses.init_pair`, and :func:`curses.pair_content`. A new function,
:func:`curses.has_extended_color_support`, indicates whether extended color
support is provided by the underlying ncurses library.
(Contributed by Jeffrey Kintscher and Hans Petter Jansson in :issue:`36982`.)

glob
----

Expand Down
16 changes: 15 additions & 1 deletion Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ def test_module_funcs(self):
curses.nocbreak, curses.noecho, curses.nonl,
curses.noqiflush, curses.noraw,
curses.reset_prog_mode, curses.termattrs,
curses.termname, curses.erasechar]:
curses.termname, curses.erasechar,
curses.has_extended_color_support]:
with self.subTest(func=func.__qualname__):
func()
if hasattr(curses, 'filter'):
Expand Down Expand Up @@ -293,6 +294,19 @@ def test_colors_funcs(self):
if hasattr(curses, 'use_default_colors'):
curses.use_default_colors()

self.assertRaises(ValueError, curses.color_content, -1)
self.assertRaises(ValueError, curses.color_content, curses.COLORS + 1)
self.assertRaises(ValueError, curses.color_content, -2**31 - 1)
self.assertRaises(ValueError, curses.color_content, 2**31)
self.assertRaises(ValueError, curses.color_content, -2**63 - 1)
self.assertRaises(ValueError, curses.color_content, 2**63 - 1)
self.assertRaises(ValueError, curses.pair_content, -1)
self.assertRaises(ValueError, curses.pair_content, curses.COLOR_PAIRS)
self.assertRaises(ValueError, curses.pair_content, -2**31 - 1)
self.assertRaises(ValueError, curses.pair_content, 2**31)
self.assertRaises(ValueError, curses.pair_content, -2**63 - 1)
self.assertRaises(ValueError, curses.pair_content, 2**63 - 1)

@requires_curses_func('keyname')
def test_keyname(self):
curses.keyname(13)
Expand Down
2 changes: 2 additions & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ Geert Jansen
Jack Jansen
Hans-Peter Jansen
Bill Janssen
Hans Petter Jansson
Jon Janzen
Thomas Jarosch
Juhana Jauhiainen
Expand Down Expand Up @@ -882,6 +883,7 @@ Sam Kimbrel
Tomohiko Kinebuchi
James King
W. Trevor King
Jeffrey Kintscher
Paul Kippes
Steve Kirsch
Sebastian Kirsche
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use ncurses extended color functions when available to support terminals with 256 colors, and add the new function :func:`curses.has_extended_color_support` to indicate whether extended color support is provided by the underlying ncurses library.
194 changes: 166 additions & 28 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,31 @@ typedef chtype attr_t; /* No attr_t type is available */
#define STRICT_SYSV_CURSES
#endif

#if defined(NCURSES_EXT_COLORS) && defined(NCURSES_EXT_FUNCS)
#define _NCURSES_EXTENDED_COLOR_FUNCS 1
#else
#define _NCURSES_EXTENDED_COLOR_FUNCS 0
#endif /* defined(NCURSES_EXT_COLORS) && defined(NCURSES_EXT_FUNCS) */

#if _NCURSES_EXTENDED_COLOR_FUNCS
#define _NCURSES_COLOR_VAL_TYPE int
#define _CURSES_INIT_COLOR_FUNC init_extended_color
#define _CURSES_INIT_PAIR_FUNC init_extended_pair
#define _COLOR_CONTENT_FUNC extended_color_content
#define _CURSES_PAIR_NUMBER_FUNC extended_pair_content
#else
#define _NCURSES_COLOR_VAL_TYPE short
#define _CURSES_INIT_COLOR_FUNC init_color
#define _CURSES_INIT_PAIR_FUNC init_pair
#define _COLOR_CONTENT_FUNC color_content
#define _CURSES_PAIR_NUMBER_FUNC pair_content
#endif /* _NCURSES_EXTENDED_COLOR_FUNCS */

#define _CURSES_FUNC_NAME_STR(s) #s

#define _CURSES_INIT_COLOR_FUNC_NAME _CURSES_FUNC_NAME_STR(_CURSES_INIT_COLOR_FUNC)
#define _CURSES_INIT_PAIR_FUNC_NAME _CURSES_FUNC_NAME_STR(_CURSES_INIT_PAIR_FUNC)

/*[clinic input]
module _curses
class _curses.window "PyCursesWindowObject *" "&PyCursesWindow_Type"
Expand Down Expand Up @@ -387,6 +412,104 @@ PyCurses_ConvertToString(PyCursesWindowObject *win, PyObject *obj,
return 0;
}

static int
color_converter(PyObject *arg, void *ptr)
{
long color_number;
int overflow;

color_number = PyLong_AsLongAndOverflow(arg, &overflow);
if (color_number == -1 && PyErr_Occurred())
return 0;

if (overflow > 0 || color_number > COLORS) {
PyErr_Format(PyExc_ValueError,
"Color number is greater than COLORS (%d).",
COLORS);
return 0;
}
else if (overflow < 0 || color_number < 0) {
PyErr_SetString(PyExc_ValueError,
"Color number is less than 0.");
return 0;
}

*(int *)ptr = (int)color_number;
return 1;
}

/*[python input]
class color_converter(CConverter):
type = 'int'
converter = 'color_converter'
[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=4260d2b6e66b3709]*/

static int
pair_converter(PyObject *arg, void *ptr)
{
long pair_number;
int overflow;

pair_number = PyLong_AsLongAndOverflow(arg, &overflow);
if (pair_number == -1 && PyErr_Occurred())
return 0;

if (overflow > 0 || pair_number > COLOR_PAIRS - 1) {
PyErr_Format(PyExc_ValueError,
"Color pair is greater than COLOR_PAIRS-1 (%d).",
COLOR_PAIRS - 1);
return 0;
}
else if (overflow < 0 || pair_number < 1) {
PyErr_SetString(PyExc_ValueError,
"Color pair is less than 1.");
return 0;
}

*(int *)ptr = (int)pair_number;
return 1;
}

/*[python input]
class pair_converter(CConverter):
type = 'int'
converter = 'pair_converter'
[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=1a918ae6a1b32af7]*/

static int
component_converter(PyObject *arg, void *ptr)
{
long component;
int overflow;

component = PyLong_AsLongAndOverflow(arg, &overflow);
if (component == -1 && PyErr_Occurred())
return 0;

if (overflow > 0 || component > 1000) {
PyErr_SetString(PyExc_ValueError,
"Color component is greater than 1000");
return 0;
}
else if (overflow < 0 || component < 0) {
PyErr_SetString(PyExc_ValueError,
"Color component is less than 0");
return 0;
}

*(short *)ptr = (short)component;
return 1;
}

/*[python input]
class component_converter(CConverter):
type = 'short'
converter = 'component_converter'
[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=38e9be01d33927fb]*/

/* Function versions of the 3 functions for testing whether curses has been
initialised or not. */

Expand Down Expand Up @@ -2585,7 +2708,7 @@ NoArgOrFlagNoReturnFunctionBody(cbreak, flag)
/*[clinic input]
_curses.color_content

color_number: short
color_number: color
The number of the color (0 - COLORS).
/

Expand All @@ -2596,15 +2719,15 @@ which will be between 0 (no component) and 1000 (maximum amount of component).
[clinic start generated code]*/

static PyObject *
_curses_color_content_impl(PyObject *module, short color_number)
/*[clinic end generated code: output=cb15cf3120d4bfc1 input=5555abb1c11e11b7]*/
_curses_color_content_impl(PyObject *module, int color_number)
/*[clinic end generated code: output=17b466df7054e0de input=c10ef58f694b13ee]*/
{
short r,g,b;
_NCURSES_COLOR_VAL_TYPE r,g,b;

PyCursesInitialised;
PyCursesInitialisedColor;

if (color_content(color_number, &r, &g, &b) != ERR)
if (_COLOR_CONTENT_FUNC(color_number, &r, &g, &b) != ERR)
return Py_BuildValue("(iii)", r, g, b);
else {
PyErr_SetString(PyCursesError,
Expand All @@ -2616,7 +2739,7 @@ _curses_color_content_impl(PyObject *module, short color_number)
/*[clinic input]
_curses.color_pair

color_number: short
color_number: color
The number of the color (0 - COLORS).
/

Expand All @@ -2627,8 +2750,8 @@ other A_* attributes. pair_number() is the counterpart to this function.
[clinic start generated code]*/

static PyObject *
_curses_color_pair_impl(PyObject *module, short color_number)
/*[clinic end generated code: output=6a84cb6b29ecaf9a input=a9d3eb6f50e4dc12]*/
_curses_color_pair_impl(PyObject *module, int color_number)
/*[clinic end generated code: output=3fd752e8e24c93fb input=b049033819ab4ef5]*/
{
PyCursesInitialised;
PyCursesInitialisedColor;
Expand Down Expand Up @@ -3027,13 +3150,13 @@ _curses_has_key_impl(PyObject *module, int key)
/*[clinic input]
_curses.init_color

color_number: short
color_number: color
The number of the color to be changed (0 - COLORS).
r: short
r: component
Red component (0 - 1000).
g: short
g: component
Green component (0 - 1000).
b: short
b: component
Blue component (0 - 1000).
/

Expand All @@ -3045,24 +3168,24 @@ most terminals; it is active only if can_change_color() returns 1.
[clinic start generated code]*/

static PyObject *
_curses_init_color_impl(PyObject *module, short color_number, short r,
short g, short b)
/*[clinic end generated code: output=280236f5efe9776a input=f3a05bd38f619175]*/
_curses_init_color_impl(PyObject *module, int color_number, short r, short g,
short b)
/*[clinic end generated code: output=d7ed71b2d818cdf2 input=8a2fe94ca9204aa5]*/
{
PyCursesInitialised;
PyCursesInitialisedColor;

return PyCursesCheckERR(init_color(color_number, r, g, b), "init_color");
return PyCursesCheckERR(_CURSES_INIT_COLOR_FUNC(color_number, r, g, b), _CURSES_INIT_COLOR_FUNC_NAME);
}

/*[clinic input]
_curses.init_pair

pair_number: short
pair_number: pair
The number of the color-pair to be changed (1 - (COLOR_PAIRS-1)).
fg: short
fg: color
Foreground color number (0 - COLORS).
bg: short
bg: color
Background color number (0 - COLORS).
/

Expand All @@ -3073,14 +3196,13 @@ all occurrences of that color-pair are changed to the new definition.
[clinic start generated code]*/

static PyObject *
_curses_init_pair_impl(PyObject *module, short pair_number, short fg,
short bg)
/*[clinic end generated code: output=9c2ce39c22f376b6 input=c9f0b11b17a2ac6d]*/
_curses_init_pair_impl(PyObject *module, int pair_number, int fg, int bg)
/*[clinic end generated code: output=a0bba03d2bbc3ee6 input=b865583a18061c1f]*/
{
PyCursesInitialised;
PyCursesInitialisedColor;

return PyCursesCheckERR(init_pair(pair_number, fg, bg), "init_pair");
return PyCursesCheckERR(_CURSES_INIT_PAIR_FUNC(pair_number, fg, bg), _CURSES_INIT_PAIR_FUNC_NAME);
}

static PyObject *ModDict;
Expand Down Expand Up @@ -3697,23 +3819,23 @@ NoArgNoReturnFunctionBody(noraw)
/*[clinic input]
_curses.pair_content

pair_number: short
pair_number: pair
The number of the color pair (1 - (COLOR_PAIRS-1)).
/

Return a tuple (fg, bg) containing the colors for the requested color pair.
[clinic start generated code]*/

static PyObject *
_curses_pair_content_impl(PyObject *module, short pair_number)
/*[clinic end generated code: output=5a72aa1a28bbacf3 input=f4d7fec5643b976b]*/
_curses_pair_content_impl(PyObject *module, int pair_number)
/*[clinic end generated code: output=4a726dd0e6885f3f input=b42eacf8a4103852]*/
{
short f, b;
_NCURSES_COLOR_VAL_TYPE f, b;

PyCursesInitialised;
PyCursesInitialisedColor;

if (pair_content(pair_number, &f, &b)==ERR) {
if (_CURSES_PAIR_NUMBER_FUNC(pair_number, &f, &b)==ERR) {
PyErr_SetString(PyCursesError,
"Argument 1 was out of range. (1..COLOR_PAIRS-1)");
return NULL;
Expand Down Expand Up @@ -4450,6 +4572,21 @@ make_ncurses_version(void)

#endif /* NCURSES_VERSION */

/*[clinic input]
_curses.has_extended_color_support

Return True if the module supports extended colors; otherwise, return False.

Extended color support allows more than 256 color-pairs for terminals
that support more than 16 colors (e.g. xterm-256color).
[clinic start generated code]*/

static PyObject *
_curses_has_extended_color_support_impl(PyObject *module)
/*[clinic end generated code: output=68f1be2b57d92e22 input=4b905f046e35ee9f]*/
{
return PyBool_FromLong(_NCURSES_EXTENDED_COLOR_FUNCS);
}

/* List of functions defined in the module */

Expand All @@ -4476,6 +4613,7 @@ static PyMethodDef PyCurses_methods[] = {
_CURSES_GETSYX_METHODDEF
_CURSES_GETWIN_METHODDEF
_CURSES_HAS_COLORS_METHODDEF
_CURSES_HAS_EXTENDED_COLOR_SUPPORT_METHODDEF
_CURSES_HAS_IC_METHODDEF
_CURSES_HAS_IL_METHODDEF
_CURSES_HAS_KEY_METHODDEF
Expand Down
Loading