Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/howto/curses.rst

    r2 r391  
    119119messed up when the application dies without restoring the terminal to its
    120120previous state.  In Python this commonly happens when your code is buggy and
    121 raises an uncaught exception.  Keys are no longer be echoed to the screen when
     121raises an uncaught exception.  Keys are no longer echoed to the screen when
    122122you type them, for example, which makes using the shell difficult.
    123123
     
    145145window of a given size, returning the new window object. ::
    146146
    147    begin_x = 20 ; begin_y = 7
    148    height = 5 ; width = 40
     147   begin_x = 20; begin_y = 7
     148   height = 5; width = 40
    149149   win = curses.newwin(height, width, begin_y, begin_x)
    150150
     
    185185   for y in range(0, 100):
    186186       for x in range(0, 100):
    187            try: pad.addch(y,x, ord('a') + (x*x+y*y) % 26 )
    188            except curses.error: pass
     187           try:
     188               pad.addch(y,x, ord('a') + (x*x+y*y) % 26)
     189           except curses.error:
     190               pass
    189191
    190192   #  Displays a section of the pad in the middle of the screen
    191    pad.refresh( 0,0, 5,5, 20,75)
     193   pad.refresh(0,0, 5,5, 20,75)
    192194
    193195The :func:`refresh` call displays a section of the pad in the rectangle
     
    272274attribute for each cell on the screen.
    273275
    274 An attribute is a integer, each bit representing a different attribute.  You can
     276An attribute is an integer, each bit representing a different attribute.  You can
    275277try to display text with multiple attribute bits set, but curses doesn't
    276278guarantee that all the possible combinations are available, or that they're all
     
    301303   stdscr.refresh()
    302304
    303 The curses library also supports color on those terminals that provide it, The
     305The curses library also supports color on those terminals that provide it. The
    304306most common such terminal is probably the Linux console, followed by color
    305307xterms.
     
    322324An example, which displays a line of text using color pair 1::
    323325
    324    stdscr.addstr( "Pretty text", curses.color_pair(1) )
     326   stdscr.addstr("Pretty text", curses.color_pair(1))
    325327   stdscr.refresh()
    326328
     
    344346with::
    345347
    346    stdscr.addstr(0,0, "RED ALERT!", curses.color_pair(1) )
     348   stdscr.addstr(0,0, "RED ALERT!", curses.color_pair(1))
    347349
    348350Very fancy terminals can change the definitions of the actual colors to a given
     
    382384   while 1:
    383385       c = stdscr.getch()
    384        if c == ord('p'): PrintDocument()
    385        elif c == ord('q'): break  # Exit the while()
    386        elif c == curses.KEY_HOME: x = y = 0
     386       if c == ord('p'):
     387           PrintDocument()
     388       elif c == ord('q'):
     389           break  # Exit the while()
     390       elif c == curses.KEY_HOME:
     391           x = y = 0
    387392
    388393The :mod:`curses.ascii` module supplies ASCII class membership functions that
     
    434439
    435440The ncurses FAQ: http://invisible-island.net/ncurses/ncurses.faq.html
    436 
Note: See TracChangeset for help on using the changeset viewer.