Commits

Andreas Stührk committed eba6c46

Don't hardcode prompt.

Comments (0)

Files changed (4)

     def prompt(self, more):
         """Show the appropriate Python prompt"""
         if not more:
-            self.echo("\x01%s\x03>>> " % (self.config.color_scheme['prompt'],))
-            self.stdout_hist += '>>> '
-            self.s_hist.append('\x01%s\x03>>> \x04' %
-                               (self.config.color_scheme['prompt'],))
+            self.echo("\x01%s\x03%s" % (self.config.color_scheme['prompt'], self.ps1))
+            self.stdout_hist += self.ps1
+            self.s_hist.append('\x01%s\x03%s\x04' %
+                               (self.config.color_scheme['prompt'], self.ps1))
         else:
             prompt_more_color = self.config.color_scheme['prompt_more']
-            self.echo("\x01%s\x03... " % (prompt_more_color, ))
-            self.stdout_hist += '... '
-            self.s_hist.append('\x01%s\x03... \x04' % (prompt_more_color, ))
+            self.echo("\x01%s\x03%s" % (prompt_more_color, self.ps2))
+            self.stdout_hist += self.ps2
+            self.s_hist.append('\x01%s\x03%s\x04' % (prompt_more_color, self.ps2))
 
     def push(self, s, insert_into_history=True):
         # curses.raw(True) prevents C-c from causing a SIGINT
         if real_lineno < 0:
             return
 
-        self.scr.move(real_lineno, 4)
+        self.scr.move(real_lineno,
+                      len(self.ps1) if lineno == 0 else len(self.ps2))
         line = format(tokens, BPythonFormatter(self.config.color_scheme))
         for string in line.split('\x04'):
             self.echo(string)
         Show the appropriate Python prompt.
         """
         if more:
-            text = '... '
+            text = self.ps2
         else:
-            text = '>>> '
+            text = self.ps1
         with self.editing:
             iter_ = self.get_cursor_iter()
             self.text_buffer.insert_with_tags_by_name(iter_, text, 'prompt')
-        iter_.forward_chars(4)
+        iter_.forward_chars(len(text))
         mark = self.text_buffer.create_mark('line_start', iter_, True)
         self.text_buffer.place_cursor(iter_)
         self.scroll_to_mark(mark, 0.2)
         self._C = {}
         self.prev_block_finished = 0
         self.interact = Interaction(self.config)
+        self.ps1 = 'spam> '
+        self.ps2 = '... '
         # previous pastebin content to prevent duplicate pastes, filled on call
         # to repl.pastebin
         self.prev_pastebin_content = ''
 
         def process():
             for line in s.split('\n'):
-                if line.startswith('>>>') or line.startswith('...'):
-                    yield line[4:]
+                if line.startswith(self.ps1):
+                    yield line[len(self.ps1):]
+                elif line.startswith(self.ps2):
+                    yield line[len(self.ps2):]
                 elif line.rstrip():
                     yield "# OUT: %s" % (line,)
         return "\n".join(process())
         # XXX what is s_hist?
         if not more:
             self.edit = BPythonEdit(self.config,
-                                    caption=('prompt', '>>> '))
-            self.stdout_hist += '>>> '
+                                    caption=('prompt', self.ps1))
+            self.stdout_hist += self.ps1
         else:
             self.edit = BPythonEdit(self.config,
-                                    caption=('prompt_more', '... '))
-            self.stdout_hist += '... '
+                                    caption=('prompt_more', self.ps2))
+            self.stdout_hist += self.ps2
 
         urwid.connect_signal(self.edit, 'change', self.on_input_change)
         urwid.connect_signal(self.edit, 'edit-pos-changed',