Changeset 391 for python/trunk/Doc/library/curses.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/curses.rst
r2 r391 45 45 Editable text widget for curses supporting :program:`Emacs`\ -like bindings. 46 46 47 Module :mod:`curses.wrapper`48 Convenience function to ensure proper terminal setup and resetting on49 application entry and exit.50 51 47 :ref:`curses-howto` 52 48 Tutorial material on using curses with Python, by Andrew Kuchling and Eric 53 49 Raymond. 54 50 55 The : file:`Demo/curses/` directory in the Python source distribution contains51 The :source:`Demo/curses/` directory in the Python source distribution contains 56 52 some example programs using the curses bindings provided by this module. 57 53 … … 80 76 .. function:: baudrate() 81 77 82 Return sthe output speed of the terminal in bits per second. On software78 Return the output speed of the terminal in bits per second. On software 83 79 terminal emulators it will have a fixed high value. Included for historical 84 80 reasons; in former times, it was used to write output loops for time delays and … … 93 89 .. function:: can_change_color() 94 90 95 Return s true or false, depending on whether the programmer can change the colors91 Return ``True`` or ``False``, depending on whether the programmer can change the colors 96 92 displayed by the terminal. 97 93 … … 108 104 .. function:: color_content(color_number) 109 105 110 Return sthe intensity of the red, green, and blue (RGB) components in the color106 Return the intensity of the red, green, and blue (RGB) components in the color 111 107 *color_number*, which must be between ``0`` and :const:`COLORS`. A 3-tuple is 112 108 returned, containing the R,G,B values for the given color, which will be between … … 116 112 .. function:: color_pair(color_number) 117 113 118 Return sthe attribute value for displaying text in the specified color. This114 Return the attribute value for displaying text in the specified color. This 119 115 attribute value can be combined with :const:`A_STANDOUT`, :const:`A_REVERSE`, 120 116 and the other :const:`A_\*` attributes. :func:`pair_number` is the counterpart … … 124 120 .. function:: curs_set(visibility) 125 121 126 Set sthe cursor state. *visibility* can be set to 0, 1, or 2, for invisible,122 Set the cursor state. *visibility* can be set to 0, 1, or 2, for invisible, 127 123 normal, or very visible. If the terminal supports the visibility requested, the 128 124 previous cursor state is returned; otherwise, an exception is raised. On many … … 133 129 .. function:: def_prog_mode() 134 130 135 Save sthe current terminal mode as the "program" mode, the mode when the running131 Save the current terminal mode as the "program" mode, the mode when the running 136 132 program is using curses. (Its counterpart is the "shell" mode, for when the 137 133 program is not in curses.) Subsequent calls to :func:`reset_prog_mode` will … … 141 137 .. function:: def_shell_mode() 142 138 143 Save sthe current terminal mode as the "shell" mode, the mode when the running139 Save the current terminal mode as the "shell" mode, the mode when the running 144 140 program is not using curses. (Its counterpart is the "program" mode, when the 145 141 program is using curses capabilities.) Subsequent calls to … … 149 145 .. function:: delay_output(ms) 150 146 151 Insert san *ms* millisecond pause in output.147 Insert an *ms* millisecond pause in output. 152 148 153 149 … … 180 176 .. function:: erasechar() 181 177 182 Return sthe user's current erase character. Under Unix operating systems this178 Return the user's current erase character. Under Unix operating systems this 183 179 is a property of the controlling tty of the curses program, and is not set by 184 180 the curses library itself. … … 188 184 189 185 The :func:`.filter` routine, if used, must be called before :func:`initscr` is 190 called. The effect is that, during those calls, LINESis set to 1; the186 called. The effect is that, during those calls, :envvar:`LINES` is set to 1; the 191 187 capabilities clear, cup, cud, cud1, cuu1, cuu, vpa are disabled; and the home 192 188 string is set to the value of cr. The effect is that the cursor is confined to … … 214 210 5-tuple ``(id, x, y, z, bstate)``. *id* is an ID value used to distinguish 215 211 multiple devices, and *x*, *y*, *z* are the event's coordinates. (*z* is 216 currently unused.) .*bstate* is an integer value whose bits will be set to212 currently unused.) *bstate* is an integer value whose bits will be set to 217 213 indicate the type of event, and will be the bitwise OR of one or more of the 218 214 following constants, where *n* is the button number from 1 to 4: … … 224 220 .. function:: getsyx() 225 221 226 Return sthe current coordinates of the virtual screen cursor in y and x. If222 Return the current coordinates of the virtual screen cursor in y and x. If 227 223 leaveok is currently true, then -1,-1 is returned. 228 224 … … 230 226 .. function:: getwin(file) 231 227 232 Read swindow related data stored in the file by an earlier :func:`putwin` call.228 Read window related data stored in the file by an earlier :func:`putwin` call. 233 229 The routine then creates and initializes a new window using that data, returning 234 230 the new window object. … … 237 233 .. function:: has_colors() 238 234 239 Return s true if the terminal can display colors; otherwise, it returns false.235 Return ``True`` if the terminal can display colors; otherwise, return ``False``. 240 236 241 237 242 238 .. function:: has_ic() 243 239 244 Return s true if the terminal has insert- and delete-character capabilities.240 Return ``True`` if the terminal has insert- and delete-character capabilities. 245 241 This function is included for historical reasons only, as all modern software 246 242 terminal emulators have such capabilities. … … 249 245 .. function:: has_il() 250 246 251 Return s true if the terminal has insert- and delete-line capabilities, orcan247 Return ``True`` if the terminal has insert- and delete-line capabilities, or can 252 248 simulate them using scrolling regions. This function is included for 253 249 historical reasons only, as all modern software terminal emulators have such … … 257 253 .. function:: has_key(ch) 258 254 259 Take s a key value *ch*, and returns trueif the current terminal type recognizes255 Take a key value *ch*, and return ``True`` if the current terminal type recognizes 260 256 a key with that value. 261 257 … … 266 262 typed by the user are immediately available to the program. However, after 267 263 blocking for *tenths* tenths of seconds, an exception is raised if nothing has 268 been typed. The value of *tenths* must be a number between 1 and 255. Use264 been typed. The value of *tenths* must be a number between ``1`` and ``255``. Use 269 265 :func:`nocbreak` to leave half-delay mode. 270 266 … … 272 268 .. function:: init_color(color_number, r, g, b) 273 269 274 Change sthe definition of a color, taking the number of the color to be changed270 Change the definition of a color, taking the number of the color to be changed 275 271 followed by three RGB values (for the amounts of red, green, and blue 276 272 components). The value of *color_number* must be between ``0`` and … … 283 279 .. function:: init_pair(pair_number, fg, bg) 284 280 285 Change sthe definition of a color-pair. It takes three arguments: the number of281 Change the definition of a color-pair. It takes three arguments: the number of 286 282 the color-pair to be changed, the foreground color number, and the background 287 283 color number. The value of *pair_number* must be between ``1`` and … … 295 291 .. function:: initscr() 296 292 297 Initialize the library. Return sa :class:`WindowObject` which represents the293 Initialize the library. Return a :class:`WindowObject` which represents the 298 294 whole screen. 299 295 … … 304 300 305 301 302 .. function:: is_term_resized(nlines, ncols) 303 304 Return ``True`` if :func:`resize_term` would modify the window structure, 305 ``False`` otherwise. 306 307 306 308 .. function:: isendwin() 307 309 308 Return s trueif :func:`endwin` has been called (that is, the curses library has310 Return ``True`` if :func:`endwin` has been called (that is, the curses library has 309 311 been deinitialized). 310 312 … … 322 324 .. function:: killchar() 323 325 324 Return sthe user's current line kill character. Under Unix operating systems326 Return the user's current line kill character. Under Unix operating systems 325 327 this is a property of the controlling tty of the curses program, and is not set 326 328 by the curses library itself. … … 329 331 .. function:: longname() 330 332 331 Return sa string containing the terminfo long name field describing the current333 Return a string containing the terminfo long name field describing the current 332 334 terminal. The maximum length of a verbose description is 128 characters. It is 333 335 defined only after the call to :func:`initscr`. … … 342 344 .. function:: mouseinterval(interval) 343 345 344 Set sthe maximum time in milliseconds that can elapse between press and release345 events in order for them to be recognized as a click, and return sthe previous346 Set the maximum time in milliseconds that can elapse between press and release 347 events in order for them to be recognized as a click, and return the previous 346 348 interval value. The default value is 200 msec, or one fifth of a second. 347 349 … … 349 351 .. function:: mousemask(mousemask) 350 352 351 Set s the mouse events to be reported, and returnsa tuple ``(availmask,353 Set the mouse events to be reported, and return a tuple ``(availmask, 352 354 oldmask)``. *availmask* indicates which of the specified mouse events can be 353 355 reported; on complete failure it returns 0. *oldmask* is the previous value of … … 363 365 .. function:: newpad(nlines, ncols) 364 366 365 Create s and returnsa pointer to a new pad data structure with the given number367 Create and return a pointer to a new pad data structure with the given number 366 368 of lines and columns. A pad is returned as a window object. 367 369 … … 373 375 methods of a pad require 6 arguments to specify the part of the pad to be 374 376 displayed and the location on the screen to be used for the display. The 375 arguments are pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol; the p377 arguments are *pminrow*, *pmincol*, *sminrow*, *smincol*, *smaxrow*, *smaxcol*; the *p* 376 378 arguments refer to the upper left corner of the pad region to be displayed and 377 the sarguments define a clipping box on the screen within which the pad region379 the *s* arguments define a clipping box on the screen within which the pad region 378 380 is to be displayed. 379 381 380 382 381 .. function:: newwin([nlines, ncols,] begin_y, begin_x) 383 .. function:: newwin(begin_y, begin_x) 384 newwin(nlines, ncols, begin_y, begin_x) 382 385 383 386 Return a new window, whose left-upper corner is at ``(begin_y, begin_x)``, and … … 417 420 .. function:: noqiflush() 418 421 419 When the noqiflushroutine is used, normal flush of input and output queues422 When the :func:`noqiflush` routine is used, normal flush of input and output queues 420 423 associated with the INTR, QUIT and SUSP characters will not be done. You may 421 424 want to call :func:`noqiflush` in a signal handler if you want output to … … 430 433 .. function:: pair_content(pair_number) 431 434 432 Return sa tuple ``(fg, bg)`` containing the colors for the requested color pair.435 Return a tuple ``(fg, bg)`` containing the colors for the requested color pair. 433 436 The value of *pair_number* must be between ``1`` and ``COLOR_PAIRS - 1``. 434 437 … … 436 439 .. function:: pair_number(attr) 437 440 438 Return sthe number of the color-pair set by the attribute value *attr*.441 Return the number of the color-pair set by the attribute value *attr*. 439 442 :func:`color_pair` is the counterpart to this function. 440 443 … … 442 445 .. function:: putp(string) 443 446 444 Equivalent to ``tputs(str, 1, putchar)``; emit sthe value of a specified445 terminfo capability for the current terminal. Note that the output of putp447 Equivalent to ``tputs(str, 1, putchar)``; emit the value of a specified 448 terminfo capability for the current terminal. Note that the output of :func:`putp` 446 449 always goes to standard output. 447 450 … … 449 452 .. function:: qiflush( [flag] ) 450 453 451 If *flag* is false, the effect is the same as calling :func:`noqiflush`. If452 *flag* is true, or no argument is provided, the queues will be flushed when454 If *flag* is ``False``, the effect is the same as calling :func:`noqiflush`. If 455 *flag* is ``True``, or no argument is provided, the queues will be flushed when 453 456 these control characters are read. 454 457 … … 463 466 .. function:: reset_prog_mode() 464 467 465 Restore sthe terminal to "program" mode, as previously saved by468 Restore the terminal to "program" mode, as previously saved by 466 469 :func:`def_prog_mode`. 467 470 … … 469 472 .. function:: reset_shell_mode() 470 473 471 Restore sthe terminal to "shell" mode, as previously saved by474 Restore the terminal to "shell" mode, as previously saved by 472 475 :func:`def_shell_mode`. 473 476 474 477 478 .. function:: resetty() 479 480 Restore the state of the terminal modes to what it was at the last call to 481 :func:`savetty`. 482 483 484 .. function:: resize_term(nlines, ncols) 485 486 Backend function used by :func:`resizeterm`, performing most of the work; 487 when resizing the windows, :func:`resize_term` blank-fills the areas that are 488 extended. The calling application should fill in these areas with 489 appropriate data. The :func:`resize_term` function attempts to resize all 490 windows. However, due to the calling convention of pads, it is not possible 491 to resize these without additional interaction with the application. 492 493 494 .. function:: resizeterm(nlines, ncols) 495 496 Resize the standard and current windows to the specified dimensions, and 497 adjusts other bookkeeping data used by the curses library that record the 498 window dimensions (in particular the SIGWINCH handler). 499 500 501 .. function:: savetty() 502 503 Save the current state of the terminal modes in a buffer, usable by 504 :func:`resetty`. 505 506 475 507 .. function:: setsyx(y, x) 476 508 477 Set sthe virtual screen cursor to *y*, *x*. If *y* and *x* are both -1, then509 Set the virtual screen cursor to *y*, *x*. If *y* and *x* are both -1, then 478 510 leaveok is set. 479 511 … … 481 513 .. function:: setupterm([termstr, fd]) 482 514 483 Initialize sthe terminal. *termstr* is a string giving the terminal name; if484 omitted, the value of the TERMenvironment variable will be used. *fd* is the515 Initialize the terminal. *termstr* is a string giving the terminal name; if 516 omitted, the value of the :envvar:`TERM` environment variable will be used. *fd* is the 485 517 file descriptor to which any initialization sequences will be sent; if not 486 518 supplied, the file descriptor for ``sys.stdout`` will be used. … … 502 534 .. function:: termattrs() 503 535 504 Return sa logical OR of all video attributes supported by the terminal. This536 Return a logical OR of all video attributes supported by the terminal. This 505 537 information is useful when a curses program needs complete control over the 506 538 appearance of the screen. … … 509 541 .. function:: termname() 510 542 511 Return s the value of the environment variable TERM, truncated to 14 characters.543 Return the value of the environment variable :envvar:`TERM`, truncated to 14 characters. 512 544 513 545 514 546 .. function:: tigetflag(capname) 515 547 516 Return sthe value of the Boolean capability corresponding to the terminfo548 Return the value of the Boolean capability corresponding to the terminfo 517 549 capability name *capname*. The value ``-1`` is returned if *capname* is not a 518 550 Boolean capability, or ``0`` if it is canceled or absent from the terminal … … 522 554 .. function:: tigetnum(capname) 523 555 524 Return sthe value of the numeric capability corresponding to the terminfo556 Return the value of the numeric capability corresponding to the terminfo 525 557 capability name *capname*. The value ``-2`` is returned if *capname* is not a 526 558 numeric capability, or ``-1`` if it is canceled or absent from the terminal … … 530 562 .. function:: tigetstr(capname) 531 563 532 Return sthe value of the string capability corresponding to the terminfo564 Return the value of the string capability corresponding to the terminfo 533 565 capability name *capname*. ``None`` is returned if *capname* is not a string 534 566 capability, or is canceled or absent from the terminal description. … … 537 569 .. function:: tparm(str[,...]) 538 570 539 Instantiate s the string *str* with the supplied parameters, where*str* should540 be a parameterized string obtained from the terminfo 541 ``tparm(tigetstr("cup"), 5, 3)`` could result in 571 Instantiate the string *str* with the supplied parameters, where *str* should 572 be a parameterized string obtained from the terminfo database. E.g. 573 ``tparm(tigetstr("cup"), 5, 3)`` could result in ``'\033[6;4H'``, the exact 542 574 result depending on terminal type. 543 575 … … 545 577 .. function:: typeahead(fd) 546 578 547 Specif iesthat the file descriptor *fd* be used for typeahead checking. If *fd*579 Specify that the file descriptor *fd* be used for typeahead checking. If *fd* 548 580 is ``-1``, then no typeahead checking is done. 549 581 … … 557 589 .. function:: unctrl(ch) 558 590 559 Return sa string which is a printable representation of the character *ch*.591 Return a string which is a printable representation of the character *ch*. 560 592 Control characters are displayed as a caret followed by the character, for 561 593 example as ``^C``. Printing characters are left as they are. … … 580 612 581 613 If used, this function should be called before :func:`initscr` or newterm are 582 called. When *flag* is false, the values of lines and columns specified in the614 called. When *flag* is ``False``, the values of lines and columns specified in the 583 615 terminfo database will be used, even if environment variables :envvar:`LINES` 584 616 and :envvar:`COLUMNS` (used by default) are set, or if curses is running in a … … 596 628 597 629 630 .. function:: wrapper(func, ...) 631 632 Initialize curses and call another callable object, *func*, which should be the 633 rest of your curses-using application. If the application raises an exception, 634 this function will restore the terminal to a sane state before re-raising the 635 exception and generating a traceback. The callable object *func* is then passed 636 the main window 'stdscr' as its first argument, followed by any other arguments 637 passed to :func:`wrapper`. Before calling *func*, :func:`wrapper` turns on 638 cbreak mode, turns off echo, enables the terminal keypad, and initializes colors 639 if the terminal has color support. On exit (whether normally or by exception) 640 it restores cooked mode, turns on echo, and disables the terminal keypad. 641 642 598 643 .. _curses-window-objects: 599 644 … … 605 650 606 651 607 .. method:: window.addch([y, x,] ch[, attr]) 652 .. method:: window.addch(ch[, attr]) 653 window.addch(y, x, ch[, attr]) 608 654 609 655 .. note:: 610 656 611 A *character* means a C character (an ASCII code), rather th en a Python657 A *character* means a C character (an ASCII code), rather than a Python 612 658 character (a string of length 1). (This note is true whenever the 613 659 documentation mentions a character.) The built-in :func:`ord` is handy for … … 619 665 620 666 621 .. method:: window.addnstr([y, x,] str, n[, attr]) 667 .. method:: window.addnstr(str, n[, attr]) 668 window.addnstr(y, x, str, n[, attr]) 622 669 623 670 Paint at most *n* characters of the string *str* at ``(y, x)`` with attributes … … 625 672 626 673 627 .. method:: window.addstr([y, x,] str[, attr]) 674 .. method:: window.addstr(str[, attr]) 675 window.addstr(y, x, str[, attr]) 628 676 629 677 Paint the string *str* at ``(y, x)`` with attributes *attr*, overwriting … … 651 699 .. method:: window.bkgd(ch[, attr]) 652 700 653 Set sthe background property of the window to the character *ch*, with701 Set the background property of the window to the character *ch*, with 654 702 attributes *attr*. The change is then applied to every character position in 655 703 that window: … … 664 712 .. method:: window.bkgdset(ch[, attr]) 665 713 666 Set sthe window's background. A window's background consists of a character and714 Set the window's background. A window's background consists of a character and 667 715 any combination of attributes. The attribute part of the background is combined 668 716 (OR'ed) with all non-blank characters that are written into the window. Both … … 709 757 710 758 Similar to :meth:`border`, but both *ls* and *rs* are *vertch* and both *ts* and 711 bs are *horch*. The default corner characters are always used by this function. 712 713 714 .. method:: window.chgat([y, x, ] [num,] attr) 715 716 Sets the attributes of *num* characters at the current cursor position, or at 759 *bs* are *horch*. The default corner characters are always used by this function. 760 761 762 .. method:: window.chgat(attr) 763 window.chgat(num, attr) 764 window.chgat(y, x, attr) 765 window.chgat(y, x, num, attr) 766 767 Set the attributes of *num* characters at the current cursor position, or at 717 768 position ``(y, x)`` if supplied. If no value of *num* is given or *num* = -1, 718 769 the attribute will be set on all the characters to the end of the line. This … … 724 775 .. method:: window.clear() 725 776 726 Like :meth:`erase`, but also cause sthe whole window to be repainted upon next777 Like :meth:`erase`, but also cause the whole window to be repainted upon next 727 778 call to :meth:`refresh`. 728 779 … … 747 798 .. method:: window.cursyncup() 748 799 749 Update sthe current cursor position of all the ancestors of the window to800 Update the current cursor position of all the ancestors of the window to 750 801 reflect the current cursor position of the window. 751 802 … … 758 809 .. method:: window.deleteln() 759 810 760 Delete the line under the cursor. All following lines are moved up by 1 line. 761 762 763 .. method:: window.derwin([nlines, ncols,] begin_y, begin_x) 811 Delete the line under the cursor. All following lines are moved up by one line. 812 813 814 .. method:: window.derwin(begin_y, begin_x) 815 window.derwin(nlines, ncols, begin_y, begin_x) 764 816 765 817 An abbreviation for "derive window", :meth:`derwin` is the same as calling 766 818 :meth:`subwin`, except that *begin_y* and *begin_x* are relative to the origin 767 of the window, rather than relative to the entire screen. Return sa window819 of the window, rather than relative to the entire screen. Return a window 768 820 object for the derived window. 769 821 … … 777 829 .. method:: window.enclose(y, x) 778 830 779 Test swhether the given pair of screen-relative character-cell coordinates are780 enclosed by the given window, returning true or false. It is useful for831 Test whether the given pair of screen-relative character-cell coordinates are 832 enclosed by the given window, returning ``True`` or ``False``. It is useful for 781 833 determining what subset of the screen windows enclose the location of a mouse 782 834 event. … … 791 843 792 844 Return a tuple ``(y, x)`` of co-ordinates of upper-left corner. 845 846 847 .. method:: window.getbkgd() 848 849 Return the given window's current background character/attribute pair. 793 850 794 851 … … 815 872 .. method:: window.getparyx() 816 873 817 Return sthe beginning coordinates of this window relative to its parent window818 into two integer variables y and x. Return s ``-1,-1`` if this window has no874 Return the beginning coordinates of this window relative to its parent window 875 into two integer variables y and x. Return ``-1, -1`` if this window has no 819 876 parent. 820 877 … … 831 888 832 889 833 .. method:: window.hline([y, x,] ch, n) 890 .. method:: window.hline(ch, n) 891 window.hline(y, x, ch, n) 834 892 835 893 Display a horizontal line starting at ``(y, x)`` with length *n* consisting of … … 839 897 .. method:: window.idcok(flag) 840 898 841 If *flag* is false, curses no longer considers using the hardware insert/delete842 character feature of the terminal; if *flag* is true, use of character insertion899 If *flag* is ``False``, curses no longer considers using the hardware insert/delete 900 character feature of the terminal; if *flag* is ``True``, use of character insertion 843 901 and deletion is enabled. When curses is first initialized, use of character 844 902 insert/delete is enabled by default. … … 853 911 .. method:: window.immedok(flag) 854 912 855 If *flag* is true, any change in the window image automatically causes the913 If *flag* is ``True``, any change in the window image automatically causes the 856 914 window to be refreshed; you no longer have to call :meth:`refresh` yourself. 857 915 However, it may degrade performance considerably, due to repeated calls to … … 865 923 866 924 867 .. method:: window.insch([y, x,] ch[, attr]) 925 .. method:: window.insch(ch[, attr]) 926 window.insch(y, x, ch[, attr]) 868 927 869 928 Paint character *ch* at ``(y, x)`` with attributes *attr*, moving the line from … … 873 932 .. method:: window.insdelln(nlines) 874 933 875 Insert s*nlines* lines into the specified window above the current line. The934 Insert *nlines* lines into the specified window above the current line. The 876 935 *nlines* bottom lines are lost. For negative *nlines*, delete *nlines* lines 877 936 starting with the one under the cursor, and move the remaining lines up. The … … 882 941 .. method:: window.insertln() 883 942 884 Insert a blank line under the cursor. All following lines are moved down by 1943 Insert a blank line under the cursor. All following lines are moved down by one 885 944 line. 886 945 887 946 888 .. method:: window.insnstr([y, x,] str, n [, attr]) 947 .. method:: window.insnstr(str, n[, attr]) 948 window.insnstr(y, x, str, n[, attr]) 889 949 890 950 Insert a character string (as many characters as will fit on the line) before … … 895 955 896 956 897 .. method:: window.insstr([y, x, ] str [, attr]) 957 .. method:: window.insstr(str[, attr]) 958 window.insstr(y, x, str[, attr]) 898 959 899 960 Insert a character string (as many characters as will fit on the line) before … … 903 964 904 965 905 .. method:: window.instr([y, x] [, n]) 906 907 Returns a string of characters, extracted from the window starting at the 966 .. method:: window.instr([n]) 967 window.instr(y, x[, n]) 968 969 Return a string of characters, extracted from the window starting at the 908 970 current cursor position, or at *y*, *x* if specified. Attributes are stripped 909 from the characters. If *n* is specified, :meth:`instr` returns returna string971 from the characters. If *n* is specified, :meth:`instr` returns a string 910 972 at most *n* characters long (exclusive of the trailing NUL). 911 973 … … 913 975 .. method:: window.is_linetouched(line) 914 976 915 Return s trueif the specified line was modified since the last call to916 :meth:`refresh`; otherwise return s false. Raisesa :exc:`curses.error`977 Return ``True`` if the specified line was modified since the last call to 978 :meth:`refresh`; otherwise return ``False``. Raise a :exc:`curses.error` 917 979 exception if *line* is not valid for the given window. 918 980 … … 920 982 .. method:: window.is_wintouched() 921 983 922 Return s trueif the specified window was modified since the last call to923 :meth:`refresh`; otherwise return s false.984 Return ``True`` if the specified window was modified since the last call to 985 :meth:`refresh`; otherwise return ``False``. 924 986 925 987 … … 947 1009 .. method:: window.mvderwin(y, x) 948 1010 949 Move sthe window inside its parent window. The screen-relative parameters of1011 Move the window inside its parent window. The screen-relative parameters of 950 1012 the window are not changed. This routine is used to display different parts of 951 1013 the parent window at the same physical position on the screen. … … 1005 1067 .. method:: window.putwin(file) 1006 1068 1007 Write sall data associated with the window into the provided file object. This1069 Write all data associated with the window into the provided file object. This 1008 1070 information can be later retrieved using the :func:`getwin` function. 1009 1071 … … 1011 1073 .. method:: window.redrawln(beg, num) 1012 1074 1013 Indicate sthat the *num* screen lines, starting at line *beg*, are corrupted and1075 Indicate that the *num* screen lines, starting at line *beg*, are corrupted and 1014 1076 should be completely redrawn on the next :meth:`refresh` call. 1015 1077 … … 1017 1079 .. method:: window.redrawwin() 1018 1080 1019 Touch esthe entire window, causing it to be completely redrawn on the next1081 Touch the entire window, causing it to be completely redrawn on the next 1020 1082 :meth:`refresh` call. 1021 1083 … … 1038 1100 1039 1101 1102 .. method:: window.resize(nlines, ncols) 1103 1104 Reallocate storage for a curses window to adjust its dimensions to the 1105 specified values. If either dimension is larger than the current values, the 1106 window's data is filled with blanks that have the current background 1107 rendition (as set by :meth:`bkgdset`) merged into them. 1108 1109 1040 1110 .. method:: window.scroll([lines=1]) 1041 1111 … … 1045 1115 .. method:: window.scrollok(flag) 1046 1116 1047 Control swhat happens when the cursor of a window is moved off the edge of the1117 Control what happens when the cursor of a window is moved off the edge of the 1048 1118 window or scrolling region, either as a result of a newline action on the bottom 1049 1119 line, or typing the last character of the last line. If *flag* is false, the … … 1070 1140 1071 1141 1072 .. method:: window.subpad([nlines, ncols,] begin_y, begin_x) 1142 .. method:: window.subpad(begin_y, begin_x) 1143 window.subpad(nlines, ncols, begin_y, begin_x) 1073 1144 1074 1145 Return a sub-window, whose upper-left corner is at ``(begin_y, begin_x)``, and … … 1076 1147 1077 1148 1078 .. method:: window.subwin([nlines, ncols,] begin_y, begin_x) 1149 .. method:: window.subwin(begin_y, begin_x) 1150 window.subwin(nlines, ncols, begin_y, begin_x) 1079 1151 1080 1152 Return a sub-window, whose upper-left corner is at ``(begin_y, begin_x)``, and … … 1087 1159 .. method:: window.syncdown() 1088 1160 1089 Touch eseach location in the window that has been touched in any of its ancestor1161 Touch each location in the window that has been touched in any of its ancestor 1090 1162 windows. This routine is called by :meth:`refresh`, so it should almost never 1091 1163 be necessary to call it manually. … … 1094 1166 .. method:: window.syncok(flag) 1095 1167 1096 If called with *flag* set to true, then :meth:`syncup` is called automatically1168 If called with *flag* set to ``True``, then :meth:`syncup` is called automatically 1097 1169 whenever there is a change in the window. 1098 1170 … … 1100 1172 .. method:: window.syncup() 1101 1173 1102 Touch esall locations in ancestors of the window that have been changed in the1174 Touch all locations in ancestors of the window that have been changed in the 1103 1175 window. 1104 1176 … … 1106 1178 .. method:: window.timeout(delay) 1107 1179 1108 Set sblocking or non-blocking read behavior for the window. If *delay* is1180 Set blocking or non-blocking read behavior for the window. If *delay* is 1109 1181 negative, blocking read is used (which will wait indefinitely for input). If 1110 1182 *delay* is zero, then non-blocking read is used, and -1 will be returned by … … 1129 1201 .. method:: window.untouchwin() 1130 1202 1131 Mark sall lines in the window as unchanged since the last call to1203 Mark all lines in the window as unchanged since the last call to 1132 1204 :meth:`refresh`. 1133 1205 1134 1206 1135 .. method:: window.vline([y, x,] ch, n) 1207 .. method:: window.vline(ch, n) 1208 window.vline(y, x, ch, n) 1136 1209 1137 1210 Display a vertical line starting at ``(y, x)`` with length *n* consisting of the … … 1176 1249 +------------------+-------------------------------+ 1177 1250 | ``A_NORMAL`` | Normal attribute. | 1251 +------------------+-------------------------------+ 1252 | ``A_REVERSE`` | Reverse background and | 1253 | | foreground colors. | 1178 1254 +------------------+-------------------------------+ 1179 1255 | ``A_STANDOUT`` | Standout mode. | … … 1585 1661 is done on the result. This method returns the window contents as a 1586 1662 string; whether blanks in the window are included is affected by the 1587 :attr:`stripspaces` member.1663 :attr:`stripspaces` attribute. 1588 1664 1589 1665 … … 1651 1727 .. method:: gather() 1652 1728 1653 This method returnsthe window contents as a string; whether blanks in the1729 Return the window contents as a string; whether blanks in the 1654 1730 window are included is affected by the :attr:`stripspaces` member. 1655 1731 … … 1657 1733 .. attribute:: stripspaces 1658 1734 1659 This data memberis a flag which controls the interpretation of blanks in1735 This attribute is a flag which controls the interpretation of blanks in 1660 1736 the window. When it is on, trailing blanks on each line are ignored; any 1661 1737 cursor motion that would land the cursor on a trailing blank goes to the … … 1663 1739 contents are gathered. 1664 1740 1665 1666 :mod:`curses.wrapper` --- Terminal handler for curses programs1667 ==============================================================1668 1669 .. module:: curses.wrapper1670 :synopsis: Terminal configuration wrapper for curses programs.1671 .. moduleauthor:: Eric Raymond <esr@thyrsus.com>1672 .. sectionauthor:: Eric Raymond <esr@thyrsus.com>1673 1674 1675 .. versionadded:: 1.61676 1677 This module supplies one function, :func:`wrapper`, which runs another function1678 which should be the rest of your curses-using application. If the application1679 raises an exception, :func:`wrapper` will restore the terminal to a sane state1680 before re-raising the exception and generating a traceback.1681 1682 1683 .. function:: wrapper(func, ...)1684 1685 Wrapper function that initializes curses and calls another function, *func*,1686 restoring normal keyboard/screen behavior on error. The callable object *func*1687 is then passed the main window 'stdscr' as its first argument, followed by any1688 other arguments passed to :func:`wrapper`.1689 1690 Before calling the hook function, :func:`wrapper` turns on cbreak mode, turns1691 off echo, enables the terminal keypad, and initializes colors if the terminal1692 has color support. On exit (whether normally or by exception) it restores1693 cooked mode, turns on echo, and disables the terminal keypad.1694
Note:
See TracChangeset
for help on using the changeset viewer.