##// END OF EJS Templates
Integrate new prompt machinery with intelli-newlining
Thomas Kluyver -
Show More
@@ -149,6 +149,9 b' class DisplayHook(Configurable):'
149 """
149 """
150 return self.shell.display_formatter.format(result)
150 return self.shell.display_formatter.format(result)
151
151
152 # This can be set to True by the write_output_prompt method in a subclass
153 prompt_end_newline = False
154
152 def write_format_data(self, format_dict, md_dict=None):
155 def write_format_data(self, format_dict, md_dict=None):
153 """Write the format data dict to the frontend.
156 """Write the format data dict to the frontend.
154
157
@@ -179,8 +182,7 b' class DisplayHook(Configurable):'
179 # because the expansion may add ANSI escapes that will interfere
182 # because the expansion may add ANSI escapes that will interfere
180 # with our ability to determine whether or not we should add
183 # with our ability to determine whether or not we should add
181 # a newline.
184 # a newline.
182 prompt_template = self.shell.prompt_manager.out_template
185 if not self.prompt_end_newline:
183 if prompt_template and not prompt_template.endswith('\n'):
184 # But avoid extraneous empty lines.
186 # But avoid extraneous empty lines.
185 result_repr = '\n' + result_repr
187 result_repr = '\n' + result_repr
186
188
@@ -42,8 +42,11 b' class RichPromptDisplayHook(DisplayHook):'
42 """Subclass of base display hook using coloured prompt"""
42 """Subclass of base display hook using coloured prompt"""
43 def write_output_prompt(self):
43 def write_output_prompt(self):
44 sys.stdout.write(self.shell.separate_out)
44 sys.stdout.write(self.shell.separate_out)
45 self.prompt_end_newline = False
45 if self.do_full_cache:
46 if self.do_full_cache:
46 tokens = self.shell.prompts.out_prompt_tokens()
47 tokens = self.shell.prompts.out_prompt_tokens()
48 if tokens and tokens[-1][1].endswith('\n'):
49 self.prompt_end_newline = True
47 if self.shell.pt_cli:
50 if self.shell.pt_cli:
48 self.shell.pt_cli.print_tokens(tokens)
51 self.shell.pt_cli.print_tokens(tokens)
49 else:
52 else:
General Comments 0
You need to be logged in to leave comments. Login now