Show More
@@ -37,6 +37,8 b' from IPython.utils import coloransi, py3compat' | |||||
37 | from IPython.core.excolors import exception_colors |
|
37 | from IPython.core.excolors import exception_colors | |
38 | from IPython.testing.skipdoctest import skip_doctest |
|
38 | from IPython.testing.skipdoctest import skip_doctest | |
39 |
|
39 | |||
|
40 | from prompt_toolkit import prompt as ptk_prompt | |||
|
41 | ||||
40 | prompt = 'ipdb> ' |
|
42 | prompt = 'ipdb> ' | |
41 |
|
43 | |||
42 | #We have to check this directly from sys.argv, config struct not yet available |
|
44 | #We have to check this directly from sys.argv, config struct not yet available | |
@@ -245,13 +247,46 b' class Pdb(OldPdb, object):' | |||||
245 | self.parser = PyColorize.Parser() |
|
247 | self.parser = PyColorize.Parser() | |
246 |
|
248 | |||
247 | # Set the prompt - the default prompt is '(Pdb)' |
|
249 | # Set the prompt - the default prompt is '(Pdb)' | |
248 | Colors = cst.active_colors |
|
250 | self.prompt = prompt | |
249 | if color_scheme == 'NoColor': |
|
251 | ||
250 | self.prompt = prompt |
|
252 | ||
251 | else: |
|
253 | def cmdloop(self, intro=None): | |
252 | # The colour markers are wrapped by bytes 01 and 02 so that readline |
|
254 | """Repeatedly issue a prompt, accept input, parse an initial prefix | |
253 | # can calculate the width. |
|
255 | off the received input, and dispatch to action methods, passing them | |
254 | self.prompt = u'\x01%s\x02%s\x01%s\x02' % (Colors.prompt, prompt, Colors.Normal) |
|
256 | the remainder of the line as argument. | |
|
257 | ||||
|
258 | override the same methods from cmd.Cmd to provide prompt toolkit replacement. | |||
|
259 | """ | |||
|
260 | if not self.use_rawinput: | |||
|
261 | raise ValueError('Sorry ipdb does not support raw_input=False') | |||
|
262 | ||||
|
263 | def get_prompt_tokens(cli): | |||
|
264 | from pygments.token import Token | |||
|
265 | return [(Token.Prompt, self.prompt)] | |||
|
266 | ||||
|
267 | self.preloop() | |||
|
268 | try: | |||
|
269 | if intro is not None: | |||
|
270 | self.intro = intro | |||
|
271 | if self.intro: | |||
|
272 | self.stdout.write(str(self.intro)+"\n") | |||
|
273 | stop = None | |||
|
274 | while not stop: | |||
|
275 | if self.cmdqueue: | |||
|
276 | line = self.cmdqueue.pop(0) | |||
|
277 | else: | |||
|
278 | try: | |||
|
279 | line = ptk_prompt(get_prompt_tokens=get_prompt_tokens) | |||
|
280 | except EOFError: | |||
|
281 | line = 'EOF' | |||
|
282 | line = self.precmd(line) | |||
|
283 | stop = self.onecmd(line) | |||
|
284 | stop = self.postcmd(stop, line) | |||
|
285 | self.postloop() | |||
|
286 | except Exception: | |||
|
287 | pass | |||
|
288 | ||||
|
289 | ||||
255 |
|
290 | |||
256 | def set_colors(self, scheme): |
|
291 | def set_colors(self, scheme): | |
257 | """Shorthand access to the color table scheme selector method.""" |
|
292 | """Shorthand access to the color table scheme selector method.""" |
General Comments 0
You need to be logged in to leave comments.
Login now