mirror of https://github.com/python/cpython
Fix a few markup errors and lots of small consistency issues.
Add "See also" link to curses.wrapper module from curses module.
This commit is contained in:
parent
cb0fc9c2ce
commit
ec4b2af6bb
|
@ -22,7 +22,10 @@ Unix.
|
||||||
characters, regardless of your locale
|
characters, regardless of your locale
|
||||||
settings.}
|
settings.}
|
||||||
\seemodule{curses.textpad}{Editable text widget for curses supporting
|
\seemodule{curses.textpad}{Editable text widget for curses supporting
|
||||||
Emacs-like bindings.}
|
\program{Emacs}-like bindings.}
|
||||||
|
\seemodule{curses.wrapper}{Convenience function to ensure proper
|
||||||
|
terminal setup and resetting on
|
||||||
|
application entry and exit.}
|
||||||
\seetext{Tutorial material on using curses with Python is available
|
\seetext{Tutorial material on using curses with Python is available
|
||||||
on the Python Web site as Andrew Kuchling's
|
on the Python Web site as Andrew Kuchling's
|
||||||
\citetitle[http://www.python.org/doc/howto/curses/curses.html]{Curses
|
\citetitle[http://www.python.org/doc/howto/curses/curses.html]{Curses
|
||||||
|
@ -34,8 +37,9 @@ Unix.
|
||||||
\subsection{Functions \label{curses-functions}}
|
\subsection{Functions \label{curses-functions}}
|
||||||
|
|
||||||
The module \module{curses} defines the following exception:
|
The module \module{curses} defines the following exception:
|
||||||
|
|
||||||
\begin{excdesc}{error}
|
\begin{excdesc}{error}
|
||||||
Curses function returned an error status.
|
Exception raised when a curses library function returns an error.
|
||||||
\end{excdesc}
|
\end{excdesc}
|
||||||
|
|
||||||
\strong{Note:} Whenever \var{x} or \var{y} arguments to a function
|
\strong{Note:} Whenever \var{x} or \var{y} arguments to a function
|
||||||
|
@ -967,8 +971,9 @@ A string representing the current version of the module.
|
||||||
Also available as \constant{__version__}.
|
Also available as \constant{__version__}.
|
||||||
\end{datadesc}
|
\end{datadesc}
|
||||||
|
|
||||||
|
Several constants are available to specify character cell attributes:
|
||||||
|
|
||||||
\begin{tableii}{c|l}{code}{Attribute}{Meaning}
|
\begin{tableii}{l|l}{code}{Attribute}{Meaning}
|
||||||
\lineii{A_ALTCHARSET}{Alternate character set mode.}
|
\lineii{A_ALTCHARSET}{Alternate character set mode.}
|
||||||
\lineii{A_BLINK}{Blink mode.}
|
\lineii{A_BLINK}{Blink mode.}
|
||||||
\lineii{A_BOLD}{Bold mode.}
|
\lineii{A_BOLD}{Bold mode.}
|
||||||
|
@ -979,12 +984,12 @@ Also available as \constant{__version__}.
|
||||||
\end{tableii}
|
\end{tableii}
|
||||||
|
|
||||||
Keys are referred to by integer constants with names starting with
|
Keys are referred to by integer constants with names starting with
|
||||||
\code{KEY_}. The exact keycaps available are system dependent.
|
\samp{KEY_}. The exact keycaps available are system dependent.
|
||||||
|
|
||||||
% XXX this table is far too large!
|
% XXX this table is far too large!
|
||||||
% XXX should this table be alphabetized?
|
% XXX should this table be alphabetized?
|
||||||
|
|
||||||
\begin{tableii}{c|l}{code}{Key constant}{Key}
|
\begin{tableii}{l|l}{code}{Key constant}{Key}
|
||||||
\lineii{KEY_MIN}{Minimum key value}
|
\lineii{KEY_MIN}{Minimum key value}
|
||||||
\lineii{KEY_BREAK}{ Break key (unreliable) }
|
\lineii{KEY_BREAK}{ Break key (unreliable) }
|
||||||
\lineii{KEY_DOWN}{ Down-arrow }
|
\lineii{KEY_DOWN}{ Down-arrow }
|
||||||
|
@ -1081,14 +1086,16 @@ Keys are referred to by integer constants with names starting with
|
||||||
\lineii{KEY_MAX}{Maximum key value}
|
\lineii{KEY_MAX}{Maximum key value}
|
||||||
\end{tableii}
|
\end{tableii}
|
||||||
|
|
||||||
On VT100s and their software emulations such as X terminal emulators,
|
On VT100s and their software emulations, such as X terminal emulators,
|
||||||
there are normally at least four function keys (KEY_F1, KEY_F2,
|
there are normally at least four function keys (\constant{KEY_F1},
|
||||||
KEY_F3, KEY_F4) available and the arrow keys mapped to KEY_UP,
|
\constant{KEY_F2}, \constant{KEY_F3}, \constant{KEY_F4}) available,
|
||||||
KEY_DOWN, KEY_LEFT and KEY_RIGHT in the obvious way. If your machine has a PC
|
and the arrow keys mapped to \constant{KEY_UP}, \constant{KEY_DOWN},
|
||||||
keybboard, it is safe to expect arrow keys and twelve function keys; also,
|
\constant{KEY_LEFT} and \constant{KEY_RIGHT} in the obvious way. If
|
||||||
the following keypad mappings are standard:
|
your machine has a PC keybboard, it is safe to expect arrow keys and
|
||||||
|
twelve function keys (older PC keyboards may have only ten function
|
||||||
|
keys); also, the following keypad mappings are standard:
|
||||||
|
|
||||||
\begin{tableii}{c|l}{code}{Keycap}{code}
|
\begin{tableii}{l|l}{kbd}{Keycap}{Constant}
|
||||||
\lineii{Insert}{KEY_IC}
|
\lineii{Insert}{KEY_IC}
|
||||||
\lineii{Delete}{KEY_DC}
|
\lineii{Delete}{KEY_DC}
|
||||||
\lineii{Home}{KEY_HOME}
|
\lineii{Home}{KEY_HOME}
|
||||||
|
@ -1105,7 +1112,7 @@ approximation.
|
||||||
\strong{Note:} These are available only after \function{initscr()} has
|
\strong{Note:} These are available only after \function{initscr()} has
|
||||||
been called.
|
been called.
|
||||||
|
|
||||||
\begin{tableii}{c|l}{code}{ACS code}{Meaning}
|
\begin{tableii}{l|l}{code}{ACS code}{Meaning}
|
||||||
\lineii{ACS_BBSS}{alternate name for upper right corner}
|
\lineii{ACS_BBSS}{alternate name for upper right corner}
|
||||||
\lineii{ACS_BLOCK}{solid square block}
|
\lineii{ACS_BLOCK}{solid square block}
|
||||||
\lineii{ACS_BOARD}{board of squares}
|
\lineii{ACS_BOARD}{board of squares}
|
||||||
|
@ -1153,7 +1160,7 @@ been called.
|
||||||
|
|
||||||
The following table lists the predefined colors:
|
The following table lists the predefined colors:
|
||||||
|
|
||||||
\begin{tableii}{c|l}{code}{Constant}{Color}
|
\begin{tableii}{l|l}{code}{Constant}{Color}
|
||||||
\lineii{COLOR_BLACK}{Black}
|
\lineii{COLOR_BLACK}{Black}
|
||||||
\lineii{COLOR_BLUE}{Blue}
|
\lineii{COLOR_BLUE}{Blue}
|
||||||
\lineii{COLOR_CYAN}{Cyan (light greenish blue)}
|
\lineii{COLOR_CYAN}{Cyan (light greenish blue)}
|
||||||
|
@ -1180,9 +1187,7 @@ Navigator, BBedit 6.x, FrameMaker, and many other programs). The
|
||||||
module also provides a rectangle-drawing function useful for framing
|
module also provides a rectangle-drawing function useful for framing
|
||||||
text boxes or for other purposes.
|
text boxes or for other purposes.
|
||||||
|
|
||||||
\subsection{Functions \label{curses-textpad-functions}}
|
The module \module{curses.textpad} defines the following function:
|
||||||
|
|
||||||
The module \module{curses.textpad} defines the following functions:
|
|
||||||
|
|
||||||
\begin{funcdesc}{rectangle}{win, uly, ulx, lry, lrx}
|
\begin{funcdesc}{rectangle}{win, uly, ulx, lry, lrx}
|
||||||
Draw a rectangle. The first argument must be a window object; the
|
Draw a rectangle. The first argument must be a window object; the
|
||||||
|
@ -1196,34 +1201,36 @@ software terminal emulators). Otherwise it will be drawn with ASCII
|
||||||
dashes, vertical bars, and plus signs.
|
dashes, vertical bars, and plus signs.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
|
|
||||||
\subsection{Textbox objects \label{curses-textpad-objects}}
|
\subsection{Textbox objects \label{curses-textpad-objects}}
|
||||||
|
|
||||||
You can instantiate a \class{Textbox} object as follows:
|
You can instantiate a \class{Textbox} object as follows:
|
||||||
|
|
||||||
\classdesc{Textbox}{win}
|
\begin{classdesc}{Textbox}{win}
|
||||||
Return a textbox widget object. The win argument should be a curses
|
Return a textbox widget object. The \var{win} argument should be a
|
||||||
\class{WindowObject} in which the textbox is to be contained. The
|
curses \class{WindowObject} in which the textbox is to be contained.
|
||||||
edit cursor of the textbox is initially located at the upper left
|
The edit cursor of the textbox is initially located at the upper left
|
||||||
hand corner of the containin window, with coordinates (0,0). The
|
hand corner of the containin window, with coordinates \code{(0, 0)}.
|
||||||
instance's \member{stripspaces} flag is initially on.
|
The instance's \member{stripspaces} flag is initially on.
|
||||||
\end{classdesc}
|
\end{classdesc}
|
||||||
|
|
||||||
Textbox objects, have the following methods:
|
\class{Textbox} objects have the following methods:
|
||||||
|
|
||||||
\begin{methoddesc}{edit}{validator=None}
|
\begin{methoddesc}{edit}{\optional{validator}}
|
||||||
This is the entry point you will normally use. It accepts editing
|
This is the entry point you will normally use. It accepts editing
|
||||||
keystrokes until one of the termination keystrokes is entered. If a
|
keystrokes until one of the termination keystrokes is entered. If
|
||||||
validator function is specified, each entered keystroke is passed to
|
\var{validator} is supplied, it must be a function. It will be called
|
||||||
it; command dispatch is done on the result. This method returns the
|
for each keystroke entered with the keystroke as a parameter; command
|
||||||
window contents as a string; whether blanks in the window are included
|
dispatch is done on the result. This method returns the window
|
||||||
is affected by the \member{stripspaces} member.
|
contents as a string; whether blanks in the window are included is
|
||||||
|
affected by the \member{stripspaces} member.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{do_command}{ch}
|
\begin{methoddesc}{do_command}{ch}
|
||||||
Process a single command keystroke. Here are the supported special
|
Process a single command keystroke. Here are the supported special
|
||||||
keystrokes:
|
keystrokes:
|
||||||
|
|
||||||
\begin{tableii}{c|l}{code}{keystroke}{action}
|
\begin{tableii}{l|l}{kbd}{Keystroke}{Action}
|
||||||
\lineii{Ctrl-A}{Go to left edge of window.}
|
\lineii{Ctrl-A}{Go to left edge of window.}
|
||||||
\lineii{Ctrl-B}{Cursor left, wrapping to previous line if appropriate.}
|
\lineii{Ctrl-B}{Cursor left, wrapping to previous line if appropriate.}
|
||||||
\lineii{Ctrl-D}{Delete character under cursor.}
|
\lineii{Ctrl-D}{Delete character under cursor.}
|
||||||
|
@ -1241,8 +1248,15 @@ keystrokes:
|
||||||
|
|
||||||
Move operations do nothing if the cursor is at an edge where the
|
Move operations do nothing if the cursor is at an edge where the
|
||||||
movement is not possible. The following synonyms are supported where
|
movement is not possible. The following synonyms are supported where
|
||||||
possible: KEY_LEFT = Ctrl-B, KEY_RIGHT = Ctrl-F, KEY_UP = Ctrl-P,
|
possible:
|
||||||
KEY_DOWN = Ctrl-N, KEY_BACKSPACE = Ctrl-h.
|
|
||||||
|
\begin{tableii}{l|l}{constant}{Constant}{Keystroke}
|
||||||
|
\lineii{KEY_LEFT}{\kbd{Ctrl-B}}
|
||||||
|
\lineii{KEY_RIGHT}{\kbd{Ctrl-F}}
|
||||||
|
\lineii{KEY_UP}{\kbd{Ctrl-P}}
|
||||||
|
\lineii{KEY_DOWN}{\kbd{Ctrl-N}}
|
||||||
|
\lineii{KEY_BACKSPACE}{\kbd{Ctrl-h}}
|
||||||
|
\end{tableii}
|
||||||
|
|
||||||
All other keystrokes are treated as a command to insert the given
|
All other keystrokes are treated as a command to insert the given
|
||||||
character and move right (with line wrapping).
|
character and move right (with line wrapping).
|
||||||
|
@ -1254,21 +1268,22 @@ the window are included is affected by the \member{stripspaces}
|
||||||
member.
|
member.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{stripspaces}{}
|
\begin{memberdesc}{stripspaces}
|
||||||
This data member is a flag which controls the interpretation of blanks in
|
This data member is a flag which controls the interpretation of blanks in
|
||||||
the window. When it is on, trailing blanks on each line are ignored;
|
the window. When it is on, trailing blanks on each line are ignored;
|
||||||
any cursor motion that would land the cursor on a trailing blank goes
|
any cursor motion that would land the cursor on a trailing blank goes
|
||||||
to the end of that line instead, and trailing blanks are stripped when
|
to the end of that line instead, and trailing blanks are stripped when
|
||||||
the window contents is gathered.
|
the window contents is gathered.
|
||||||
\end{methoddesc}
|
\end{memberdesc}
|
||||||
|
|
||||||
|
|
||||||
\section{\module{curses.wrapper} ---
|
\section{\module{curses.wrapper} ---
|
||||||
Exception-handling wrapper for curses programs.}
|
Terminal handler for curses programs}
|
||||||
|
|
||||||
\declaremodule{standard}{curses.wrapper}
|
\declaremodule{standard}{curses.wrapper}
|
||||||
\sectionauthor{Eric Raymond}{esr@thyrsus.com}
|
\sectionauthor{Eric Raymond}{esr@thyrsus.com}
|
||||||
\moduleauthor{Eric Raymond}{esr@thyrsus.com}
|
\moduleauthor{Eric Raymond}{esr@thyrsus.com}
|
||||||
\modulesynopsis{Exception-handling wrapper for curses programs.}
|
\modulesynopsis{Terminal configuration wrapper for curses programs.}
|
||||||
\versionadded{1.6}
|
\versionadded{1.6}
|
||||||
|
|
||||||
This module supplies one function, \function{wrapper()}, which runs
|
This module supplies one function, \function{wrapper()}, which runs
|
||||||
|
@ -1277,12 +1292,10 @@ application. If the application raises an exception,
|
||||||
\function{wrapper()} will restore the terminal to a sane state before
|
\function{wrapper()} will restore the terminal to a sane state before
|
||||||
passing it further up the stack and generating a traceback.
|
passing it further up the stack and generating a traceback.
|
||||||
|
|
||||||
\subsection{Functions \label{curses-wrapper-functions}}
|
\begin{funcdesc}{wrapper}{func, \moreargs}
|
||||||
|
|
||||||
\begin{funcdesc}{wrapper}{func, *rest}
|
|
||||||
Wrapper function that initializes curses and calls another function,
|
Wrapper function that initializes curses and calls another function,
|
||||||
\function{func}, restoring normal keyboard/screen behavior on error.
|
\var{func}, restoring normal keyboard/screen behavior on error.
|
||||||
The callable object 'func' is then passed the main window 'stdscr'
|
The callable object \var{func} is then passed the main window 'stdscr'
|
||||||
as its first argument, followed by any other arguments passed to
|
as its first argument, followed by any other arguments passed to
|
||||||
\function{wrapper()}.
|
\function{wrapper()}.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
Loading…
Reference in New Issue