mirror of
https://github.com/python/cpython.git
synced 2025-08-01 23:53:15 +00:00
Marked keystrokes with the :kbd: role.
Fixed the case of the "Ctrl-" prefixes.
This commit is contained in:
parent
06171bd52a
commit
0424eaf753
19 changed files with 32 additions and 32 deletions
|
@ -348,7 +348,7 @@ complete example using the GNU readline library (you may want to ignore
|
||||||
{
|
{
|
||||||
line = readline (prompt);
|
line = readline (prompt);
|
||||||
|
|
||||||
if (NULL == line) /* CTRL-D pressed */
|
if (NULL == line) /* Ctrl-D pressed */
|
||||||
{
|
{
|
||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,14 +81,14 @@ by entering a few expressions of your choice and seeing the results::
|
||||||
'HelloHelloHello'
|
'HelloHelloHello'
|
||||||
|
|
||||||
Many people use the interactive mode as a convenient yet highly programmable
|
Many people use the interactive mode as a convenient yet highly programmable
|
||||||
calculator. When you want to end your interactive Python session, hold the Ctrl
|
calculator. When you want to end your interactive Python session, hold the :kbd:`Ctrl`
|
||||||
key down while you enter a Z, then hit the "Enter" key to get back to your
|
key down while you enter a :kbd:`Z`, then hit the ":kbd:`Enter`" key to get back to your
|
||||||
Windows command prompt.
|
Windows command prompt.
|
||||||
|
|
||||||
You may also find that you have a Start-menu entry such as :menuselection:`Start
|
You may also find that you have a Start-menu entry such as :menuselection:`Start
|
||||||
--> Programs --> Python 3.3 --> Python (command line)` that results in you
|
--> Programs --> Python 3.3 --> Python (command line)` that results in you
|
||||||
seeing the ``>>>`` prompt in a new window. If so, the window will disappear
|
seeing the ``>>>`` prompt in a new window. If so, the window will disappear
|
||||||
after you enter the Ctrl-Z character; Windows is running a single "python"
|
after you enter the :kbd:`Ctrl-Z` character; Windows is running a single "python"
|
||||||
command in the window, and closes it when you terminate the interpreter.
|
command in the window, and closes it when you terminate the interpreter.
|
||||||
|
|
||||||
If the ``python`` command, instead of displaying the interpreter prompt ``>>>``,
|
If the ``python`` command, instead of displaying the interpreter prompt ``>>>``,
|
||||||
|
@ -131,8 +131,8 @@ you should make sure that entering the command ::
|
||||||
|
|
||||||
c:\Python33\python
|
c:\Python33\python
|
||||||
|
|
||||||
starts up the interpreter as above (and don't forget you'll need a "CTRL-Z" and
|
starts up the interpreter as above (and don't forget you'll need a ":kbd:`Ctrl-Z`" and
|
||||||
an "Enter" to get out of it). Once you have verified the directory, you can
|
an ":kbd:`Enter`" to get out of it). Once you have verified the directory, you can
|
||||||
add it to the system path to make it easier to start Python by just running
|
add it to the system path to make it easier to start Python by just running
|
||||||
the ``python`` command. This is currently an option in the installer as of
|
the ``python`` command. This is currently an option in the installer as of
|
||||||
CPython 3.3.
|
CPython 3.3.
|
||||||
|
@ -327,7 +327,7 @@ Prior to Python 2.7 and 3.2, to terminate a process, you can use :mod:`ctypes`::
|
||||||
return (0 != kernel32.TerminateProcess(handle, 0))
|
return (0 != kernel32.TerminateProcess(handle, 0))
|
||||||
|
|
||||||
In 2.7 and 3.2, :func:`os.kill` is implemented similar to the above function,
|
In 2.7 and 3.2, :func:`os.kill` is implemented similar to the above function,
|
||||||
with the additional feature of being able to send CTRL+C and CTRL+BREAK
|
with the additional feature of being able to send :kbd:`Ctrl+C` and :kbd:`Ctrl+Break`
|
||||||
to console subprocesses which are designed to handle those signals. See
|
to console subprocesses which are designed to handle those signals. See
|
||||||
:func:`os.kill` for further details.
|
:func:`os.kill` for further details.
|
||||||
|
|
||||||
|
|
|
@ -853,7 +853,7 @@ the :meth:`BaseEventLoop.add_signal_handler` method::
|
||||||
loop.add_signal_handler(getattr(signal, signame),
|
loop.add_signal_handler(getattr(signal, signame),
|
||||||
functools.partial(ask_exit, signame))
|
functools.partial(ask_exit, signame))
|
||||||
|
|
||||||
print("Event loop running forever, press CTRL+c to interrupt.")
|
print("Event loop running forever, press Ctrl+C to interrupt.")
|
||||||
print("pid %s: send SIGINT or SIGTERM to exit." % os.getpid())
|
print("pid %s: send SIGINT or SIGTERM to exit." % os.getpid())
|
||||||
try:
|
try:
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
|
|
|
@ -539,7 +539,7 @@ received data and close the connection::
|
||||||
coro = loop.create_server(EchoServerClientProtocol, '127.0.0.1', 8888)
|
coro = loop.create_server(EchoServerClientProtocol, '127.0.0.1', 8888)
|
||||||
server = loop.run_until_complete(coro)
|
server = loop.run_until_complete(coro)
|
||||||
|
|
||||||
# Serve requests until CTRL+c is pressed
|
# Serve requests until Ctrl+C is pressed
|
||||||
print('Serving on {}'.format(server.sockets[0].getsockname()))
|
print('Serving on {}'.format(server.sockets[0].getsockname()))
|
||||||
try:
|
try:
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
|
|
|
@ -312,7 +312,7 @@ TCP echo server using the :func:`asyncio.start_server` function::
|
||||||
coro = asyncio.start_server(handle_echo, '127.0.0.1', 8888, loop=loop)
|
coro = asyncio.start_server(handle_echo, '127.0.0.1', 8888, loop=loop)
|
||||||
server = loop.run_until_complete(coro)
|
server = loop.run_until_complete(coro)
|
||||||
|
|
||||||
# Serve requests until CTRL+c is pressed
|
# Serve requests until Ctrl+C is pressed
|
||||||
print('Serving on {}'.format(server.sockets[0].getsockname()))
|
print('Serving on {}'.format(server.sockets[0].getsockname()))
|
||||||
try:
|
try:
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
|
|
|
@ -330,8 +330,8 @@ Go to file/line
|
||||||
Editing and navigation
|
Editing and navigation
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
In this section, 'C' refers to the Control key on Windows and Unix and
|
In this section, 'C' refers to the :kbd:`Control` key on Windows and Unix and
|
||||||
the Command key on Mac OSX.
|
the :kbd:`Command` key on Mac OSX.
|
||||||
|
|
||||||
* :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right
|
* :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right
|
||||||
|
|
||||||
|
|
|
@ -1174,7 +1174,7 @@ object -- see :ref:`multiprocessing-managers`.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
If the SIGINT signal generated by Ctrl-C arrives while the main thread is
|
If the SIGINT signal generated by :kbd:`Ctrl-C` arrives while the main thread is
|
||||||
blocked by a call to :meth:`BoundedSemaphore.acquire`, :meth:`Lock.acquire`,
|
blocked by a call to :meth:`BoundedSemaphore.acquire`, :meth:`Lock.acquire`,
|
||||||
:meth:`RLock.acquire`, :meth:`Semaphore.acquire`, :meth:`Condition.acquire`
|
:meth:`RLock.acquire`, :meth:`Semaphore.acquire`, :meth:`Condition.acquire`
|
||||||
or :meth:`Condition.wait` then the call will be immediately interrupted and
|
or :meth:`Condition.wait` then the call will be immediately interrupted and
|
||||||
|
|
|
@ -156,8 +156,8 @@ access further features, you have to do this yourself:
|
||||||
that matches one of these patterns. [1]_
|
that matches one of these patterns. [1]_
|
||||||
|
|
||||||
By default, Pdb sets a handler for the SIGINT signal (which is sent when the
|
By default, Pdb sets a handler for the SIGINT signal (which is sent when the
|
||||||
user presses Ctrl-C on the console) when you give a ``continue`` command.
|
user presses :kbd:`Ctrl-C` on the console) when you give a ``continue`` command.
|
||||||
This allows you to break into the debugger again by pressing Ctrl-C. If you
|
This allows you to break into the debugger again by pressing :kbd:`Ctrl-C`. If you
|
||||||
want Pdb not to touch the SIGINT handler, set *nosigint* tot true.
|
want Pdb not to touch the SIGINT handler, set *nosigint* tot true.
|
||||||
|
|
||||||
Example call to enable tracing with *skip*::
|
Example call to enable tracing with *skip*::
|
||||||
|
|
|
@ -95,7 +95,7 @@ The variables defined in the :mod:`signal` module are:
|
||||||
|
|
||||||
.. data:: CTRL_C_EVENT
|
.. data:: CTRL_C_EVENT
|
||||||
|
|
||||||
The signal corresponding to the CTRL+C keystroke event. This signal can
|
The signal corresponding to the :kbd:`Ctrl+C` keystroke event. This signal can
|
||||||
only be used with :func:`os.kill`.
|
only be used with :func:`os.kill`.
|
||||||
|
|
||||||
Availability: Windows.
|
Availability: Windows.
|
||||||
|
@ -105,7 +105,7 @@ The variables defined in the :mod:`signal` module are:
|
||||||
|
|
||||||
.. data:: CTRL_BREAK_EVENT
|
.. data:: CTRL_BREAK_EVENT
|
||||||
|
|
||||||
The signal corresponding to the CTRL+BREAK keystroke event. This signal can
|
The signal corresponding to the :kbd:`Ctrl+Break` keystroke event. This signal can
|
||||||
only be used with :func:`os.kill`.
|
only be used with :func:`os.kill`.
|
||||||
|
|
||||||
Availability: Windows.
|
Availability: Windows.
|
||||||
|
|
|
@ -554,9 +554,9 @@ ttk.Notebook
|
||||||
This will extend the bindings for the toplevel window containing the
|
This will extend the bindings for the toplevel window containing the
|
||||||
notebook as follows:
|
notebook as follows:
|
||||||
|
|
||||||
* Control-Tab: selects the tab following the currently selected one.
|
* :kbd:`Control-Tab`: selects the tab following the currently selected one.
|
||||||
* Shift-Control-Tab: selects the tab preceding the currently selected one.
|
* :kbd:`Shift-Control-Tab`: selects the tab preceding the currently selected one.
|
||||||
* Alt-K: where K is the mnemonic (underlined) character of any tab, will
|
* :kbd:`Alt-K`: where *K* is the mnemonic (underlined) character of any tab, will
|
||||||
select that tab.
|
select that tab.
|
||||||
|
|
||||||
Multiple notebooks in a single toplevel may be enabled for traversal,
|
Multiple notebooks in a single toplevel may be enabled for traversal,
|
||||||
|
|
|
@ -204,8 +204,8 @@ Command-line options
|
||||||
|
|
||||||
.. cmdoption:: -c, --catch
|
.. cmdoption:: -c, --catch
|
||||||
|
|
||||||
Control-C during the test run waits for the current test to end and then
|
:kbd:`Control-C` during the test run waits for the current test to end and then
|
||||||
reports all the results so far. A second control-C raises the normal
|
reports all the results so far. A second :kbd:`Control-C` raises the normal
|
||||||
:exc:`KeyboardInterrupt` exception.
|
:exc:`KeyboardInterrupt` exception.
|
||||||
|
|
||||||
See `Signal Handling`_ for the functions that provide this functionality.
|
See `Signal Handling`_ for the functions that provide this functionality.
|
||||||
|
|
|
@ -25,7 +25,7 @@ some cases of running out of memory. All error messages are written to the
|
||||||
standard error stream; normal output from executed commands is written to
|
standard error stream; normal output from executed commands is written to
|
||||||
standard output.
|
standard output.
|
||||||
|
|
||||||
Typing the interrupt character (usually Control-C or DEL) to the primary or
|
Typing the interrupt character (usually :kbd:`Control-C` or :kbd:`Delete`) to the primary or
|
||||||
secondary prompt cancels the input and returns to the primary prompt. [#]_
|
secondary prompt cancels the input and returns to the primary prompt. [#]_
|
||||||
Typing an interrupt while a command is executing raises the
|
Typing an interrupt while a command is executing raises the
|
||||||
:exc:`KeyboardInterrupt` exception, which may be handled by a :keyword:`try`
|
:exc:`KeyboardInterrupt` exception, which may be handled by a :keyword:`try`
|
||||||
|
|
|
@ -38,7 +38,7 @@ following command: ``quit()``.
|
||||||
The interpreter's line-editing features include interactive editing, history
|
The interpreter's line-editing features include interactive editing, history
|
||||||
substitution and code completion on systems that support readline. Perhaps the
|
substitution and code completion on systems that support readline. Perhaps the
|
||||||
quickest check to see whether command line editing is supported is typing
|
quickest check to see whether command line editing is supported is typing
|
||||||
Control-P to the first Python prompt you get. If it beeps, you have command
|
:kbd:`Control-P` to the first Python prompt you get. If it beeps, you have command
|
||||||
line editing; see Appendix :ref:`tut-interacting` for an introduction to the
|
line editing; see Appendix :ref:`tut-interacting` for an introduction to the
|
||||||
keys. If nothing appears to happen, or if ``^P`` is echoed, command line
|
keys. If nothing appears to happen, or if ``^P`` is echoed, command line
|
||||||
editing isn't available; you'll only be able to use backspace to remove
|
editing isn't available; you'll only be able to use backspace to remove
|
||||||
|
|
|
@ -41,7 +41,7 @@ additional methods of invocation:
|
||||||
|
|
||||||
* When called with standard input connected to a tty device, it prompts for
|
* When called with standard input connected to a tty device, it prompts for
|
||||||
commands and executes them until an EOF (an end-of-file character, you can
|
commands and executes them until an EOF (an end-of-file character, you can
|
||||||
produce that with *Ctrl-D* on UNIX or *Ctrl-Z, Enter* on Windows) is read.
|
produce that with :kbd:`Ctrl-D` on UNIX or :kbd:`Ctrl-Z, Enter` on Windows) is read.
|
||||||
* When called with a file name argument or with a file as standard input, it
|
* When called with a file name argument or with a file as standard input, it
|
||||||
reads and executes a script from that file.
|
reads and executes a script from that file.
|
||||||
* When called with a directory name argument, it reads and executes an
|
* When called with a directory name argument, it reads and executes an
|
||||||
|
|
|
@ -1174,8 +1174,8 @@ partial list:
|
||||||
|
|
||||||
* In the editor window, there is now a line/column bar at the bottom.
|
* In the editor window, there is now a line/column bar at the bottom.
|
||||||
|
|
||||||
* Three new keystroke commands: Check module (Alt-F5), Import module (F5) and
|
* Three new keystroke commands: Check module (:kbd:`Alt-F5`), Import module (:kbd:`F5`) and
|
||||||
Run script (Ctrl-F5).
|
Run script (:kbd:`Ctrl-F5`).
|
||||||
|
|
||||||
.. ======================================================================
|
.. ======================================================================
|
||||||
|
|
||||||
|
|
|
@ -827,7 +827,7 @@ inheritance relationships are::
|
||||||
This rearrangement was done because people often want to catch all exceptions
|
This rearrangement was done because people often want to catch all exceptions
|
||||||
that indicate program errors. :exc:`KeyboardInterrupt` and :exc:`SystemExit`
|
that indicate program errors. :exc:`KeyboardInterrupt` and :exc:`SystemExit`
|
||||||
aren't errors, though, and usually represent an explicit action such as the user
|
aren't errors, though, and usually represent an explicit action such as the user
|
||||||
hitting Control-C or code calling :func:`sys.exit`. A bare ``except:`` will
|
hitting :kbd:`Control-C` or code calling :func:`sys.exit`. A bare ``except:`` will
|
||||||
catch all exceptions, so you commonly need to list :exc:`KeyboardInterrupt` and
|
catch all exceptions, so you commonly need to list :exc:`KeyboardInterrupt` and
|
||||||
:exc:`SystemExit` in order to re-raise them. The usual pattern is::
|
:exc:`SystemExit` in order to re-raise them. The usual pattern is::
|
||||||
|
|
||||||
|
|
|
@ -2320,7 +2320,7 @@ Port-Specific Changes: Windows
|
||||||
* The :func:`os.kill` function now works on Windows. The signal value
|
* The :func:`os.kill` function now works on Windows. The signal value
|
||||||
can be the constants :const:`CTRL_C_EVENT`,
|
can be the constants :const:`CTRL_C_EVENT`,
|
||||||
:const:`CTRL_BREAK_EVENT`, or any integer. The first two constants
|
:const:`CTRL_BREAK_EVENT`, or any integer. The first two constants
|
||||||
will send Control-C and Control-Break keystroke events to
|
will send :kbd:`Control-C` and :kbd:`Control-Break` keystroke events to
|
||||||
subprocesses; any other value will use the :c:func:`TerminateProcess`
|
subprocesses; any other value will use the :c:func:`TerminateProcess`
|
||||||
API. (Contributed by Miki Tebeka; :issue:`1220212`.)
|
API. (Contributed by Miki Tebeka; :issue:`1220212`.)
|
||||||
|
|
||||||
|
|
|
@ -1657,7 +1657,7 @@ class Win32KillTests(unittest.TestCase):
|
||||||
os.kill(proc.pid, signal.SIGINT)
|
os.kill(proc.pid, signal.SIGINT)
|
||||||
self.fail("subprocess did not stop on {}".format(name))
|
self.fail("subprocess did not stop on {}".format(name))
|
||||||
|
|
||||||
@unittest.skip("subprocesses aren't inheriting CTRL+C property")
|
@unittest.skip("subprocesses aren't inheriting Ctrl+C property")
|
||||||
def test_CTRL_C_EVENT(self):
|
def test_CTRL_C_EVENT(self):
|
||||||
from ctypes import wintypes
|
from ctypes import wintypes
|
||||||
import ctypes
|
import ctypes
|
||||||
|
@ -1670,7 +1670,7 @@ class Win32KillTests(unittest.TestCase):
|
||||||
SetConsoleCtrlHandler.restype = wintypes.BOOL
|
SetConsoleCtrlHandler.restype = wintypes.BOOL
|
||||||
|
|
||||||
# Calling this with NULL and FALSE causes the calling process to
|
# Calling this with NULL and FALSE causes the calling process to
|
||||||
# handle CTRL+C, rather than ignore it. This property is inherited
|
# handle Ctrl+C, rather than ignore it. This property is inherited
|
||||||
# by subprocesses.
|
# by subprocesses.
|
||||||
SetConsoleCtrlHandler(NULL, 0)
|
SetConsoleCtrlHandler(NULL, 0)
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ class TestProgram(object):
|
||||||
if self.catchbreak is None:
|
if self.catchbreak is None:
|
||||||
parser.add_argument('-c', '--catch', dest='catchbreak',
|
parser.add_argument('-c', '--catch', dest='catchbreak',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Catch ctrl-C and display results so far')
|
help='Catch Ctrl-C and display results so far')
|
||||||
self.catchbreak = False
|
self.catchbreak = False
|
||||||
if self.buffer is None:
|
if self.buffer is None:
|
||||||
parser.add_argument('-b', '--buffer', dest='buffer',
|
parser.add_argument('-b', '--buffer', dest='buffer',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue