Skip to content

gh-152502: Detect the curses mouse interface and is_* methods portably#152705

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-152502-curses-mouse-probes
Jun 30, 2026
Merged

gh-152502: Detect the curses mouse interface and is_* methods portably#152705
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-152502-curses-mouse-probes

Conversation

@serhiy-storchaka

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

Copy link
Copy Markdown
Member

The curses mouse interface (getmouse(), has_mouse(), the BUTTON* constants, window.mouse_trafo(), ...) and the window is_*() state-query methods were gated on ncurses-specific macros (NCURSES_MOUSE_VERSION, NCURSES_EXT_FUNCS), so they were dropped on other curses implementations that provide them, such as NetBSD curses and PDCurses (the latter underpins windows-curses).

They are now gated on:

  • configure capability probes, for functions that NetBSD curses provides (it defines no identifying macro, so a probe is the only way to detect it);
  • NCURSES_EXT_FUNCS or the PDCURSES macro, for functions that only ncurses and PDCurses provide.

getmouse() is probed with its X/Open getmouse(MEVENT *) signature specifically, because PDCurses declares an incompatible getmouse(void) unless built for the ncurses mouse API. PDC_NCMOUSE is now always defined so PDCurses exposes that ncurses-compatible mouse interface, which is the one this module uses, and Windows gets the whole API through the PDCURSES macro with no configure step.

Validated by compiling against ncurses (plus test_curses), NetBSD curses, PDCurses with and without PDC_NCMOUSE, and the PDCurses-on-Windows path.

…ortably

The mouse interface (getmouse(), has_mouse(), the BUTTON* constants,
window.mouse_trafo(), ...) and the window is_*() state-query methods were gated
on ncurses-specific macros, so they were dropped on other curses implementations
that provide them, such as NetBSD curses and PDCurses.

Gate them instead on configure capability probes (for functions NetBSD curses
provides, since it defines no identifying macro) or on NCURSES_EXT_FUNCS or the
PDCURSES macro (for functions only ncurses and PDCurses provide).  Probe for
getmouse() with its X/Open getmouse(MEVENT *) signature, since PDCurses declares
an incompatible getmouse(void) unless built for the ncurses mouse API, which
PDC_NCMOUSE now always selects.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes and removed needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 30, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33379721 | 📁 Comparing a335162 against main (a3dc784)

  🔍 Preview build  

2 files changed
± library/curses.html
± whatsnew/changelog.html

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) June 30, 2026 19:11
@serhiy-storchaka serhiy-storchaka merged commit 7bbea4f into python:main Jun 30, 2026
69 checks passed
@bedevere-app

bedevere-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

GH-152707 is a backport of this pull request to the 3.15 branch.

serhiy-storchaka added a commit that referenced this pull request Jun 30, 2026
…) (GH-152707)

The mouse interface (getmouse(), the BUTTON* constants, ...) was gated on the
ncurses-specific NCURSES_MOUSE_VERSION macro, so it was dropped on other curses
implementations that provide it, such as NetBSD curses and PDCurses.

Gate it instead on a configure capability probe or the PDCURSES macro.  Probe
for getmouse() with its X/Open getmouse(MEVENT *) signature, since PDCurses
declares an incompatible getmouse(void) unless built for the ncurses mouse API,
which PDC_NCMOUSE now always selects.

(cherry picked from commit 7bbea4f)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@bedevere-app

bedevere-app Bot commented Jul 1, 2026

Copy link
Copy Markdown

GH-152734 is a backport of this pull request to the 3.14 branch.

@bedevere-app

bedevere-app Bot commented Jul 1, 2026

Copy link
Copy Markdown

GH-152735 is a backport of this pull request to the 3.13 branch.

serhiy-storchaka added a commit that referenced this pull request Jul 1, 2026
…) (GH-152735)

The mouse interface (getmouse(), the BUTTON* constants, ...) was gated on the
ncurses-specific NCURSES_MOUSE_VERSION macro, so it was dropped on other curses
implementations that provide it, such as NetBSD curses and PDCurses.

Gate it instead on a configure capability probe or the PDCURSES macro.  Probe
for getmouse() with its X/Open getmouse(MEVENT *) signature, since PDCurses
declares an incompatible getmouse(void) unless built for the ncurses mouse API,
which PDC_NCMOUSE now always selects.

(cherry picked from commit 7bbea4f)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 1, 2026
…) (GH-152734)

The mouse interface (getmouse(), the BUTTON* constants, ...) was gated on the
ncurses-specific NCURSES_MOUSE_VERSION macro, so it was dropped on other curses
implementations that provide it, such as NetBSD curses and PDCurses.

Gate it instead on a configure capability probe or the PDCURSES macro.  Probe
for getmouse() with its X/Open getmouse(MEVENT *) signature, since PDCurses
declares an incompatible getmouse(void) unless built for the ncurses mouse API,
which PDC_NCMOUSE now always selects.

(cherry picked from commit 7bbea4f)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant