py_curses.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef Py_CURSES_H
  2. #define Py_CURSES_H
  3. #ifdef __APPLE__
  4. /*
  5. ** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards
  6. ** against multiple definition of wchar_t.
  7. */
  8. #ifdef _BSD_WCHAR_T_DEFINED_
  9. #define _WCHAR_T
  10. #endif
  11. #endif /* __APPLE__ */
  12. /* On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards
  13. against multiple definition of wchar_t and wint_t. */
  14. #if defined(__FreeBSD__) && defined(_XOPEN_SOURCE_EXTENDED)
  15. # ifndef __wchar_t
  16. # define __wchar_t
  17. # endif
  18. # ifndef __wint_t
  19. # define __wint_t
  20. # endif
  21. #endif
  22. #if !defined(HAVE_CURSES_IS_PAD) && defined(WINDOW_HAS_FLAGS)
  23. /* The following definition is necessary for ncurses 5.7; without it,
  24. some of [n]curses.h set NCURSES_OPAQUE to 1, and then Python
  25. can't get at the WINDOW flags field. */
  26. #define NCURSES_OPAQUE 0
  27. #endif
  28. #ifdef HAVE_NCURSES_H
  29. #include <ncurses.h>
  30. #else
  31. #include <curses.h>
  32. #endif
  33. #if defined(__MINGW32__)
  34. #include <windows.h>
  35. #if !defined(_ISPAD)
  36. #define _ISPAD 0x10
  37. #endif
  38. #endif
  39. #ifdef HAVE_NCURSES_H
  40. /* configure was checking <curses.h>, but we will
  41. use <ncurses.h>, which has some or all these features. */
  42. #if !defined(WINDOW_HAS_FLAGS) && !(NCURSES_OPAQUE+0)
  43. #define WINDOW_HAS_FLAGS 1
  44. #endif
  45. #if !defined(HAVE_CURSES_IS_PAD) && NCURSES_VERSION_PATCH+0 >= 20090906
  46. #define HAVE_CURSES_IS_PAD 1
  47. #endif
  48. #ifndef MVWDELCH_IS_EXPRESSION
  49. #define MVWDELCH_IS_EXPRESSION 1
  50. #endif
  51. #endif
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. #define PyCurses_API_pointers 4
  56. /* Type declarations */
  57. typedef struct {
  58. PyObject_HEAD
  59. WINDOW *win;
  60. char *encoding;
  61. } PyCursesWindowObject;
  62. #define PyCursesWindow_Check(v) Py_IS_TYPE(v, &PyCursesWindow_Type)
  63. #define PyCurses_CAPSULE_NAME "_curses._C_API"
  64. #ifdef CURSES_MODULE
  65. /* This section is used when compiling _cursesmodule.c */
  66. #else
  67. /* This section is used in modules that use the _cursesmodule API */
  68. static void **PyCurses_API;
  69. #define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0])
  70. #define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;}
  71. #define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;}
  72. #define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;}
  73. #define import_curses() \
  74. PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1);
  75. #endif
  76. /* general error messages */
  77. static const char catchall_ERR[] = "curses function returned ERR";
  78. static const char catchall_NULL[] = "curses function returned NULL";
  79. #ifdef __cplusplus
  80. }
  81. #endif
  82. #endif /* !defined(Py_CURSES_H) */