Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6c95da38
Kaydet (Commit)
6c95da38
authored
Tem 24, 2007
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
ccMake test_curses pass.
Can't guarantee I caught every spot.
üst
51a883bf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
35 deletions
+74
-35
_cursesmodule.c
Modules/_cursesmodule.c
+74
-35
No files found.
Modules/_cursesmodule.c
Dosyayı görüntüle @
6c95da38
...
@@ -201,6 +201,8 @@ PyCurses_ConvertToChtype(PyObject *obj, chtype *ch)
...
@@ -201,6 +201,8 @@ PyCurses_ConvertToChtype(PyObject *obj, chtype *ch)
}
else
if
(
PyString_Check
(
obj
)
}
else
if
(
PyString_Check
(
obj
)
&&
(
PyString_Size
(
obj
)
==
1
))
{
&&
(
PyString_Size
(
obj
)
==
1
))
{
*
ch
=
(
chtype
)
*
PyString_AsString
(
obj
);
*
ch
=
(
chtype
)
*
PyString_AsString
(
obj
);
}
else
if
(
PyUnicode_Check
(
obj
)
&&
PyUnicode_GetSize
(
obj
)
==
1
)
{
*
ch
=
(
chtype
)
*
PyUnicode_AS_UNICODE
(
obj
);
}
else
{
}
else
{
return
0
;
return
0
;
}
}
...
@@ -1281,19 +1283,43 @@ PyCursesWindow_Overwrite(PyCursesWindowObject *self, PyObject *args)
...
@@ -1281,19 +1283,43 @@ PyCursesWindow_Overwrite(PyCursesWindowObject *self, PyObject *args)
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_PutWin
(
PyCursesWindowObject
*
self
,
PyObject
*
args
)
PyCursesWindow_PutWin
(
PyCursesWindowObject
*
self
,
PyObject
*
stream
)
{
{
PyObject
*
temp
;
/* We have to simulate this by writing to a temporary FILE*,
then reading back, then writing to the argument stream. */
if
(
!
PyArg_ParseTuple
(
args
,
"O;fileobj"
,
&
temp
))
char
fn
[
100
];
return
NULL
;
int
fd
;
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a file object"
);
FILE
*
fp
;
return
NULL
;
PyObject
*
res
;
#if 0
strcpy
(
fn
,
"/tmp/py.curses.putwin.XXXXXX"
);
return PyCursesCheckERR(putwin(self->win, PyFile_AsFile(temp)),
fd
=
mkstemp
(
fn
);
"putwin");
if
(
fd
<
0
)
#endif
return
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
fn
);
fp
=
fdopen
(
fd
,
"wb+"
);
if
(
fp
==
NULL
)
{
close
(
fd
);
return
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
fn
);
}
res
=
PyCursesCheckERR
(
putwin
(
self
->
win
,
fp
),
"putwin"
);
if
(
res
==
NULL
)
{
fclose
(
fp
);
return
res
;
}
fseek
(
fp
,
0
,
0
);
while
(
1
)
{
char
buf
[
BUFSIZ
];
int
n
=
fread
(
buf
,
1
,
BUFSIZ
,
fp
);
if
(
n
<=
0
)
break
;
Py_DECREF
(
res
);
res
=
PyObject_CallMethod
(
stream
,
"write"
,
"y#"
,
buf
,
n
);
if
(
res
==
NULL
)
break
;
}
fclose
(
fp
);
remove
(
fn
);
return
res
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1533,7 +1559,7 @@ static PyMethodDef PyCursesWindow_Methods[] = {
...
@@ -1533,7 +1559,7 @@ static PyMethodDef PyCursesWindow_Methods[] = {
{
"overlay"
,
(
PyCFunction
)
PyCursesWindow_Overlay
,
METH_VARARGS
},
{
"overlay"
,
(
PyCFunction
)
PyCursesWindow_Overlay
,
METH_VARARGS
},
{
"overwrite"
,
(
PyCFunction
)
PyCursesWindow_Overwrite
,
{
"overwrite"
,
(
PyCFunction
)
PyCursesWindow_Overwrite
,
METH_VARARGS
},
METH_VARARGS
},
{
"putwin"
,
(
PyCFunction
)
PyCursesWindow_PutWin
,
METH_
VARARGS
},
{
"putwin"
,
(
PyCFunction
)
PyCursesWindow_PutWin
,
METH_
O
},
{
"redrawln"
,
(
PyCFunction
)
PyCursesWindow_RedrawLine
,
METH_VARARGS
},
{
"redrawln"
,
(
PyCFunction
)
PyCursesWindow_RedrawLine
,
METH_VARARGS
},
{
"redrawwin"
,
(
PyCFunction
)
PyCursesWindow_redrawwin
,
METH_NOARGS
},
{
"redrawwin"
,
(
PyCFunction
)
PyCursesWindow_redrawwin
,
METH_NOARGS
},
{
"refresh"
,
(
PyCFunction
)
PyCursesWindow_Refresh
,
METH_VARARGS
},
{
"refresh"
,
(
PyCFunction
)
PyCursesWindow_Refresh
,
METH_VARARGS
},
...
@@ -1742,27 +1768,48 @@ PyCurses_UngetMouse(PyObject *self, PyObject *args)
...
@@ -1742,27 +1768,48 @@ PyCurses_UngetMouse(PyObject *self, PyObject *args)
#endif
#endif
static
PyObject
*
static
PyObject
*
PyCurses_GetWin
(
PyCursesWindowObject
*
self
,
PyObject
*
temp
)
PyCurses_GetWin
(
PyCursesWindowObject
*
self
,
PyObject
*
stream
)
{
{
#if 0
char
fn
[
100
];
int
fd
;
FILE
*
fp
;
PyObject
*
data
;
WINDOW
*
win
;
WINDOW
*
win
;
#endif
PyCursesInitialised
PyCursesInitialised
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a file object"
);
strcpy
(
fn
,
"/tmp/py.curses.getwin.XXXXXX"
);
return
NULL
;
fd
=
mkstemp
(
fn
);
if
(
fd
<
0
)
#if 0
return
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
fn
);
win = getwin(PyFile_AsFile(temp));
fp
=
fdopen
(
fd
,
"wb+"
);
if
(
fp
==
NULL
)
{
close
(
fd
);
return
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
fn
);
}
data
=
PyObject_CallMethod
(
stream
,
"read"
,
""
);
if
(
data
==
NULL
)
{
fclose
(
fp
);
return
NULL
;
}
if
(
!
PyBytes_Check
(
data
))
{
PyErr_Format
(
PyExc_TypeError
,
"f.read() returned %.100s instead of bytes"
,
data
->
ob_type
->
tp_name
);
Py_DECREF
(
data
);
fclose
(
fp
);
return
NULL
;
}
fwrite
(
PyBytes_AS_STRING
(
data
),
1
,
PyBytes_GET_SIZE
(
data
),
fp
);
Py_DECREF
(
data
);
fseek
(
fp
,
0
,
0
);
win
=
getwin
(
fp
);
fclose
(
fp
);
if
(
win
==
NULL
)
{
if
(
win
==
NULL
)
{
PyErr_SetString
(
PyCursesError
,
catchall_NULL
);
PyErr_SetString
(
PyCursesError
,
catchall_NULL
);
return
NULL
;
return
NULL
;
}
}
return
PyCursesWindow_New
(
win
);
return
PyCursesWindow_New
(
win
);
#endif
}
}
static
PyObject
*
static
PyObject
*
...
@@ -2480,11 +2527,7 @@ PyCurses_UnCtrl(PyObject *self, PyObject *args)
...
@@ -2480,11 +2527,7 @@ PyCurses_UnCtrl(PyObject *self, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"O;ch or int"
,
&
temp
))
return
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"O;ch or int"
,
&
temp
))
return
NULL
;
if
(
PyInt_CheckExact
(
temp
))
if
(
!
PyCurses_ConvertToChtype
(
temp
,
&
ch
))
{
ch
=
(
chtype
)
PyInt_AsLong
(
temp
);
else
if
(
PyString_Check
(
temp
))
ch
=
(
chtype
)
*
PyString_AsString
(
temp
);
else
{
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a ch or an int"
);
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a ch or an int"
);
return
NULL
;
return
NULL
;
}
}
...
@@ -2496,17 +2539,13 @@ static PyObject *
...
@@ -2496,17 +2539,13 @@ static PyObject *
PyCurses_UngetCh
(
PyObject
*
self
,
PyObject
*
args
)
PyCurses_UngetCh
(
PyObject
*
self
,
PyObject
*
args
)
{
{
PyObject
*
temp
;
PyObject
*
temp
;
int
ch
;
chtype
ch
;
PyCursesInitialised
PyCursesInitialised
if
(
!
PyArg_ParseTuple
(
args
,
"O;ch or int"
,
&
temp
))
return
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"O;ch or int"
,
&
temp
))
return
NULL
;
if
(
PyInt_CheckExact
(
temp
))
if
(
!
PyCurses_ConvertToChtype
(
temp
,
&
ch
))
{
ch
=
(
int
)
PyInt_AsLong
(
temp
);
else
if
(
PyString_Check
(
temp
))
ch
=
(
int
)
*
PyString_AsString
(
temp
);
else
{
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a ch or an int"
);
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a ch or an int"
);
return
NULL
;
return
NULL
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment