MCPcopy Index your code
hub / github.com/python/cpython / process_prompt

Method process_prompt

Lib/_pyrepl/reader.py:400–409  ·  view source on GitHub ↗

r"""Return a tuple with the prompt string and its visible length. The prompt string has the zero-width brackets recognized by shells (\x01 and \x02) removed. The length ignores anything between those brackets as well as any ANSI escape sequences.

(prompt: str)

Source from the content-addressed store, hash-verified

398
399 @staticmethod
400 def process_prompt(prompt: str) -> tuple[str, int]:
401 r"""Return a tuple with the prompt string and its visible length.
402
403 The prompt string has the zero-width brackets recognized by shells
404 (\x01 and \x02) removed. The length ignores anything between those
405 brackets as well as any ANSI escape sequences.
406 """
407 out_prompt = unbracket(prompt, including_content=False)
408 visible_prompt = unbracket(prompt, including_content=True)
409 return out_prompt, wlen(visible_prompt)
410
411 def bow(self, p: int | None = None) -> int:
412 """Return the 0-based index of the word break preceding p most

Callers 2

calc_screenMethod · 0.95
test_prompt_lengthMethod · 0.80

Calls 2

unbracketFunction · 0.85
wlenFunction · 0.85

Tested by 1

test_prompt_lengthMethod · 0.64