summaryrefslogtreecommitdiff
path: root/cmd2
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2022-02-17 10:47:54 -0500
committerKevin Van Brunt <kmvanbrunt@gmail.com>2022-02-17 11:13:34 -0500
commit4621b0501acdaea7230eef97ffa526d14820af80 (patch)
tree0f0061e6eaf4ca5d64d16fed6397b37cc152cd80 /cmd2
parent07f059c17b4cb6577fbc7a2ce42d7c5bf98a83c8 (diff)
downloadcmd2-git-4621b0501acdaea7230eef97ffa526d14820af80.tar.gz
cmd2 now uses pyreadline3 when running any version of Python on Windows
Diffstat (limited to 'cmd2')
-rw-r--r--cmd2/cmd2.py8
-rw-r--r--cmd2/rl_utils.py15
2 files changed, 11 insertions, 12 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 7fc2d4a3..912f00b7 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -155,7 +155,7 @@ else:
if rl_type == RlType.PYREADLINE:
- # Save the original pyreadline display completion function since we need to override it and restore it
+ # Save the original pyreadline3 display completion function since we need to override it and restore it
# noinspection PyProtectedMember,PyUnresolvedReferences
orig_pyreadline_display = readline.rl.mode._display_completions
@@ -1747,7 +1747,7 @@ class Cmd(cmd.Cmd):
padding = 2 * ' '
elif rl_type == RlType.PYREADLINE:
- # Add 3 to the padding of 1 that pyreadline uses for a total of 4.
+ # Add 3 to the padding of 1 that pyreadline3 uses for a total of 4.
padding = 3 * ' '
else:
@@ -1820,7 +1820,7 @@ class Cmd(cmd.Cmd):
rl_force_redisplay()
def _display_matches_pyreadline(self, matches: List[str]) -> None: # pragma: no cover
- """Prints a match list using pyreadline's _display_completions()
+ """Prints a match list using pyreadline3's _display_completions()
:param matches: the tab completion matches to display
"""
@@ -1841,7 +1841,7 @@ class Cmd(cmd.Cmd):
# Redraw the prompt and input lines
rl_force_redisplay()
- # Otherwise use pyreadline's formatter
+ # Otherwise use pyreadline3's formatter
else:
# Check if we should show display_matches
if self.display_matches:
diff --git a/cmd2/rl_utils.py b/cmd2/rl_utils.py
index cb73e836..e9557f01 100644
--- a/cmd2/rl_utils.py
+++ b/cmd2/rl_utils.py
@@ -26,13 +26,12 @@ from typing import (
# The workaround for Python environments using libedit is to install the gnureadline Python library.
#########################################################################################################################
-# Prefer statically linked gnureadline if available due to issues with libedit
+# Prefer statically linked gnureadline if installed due to compatibility issues with libedit
try:
# noinspection PyPackageRequirements
import gnureadline as readline # type: ignore[import]
except ImportError:
- # Try to import readline, but allow failure for convenience in Windows unit testing.
- # Note: If this actually fails, you should install gnureadline on Linux/Mac or pyreadline on Windows.
+ # Note: If this actually fails, you should install gnureadline on Linux/Mac or pyreadline3 on Windows.
try:
# noinspection PyUnresolvedReferences
import readline # type: ignore[no-redef]
@@ -57,8 +56,8 @@ vt100_support = False
# Explanation for why Readline wasn't loaded
_rl_warn_reason = ''
-# The order of this check matters since importing pyreadline/pyreadline3 will also show readline in the modules list
-if 'pyreadline' in sys.modules or 'pyreadline3' in sys.modules:
+# The order of this check matters since importing pyreadline3 will also show readline in the modules list
+if 'pyreadline3' in sys.modules:
rl_type = RlType.PYREADLINE
import atexit
@@ -109,7 +108,7 @@ if 'pyreadline' in sys.modules or 'pyreadline3' in sys.modules:
vt100_support = vt100_stdout_support and vt100_stderr_support
############################################################################################################
- # pyreadline is incomplete in terms of the Python readline API. Add the missing functions we need.
+ # pyreadline3 is incomplete in terms of the Python readline API. Add the missing functions we need.
############################################################################################################
# readline.redisplay()
try:
@@ -125,7 +124,7 @@ if 'pyreadline' in sys.modules or 'pyreadline3' in sys.modules:
# noinspection PyProtectedMember,PyUnresolvedReferences
def pyreadline_remove_history_item(pos: int) -> None:
"""
- An implementation of remove_history_item() for pyreadline
+ An implementation of remove_history_item() for pyreadline3
:param pos: The 0-based position in history to remove
"""
# Save of the current location of the history cursor
@@ -162,7 +161,7 @@ if rl_type == RlType.NONE: # pragma: no cover
if not _rl_warn_reason:
_rl_warn_reason = (
"no supported version of readline was found. To resolve this, install\n"
- "pyreadline on Windows or gnureadline on Linux/Mac."
+ "pyreadline3 on Windows or gnureadline on Linux/Mac."
)
rl_warning = "Readline features including tab completion have been disabled because\n" + _rl_warn_reason + '\n\n'
else: