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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
33 deletions
+72
-33
_cursesmodule.c
Modules/_cursesmodule.c
+72
-33
No files found.
Modules/_cursesmodule.c
Dosyayı görüntüle @
6c95da38
...
...
@@ -201,6 +201,8 @@ PyCurses_ConvertToChtype(PyObject *obj, chtype *ch)
}
else
if
(
PyString_Check
(
obj
)
&&
(
PyString_Size
(
obj
)
==
1
))
{
*
ch
=
(
chtype
)
*
PyString_AsString
(
obj
);
}
else
if
(
PyUnicode_Check
(
obj
)
&&
PyUnicode_GetSize
(
obj
)
==
1
)
{
*
ch
=
(
chtype
)
*
PyUnicode_AS_UNICODE
(
obj
);
}
else
{
return
0
;
}
...
...
@@ -1281,19 +1283,43 @@ PyCursesWindow_Overwrite(PyCursesWindowObject *self, PyObject *args)
}
static
PyObject
*
PyCursesWindow_PutWin
(
PyCursesWindowObject
*
self
,
PyObject
*
args
)
PyCursesWindow_PutWin
(
PyCursesWindowObject
*
self
,
PyObject
*
stream
)
{
PyObject
*
temp
;
if
(
!
PyArg_ParseTuple
(
args
,
"O;fileobj"
,
&
temp
))
return
NULL
;
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a file object"
)
;
return
NULL
;
/* We have to simulate this by writing to a temporary FILE*,
then reading back, then writing to the argument stream. */
char
fn
[
100
];
int
fd
;
FILE
*
fp
;
PyObject
*
res
;
#if 0
return PyCursesCheckERR(putwin(self->win, PyFile_AsFile(temp)),
"putwin");
#endif
strcpy
(
fn
,
"/tmp/py.curses.putwin.XXXXXX"
);
fd
=
mkstemp
(
fn
);
if
(
fd
<
0
)
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
*
...
...
@@ -1533,7 +1559,7 @@ static PyMethodDef PyCursesWindow_Methods[] = {
{
"overlay"
,
(
PyCFunction
)
PyCursesWindow_Overlay
,
METH_VARARGS
},
{
"overwrite"
,
(
PyCFunction
)
PyCursesWindow_Overwrite
,
METH_VARARGS
},
{
"putwin"
,
(
PyCFunction
)
PyCursesWindow_PutWin
,
METH_
VARARGS
},
{
"putwin"
,
(
PyCFunction
)
PyCursesWindow_PutWin
,
METH_
O
},
{
"redrawln"
,
(
PyCFunction
)
PyCursesWindow_RedrawLine
,
METH_VARARGS
},
{
"redrawwin"
,
(
PyCFunction
)
PyCursesWindow_redrawwin
,
METH_NOARGS
},
{
"refresh"
,
(
PyCFunction
)
PyCursesWindow_Refresh
,
METH_VARARGS
},
...
...
@@ -1742,27 +1768,48 @@ PyCurses_UngetMouse(PyObject *self, PyObject *args)
#endif
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
;
#endif
PyCursesInitialised
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a file object"
);
strcpy
(
fn
,
"/tmp/py.curses.getwin.XXXXXX"
);
fd
=
mkstemp
(
fn
);
if
(
fd
<
0
)
return
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
fn
);
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 0
win = getwin(PyFile_AsFile(temp));
}
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
)
{
PyErr_SetString
(
PyCursesError
,
catchall_NULL
);
return
NULL
;
}
return
PyCursesWindow_New
(
win
);
#endif
}
static
PyObject
*
...
...
@@ -2480,11 +2527,7 @@ PyCurses_UnCtrl(PyObject *self, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"O;ch or int"
,
&
temp
))
return
NULL
;
if
(
PyInt_CheckExact
(
temp
))
ch
=
(
chtype
)
PyInt_AsLong
(
temp
);
else
if
(
PyString_Check
(
temp
))
ch
=
(
chtype
)
*
PyString_AsString
(
temp
);
else
{
if
(
!
PyCurses_ConvertToChtype
(
temp
,
&
ch
))
{
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a ch or an int"
);
return
NULL
;
}
...
...
@@ -2496,17 +2539,13 @@ static PyObject *
PyCurses_UngetCh
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
temp
;
int
ch
;
chtype
ch
;
PyCursesInitialised
if
(
!
PyArg_ParseTuple
(
args
,
"O;ch or int"
,
&
temp
))
return
NULL
;
if
(
PyInt_CheckExact
(
temp
))
ch
=
(
int
)
PyInt_AsLong
(
temp
);
else
if
(
PyString_Check
(
temp
))
ch
=
(
int
)
*
PyString_AsString
(
temp
);
else
{
if
(
!
PyCurses_ConvertToChtype
(
temp
,
&
ch
))
{
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a ch or an int"
);
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