Coverage for /home/anselor/src/cmd2/cmd2/rl_utils.py : 96%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# coding=utf-8 Imports the proper readline for the platform and provides utility functions for it """
# Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) # Try to import readline, but allow failure for convenience in Windows unit testing # Note: If this actually fails, you should install readline on Linux or Mac or pyreadline on Windows # noinspection PyUnresolvedReferences except ImportError: # pragma: no cover pass
"""Readline library types we recognize"""
# Check what implementation of readline we are using
# The order of this check matters since importing pyreadline will also show readline in the modules list rl_type = RlType.PYREADLINE
# We don't support libedit
# Load the readline lib so we can access members of it
""" Causes readline to redraw prompt and input line """
if rl_type == RlType.GNU: # pragma: no cover # rl_forced_update_display() is the proper way to redraw the prompt and line, but we # have to use ctypes to do it since Python's readline API does not wrap the function readline_lib.rl_forced_update_display()
# After manually updating the display, readline asks that rl_display_fixed be set to 1 for efficiency display_fixed = ctypes.c_int.in_dll(readline_lib, "rl_display_fixed") display_fixed.value = 1
elif rl_type == RlType.PYREADLINE: # pragma: no cover # noinspection PyProtectedMember readline.rl.mode._print_prompt() |