Skip to content

Commit a9826fd

Browse files
committed
Branch merge to keep up to date
2 parents 08be789 + d2d3702 commit a9826fd

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

bpython/cli.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,9 @@ def clear_current_line(self):
342342
def clear_wrapped_lines(self):
343343
"""Clear the wrapped lines of the current input."""
344344
# curses does not handle this on its own. Sad.
345-
width = self.scr.getmaxyx()[1]
346-
for y in xrange(self.iy + 1, self.iy + len(self.s) // width + 1):
345+
height, width = self.scr.getmaxyx()
346+
max_y = min(self.iy + (self.ix + len(self.s)) // width + 1, height)
347+
for y in xrange(self.iy + 1, max_y):
347348
self.scr.move(y, 0)
348349
self.scr.clrtoeol()
349350

@@ -461,6 +462,13 @@ def echo(self, s, redraw=True):
461462
# Replace NUL bytes, as addstr raises an exception otherwise
462463
s = s.replace('\x00', '')
463464

465+
screen_height, screen_width = self.scr.getmaxyx()
466+
if self.iy >= (screen_height - 1):
467+
lines = (self.ix + len(s)) // screen_width
468+
if lines > 0:
469+
self.scr.scroll(lines)
470+
self.iy -= lines
471+
self.scr.move(self.iy, self.ix)
464472
self.scr.addstr(s, a)
465473

466474
if redraw and not self.evaluating:
@@ -481,12 +489,7 @@ def fwd(self):
481489
"""Same as back() but, well, forward"""
482490

483491
self.cpos = 0
484-
485-
width = self.scr.getmaxyx()[1]
486-
for y in xrange(self.iy + 1, self.iy + len(self.s) // width + 1):
487-
self.scr.move(y, 0)
488-
self.scr.clrtoeol()
489-
492+
self.clear_wrapped_lines()
490493
self.rl_history.enter(self.s)
491494
self.s = self.rl_history.forward()
492495
self.print_line(self.s, clr=True)
@@ -1397,7 +1400,7 @@ def init_wins(scr, colors, config):
13971400
# This should show to be configured keys from ~/.bpython/config
13981401
#
13991402
statusbar = Statusbar(scr, main_win, background, config,
1400-
" <%s> Rewind <%s> Save <%s> Pastebin <%s> Pager <%s> Show Source " %
1403+
" <%s> Rewind <%s> Save <%s> Pastebin <%s> Pager <%s> Show Source " %
14011404
(config.undo_key, config.save_key,
14021405
config.pastebin_key, config.last_output_key,
14031406
config.show_source_key),

bpython/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def loadini(struct, configfile):
4545
'paste_time': 0.02,
4646
'syntax': True,
4747
'tab_length': 4,
48+
'pastebin_confirm': True,
49+
'pastebin_private': False,
4850
'pastebin_url': 'http://bpaste.net/xmlrpc/',
4951
'pastebin_show_url': 'http://bpaste.net/show/$paste_id/',
5052
},
@@ -92,6 +94,8 @@ def loadini(struct, configfile):
9294
struct.exit_key = config.get('keyboard', 'exit')
9395
struct.last_output_key = config.get('keyboard', 'last_output')
9496

97+
struct.pastebin_confirm = config.getboolean('general', 'pastebin_confirm')
98+
struct.pastebin_private = config.getboolean('general', 'pastebin_private')
9599
struct.pastebin_url = config.get('general', 'pastebin_url')
96100
struct.pastebin_show_url = config.get('general', 'pastebin_show_url')
97101

bpython/repl.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
from bpython import importcompletion, inspection
4747
from bpython.formatter import Parenthesis
4848

49+
# Needed for special handling of __abstractmethods__
50+
# abc only exists since 2.6, so check both that it exists and that it's
51+
# the one we're expecting
52+
try:
53+
import abc
54+
abc.ABCMeta
55+
has_abc = True
56+
except (ImportError, AttributeError):
57+
has_abc = False
58+
4959
py3 = sys.version_info[0] == 3
5060

5161

@@ -339,6 +349,11 @@ def attr_lookup(self, obj, expr, attr):
339349
if hasattr(obj, '__class__'):
340350
words.append('__class__')
341351
words = words + rlcompleter.get_class_members(obj.__class__)
352+
if has_abc and not isinstance(obj.__class__, abc.ABCMeta):
353+
try:
354+
words.remove('__abstractmethods__')
355+
except ValueError:
356+
pass
342357

343358
matches = []
344359
n = len(attr)
@@ -625,9 +640,10 @@ def write2file(self):
625640
def pastebin(self):
626641
"""Upload to a pastebin and display the URL in the status bar."""
627642

628-
if not self.statusbar.prompt("Pastebin buffer? (y/N) "
643+
if (self.config.pastebin_confirm and
644+
not self.statusbar.prompt("Pastebin buffer? (y/N) "
629645
).lower().startswith('y'
630-
):
646+
)):
631647
self.statusbar.message("Pastebin aborted")
632648
return
633649

0 commit comments

Comments
 (0)