X Tutup
Skip to content

Commit 614b659

Browse files
committed
Don't hardcode prompt.
1 parent bf8833d commit 614b659

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

bpython/cli.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -944,15 +944,15 @@ def print_line(self, s, clr=False, newline=False):
944944
def prompt(self, more):
945945
"""Show the appropriate Python prompt"""
946946
if not more:
947-
self.echo("\x01%s\x03>>> " % (self.config.color_scheme['prompt'],))
948-
self.stdout_hist += '>>> '
949-
self.s_hist.append('\x01%s\x03>>> \x04' %
950-
(self.config.color_scheme['prompt'],))
947+
self.echo("\x01%s\x03%s" % (self.config.color_scheme['prompt'], self.ps1))
948+
self.stdout_hist += self.ps1
949+
self.s_hist.append('\x01%s\x03%s\x04' %
950+
(self.config.color_scheme['prompt'], self.ps1))
951951
else:
952952
prompt_more_color = self.config.color_scheme['prompt_more']
953-
self.echo("\x01%s\x03... " % (prompt_more_color, ))
954-
self.stdout_hist += '... '
955-
self.s_hist.append('\x01%s\x03... \x04' % (prompt_more_color, ))
953+
self.echo("\x01%s\x03%s" % (prompt_more_color, self.ps2))
954+
self.stdout_hist += self.ps2
955+
self.s_hist.append('\x01%s\x03%s\x04' % (prompt_more_color, self.ps2))
956956

957957
def push(self, s, insert_into_history=True):
958958
# curses.raw(True) prevents C-c from causing a SIGINT
@@ -1041,7 +1041,8 @@ def reprint_line(self, lineno, tokens):
10411041
if real_lineno < 0:
10421042
return
10431043

1044-
self.scr.move(real_lineno, 4)
1044+
self.scr.move(real_lineno,
1045+
len(self.ps1) if lineno == 0 else len(self.ps2))
10451046
line = format(tokens, BPythonFormatter(self.config.color_scheme))
10461047
for string in line.split('\x04'):
10471048
self.echo(string)

bpython/gtk_.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,13 +672,13 @@ def prompt(self, more):
672672
Show the appropriate Python prompt.
673673
"""
674674
if more:
675-
text = '... '
675+
text = self.ps2
676676
else:
677-
text = '>>> '
677+
text = self.ps1
678678
with self.editing:
679679
iter_ = self.get_cursor_iter()
680680
self.text_buffer.insert_with_tags_by_name(iter_, text, 'prompt')
681-
iter_.forward_chars(4)
681+
iter_.forward_chars(len(text))
682682
mark = self.text_buffer.create_mark('line_start', iter_, True)
683683
self.text_buffer.place_cursor(iter_)
684684
self.scroll_to_mark(mark, 0.2)

bpython/repl.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ def __init__(self, interp, config):
340340
self._C = {}
341341
self.prev_block_finished = 0
342342
self.interact = Interaction(self.config)
343+
self.ps1 = 'spam> '
344+
self.ps2 = '... '
343345
# previous pastebin content to prevent duplicate pastes, filled on call
344346
# to repl.pastebin
345347
self.prev_pastebin_content = ''
@@ -668,8 +670,10 @@ def formatforfile(self, s):
668670

669671
def process():
670672
for line in s.split('\n'):
671-
if line.startswith('>>>') or line.startswith('...'):
672-
yield line[4:]
673+
if line.startswith(self.ps1):
674+
yield line[len(self.ps1):]
675+
elif line.startswith(self.ps2):
676+
yield line[len(self.ps2):]
673677
elif line.rstrip():
674678
yield "# OUT: %s" % (line,)
675679
return "\n".join(process())

bpython/urwid.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -745,12 +745,12 @@ def prompt(self, more):
745745
# XXX what is s_hist?
746746
if not more:
747747
self.edit = BPythonEdit(self.config,
748-
caption=('prompt', '>>> '))
749-
self.stdout_hist += '>>> '
748+
caption=('prompt', self.ps1))
749+
self.stdout_hist += self.ps1
750750
else:
751751
self.edit = BPythonEdit(self.config,
752-
caption=('prompt_more', '... '))
753-
self.stdout_hist += '... '
752+
caption=('prompt_more', self.ps2))
753+
self.stdout_hist += self.ps2
754754

755755
urwid.connect_signal(self.edit, 'change', self.on_input_change)
756756
urwid.connect_signal(self.edit, 'edit-pos-changed',

0 commit comments

Comments
 (0)
X Tutup