Show More
@@ -63,12 +63,18 b' class RichPromptDisplayHook(DisplayHook):' | |||||
63 | """Subclass of base display hook using coloured prompt""" |
|
63 | """Subclass of base display hook using coloured prompt""" | |
64 | def write_output_prompt(self): |
|
64 | def write_output_prompt(self): | |
65 | sys.stdout.write(self.shell.separate_out) |
|
65 | sys.stdout.write(self.shell.separate_out) | |
66 | self.prompt_end_newline = False |
|
66 | # If we're not displaying a prompt, it effectively ends with a newline, | |
|
67 | # because the output will be left-aligned. | |||
|
68 | self.prompt_end_newline = True | |||
|
69 | ||||
67 | if self.do_full_cache: |
|
70 | if self.do_full_cache: | |
68 | tokens = self.shell.prompts.out_prompt_tokens() |
|
71 | tokens = self.shell.prompts.out_prompt_tokens() | |
69 | if tokens and tokens[-1][1].endswith('\n'): |
|
72 | prompt_txt = ''.join(s for t, s in tokens) | |
70 | self.prompt_end_newline = True |
|
73 | if prompt_txt and not prompt_txt.endswith('\n'): | |
|
74 | # Ask for a newline before multiline output | |||
|
75 | self.prompt_end_newline = False | |||
|
76 | ||||
71 | if self.shell.pt_cli: |
|
77 | if self.shell.pt_cli: | |
72 | self.shell.pt_cli.print_tokens(tokens) |
|
78 | self.shell.pt_cli.print_tokens(tokens) | |
73 | else: |
|
79 | else: | |
74 |
sys.stdout.write( |
|
80 | sys.stdout.write(prompt_txt) |
General Comments 0
You need to be logged in to leave comments.
Login now