comparison mercurial/ui.py @ 52253:b3214b7d2390 stable

ui: fix escape sequences in in readline prompts (issue6930) Text that is meant to represent zero-width output in a readline prompt, such as terminal escape sequences, is supposed to be delimited by \001 ... \002: > Applications may indicate that the prompt contains characters that > take up no physical screen space when displayed by bracketing a > sequence of such characters with the special markers > RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE (declared in > readline.h `\001' and `\002', respectively). This may be used to > embed terminal-specific escape sequences in prompts. https://tiswww.cwru.edu/php/chet/readline/readline.html#index-rl_005fexpand_005fprompt When formatting a readline prompt in ui._readline, arrange to do this in the color.py labelling routines. Keeping mutable dynamically scoped state like this isn't great but threading it as a parameter through all the subroutines seems like much more trouble. (This doesn't address the missing line break -- that's a separate bug in libedit.) https://bz.mercurial-scm.org/show_bug.cgi?id=6930
author Taylor R Campbell <campbell+mercurial@mumble.net>
date Thu, 05 Dec 2024 20:46:21 +0000
parents f4733654f144
children b7afc38468bd
comparison
equal deleted inserted replaced
52252:64baff9f7dad 52253:b3214b7d2390
263 self.insecureconnections = False 263 self.insecureconnections = False
264 # Blocked time 264 # Blocked time
265 self.logblockedtimes = False 265 self.logblockedtimes = False
266 # color mode: see mercurial/color.py for possible value 266 # color mode: see mercurial/color.py for possible value
267 self._colormode = None 267 self._colormode = None
268 # readline prompt: is this currently for a readline prompt?
269 self._readlineprompt = False
268 self._terminfoparams = {} 270 self._terminfoparams = {}
269 self._styles = {} 271 self._styles = {}
270 self._uninterruptible = False 272 self._uninterruptible = False
271 self.showtimestamp = False 273 self.showtimestamp = False
272 274
1743 self._fmsgout, prompt, type=b'prompt', **promptopts 1745 self._fmsgout, prompt, type=b'prompt', **promptopts
1744 ) 1746 )
1745 self.flush() 1747 self.flush()
1746 prompt = b' ' 1748 prompt = b' '
1747 else: 1749 else:
1748 prompt = self.label(prompt, b'ui.prompt') + b' ' 1750 wasreadlineprompt = self._readlineprompt
1751 try:
1752 self._readlineprompt = True
1753 prompt = self.label(prompt, b'ui.prompt') + b' '
1754 finally:
1755 self._readlineprompt = wasreadlineprompt
1749 1756
1750 # prompt ' ' must exist; otherwise readline may delete entire line 1757 # prompt ' ' must exist; otherwise readline may delete entire line
1751 # - http://bugs.python.org/issue12833 1758 # - http://bugs.python.org/issue12833
1752 with self.timeblockedsection(b'stdio'): 1759 with self.timeblockedsection(b'stdio'):
1753 if usereadline: 1760 if usereadline: