Back to index

python3.2  3.2.2
Classes | Defines | Typedefs | Functions | Variables
_curses_panel.c File Reference
#include "Python.h"
#include "py_curses.h"
#include <panel.h>

Go to the source code of this file.

Classes

struct  PyCursesPanelObject
struct  _list_of_panels

Defines

#define PyCursesPanel_Check(v)   (Py_TYPE(v) == &PyCursesPanel_Type)
#define Panel_NoArgNoReturnFunction(X)
#define Panel_NoArgTrueFalseFunction(X)
#define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR)

Typedefs

typedef struct _list_of_panels list_of_panels

Functions

static PyObjectPyCursesCheckERR (int code, char *fname)
static int insert_lop (PyCursesPanelObject *po)
static void remove_lop (PyCursesPanelObject *po)
static PyCursesPanelObjectfind_po (PANEL *pan)
 Panel_NoArgNoReturnFunction (bottom_panel)
static void PyCursesPanel_Dealloc (PyCursesPanelObject *po)
static PyObjectPyCursesPanel_above (PyCursesPanelObject *self)
static PyObjectPyCursesPanel_below (PyCursesPanelObject *self)
static PyObjectPyCursesPanel_window (PyCursesPanelObject *self)
static PyObjectPyCursesPanel_replace_panel (PyCursesPanelObject *self, PyObject *args)
static PyObjectPyCursesPanel_set_panel_userptr (PyCursesPanelObject *self, PyObject *obj)
static PyObjectPyCursesPanel_userptr (PyCursesPanelObject *self)
static PyObjectPyCurses_bottom_panel (PyObject *self)
static PyObjectPyCurses_new_panel (PyObject *self, PyObject *args)
static PyObjectPyCurses_top_panel (PyObject *self)
static PyObjectPyCurses_update_panels (PyObject *self)
PyMODINIT_FUNC PyInit__curses_panel (void)

Variables

static char * PyCursesVersion = "2.1"
static PyObjectPyCursesError
PyTypeObject PyCursesPanel_Type
static list_of_panelslop
static PyMethodDef PyCursesPanel_Methods []
static PyMethodDef PyCurses_methods []
static struct PyModuleDef

Class Documentation

struct PyCursesPanelObject

Definition at line 51 of file _curses_panel.c.

Collaboration diagram for PyCursesPanelObject:
Class Members
PyObject_HEAD PANEL * pan
PyCursesWindowObject * wo
struct _list_of_panels

Definition at line 78 of file _curses_panel.c.

Collaboration diagram for _list_of_panels:
Class Members
struct _list_of_panels * next
PyCursesPanelObject * po

Define Documentation

#define Panel_NoArgNoReturnFunction (   X)
Value:
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \
{ return PyCursesCheckERR(X(self->pan), # X); }

Definition at line 145 of file _curses_panel.c.

Value:
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \
{ \
  if (X (self->pan) == FALSE) { Py_INCREF(Py_False); return Py_False; } \
  else { Py_INCREF(Py_True); return Py_True; } }

Definition at line 149 of file _curses_panel.c.

#define Panel_TwoArgNoReturnFunction (   X,
  TYPE,
  PARSESTR 
)
Value:
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \
{ \
  TYPE arg1, arg2; \
  if (!PyArg_ParseTuple(args, PARSESTR, &arg1, &arg2)) return NULL; \
  return PyCursesCheckERR(X(self->pan, arg1, arg2), # X); }

Definition at line 155 of file _curses_panel.c.

#define PyCursesPanel_Check (   v)    (Py_TYPE(v) == &PyCursesPanel_Type)

Definition at line 59 of file _curses_panel.c.


Typedef Documentation


Function Documentation

static PyCursesPanelObject* find_po ( PANEL *  pan) [static]

Definition at line 130 of file _curses_panel.c.

{
    list_of_panels *temp;
    for (temp = lop; temp->po->pan != pan; temp = temp->next)
        if (temp->next == NULL) return NULL;    /* not found!? */
    return temp->po;
}

Here is the caller graph for this function:

static int insert_lop ( PyCursesPanelObject po) [static]

Definition at line 88 of file _curses_panel.c.

{
    list_of_panels *new;

    if ((new = (list_of_panels *)malloc(sizeof(list_of_panels))) == NULL) {
        PyErr_NoMemory();
        return -1;
    }
    new->po = po;
    new->next = lop;
    lop = new;
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Panel_NoArgNoReturnFunction ( bottom_panel  )

Definition at line 164 of file _curses_panel.c.

{
    PyCursesPanelObject *po;

    po = PyObject_NEW(PyCursesPanelObject, &PyCursesPanel_Type);
    if (po == NULL) return NULL;
    po->pan = pan;
    if (insert_lop(po) < 0) {
        po->wo = NULL;
        Py_DECREF(po);
        return NULL;
    }
    po->wo = wo;
    Py_INCREF(wo);
    return (PyObject *)po;
}

Here is the call graph for this function:

static PyObject* PyCurses_bottom_panel ( PyObject self) [static]

Definition at line 374 of file _curses_panel.c.

{
    PANEL *pan;
    PyCursesPanelObject *po;

    PyCursesInitialised;

    pan = panel_above(NULL);

    if (pan == NULL) {          /* valid output, it means
                                   there's no panel at all */
        Py_INCREF(Py_None);
        return Py_None;
    }
    po = find_po(pan);
    if (po == NULL) {
        PyErr_SetString(PyExc_RuntimeError,
                        "panel_above: can't find Panel Object");
        return NULL;
    }
    Py_INCREF(po);
    return (PyObject *)po;
}

Here is the call graph for this function:

static PyObject* PyCurses_new_panel ( PyObject self,
PyObject args 
) [static]

Definition at line 399 of file _curses_panel.c.

{
    PyCursesWindowObject *win;
    PANEL *pan;

    if (!PyArg_ParseTuple(args, "O!", &PyCursesWindow_Type, &win))
        return NULL;
    pan = new_panel(win->win);
    if (pan == NULL) {
        PyErr_SetString(PyCursesError, catchall_NULL);
        return NULL;
    }
    return (PyObject *)PyCursesPanel_New(pan, win);
}

Here is the call graph for this function:

static PyObject* PyCurses_top_panel ( PyObject self) [static]

Definition at line 420 of file _curses_panel.c.

{
    PANEL *pan;
    PyCursesPanelObject *po;

    PyCursesInitialised;

    pan = panel_below(NULL);

    if (pan == NULL) {          /* valid output, it means
                                   there's no panel at all */
        Py_INCREF(Py_None);
        return Py_None;
    }
    po = find_po(pan);
    if (po == NULL) {
        PyErr_SetString(PyExc_RuntimeError,
                        "panel_below: can't find Panel Object");
        return NULL;
    }
    Py_INCREF(po);
    return (PyObject *)po;
}

Here is the call graph for this function:

static PyObject* PyCurses_update_panels ( PyObject self) [static]

Definition at line 444 of file _curses_panel.c.

{
    PyCursesInitialised;
    update_panels();
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject* PyCursesCheckERR ( int  code,
char *  fname 
) [static]

Definition at line 30 of file _curses_panel.c.

{
    if (code != ERR) {
        Py_INCREF(Py_None);
        return Py_None;
    } else {
        if (fname == NULL) {
            PyErr_SetString(PyCursesError, catchall_ERR);
        } else {
            PyErr_Format(PyCursesError, "%s() returned ERR", fname);
        }
        return NULL;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* PyCursesPanel_above ( PyCursesPanelObject self) [static]

Definition at line 205 of file _curses_panel.c.

{
    PANEL *pan;
    PyCursesPanelObject *po;

    pan = panel_above(self->pan);

    if (pan == NULL) {          /* valid output, it means the calling panel
                                   is on top of the stack */
        Py_INCREF(Py_None);
        return Py_None;
    }
    po = find_po(pan);
    if (po == NULL) {
        PyErr_SetString(PyExc_RuntimeError,
                        "panel_above: can't find Panel Object");
        return NULL;
    }
    Py_INCREF(po);
    return (PyObject *)po;
}

Here is the call graph for this function:

static PyObject* PyCursesPanel_below ( PyCursesPanelObject self) [static]

Definition at line 230 of file _curses_panel.c.

{
    PANEL *pan;
    PyCursesPanelObject *po;

    pan = panel_below(self->pan);

    if (pan == NULL) {          /* valid output, it means the calling panel
                                   is on the bottom of the stack */
        Py_INCREF(Py_None);
        return Py_None;
    }
    po = find_po(pan);
    if (po == NULL) {
        PyErr_SetString(PyExc_RuntimeError,
                        "panel_below: can't find Panel Object");
        return NULL;
    }
    Py_INCREF(po);
    return (PyObject *)po;
}

Here is the call graph for this function:

static void PyCursesPanel_Dealloc ( PyCursesPanelObject po) [static]

Definition at line 192 of file _curses_panel.c.

{
    (void)del_panel(po->pan);
    if (po->wo != NULL) {
        Py_DECREF(po->wo);
        remove_lop(po);
    }
    PyObject_DEL(po);
}

Here is the call graph for this function:

static PyObject* PyCursesPanel_replace_panel ( PyCursesPanelObject self,
PyObject args 
) [static]

Definition at line 260 of file _curses_panel.c.

{
    PyCursesPanelObject *po;
    PyCursesWindowObject *temp;
    int rtn;

    if (PyTuple_Size(args) != 1) {
        PyErr_SetString(PyExc_TypeError, "replace requires one argument");
        return NULL;
    }
    if (!PyArg_ParseTuple(args, "O!;window object",
                          &PyCursesWindow_Type, &temp))
        return NULL;

    po = find_po(self->pan);
    if (po == NULL) {
        PyErr_SetString(PyExc_RuntimeError,
                        "replace_panel: can't find Panel Object");
        return NULL;
    }

    rtn = replace_panel(self->pan, temp->win);
    if (rtn == ERR) {
        PyErr_SetString(PyCursesError, "replace_panel() returned ERR");
        return NULL;
    }
    Py_DECREF(po->wo);
    po->wo = temp;
    Py_INCREF(po->wo);
    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* PyCursesPanel_set_panel_userptr ( PyCursesPanelObject self,
PyObject obj 
) [static]

Definition at line 294 of file _curses_panel.c.

{
    Py_INCREF(obj);
    return PyCursesCheckERR(set_panel_userptr(self->pan, (void*)obj),
                            "set_panel_userptr");
}

Here is the call graph for this function:

static PyObject* PyCursesPanel_userptr ( PyCursesPanelObject self) [static]

Definition at line 302 of file _curses_panel.c.

{
    PyObject *obj;
    PyCursesInitialised;
    obj = (PyObject *) panel_userptr(self->pan);
    if (obj == NULL) {
        PyErr_SetString(PyCursesError, "no userptr set");
        return NULL;
    }

    Py_INCREF(obj);
    return obj;
}

Here is the call graph for this function:

static PyObject* PyCursesPanel_window ( PyCursesPanelObject self) [static]

Definition at line 253 of file _curses_panel.c.

{
    Py_INCREF(self->wo);
    return (PyObject *)self->wo;
}

Definition at line 479 of file _curses_panel.c.

{
    PyObject *m, *d, *v;

    /* Initialize object type */
    if (PyType_Ready(&PyCursesPanel_Type) < 0)
        return NULL;

    import_curses();

    /* Create the module and add the functions */
    m = PyModule_Create(&_curses_panelmodule);
    if (m == NULL)
        return NULL;
    d = PyModule_GetDict(m);

    /* For exception _curses_panel.error */
    PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL);
    PyDict_SetItemString(d, "error", PyCursesError);

    /* Make the version available */
    v = PyUnicode_FromString(PyCursesVersion);
    PyDict_SetItemString(d, "version", v);
    PyDict_SetItemString(d, "__version__", v);
    Py_DECREF(v);
    return m;
}

Here is the call graph for this function:

static void remove_lop ( PyCursesPanelObject po) [static]

Definition at line 104 of file _curses_panel.c.

{
    list_of_panels *temp, *n;

    temp = lop;
    if (temp->po == po) {
        lop = temp->next;
        free(temp);
        return;
    }
    while (temp->next == NULL || temp->next->po != po) {
        if (temp->next == NULL) {
            PyErr_SetString(PyExc_RuntimeError,
                            "remove_lop: can't find Panel Object");
            return;
        }
        temp = temp->next;
    }
    n = temp->next->next;
    free(temp->next);
    temp->next = n;
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

list_of_panels* lop [static]

Definition at line 84 of file _curses_panel.c.

Initial value:

Definition at line 455 of file _curses_panel.c.

Definition at line 19 of file _curses_panel.c.

Initial value:
 {
    {"above",           (PyCFunction)PyCursesPanel_above, METH_NOARGS},
    {"below",           (PyCFunction)PyCursesPanel_below, METH_NOARGS},
    {"bottom",          (PyCFunction)PyCursesPanel_bottom_panel, METH_NOARGS},
    {"hidden",          (PyCFunction)PyCursesPanel_panel_hidden, METH_NOARGS},
    {"hide",            (PyCFunction)PyCursesPanel_hide_panel, METH_NOARGS},
    {"move",            (PyCFunction)PyCursesPanel_move_panel, METH_VARARGS},
    {"replace",         (PyCFunction)PyCursesPanel_replace_panel, METH_VARARGS},
    {"set_userptr",     (PyCFunction)PyCursesPanel_set_panel_userptr, METH_O},
    {"show",            (PyCFunction)PyCursesPanel_show_panel, METH_NOARGS},
    {"top",             (PyCFunction)PyCursesPanel_top_panel, METH_NOARGS},
    {"userptr",         (PyCFunction)PyCursesPanel_userptr, METH_NOARGS},
    {"window",          (PyCFunction)PyCursesPanel_window, METH_NOARGS},
    {NULL,              NULL}   
}

Definition at line 319 of file _curses_panel.c.

Definition at line 57 of file _curses_panel.c.

char* PyCursesVersion = "2.1" [static]

Definition at line 9 of file _curses_panel.c.

struct PyModuleDef [static]
Initial value:
 {
        PyModuleDef_HEAD_INIT,
        "_curses_panel",
        NULL,
        -1,
        PyCurses_methods,
        NULL,
        NULL,
        NULL,
        NULL
}

Definition at line 466 of file _curses_panel.c.