@@ -22,7 +22,10 @@ \section{\module{curses} ---
2222 characters, regardless of your locale
2323 settings.}
2424 \seemodule {curses.textpad}{Editable text widget for curses supporting
25- Emacs-like bindings.}
25+ \program {Emacs}-like bindings.}
26+ \seemodule {curses.wrapper}{Convenience function to ensure proper
27+ terminal setup and resetting on
28+ application entry and exit.}
2629 \seetext {Tutorial material on using curses with Python is available
2730 on the Python Web site as Andrew Kuchling's
2831\citetitle [http://www.python.org/doc/howto/curses/curses.html]{Curses
@@ -34,8 +37,9 @@ \section{\module{curses} ---
3437\subsection {Functions \label {curses-functions } }
3538
3639The module \module {curses} defines the following exception:
40+
3741\begin {excdesc }{error}
38- Curses function returned an error status .
42+ Exception raised when a curses library function returns an error.
3943\end {excdesc }
4044
4145\strong {Note:} Whenever \var {x} or \var {y} arguments to a function
@@ -967,8 +971,9 @@ \subsection{Constants}
967971Also available as \constant {__version__}.
968972\end {datadesc }
969973
974+ Several constants are available to specify character cell attributes:
970975
971- \begin {tableii }{c |l}{code}{Attribute}{Meaning}
976+ \begin {tableii }{l |l}{code}{Attribute}{Meaning}
972977 \lineii {A_ALTCHARSET}{Alternate character set mode.}
973978 \lineii {A_BLINK}{Blink mode.}
974979 \lineii {A_BOLD}{Bold mode.}
@@ -979,12 +984,12 @@ \subsection{Constants}
979984\end {tableii }
980985
981986Keys are referred to by integer constants with names starting with
982- \code {KEY_}. The exact keycaps available are system dependent.
987+ \samp {KEY_}. The exact keycaps available are system dependent.
983988
984989% XXX this table is far too large!
985990% XXX should this table be alphabetized?
986991
987- \begin {tableii }{c |l}{code}{Key constant}{Key}
992+ \begin {tableii }{l |l}{code}{Key constant}{Key}
988993 \lineii {KEY_MIN}{Minimum key value}
989994 \lineii {KEY_BREAK}{ Break key (unreliable) }
990995 \lineii {KEY_DOWN}{ Down-arrow }
@@ -1081,14 +1086,16 @@ \subsection{Constants}
10811086 \lineii {KEY_MAX}{Maximum key value}
10821087\end {tableii }
10831088
1084- On VT100s and their software emulations such as X terminal emulators,
1085- there are normally at least four function keys (KEY_F1, KEY_F2,
1086- KEY_F3, KEY_F4) available and the arrow keys mapped to KEY_UP,
1087- KEY_DOWN, KEY_LEFT and KEY_RIGHT in the obvious way. If your machine has a PC
1088- keybboard, it is safe to expect arrow keys and twelve function keys; also,
1089- the following keypad mappings are standard:
1089+ On VT100s and their software emulations, such as X terminal emulators,
1090+ there are normally at least four function keys (\constant {KEY_F1},
1091+ \constant {KEY_F2}, \constant {KEY_F3}, \constant {KEY_F4}) available,
1092+ and the arrow keys mapped to \constant {KEY_UP}, \constant {KEY_DOWN},
1093+ \constant {KEY_LEFT} and \constant {KEY_RIGHT} in the obvious way. If
1094+ your machine has a PC keybboard, it is safe to expect arrow keys and
1095+ twelve function keys (older PC keyboards may have only ten function
1096+ keys); also, the following keypad mappings are standard:
10901097
1091- \begin {tableii }{c |l}{code }{Keycap}{code }
1098+ \begin {tableii }{l |l}{kbd }{Keycap}{Constant }
10921099 \lineii {Insert}{KEY_IC}
10931100 \lineii {Delete}{KEY_DC}
10941101 \lineii {Home}{KEY_HOME}
@@ -1105,7 +1112,7 @@ \subsection{Constants}
11051112\strong {Note:} These are available only after \function {initscr()} has
11061113been called.
11071114
1108- \begin {tableii }{c |l}{code}{ACS code}{Meaning}
1115+ \begin {tableii }{l |l}{code}{ACS code}{Meaning}
11091116 \lineii {ACS_BBSS}{alternate name for upper right corner}
11101117 \lineii {ACS_BLOCK}{solid square block}
11111118 \lineii {ACS_BOARD}{board of squares}
@@ -1153,7 +1160,7 @@ \subsection{Constants}
11531160
11541161The following table lists the predefined colors:
11551162
1156- \begin {tableii }{c |l}{code}{Constant}{Color}
1163+ \begin {tableii }{l |l}{code}{Constant}{Color}
11571164 \lineii {COLOR_BLACK}{Black}
11581165 \lineii {COLOR_BLUE}{Blue}
11591166 \lineii {COLOR_CYAN}{Cyan (light greenish blue)}
@@ -1180,9 +1187,7 @@ \section{\module{curses.textpad} ---
11801187module also provides a rectangle-drawing function useful for framing
11811188text boxes or for other purposes.
11821189
1183- \subsection {Functions \label {curses-textpad-functions } }
1184-
1185- The module \module {curses.textpad} defines the following functions:
1190+ The module \module {curses.textpad} defines the following function:
11861191
11871192\begin {funcdesc }{rectangle}{win, uly, ulx, lry, lrx}
11881193Draw a rectangle. The first argument must be a window object; the
@@ -1196,34 +1201,36 @@ \subsection{Functions \label{curses-textpad-functions}}
11961201dashes, vertical bars, and plus signs.
11971202\end {funcdesc }
11981203
1204+
11991205\subsection {Textbox objects \label {curses-textpad-objects } }
12001206
12011207You can instantiate a \class {Textbox} object as follows:
12021208
1203- \classdesc {Textbox}{win}
1204- Return a textbox widget object. The win argument should be a curses
1205- \class {WindowObject} in which the textbox is to be contained. The
1206- edit cursor of the textbox is initially located at the upper left
1207- hand corner of the containin window, with coordinates (0,0). The
1208- instance's \member {stripspaces} flag is initially on.
1209+ \begin { classdesc } {Textbox}{win}
1210+ Return a textbox widget object. The \var { win} argument should be a
1211+ curses \class {WindowObject} in which the textbox is to be contained.
1212+ The edit cursor of the textbox is initially located at the upper left
1213+ hand corner of the containin window, with coordinates \code { (0, 0)}.
1214+ The instance's \member {stripspaces} flag is initially on.
12091215\end {classdesc }
12101216
1211- Textbox objects, have the following methods:
1217+ \class { Textbox} objects have the following methods:
12121218
1213- \begin {methoddesc }{edit}{validator=None }
1219+ \begin {methoddesc }{edit}{\optional { validator} }
12141220This is the entry point you will normally use. It accepts editing
1215- keystrokes until one of the termination keystrokes is entered. If a
1216- validator function is specified, each entered keystroke is passed to
1217- it; command dispatch is done on the result. This method returns the
1218- window contents as a string; whether blanks in the window are included
1219- is affected by the \member {stripspaces} member.
1221+ keystrokes until one of the termination keystrokes is entered. If
1222+ \var {validator} is supplied, it must be a function. It will be called
1223+ for each keystroke entered with the keystroke as a parameter; command
1224+ dispatch is done on the result. This method returns the window
1225+ contents as a string; whether blanks in the window are included is
1226+ affected by the \member {stripspaces} member.
12201227\end {methoddesc }
12211228
12221229\begin {methoddesc }{do_command}{ch}
12231230Process a single command keystroke. Here are the supported special
12241231keystrokes:
12251232
1226- \begin {tableii }{c |l}{code}{keystroke}{action }
1233+ \begin {tableii }{l |l}{kbd}{Keystroke}{Action }
12271234 \lineii {Ctrl-A}{Go to left edge of window.}
12281235 \lineii {Ctrl-B}{Cursor left, wrapping to previous line if appropriate.}
12291236 \lineii {Ctrl-D}{Delete character under cursor.}
@@ -1241,8 +1248,15 @@ \subsection{Textbox objects \label{curses-textpad-objects}}
12411248
12421249Move operations do nothing if the cursor is at an edge where the
12431250movement is not possible. The following synonyms are supported where
1244- possible: KEY_LEFT = Ctrl-B, KEY_RIGHT = Ctrl-F, KEY_UP = Ctrl-P,
1245- KEY_DOWN = Ctrl-N, KEY_BACKSPACE = Ctrl-h.
1251+ possible:
1252+
1253+ \begin {tableii }{l|l}{constant}{Constant}{Keystroke}
1254+ \lineii {KEY_LEFT}{\kbd {Ctrl-B}}
1255+ \lineii {KEY_RIGHT}{\kbd {Ctrl-F}}
1256+ \lineii {KEY_UP}{\kbd {Ctrl-P}}
1257+ \lineii {KEY_DOWN}{\kbd {Ctrl-N}}
1258+ \lineii {KEY_BACKSPACE}{\kbd {Ctrl-h}}
1259+ \end {tableii }
12461260
12471261All other keystrokes are treated as a command to insert the given
12481262character and move right (with line wrapping).
@@ -1254,21 +1268,22 @@ \subsection{Textbox objects \label{curses-textpad-objects}}
12541268member.
12551269\end {methoddesc }
12561270
1257- \begin {methoddesc }{stripspaces}{ }
1271+ \begin {memberdesc }{stripspaces}
12581272This data member is a flag which controls the interpretation of blanks in
12591273the window. When it is on, trailing blanks on each line are ignored;
12601274any cursor motion that would land the cursor on a trailing blank goes
12611275to the end of that line instead, and trailing blanks are stripped when
12621276the window contents is gathered.
1263- \end {methoddesc }
1277+ \end {memberdesc }
1278+
12641279
12651280\section {\module {curses.wrapper} ---
1266- Exception-handling wrapper for curses programs. }
1281+ Terminal handler for curses programs }
12671282
12681283\declaremodule {standard}{curses.wrapper}
12691284\sectionauthor {Eric Raymond}{
[email protected] }
12701285\moduleauthor {Eric Raymond}{
[email protected] }
1271- \modulesynopsis {Exception-handling wrapper for curses programs.}
1286+ \modulesynopsis {Terminal configuration wrapper for curses programs.}
12721287\versionadded {1.6}
12731288
12741289This module supplies one function, \function {wrapper()}, which runs
@@ -1277,12 +1292,10 @@ \section{\module{curses.wrapper} ---
12771292\function {wrapper()} will restore the terminal to a sane state before
12781293passing it further up the stack and generating a traceback.
12791294
1280- \subsection {Functions \label {curses-wrapper-functions } }
1281-
1282- \begin {funcdesc }{wrapper}{func, *rest}
1295+ \begin {funcdesc }{wrapper}{func, \moreargs }
12831296Wrapper function that initializes curses and calls another function,
1284- \function {func}, restoring normal keyboard/screen behavior on error.
1285- The callable object ' func' is then passed the main window 'stdscr'
1297+ \var {func}, restoring normal keyboard/screen behavior on error.
1298+ The callable object \var { func} is then passed the main window 'stdscr'
12861299as its first argument, followed by any other arguments passed to
12871300\function {wrapper()}.
12881301\end {funcdesc }
0 commit comments