Skip to content

Commit 84d581a

Browse files
rybarczykjsebastinas
authored andcommitted
rename s_hist to screen_hist
1 parent 93cfe58 commit 84d581a

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

bpython/cli.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,8 @@ def p_key(self, key):
967967
return ""
968968

969969
elif key in key_dispatch[config.clear_screen_key]:
970-
self.s_hist = [self.s_hist[-1]]
970+
# clear all but current line
971+
self.screen_hist = [self.screen_hist[-1]]
971972
self.highlighted_paren = None
972973
self.redraw()
973974
return ""
@@ -1099,7 +1100,7 @@ def prompt(self, more):
10991100
self.stdout_hist += self.ps1
11001101
else:
11011102
self.stdout_hist += self.ps1.encode(getpreferredencoding())
1102-
self.s_hist.append(
1103+
self.screen_hist.append(
11031104
"\x01%s\x03%s\x04"
11041105
% (self.config.color_scheme["prompt"], self.ps1)
11051106
)
@@ -1110,7 +1111,7 @@ def prompt(self, more):
11101111
self.stdout_hist += self.ps2
11111112
else:
11121113
self.stdout_hist += self.ps2.encode(getpreferredencoding())
1113-
self.s_hist.append(
1114+
self.screen_hist.append(
11141115
"\x01%s\x03%s\x04" % (prompt_more_color, self.ps2)
11151116
)
11161117

@@ -1128,15 +1129,15 @@ def push(self, s, insert_into_history=True):
11281129
curses.raw(True)
11291130

11301131
def redraw(self):
1131-
"""Redraw the screen."""
1132+
"""Redraw the screen using screen_hist"""
11321133
self.scr.erase()
1133-
for k, s in enumerate(self.s_hist):
1134+
for k, s in enumerate(self.screen_hist):
11341135
if not s:
11351136
continue
11361137
self.iy, self.ix = self.scr.getyx()
11371138
for i in s.split("\x04"):
11381139
self.echo(i, redraw=False)
1139-
if k < len(self.s_hist) - 1:
1140+
if k < len(self.screen_hist) - 1:
11401141
self.scr.addstr("\n")
11411142
self.iy, self.ix = self.scr.getyx()
11421143
self.print_line(self.s)
@@ -1175,7 +1176,7 @@ def repl(self):
11751176
return self.exit_value
11761177

11771178
self.history.append(inp)
1178-
self.s_hist[-1] += self.f_string
1179+
self.screen_hist[-1] += self.f_string
11791180
if py3:
11801181
self.stdout_hist += inp + "\n"
11811182
else:
@@ -1234,7 +1235,7 @@ def reevaluate(self):
12341235
self.f_string = ""
12351236
self.buffer = []
12361237
self.scr.erase()
1237-
self.s_hist = []
1238+
self.screen_hist = []
12381239
# Set cursor position to -1 to prevent paren matching
12391240
self.cpos = -1
12401241

@@ -1247,7 +1248,7 @@ def reevaluate(self):
12471248
else:
12481249
self.stdout_hist += line.encode(getpreferredencoding()) + "\n"
12491250
self.print_line(line)
1250-
self.s_hist[-1] += self.f_string
1251+
self.screen_hist[-1] += self.f_string
12511252
# I decided it was easier to just do this manually
12521253
# than to make the print_line and history stuff more flexible.
12531254
self.scr.addstr("\n")
@@ -1288,7 +1289,7 @@ def write(self, s):
12881289
self.stdout_hist += t
12891290

12901291
self.echo(s)
1291-
self.s_hist.append(s.rstrip())
1292+
self.screen_hist.append(s.rstrip())
12921293

12931294
def show_list(
12941295
self, items, arg_pos, topline=None, formatter=None, current_item=None
@@ -1551,7 +1552,7 @@ def send_current_line_to_editor(self):
15511552
self.stdout_hist += line.encode(getpreferredencoding()) + "\n"
15521553
self.history.append(line)
15531554
self.print_line(line)
1554-
self.s_hist[-1] += self.f_string
1555+
self.screen_hist[-1] += self.f_string
15551556
self.scr.addstr("\n")
15561557
self.more = self.push(line)
15571558
self.prompt(self.more)

bpython/repl.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,9 @@ def __init__(self, interp, config):
447447
self.rl_history = History(
448448
duplicates=config.hist_duplicates, hist_size=config.hist_length
449449
)
450-
self.s_hist = []
450+
# all input and output, stored as old style format strings
451+
# (\x01, \x02, ...) for cli.py
452+
self.screen_hist = []
451453
self.history = [] # commands executed since beginning of session
452454
self.redo_stack = []
453455
self.evaluating = False

bpython/urwid.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,6 @@ def reevaluate(self):
908908
self.f_string = ""
909909
self.buffer = []
910910
self.scr.erase()
911-
self.s_hist = []
912911
# Set cursor position to -1 to prevent paren matching
913912
self.cpos = -1
914913

@@ -923,7 +922,6 @@ def reevaluate(self):
923922
line.encode(locale.getpreferredencoding()) + "\n"
924923
)
925924
self.print_line(line)
926-
self.s_hist[-1] += self.f_string
927925
# I decided it was easier to just do this manually
928926
# than to make the print_line and history stuff more flexible.
929927
self.scr.addstr("\n")
@@ -964,7 +962,6 @@ def write(self, s):
964962
self.stdout_hist += t
965963

966964
self.echo(s)
967-
self.s_hist.append(s.rstrip())
968965

969966
def push(self, s, insert_into_history=True):
970967
# Restore the original SIGINT handler. This is needed to be able
@@ -1013,7 +1010,6 @@ def prompt(self, more):
10131010
self.current_output = None
10141011
# XXX is this the right place?
10151012
self.rl_history.reset()
1016-
# XXX what is s_hist?
10171013

10181014
# We need the caption to use unicode as urwid normalizes later
10191015
# input to be the same type, using ascii as encoding. If the
@@ -1074,7 +1070,6 @@ def handle_input(self, event):
10741070
inp = self.edit.get_edit_text()
10751071
self.history.append(inp)
10761072
self.edit.make_readonly()
1077-
# XXX what is this s_hist thing?
10781073
if py3:
10791074
self.stdout_hist += inp
10801075
else:

0 commit comments

Comments
 (0)