Skip to content

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

Open
serhiy-storchaka wants to merge 2 commits into
python:mainfrom
serhiy-storchaka:curses-state-getters
Open

gh-151776: Add curses state-query functions#151778
serhiy-storchaka wants to merge 2 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

Documentation build overview

📚 cpython-previews | 🛠️ Build #33227312 | 📁 Comparing c1d7b20 against main (aa5b164)

  🔍 Preview build  

3 files changed
± library/curses.html
± whatsnew/3.16.html
± whatsnew/changelog.html

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant