Skip to content

gh-151776: Add curses state-query functions#151778

Merged
serhiy-storchaka merged 6 commits into
python:mainfrom
serhiy-storchaka:curses-state-getters
Jun 24, 2026
Merged

gh-151776: Add curses state-query functions#151778
serhiy-storchaka merged 6 commits into
python:mainfrom
serhiy-storchaka:curses-state-getters

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jun 20, 2026

Copy link
Copy Markdown
Member

Wrap the ncurses "opaque" accessors that report curses state which the standard API can only set, never read back.

New window methods:

  • is_cleared, is_idcok, is_idlok, is_immedok, is_keypad, is_leaveok, is_nodelay, is_notimeout, is_scrollok and is_syncok return the value set by the matching setter.
  • is_pad and is_subwin report the kind of window.
  • getdelay() returns the read timeout in milliseconds (as set by nodelay()/timeout()).
  • getscrreg() returns the current scrolling region as a (top, bottom) tuple.
  • getparent() returns the parent window, or None if the window is not a subwindow.

New module functions: is_cbreak, is_echo, is_nl and is_raw report the current terminal mode set by cbreak, echo, nl and raw.

All of these are available only when Python is built against an ncurses with NCURSES_EXT_FUNCS (ncurses 5.9 and later).

🤖 Generated with Claude Code

Add window methods and module functions that report curses state which could
previously only be set: the window getters is_cleared(), is_idcok(),
is_idlok(), is_immedok(), is_keypad(), is_leaveok(), is_nodelay(),
is_notimeout(), is_pad(), is_scrollok(), is_subwin(), is_syncok(),
getdelay(), getparent() and getscrreg(), and the functions is_cbreak(),
is_echo(), is_nl() and is_raw().  They are available when built against an
ncurses with NCURSES_EXT_FUNCS.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@read-the-docs-community

read-the-docs-community Bot commented Jun 20, 2026

Copy link
Copy Markdown

serhiy-storchaka and others added 4 commits June 20, 2026 12:32
These four functions were added in ncurses 6.5; guarding them with the same
NCURSES_EXT_FUNCS >= 20110404 as the window getters broke the build on older
ncurses (e.g. macOS, which ships 6.0).  Require NCURSES_EXT_FUNCS >= 20240427.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts:
#	Doc/library/curses.rst
#	Modules/clinic/_cursesmodule.c.h
# Conflicts:
#	Modules/clinic/_cursesmodule.c.h
The new window state-query methods grew PyCursesWindow_methods[] past the
default 200-line limit, crashing check-c-globals.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts:
#	Doc/whatsnew/3.16.rst
#	Modules/clinic/_cursesmodule.c.h
@serhiy-storchaka serhiy-storchaka merged commit a52f428 into python:main Jun 24, 2026
54 checks passed
@serhiy-storchaka serhiy-storchaka deleted the curses-state-getters branch June 24, 2026 19:31
@StanFromIreland

StanFromIreland commented Jun 26, 2026

Copy link
Copy Markdown
Member

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

Thank you for noticing. They are terminal depending. I forgot to run these tests on different terminals. #152304 should fix the test.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants