cmd2.rl_utils
cmd2.rl_utils
Imports the proper Readline for the platform and provides utility functions for it.
vt100_stdout_support
module-attribute
vt100_stdout_support = enable_win_vt100(GetStdHandle(STD_OUT_HANDLE))
vt100_stderr_support
module-attribute
vt100_stderr_support = enable_win_vt100(GetStdHandle(STD_ERROR_HANDLE))
rl_warning
module-attribute
rl_warning = f'Readline features including tab completion have been disabled because {_rl_warn_reason}
'
RlType
enable_win_vt100
Enable VT100 character sequences in a Windows console.
This only works on Windows 10 and up
| PARAMETER | DESCRIPTION |
|---|---|
handle
|
the handle on which to enable vt100
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if vt100 characters are enabled for the handle. |
Source code in cmd2/rl_utils.py
pyreadline_remove_history_item
Remove the specified item number from the pyreadline3 history.
An implementation of remove_history_item() for pyreadline3.
| PARAMETER | DESCRIPTION |
|---|---|
pos
|
The 0-based position in history to remove.
TYPE:
|
Source code in cmd2/rl_utils.py
rl_force_redisplay
Causes readline to display the prompt and input text wherever the cursor is and start reading input from this location.
This is the proper way to restore the input line after printing to the screen.
Source code in cmd2/rl_utils.py
rl_get_point
Return the offset of the current cursor position in rl_line_buffer.
Source code in cmd2/rl_utils.py
rl_get_prompt
Get Readline's prompt.
Source code in cmd2/rl_utils.py
rl_get_display_prompt
Get Readline's currently displayed prompt.
In GNU Readline, the displayed prompt sometimes differs from the prompt. This occurs in functions that use the prompt string as a message area, such as incremental search.
Source code in cmd2/rl_utils.py
rl_set_prompt
Set Readline's prompt.
| PARAMETER | DESCRIPTION |
|---|---|
prompt
|
the new prompt value.
TYPE:
|
Source code in cmd2/rl_utils.py
rl_escape_prompt
Overcome bug in GNU Readline in relation to calculation of prompt length in presence of ANSI escape codes.
| PARAMETER | DESCRIPTION |
|---|---|
prompt
|
original prompt
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
prompt safe to pass to GNU Readline |
Source code in cmd2/rl_utils.py
rl_unescape_prompt
Remove escape characters from a Readline prompt.
Source code in cmd2/rl_utils.py
rl_in_search_mode
Check if readline is doing either an incremental (e.g. Ctrl-r) or non-incremental (e.g. Esc-p) search.