Skip to content

Commit 5bce3d0

Browse files
committed
Documented async functions
1 parent f70d55b commit 5bce3d0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/unfreefeatures.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,26 @@ Exit code to shell
189189
The ``self.exit_code`` attribute of your ``cmd2`` application controls
190190
what exit code is sent to the shell when your application exits from
191191
``cmdloop()``.
192+
193+
194+
Asynchronous printing
195+
=====================
196+
``cmd2`` provides two functions to provide asynchronous feedback to the user without interfering with
197+
the command line. This means the feedback is provided to the user when they are still entering text at
198+
the prompt. To use this functionality, the application must be running in any terminal that supports
199+
VT100 control characters and readline. Linux, Mac, and Windows 10 and greater all support these.
200+
201+
_async_alert()
202+
Used to display an important message to the user while they are at the prompt in between commands.
203+
To the user it appears as if an alert message is printed above the prompt and their current input
204+
text and cursor location is left alone.
205+
206+
_async_update_prompt()
207+
Updates the prompt while the user is still typing at it. This is good for alerting the user to system
208+
changes dynamically in between commands. For instance you could alter the color of the prompt to indicate
209+
a system status or increase a counter to report an event.
210+
211+
212+
The easiest way to understand these function is to see the AsyncPrinting_ example for a demonstration.
213+
214+
.. _AsyncPrinting: https://github.com/python-cmd2/cmd2/blob/master/examples/async_printing.py

0 commit comments

Comments
 (0)