MCPcopy
hub / github.com/pallets/click / _readline_prompt

Function _readline_prompt

src/click/termui.py:84–101  ·  view source on GitHub ↗

Call a prompt function, passing the full prompt on non-Windows so readline can handle line editing and cursor positioning correctly. On Windows the prompt is written separately via :func:`echo` for colorama support, with only the last character passed to *func*.

(func: t.Callable[[str], str], text: str, err: bool)

Source from the content-addressed store, hash-verified

82
83
84def _readline_prompt(func: t.Callable[[str], str], text: str, err: bool) -> str:
85 """Call a prompt function, passing the full prompt on non-Windows so
86 readline can handle line editing and cursor positioning correctly.
87
88 On Windows the prompt is written separately via :func:`echo` for
89 colorama support, with only the last character passed to *func*.
90 """
91 if WIN:
92 # Write the prompt separately so that we get nice coloring
93 # through colorama on Windows.
94 echo(text[:-1], nl=False, err=err)
95 # Echo the last character to stdout to work around an issue
96 # where readline causes backspace to clear the whole line.
97 return func(text[-1:])
98 if err:
99 with redirect_stdout(sys.stderr):
100 return func(text)
101 return func(text)
102
103
104def _build_prompt(

Callers 2

prompt_funcFunction · 0.85
confirmFunction · 0.85

Calls 2

funcFunction · 0.85
echoFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…