summaryrefslogtreecommitdiff
path: root/cmd2/rl_utils.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-25 19:10:46 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-25 19:10:46 -0400
commit39e43d6329eb517ac58f95a8ca37e7e489d446cb (patch)
tree7244b69c9ea882c81a5379426f93ba2b2281229c /cmd2/rl_utils.py
parent5f46487bf7909045f217c89c7ade2d9fa89ebd7b (diff)
downloadcmd2-git-39e43d6329eb517ac58f95a8ca37e7e489d446cb.tar.gz
Addressing code review comments
Diffstat (limited to 'cmd2/rl_utils.py')
-rw-r--r--cmd2/rl_utils.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/cmd2/rl_utils.py b/cmd2/rl_utils.py
index 3fac5696..0819232d 100644
--- a/cmd2/rl_utils.py
+++ b/cmd2/rl_utils.py
@@ -71,8 +71,8 @@ if 'pyreadline' in sys.modules:
# Enable VT100 sequences for stdout and stderr
STD_OUT_HANDLE = -11
STD_ERROR_HANDLE = -12
- vt100_support = enable_win_vt100(readline.rl.console.GetStdHandle(STD_OUT_HANDLE)) and \
- enable_win_vt100(readline.rl.console.GetStdHandle(STD_ERROR_HANDLE))
+ vt100_support = (enable_win_vt100(readline.rl.console.GetStdHandle(STD_OUT_HANDLE)) and
+ enable_win_vt100(readline.rl.console.GetStdHandle(STD_ERROR_HANDLE)))
############################################################################################################
# pyreadline is incomplete in terms of the Python readline API. Add the missing functions we need.
@@ -174,15 +174,19 @@ def rl_set_prompt(prompt: str) -> None: # pragma: no cover
readline.rl._set_prompt(safe_prompt)
-def rl_make_safe_prompt(prompt: str, start: str = "\x01", end: str = "\x02") -> str: # pragma: no cover
+def rl_make_safe_prompt(prompt: str) -> str: # pragma: no cover
"""Overcome bug in GNU Readline in relation to calculation of prompt length in presence of ANSI escape codes.
:param prompt: original prompt
- :param start: start code to tell GNU Readline about beginning of invisible characters
- :param end: end code to tell GNU Readline about end of invisible characters
:return: prompt safe to pass to GNU Readline
"""
if rl_type == RlType.GNU:
+ # start code to tell GNU Readline about beginning of invisible characters
+ start = "\x01"
+
+ # end code to tell GNU Readline about end of invisible characters
+ end = "\x02"
+
escaped = False
result = ""