File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -75,22 +75,24 @@ def pyreadline_remove_history_item(pos: int) -> None:
75
75
readline_lib = ctypes .CDLL (readline .__file__ )
76
76
77
77
78
+ # noinspection PyProtectedMember
78
79
def rl_force_redisplay () -> None :
79
80
"""
80
- Causes readline to redraw prompt and input line
81
+ Causes readline to display the prompt and input text wherever the cursor is and start
82
+ reading input from this location. This is the proper way to restore the input line after
83
+ printing to the screen
81
84
"""
82
85
if not sys .stdout .isatty ():
83
86
return
84
87
85
88
if rl_type == RlType .GNU : # pragma: no cover
86
- # rl_forced_update_display() is the proper way to redraw the prompt and line, but we
87
- # have to use ctypes to do it since Python's readline API does not wrap the function
88
89
readline_lib .rl_forced_update_display ()
89
90
90
91
# After manually updating the display, readline asks that rl_display_fixed be set to 1 for efficiency
91
92
display_fixed = ctypes .c_int .in_dll (readline_lib , "rl_display_fixed" )
92
93
display_fixed .value = 1
93
94
94
95
elif rl_type == RlType .PYREADLINE : # pragma: no cover
95
- # noinspection PyProtectedMember
96
+ # Call _print_prompt() first to set the new location of the prompt
96
97
readline .rl .mode ._print_prompt ()
98
+ readline .rl .mode ._update_line ()
You can’t perform that action at this time.
0 commit comments