Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:54

0001 
0002 #ifndef Py_CURSES_H
0003 #define Py_CURSES_H
0004 
0005 #ifdef __APPLE__
0006 /*
0007 ** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards
0008 ** against multiple definition of wchar_t.
0009 */
0010 #ifdef _BSD_WCHAR_T_DEFINED_
0011 #define _WCHAR_T
0012 #endif
0013 #endif /* __APPLE__ */
0014 
0015 /* On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards
0016    against multiple definition of wchar_t and wint_t. */
0017 #if defined(__FreeBSD__) && defined(_XOPEN_SOURCE_EXTENDED)
0018 # ifndef __wchar_t
0019 #   define __wchar_t
0020 # endif
0021 # ifndef __wint_t
0022 #   define __wint_t
0023 # endif
0024 #endif
0025 
0026 #if defined(WINDOW_HAS_FLAGS) && defined(__APPLE__)
0027 /* gh-109617, gh-115383: we can rely on the default value for NCURSES_OPAQUE on
0028    most platforms, but not on macOS. This is because, starting with Xcode 15,
0029    Apple-provided ncurses.h comes from ncurses 6 (which defaults to opaque
0030    structs) but can still be linked to older versions of ncurses dynamic
0031    libraries which don't provide functions such as is_pad() to deal with opaque
0032    structs. Setting NCURSES_OPAQUE to 0 is harmless in all ncurses releases to
0033    this date (provided that a thread-safe implementation is not required), but
0034    this might change in the future. This fix might become irrelevant once
0035    support for macOS 13 or earlier is dropped. */
0036 #define NCURSES_OPAQUE 0
0037 #endif
0038 
0039 #if defined(HAVE_NCURSESW_NCURSES_H)
0040 #  include <ncursesw/ncurses.h>
0041 #elif defined(HAVE_NCURSESW_CURSES_H)
0042 #  include <ncursesw/curses.h>
0043 #elif defined(HAVE_NCURSES_NCURSES_H)
0044 #  include <ncurses/ncurses.h>
0045 #elif defined(HAVE_NCURSES_CURSES_H)
0046 #  include <ncurses/curses.h>
0047 #elif defined(HAVE_NCURSES_H)
0048 #  include <ncurses.h>
0049 #elif defined(HAVE_CURSES_H)
0050 #  include <curses.h>
0051 #endif
0052 
0053 #ifdef NCURSES_VERSION
0054 /* configure was checking <curses.h>, but we will
0055    use <ncurses.h>, which has some or all these features. */
0056 #if !defined(WINDOW_HAS_FLAGS) && \
0057     (NCURSES_VERSION_PATCH+0 < 20070303 || !(NCURSES_OPAQUE+0))
0058 /* the WINDOW flags field was always accessible in ncurses prior to 20070303;
0059    after that, it depends on the value of NCURSES_OPAQUE. */
0060 #define WINDOW_HAS_FLAGS 1
0061 #endif
0062 #if !defined(HAVE_CURSES_IS_PAD) && NCURSES_VERSION_PATCH+0 >= 20090906
0063 #define HAVE_CURSES_IS_PAD 1
0064 #endif
0065 #ifndef MVWDELCH_IS_EXPRESSION
0066 #define MVWDELCH_IS_EXPRESSION 1
0067 #endif
0068 #endif
0069 
0070 #ifdef __cplusplus
0071 extern "C" {
0072 #endif
0073 
0074 #define PyCurses_API_pointers 4
0075 
0076 /* Type declarations */
0077 
0078 typedef struct PyCursesWindowObject {
0079     PyObject_HEAD
0080     WINDOW *win;
0081     char *encoding;
0082     struct PyCursesWindowObject *orig;
0083 } PyCursesWindowObject;
0084 
0085 #define PyCursesWindow_Check(v) Py_IS_TYPE((v), &PyCursesWindow_Type)
0086 
0087 #define PyCurses_CAPSULE_NAME "_curses._C_API"
0088 
0089 
0090 #ifdef CURSES_MODULE
0091 /* This section is used when compiling _cursesmodule.c */
0092 
0093 #else
0094 /* This section is used in modules that use the _cursesmodule API */
0095 
0096 static void **PyCurses_API;
0097 
0098 #define PyCursesWindow_Type (*_PyType_CAST(PyCurses_API[0]))
0099 #define PyCursesSetupTermCalled  {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;}
0100 #define PyCursesInitialised      {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;}
0101 #define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;}
0102 
0103 #define import_curses() \
0104     PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1);
0105 
0106 #endif
0107 
0108 /* general error messages */
0109 static const char catchall_ERR[]  = "curses function returned ERR";
0110 static const char catchall_NULL[] = "curses function returned NULL";
0111 
0112 #ifdef __cplusplus
0113 }
0114 #endif
0115 
0116 #endif /* !defined(Py_CURSES_H) */
0117