]> granicus.if.org Git - python/commitdiff
[Patch #739124] Add use_default_colors() to curses module
authorAndrew M. Kuchling <amk@amk.ca>
Wed, 13 Aug 2003 23:11:04 +0000 (23:11 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Wed, 13 Aug 2003 23:11:04 +0000 (23:11 +0000)
Doc/lib/libcurses.tex
Doc/whatsnew/whatsnew24.tex
Lib/test/test_curses.py
Misc/ACKS
Misc/NEWS
Modules/_cursesmodule.c

index 296e8874fcaff66b2f5ac338ee17295279047e04..1eace435c07a9d0ede6f05e3d966da103bb987f6 100644 (file)
@@ -537,6 +537,15 @@ a window (in which case default behavior would be to use the window
 size if \envvar{LINES} and \envvar{COLUMNS} are not set).
 \end{funcdesc}
 
+\begin{funcdesc}{use_default_colors}{}
+Allow use of default values for colors on terminals supporting this
+feature. Use this to support transparency in your
+application.  The default color is assigned to the color number -1.
+After calling this function, 
+\function{init_pair(x, curses.COLOR_RED, -1)} initializes, for instance,
+color pair \var{x} to a red foreground color on the default background.
+\end{funcdesc}
+
 \subsection{Window Objects \label{curses-window-objects}}
 
 Window objects, as returned by \function{initscr()} and
index e49825f507597235176456335caf89fc740b6401..2f0df30fe172692a30b3bb0f7b4b0ee7b6ff8398 100644 (file)
@@ -69,8 +69,11 @@ details.
 
 \begin{itemize}
 
-\item Descriptions go here.
-
+\item The \module{curses} modules now supports the ncurses extension 
+   \function{use_default_colors()}.   On platforms where the terminal 
+   supports transparency, this makes it possible to use a transparent background.
+   (Contributed by J\"org Lehmann.)
+   
 \end{itemize}
 
 
index 188da8d28601fabeac6fe75d3c69631654d4e69e..f62783f54e2a7956d6ecce1d0cdc7c15d9db6079 100644 (file)
@@ -181,6 +181,9 @@ def module_funcs(stdscr):
         curses.pair_content(curses.COLOR_PAIRS)
         curses.pair_number(0)
 
+    if hasattr(curses, 'use_default_colors'):
+        curses.use_default_colors()
+
     if hasattr(curses, 'keyname'):
         curses.keyname(13)
 
index de27616d9eaa2f7d7013aa8d9878c1898477b242..a0206ab7147991d35ff4f7636c95eac6cab902a7 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -325,6 +325,7 @@ Inyeol Lee
 John J. Lee
 Luc Lefebvre
 Kip Lehman
+Joerg Lehmann
 Marc-Andre Lemburg
 William Lewis
 Robert van Liere
index 93c7fb8b8d594cd63ac0f34486c14ac0c18d7c0e..ee464cac67b9936b5e8f5c1febdd344e73dc00ca 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -22,6 +22,8 @@ Extension modules
 
 - The signal module now exposes SIGRTMIN and SIGRTMAX (if available).
 
+- curses module now supports use_default_colors().  [patch #739124]
+
 Library
 -------
 
index 4424dae6923f4db720e6b3df2c29b2ce472635f1..51f4c388fe6e046bcbcf20d541164f23d7777054 100644 (file)
@@ -47,7 +47,7 @@ unsupported functions:
        resizeterm restartterm ripoffline scr_dump
        scr_init scr_restore scr_set scrl set_curterm set_term setterm
        tgetent tgetflag tgetnum tgetstr tgoto timeout tputs
-       use_default_colors vidattr vidputs waddchnstr waddchstr wchgat
+       vidattr vidputs waddchnstr waddchstr wchgat
        wcolor_set winchnstr winchstr winnstr wmouse_trafo wscrl
 
 Low-priority: 
@@ -2354,6 +2354,26 @@ PyCurses_Use_Env(PyObject *self, PyObject *args)
   return Py_None;
 }
 
+#ifndef STRICT_SYSV_CURSES
+static PyObject *
+PyCurses_Use_Default_Colors(PyObject *self)
+{
+  int code;
+
+  PyCursesInitialised
+  PyCursesInitialisedColor
+
+  code = use_default_colors();
+  if (code != ERR) {
+    Py_INCREF(Py_None);
+    return Py_None;
+  } else {
+    PyErr_SetString(PyCursesError, "use_default_colors() returned ERR");
+    return NULL;
+  }
+}
+#endif /* STRICT_SYSV_CURSES */
+
 /* List of functions defined in the module */
 
 static PyMethodDef PyCurses_methods[] = {
@@ -2434,6 +2454,9 @@ static PyMethodDef PyCurses_methods[] = {
   {"unctrl",              (PyCFunction)PyCurses_UnCtrl, METH_VARARGS},
   {"ungetch",             (PyCFunction)PyCurses_UngetCh, METH_VARARGS},
   {"use_env",             (PyCFunction)PyCurses_Use_Env, METH_VARARGS},
+#ifndef STRICT_SYSV_CURSES
+  {"use_default_colors",  (PyCFunction)PyCurses_Use_Default_Colors, METH_NOARGS},
+#endif
   {NULL,                 NULL}         /* sentinel */
 };