Index: curses.rst =================================================================== --- curses.rst (revision 70021) +++ curses.rst (working copy) @@ -173,6 +173,11 @@ ``stdscr.refresh()`` or the :func:`refresh` method of some other relevant window. +The previous being said however, some implementations of ncurses, such as +the GNU version of ncurses, will immediately refresh the display when +the following methods are called `addchstr`, `addchnstr`, `mvaddchstr`, and +`mvaddchnstr`. These methods are invoked via the :func:`addchstr` method. + A pad is a special case of a window; it can be larger than the actual display screen, and only a portion of it displayed at a time. Creating a pad simply requires the pad's height and width, while refreshing a pad requires giving the @@ -353,7 +358,62 @@ which returns TRUE if the capability is there. If you're lucky enough to have such a talented terminal, consult your system's man pages for more information. +Starting in release 2.7, the curses support has been extended to include the +:meth:`addchstr` family of functions. These include: :meth:`addchstr`, +:meth:`addchnstr`, :meth:`mvaddchstr`, :meth:`mvaddchnstr`, :meth:`mvwaddchstr`, +:meth:`mvwaddchnstr`, :meth:`waddchstr`, :meth:`waddchnstr`. As with the +:func:`addchstr` on the curses and the curses window objects. The curses library +names its functions to indicate whether the call applies to the screen or a window. +For example, addchstr applies to the screen, and waddchstr applies to a window. In +the Python module this is indicated by whether you call curses.addchstr, or +somewindow.addchstr. The appropriate method is invoked accordingly, based on the +arguments passed in. See the following table. ++---------------------------------+-----------------------------------------------+ +| Arguments | Description | ++=================================+===============================================+ +| *int_list* | Invokes either the :meth:`addchstr`, | +| | or the :meth:`waddchstr` method. | ++---------------------------------+-----------------------------------------------+ +| *int_list*, *int* | Invokes either the :meth:`addchnstr` | +| | or the :meth:`waddchnstr` method. | ++---------------------------------+-----------------------------------------------+ +| *y*, *x*, *int_list* | Invokes either the :meth:`mvaddchstr` | +| | or the :meth:`mvwaddchstr` method. | ++---------------------------------+-----------------------------------------------+ +| *y*, *x*, *int_list*, *int* | Invokes either the :meth:`mvaddchnstr` | +| | or the :meth:`mvwaddchnstr` method. | ++---------------------------------+-----------------------------------------------+ + +The *long_list* argument is a Python list of integers. Each integer encapsulates +all of the information needed to represent that character on the terminal. For +example, suppose we have the following python code:: + + curses.init_pair(1, curses.BLUE, curses.WHITE) + curses.init_pair(2, curses.YELLOW, curses.RED) + + attrBWU = curses.color_pair(1) | curses.A_UNDERLINE + attrYRB = curses.color_pair(2) | curses.A_BOLD + + msg = [] + s = "Hello" + for i in range(0, len(s)): + chtype = ord(s[i]) | attrBWU + msg.append(chtype) + + msg.append(ord(" ")) + + s = "World" + for i in range(0, len(s)): + chtype = ord(s[i]) | attrYRB + msg.append(chtype) + + curses.addchstr(10, 20, msg) + +The terminal would immediately (no refresh needed) display "Hello World" starting at +row 10 column 20. Hello would be blue on white, bolded, and World would be yellow +on red, underlined. Note, the cursor position would remain unaffected. + User Input ==========