Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
PyPy
pypy
Commits
28382af84334
Commit
01eeed3f
authored
Oct 31, 2019
by
Matti Picus
Browse files
backport ncurses changes from portable-pypy
parent
3c4872b35c28
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib_pypy/_curses_build.py
View file @
28382af8
from
cffi
import
FFI
import
os
# On some systems, the ncurses library is
# located at /usr/include/ncurses, so we must check this case.
# Let's iterate over well known paths
incdirs
=
[]
for
_path
in
[
'/usr/include'
,
'/usr/include/ncurses'
]:
if
os
.
path
.
isfile
(
os
.
path
.
join
(
_path
,
'panel.h'
)):
incdirs
.
append
(
_path
)
break
def
find_library
(
options
):
for
library
in
options
:
ffi
=
FFI
()
ffi
.
set_source
(
"_curses_cffi_check"
,
""
,
libraries
=
[
library
])
try
:
ffi
.
compile
()
except
VerificationError
as
e
:
e_last
=
e
continue
else
:
return
library
# If none of the options is available, present the user a meaningful
# error message
raise
e_last
def
find_curses_include_dirs
():
if
os
.
path
.
exists
(
'/usr/include/ncurses'
):
return
[
'/usr/include/ncurses'
]
if
os
.
path
.
exists
(
'/usr/include/ncursesw'
):
return
[
'/usr/include/ncursesw'
]
return
[]
ffi
=
FFI
()
...
...
@@ -59,8 +73,9 @@ int _m_ispad(WINDOW *win) {
void _m_getsyx(int *yx) {
getsyx(yx[0], yx[1]);
}
"""
,
include_dirs
=
incdirs
,
libraries
=
[
'ncurses'
,
'panel'
])
"""
,
libraries
=
[
find_library
([
'ncurses'
,
'ncursesw'
]),
find_library
([
'panel'
,
'panelw'
])],
include_dirs
=
find_curses_include_dirs
())
ffi
.
cdef
(
"""
...
...
@@ -71,6 +86,8 @@ typedef unsigned char bool;
typedef unsigned long... chtype;
typedef chtype attr_t;
typedef int... wint_t;
typedef struct
{
short id; /* ID to distinguish multiple devices */
...
...
@@ -82,6 +99,7 @@ MEVENT;
static const int ERR, OK;
static const int TRUE, FALSE;
static const int KEY_MIN, KEY_MAX;
static const int KEY_CODE_YES;
static const int COLOR_BLACK;
static const int COLOR_RED;
...
...
@@ -168,6 +186,8 @@ char erasechar(void);
void filter(void);
int flash(void);
int flushinp(void);
int wget_wch(WINDOW *, wint_t *);
int mvwget_wch(WINDOW *, int, int, wint_t *);
chtype getbkgd(WINDOW *);
WINDOW * getwin(FILE *);
int halfdelay(int);
...
...
@@ -243,6 +263,7 @@ int touchline(WINDOW *, int, int);
int touchwin(WINDOW *);
int typeahead(int);
int ungetch(int);
int unget_wch(const wchar_t);
int untouchwin(WINDOW *);
void use_env(bool);
int waddch(WINDOW *, const chtype);
...
...
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