Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ebd3f6

Browse files
Tweak curses.wrapper so it initializes colors if they are available.
1 parent 46a4151 commit 1ebd3f6

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

Doc/lib/libcurses.tex

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,8 +1300,9 @@ \section{\module{curses.wrapper} ---
13001300
\function{wrapper()}.
13011301
\end{funcdesc}
13021302

1303-
Before calling the hook function, \function{wrapper()} turns on
1304-
cbreak mode, turns off echo, and enables the terminal keypad. On
1305-
exit (whether normally or by exception) it restores cooked mode,
1306-
turns on echo, and disables the terminal keypad.
1303+
Before calling the hook function, \function{wrapper()} turns on cbreak
1304+
mode, turns off echo, enables the terminal keypad, and initializes
1305+
colors if the terminal has color support. On exit (whether normally
1306+
or by exception) it restores cooked mode, turns on echo, and disables
1307+
the terminal keypad.
13071308

Lib/curses/wrapper.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ def wrapper(func, *rest):
3232
# a special value like curses.KEY_LEFT will be returned
3333
stdscr.keypad(1)
3434

35+
# Start color, too. Harmless if the terminal doesn't have
36+
# color; user can test with has_color() later on. The try/catch
37+
# works around a minor bit of over-conscientiousness in the curses
38+
# module -- the error return from C start_color() is ignorable.
39+
try:
40+
curses.start_color()
41+
except:
42+
pass
43+
3544
res = apply(func, (stdscr,) + rest)
3645
except:
3746
# In the event of an error, restore the terminal

configure.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,12 @@ AC_SUBST(HAVE_GETHOSTBYNAME)
10141014
# checks for system services
10151015
# (none yet)
10161016

1017+
# Cope with the DB mess. If we detect libdba, assume it's a version 2
1018+
# or later DB and should be linked first (before the DB 1.xx stuff in glibc).
1019+
# Also define an appropriate symbol so we can conditionalize code in the
1020+
# dbmmodule; the API has changed since 1.xx.
1021+
AC_CHECK_LIB(dba, __db_mutex_lock)
1022+
10171023
# Linux requires this for correct f.p. operations
10181024
AC_CHECK_FUNC(__fpu_control,
10191025
[],

0 commit comments

Comments
 (0)