📄 _cursesmodule.c
字号:
{"clearok", (PyCFunction)PyCursesWindow_clearok},
{"clrtobot", (PyCFunction)PyCursesWindow_wclrtobot},
{"clrtoeol", (PyCFunction)PyCursesWindow_wclrtoeol},
{"cursyncup", (PyCFunction)PyCursesWindow_wcursyncup},
{"delch", (PyCFunction)PyCursesWindow_DelCh},
{"deleteln", (PyCFunction)PyCursesWindow_wdeleteln},
{"derwin", (PyCFunction)PyCursesWindow_DerWin},
{"echochar", (PyCFunction)PyCursesWindow_EchoChar},
#ifdef NCURSES_MOUSE_VERSION
{"enclose", (PyCFunction)PyCursesWindow_Enclose},
#endif
{"erase", (PyCFunction)PyCursesWindow_werase},
{"getbegyx", (PyCFunction)PyCursesWindow_getbegyx},
{"getbkgd", (PyCFunction)PyCursesWindow_GetBkgd},
{"getch", (PyCFunction)PyCursesWindow_GetCh},
{"getkey", (PyCFunction)PyCursesWindow_GetKey},
{"getmaxyx", (PyCFunction)PyCursesWindow_getmaxyx},
{"getparyx", (PyCFunction)PyCursesWindow_getparyx},
{"getstr", (PyCFunction)PyCursesWindow_GetStr},
{"getyx", (PyCFunction)PyCursesWindow_getyx},
{"hline", (PyCFunction)PyCursesWindow_Hline},
{"idcok", (PyCFunction)PyCursesWindow_idcok},
{"idlok", (PyCFunction)PyCursesWindow_idlok},
{"immedok", (PyCFunction)PyCursesWindow_immedok},
{"inch", (PyCFunction)PyCursesWindow_InCh},
{"insch", (PyCFunction)PyCursesWindow_InsCh},
{"insdelln", (PyCFunction)PyCursesWindow_winsdelln},
{"insertln", (PyCFunction)PyCursesWindow_winsertln},
{"insnstr", (PyCFunction)PyCursesWindow_InsNStr},
{"insstr", (PyCFunction)PyCursesWindow_InsStr},
{"instr", (PyCFunction)PyCursesWindow_InStr},
{"is_linetouched", (PyCFunction)PyCursesWindow_Is_LineTouched},
{"is_wintouched", (PyCFunction)PyCursesWindow_is_wintouched},
{"keypad", (PyCFunction)PyCursesWindow_keypad},
{"leaveok", (PyCFunction)PyCursesWindow_leaveok},
{"move", (PyCFunction)PyCursesWindow_wmove},
{"mvderwin", (PyCFunction)PyCursesWindow_mvderwin},
{"mvwin", (PyCFunction)PyCursesWindow_mvwin},
{"nodelay", (PyCFunction)PyCursesWindow_nodelay},
{"notimeout", (PyCFunction)PyCursesWindow_notimeout},
{"noutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh},
/* Backward compatibility alias -- remove in Python 2.1 */
{"nooutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh},
{"overlay", (PyCFunction)PyCursesWindow_Overlay, METH_VARARGS},
{"overwrite", (PyCFunction)PyCursesWindow_Overwrite,
METH_VARARGS},
{"putwin", (PyCFunction)PyCursesWindow_PutWin},
{"redrawln", (PyCFunction)PyCursesWindow_RedrawLine},
{"redrawwin", (PyCFunction)PyCursesWindow_redrawwin},
{"refresh", (PyCFunction)PyCursesWindow_Refresh},
#ifndef STRICT_SYSV_CURSES
{"resize", (PyCFunction)PyCursesWindow_wresize},
#endif
{"scroll", (PyCFunction)PyCursesWindow_Scroll},
{"scrollok", (PyCFunction)PyCursesWindow_scrollok},
{"setscrreg", (PyCFunction)PyCursesWindow_SetScrollRegion},
{"standend", (PyCFunction)PyCursesWindow_wstandend},
{"standout", (PyCFunction)PyCursesWindow_wstandout},
{"subpad", (PyCFunction)PyCursesWindow_SubWin},
{"subwin", (PyCFunction)PyCursesWindow_SubWin},
{"syncdown", (PyCFunction)PyCursesWindow_wsyncdown},
{"syncok", (PyCFunction)PyCursesWindow_syncok},
{"syncup", (PyCFunction)PyCursesWindow_wsyncup},
{"timeout", (PyCFunction)PyCursesWindow_wtimeout},
{"touchline", (PyCFunction)PyCursesWindow_TouchLine},
{"touchwin", (PyCFunction)PyCursesWindow_touchwin},
{"untouchwin", (PyCFunction)PyCursesWindow_untouchwin},
{"vline", (PyCFunction)PyCursesWindow_Vline},
{NULL, NULL} /* sentinel */
};
static PyObject *
PyCursesWindow_GetAttr(PyCursesWindowObject *self, char *name)
{
return Py_FindMethod(PyCursesWindow_Methods, (PyObject *)self, name);
}
/* -------------------------------------------------------*/
PyTypeObject PyCursesWindow_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"_curses.curses window", /*tp_name*/
sizeof(PyCursesWindowObject), /*tp_basicsize*/
0, /*tp_itemsize*/
/* methods */
(destructor)PyCursesWindow_Dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc)PyCursesWindow_GetAttr, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
};
/*********************************************************************
Global Functions
**********************************************************************/
NoArgNoReturnFunction(beep)
NoArgNoReturnFunction(def_prog_mode)
NoArgNoReturnFunction(def_shell_mode)
NoArgNoReturnFunction(doupdate)
NoArgNoReturnFunction(endwin)
NoArgNoReturnFunction(flash)
NoArgNoReturnFunction(nocbreak)
NoArgNoReturnFunction(noecho)
NoArgNoReturnFunction(nonl)
NoArgNoReturnFunction(noraw)
NoArgNoReturnFunction(reset_prog_mode)
NoArgNoReturnFunction(reset_shell_mode)
NoArgNoReturnFunction(resetty)
NoArgNoReturnFunction(savetty)
NoArgOrFlagNoReturnFunction(cbreak)
NoArgOrFlagNoReturnFunction(echo)
NoArgOrFlagNoReturnFunction(nl)
NoArgOrFlagNoReturnFunction(raw)
NoArgReturnIntFunction(baudrate)
NoArgReturnIntFunction(termattrs)
NoArgReturnStringFunction(termname)
NoArgReturnStringFunction(longname)
NoArgTrueFalseFunction(can_change_color)
NoArgTrueFalseFunction(has_colors)
NoArgTrueFalseFunction(has_ic)
NoArgTrueFalseFunction(has_il)
NoArgTrueFalseFunction(isendwin)
NoArgNoReturnVoidFunction(filter)
NoArgNoReturnVoidFunction(flushinp)
NoArgNoReturnVoidFunction(noqiflush)
static PyObject *
PyCurses_Color_Content(PyObject *self, PyObject *args)
{
short color,r,g,b;
PyCursesInitialised
PyCursesInitialisedColor
if (ARG_COUNT(args) != 1) {
PyErr_SetString(PyExc_TypeError,
"color_content requires 1 argument");
return NULL;
}
if (!PyArg_Parse(args, "h;color", &color)) return NULL;
if (color_content(color, &r, &g, &b) != ERR)
return Py_BuildValue("(iii)", r, g, b);
else {
PyErr_SetString(PyCursesError,
"Argument 1 was out of range. Check value of COLORS.");
return NULL;
}
}
static PyObject *
PyCurses_color_pair(PyObject *self, PyObject *args)
{
int n;
PyCursesInitialised
PyCursesInitialisedColor
if (ARG_COUNT(args) != 1) {
PyErr_SetString(PyExc_TypeError, "color_pair requires 1 argument");
return NULL;
}
if (!PyArg_Parse(args, "i;number", &n)) return NULL;
return PyInt_FromLong((long) (n << 8));
}
static PyObject *
PyCurses_Curs_Set(PyObject *self, PyObject *args)
{
int vis,erg;
PyCursesInitialised
if (ARG_COUNT(args)!=1) {
PyErr_SetString(PyExc_TypeError, "curs_set requires 1 argument");
return NULL;
}
if (!PyArg_Parse(args, "i;int", &vis)) return NULL;
erg = curs_set(vis);
if (erg == ERR) return PyCursesCheckERR(erg, "curs_set");
return PyInt_FromLong((long) erg);
}
static PyObject *
PyCurses_Delay_Output(PyObject *self, PyObject *args)
{
int ms;
PyCursesInitialised
if (ARG_COUNT(args) != 1) {
PyErr_SetString(PyExc_TypeError, "delay_output requires 1 argument");
return NULL;
}
if (!PyArg_Parse(args, "i;ms", &ms)) return NULL;
return PyCursesCheckERR(delay_output(ms), "delay_output");
}
static PyObject *
PyCurses_EraseChar(PyObject *self, PyObject *args)
{
char ch;
PyCursesInitialised
if (!PyArg_NoArgs(args)) return NULL;
ch = erasechar();
return PyString_FromStringAndSize(&ch, 1);
}
static PyObject *
PyCurses_getsyx(PyObject *self, PyObject *args)
{
int x,y;
PyCursesInitialised
if (!PyArg_NoArgs(args)) return NULL;
getsyx(y, x);
return Py_BuildValue("(ii)", y, x);
}
#ifdef NCURSES_MOUSE_VERSION
static PyObject *
PyCurses_GetMouse(PyObject *self, PyObject *args)
{
int rtn;
MEVENT event;
PyCursesInitialised
if (!PyArg_NoArgs(args)) return NULL;
rtn = getmouse( &event );
if (rtn == ERR) {
PyErr_SetString(PyCursesError, "getmouse() returned ERR");
return NULL;
}
return Py_BuildValue("(hiiil)",
(short)event.id,
event.x, event.y, event.z,
(long) event.bstate);
}
static PyObject *
PyCurses_UngetMouse(PyObject *self, PyObject *args)
{
MEVENT event;
PyCursesInitialised
if (!PyArg_ParseTuple(args, "(hiiil)",
&event.id,
&event.x, &event.y, &event.z,
(int *) &event.bstate))
return NULL;
return PyCursesCheckERR(ungetmouse(&event), "ungetmouse");
}
#endif
static PyObject *
PyCurses_GetWin(PyCursesWindowObject *self, PyObject *args)
{
WINDOW *win;
PyObject *temp;
PyCursesInitialised
if (!PyArg_Parse(args, "O;fileobj", &temp)) return NULL;
if (!PyFile_Check(temp)) {
PyErr_SetString(PyExc_TypeError, "argument must be a file object");
return NULL;
}
win = getwin(PyFile_AsFile(temp));
if (win == NULL) {
PyErr_SetString(PyCursesError, catchall_NULL);
return NULL;
}
return PyCursesWindow_New(win);
}
static PyObject *
PyCurses_HalfDelay(PyObject *self, PyObject *args)
{
unsigned char tenths;
PyCursesInitialised
switch(ARG_COUNT(args)) {
case 1:
if (!PyArg_Parse(args, "b;tenths", &tenths)) return NULL;
break;
default:
PyErr_SetString(PyExc_TypeError, "halfdelay requires 1 argument");
return NULL;
}
return PyCursesCheckERR(halfdelay(tenths), "halfdelay");
}
#ifndef STRICT_SYSV_CURSES
/* No has_key! */
static PyObject * PyCurses_has_key(PyObject *self, PyObject *args)
{
int ch;
PyCursesInitialised
if (!PyArg_Parse(args,"i",&ch)) return NULL;
if (has_key(ch) == FALSE) {
Py_INCREF(Py_False);
return Py_False;
}
Py_INCREF(Py_True);
return Py_True;
}
#endif /* STRICT_SYSV_CURSES */
static PyObject *
PyCurses_Init_Color(PyObject *self, PyObject *args)
{
short color, r, g, b;
PyCursesInitialised
PyCursesInitialisedColor
switch(ARG_COUNT(args)) {
case 4:
if (!PyArg_Parse(args, "(hhhh);color,r,g,b", &color, &r, &g, &b)) return NULL;
break;
default:
PyErr_SetString(PyExc_TypeError, "init_color requires 4 arguments");
return NULL;
}
return PyCursesCheckERR(init_color(color, r, g, b), "init_color");
}
static PyObject *
PyCurses_Init_Pair(PyObject *self, PyObject *args)
{
short pair, f, b;
PyCursesInitialised
PyCursesInitialisedColor
if (ARG_COUNT(args) != 3) {
PyErr_SetString(PyExc_TypeError, "init_pair requires 3 arguments");
return NULL;
}
if (!PyArg_Parse(args, "(hhh);pair, f, b", &pair, &f, &b)) return NULL;
return PyCursesCheckERR(init_pair(pair, f, b), "init_pair");
}
static PyObject *ModDict;
static PyObject *
PyCurses_InitScr(PyObject *self, PyObject *args)
{
WINDOW *win;
PyObject *nlines, *cols;
if (!PyArg_NoArgs(args)) return NULL;
if (initialised == TRUE) {
wrefresh(stdscr);
return (PyObject *)PyCursesWindow_New(stdscr);
}
win = initscr();
if (win == NULL) {
PyErr_SetString(PyCursesError, catchall_NULL);
return NULL;
}
initialised = initialised_setupterm = TRUE;
/* This was moved from initcurses() because it core dumped on SGI,
where they're not defined until you've called initscr() */
#define SetDictInt(string,ch) \
PyDict_SetItemString(ModDict,string,PyInt_FromLong((long) (ch)));
/* Here are some graphic symbols you can use */
SetDictInt("ACS_ULCORNER", (ACS_ULCORNER));
SetDictInt("ACS_LLCORNER", (ACS_LLCORNER));
SetDictInt("ACS_URCORNER", (ACS_URCORNER));
SetDictInt("ACS_LRCORNER", (ACS_LRCORNER));
SetDictInt("ACS_LTEE", (ACS_LTEE));
SetDictInt("ACS_RTEE", (ACS_RTEE));
SetDictInt("ACS_BTEE", (ACS_BTEE));
SetDictInt("ACS_TTEE", (ACS_TTEE));
SetDictInt("ACS_HLINE", (ACS_HLINE));
SetDictInt("ACS_VLINE", (ACS_VLINE));
SetDictInt("ACS_PLUS", (ACS_PLUS));
#if !defined(__hpux) || defined(HAVE_NCURSES_H)
/* On HP/UX 11, these are of type cchar_t, which is not an
integral type. If this is a problem on more platforms, a
configure test should be added to determine whether ACS_S1
is of integral type. */
SetDictInt("ACS_S1", (ACS_S1));
SetDictInt("ACS_S9", (ACS_S9));
SetDictInt("ACS_DIAMOND", (ACS_DIAMOND));
SetDictInt("ACS_CKBOARD", (ACS_CKBOARD));
SetDictInt("ACS_DEGREE", (ACS_DEGREE));
SetDictInt("ACS_PLMINUS", (ACS_PLMINUS));
SetDictInt("ACS_BULLET", (ACS_BULLET));
SetDictInt("ACS_LARROW", (ACS_LARROW));
SetDictInt("ACS_RARROW", (ACS_RARROW));
SetDictInt("ACS_DARROW", (ACS_DARROW));
SetDictInt("ACS_UARROW", (ACS_UARROW));
SetDictInt("ACS_BOARD", (ACS_BOARD));
SetDictInt("ACS_LANTERN", (ACS_LANTERN));
SetDictInt("ACS_BLOCK", (ACS_BLOCK));
#endif
SetDictInt("ACS_BSSB", (ACS_ULCORNER));
SetDictInt("ACS_SSBB", (ACS_LLCORNER));
SetDictInt("ACS_BBSS", (ACS_URCORNER));
SetDictInt("ACS_SBBS", (ACS_LRCORNER));
SetDictInt("ACS_SBSS", (ACS_RTEE));
SetDictInt("ACS_SSSB", (ACS_LTEE));
SetDictInt("ACS_SSBS", (ACS_BTEE));
SetDictInt("ACS_BSSS", (ACS_TTEE));
SetDictInt("ACS_BSBS", (ACS_HLINE));
SetDictInt("ACS_SBSB", (ACS_VLINE));
SetDictInt("ACS_SSSS", (ACS_PLUS));
/* The following are never available with strict SYSV curses */
#ifdef ACS_S3
SetDictInt("ACS_S3", (ACS_S3));
#endif
#ifdef ACS_S7
SetDictInt("ACS_S7", (ACS_S7));
#endif
#ifdef ACS_LEQUAL
SetDictInt("ACS_LEQUAL", (ACS_LEQUAL));
#endif
#ifdef ACS_GEQUAL
SetDictInt("ACS_GEQUAL", (ACS_GEQUAL));
#endif
#ifdef ACS_PI
SetDictInt("ACS_PI", (ACS_PI));
#endif
#ifdef ACS_NEQUAL
SetDictInt("ACS_NEQUAL", (ACS_NEQUAL));
#endif
#ifdef ACS_STERLING
SetDictInt("ACS_STERLING", (ACS_STERLING));
#endif
nlines = PyInt_FromLong((long) LINES);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -