Curses C API
************

"curses" 為擴充模組公開了一個小型的 C 介面。使用者必須包含標頭檔
"py_curses.h"（此檔案不會由 "Python.h" 預設包含），並且必須觸發
"import_curses()" 以填充 (populate) "PyCurses_API"，通常是作為模組初始
化函式的一部分。

警告:

  Neither the C API nor the pure Python "curses" module are compatible
  with subinterpreters.

import_curses()

   引入 curses C API。呼叫此巨集不需要寫分號。

   On success, populate the "PyCurses_API" pointer.

   On failure, set "PyCurses_API" to NULL and set an exception. The
   caller must check if an error occurred via "PyErr_Occurred()":

      import_curses();  // 建議要寫分號但非必要
      if (PyErr_Occurred()) { /* 清理 */ }

void **PyCurses_API

   Dynamically allocated object containing the curses C API. This
   variable is only available once "import_curses" succeeds.

   "PyCurses_API[0]" corresponds to "PyCursesWindow_Type".

   "PyCurses_API[1]"、"PyCurses_API[2]" 和 "PyCurses_API[3]" 是指向 型
   別為 "int (*)(void)" 的謂詞函式 (predicate functions) 的指標。

   When called, these predicates return whether "curses.setupterm()",
   "curses.initscr()", and "curses.start_color()" have been called
   respectively.

   See also the convenience macros "PyCursesSetupTermCalled",
   "PyCursesInitialised", and "PyCursesInitialisedColor".

   備註:

     The number of entries in this structure is subject to changes.
     Consider using "PyCurses_API_pointers" to check if new fields are
     available or not.

PyCurses_API_pointers

   The number of accessible fields ("4") in "PyCurses_API". This
   number is incremented whenever new fields are added.

PyTypeObject PyCursesWindow_Type

   The heap type corresponding to "curses.window".

int PyCursesWindow_Check(PyObject *op)

   如果 *op* 是 "curses.window" 實例則回傳 true，否則回傳 false。

The following macros are convenience macros expanding into C
statements. In particular, they can only be used as "macro;" or
"macro", but not "macro()" or "macro();".

PyCursesSetupTermCalled

   如果已呼叫 "curses.setupterm()"，則為巨集檢查。

   巨集展開大致相當於：

      {
          typedef int (*predicate_t)(void);
          predicate_t was_setupterm_called = (predicate_t)PyCurses_API[1];
          if (!was_setupterm_called()) {
              return NULL;
          }
      }

PyCursesInitialised

   如果已呼叫 "curses.initscr()"，則為巨集檢查。

   巨集展開大致相當於：

      {
          typedef int (*predicate_t)(void);
          predicate_t was_initscr_called = (predicate_t)PyCurses_API[2];
          if (!was_initscr_called()) {
              return NULL;
          }
      }

PyCursesInitialisedColor

   如果已呼叫 "curses.start_color()"，則為巨集檢查。

   巨集展開大致相當於：

      {
          typedef int (*predicate_t)(void);
          predicate_t was_start_color_called = (predicate_t)PyCurses_API[3];
          if (!was_start_color_called()) {
              return NULL;
          }
      }


內部資料
********

以下物件由 C API 所公開，但應視為僅供內部使用。

PyCurses_CAPSULE_NAME

   Name of the curses capsule to pass to "PyCapsule_Import()".

   僅供內部使用。請改用 "import_curses"。
