X Tutup
Skip to content

Commit 171eb8e

Browse files
committed
Add the possibility to send the latest output to pager.
This closes issue bpython#49.
1 parent 72de2a5 commit 171eb8e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

bpython/cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
from bpython.keys import key_dispatch
7272

7373
from bpython import __version__
74+
from bpython.pager import page
7475

7576
def log(x):
7677
f = open('/tmp/bpython.log', 'a')
@@ -481,6 +482,7 @@ def __init__(self, scr, interp, statusbar=None, idle=None):
481482
self.paste_mode = False
482483
self.last_key_press = time.time()
483484
self.paste_time = 0.02
485+
self.prev_block_finished = 0
484486
sys.path.insert(0, '.')
485487

486488
if not OPTS.arg_spec:
@@ -1265,8 +1267,10 @@ def repl(self):
12651267
# Keep two copies so you can go up and down in the hist:
12661268
if inp:
12671269
self.rl_hist.append(inp + '\n')
1270+
stdout_position = len(self.stdout_hist)
12681271
more = self.push(inp) or self.paste_mode
12691272
if not more:
1273+
self.prev_block_finished = stdout_position
12701274
self.s = ''
12711275

12721276
def size(self):
@@ -1585,6 +1589,10 @@ def p_key(self):
15851589
self.pastebin()
15861590
return ''
15871591

1592+
elif self.c in key_dispatch[OPTS.last_output_key]:
1593+
page(self.stdout_hist[self.prev_block_finished:-4])
1594+
return ''
1595+
15881596
elif self.c == '\n':
15891597
self.lf()
15901598
return None

bpython/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def loadini(struct, configfile):
7070
struct.clear_line_key = config.safeget('keyboard', 'clear_line', 'C-u')
7171
struct.clear_screen_key = config.safeget('keyboard', 'clear_screen', 'C-l')
7272
struct.exit_key = config.safeget('keyboard', 'exit', 'C-d')
73+
struct.last_output_key = config.safeget('keyboard', 'last_output', 'F9')
7374

7475
color_scheme_name = config.safeget('general', 'color_scheme', 'default')
7576

0 commit comments

Comments
 (0)
X Tutup