Skip to content

Commit d56215b

Browse files
author
Bob Farrell
committed
All columns in list window now used fully
No idea how I didn't notice this one sooner; I think it was just there in my periphery and I got used to it and forgot it was actually there, but now the rightmost column gets fully used. I also fixed another couple of little bugs that don't come up very often. committer: Bob Farrell <bob@keys.(none)>
1 parent c3159a1 commit d56215b

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

‎CHANGELOG‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
v0.6.1
2+
======
3+
Somehow it escaped my attention that the list window was never
4+
fully using the rightmost column, except for the first row. This
5+
is because me and numbers don't have the best relationship. I think
6+
stability is really improving with the latest spat of bugfixes,
7+
keep me informed of any bugs.
8+
19
v0.6.0
210
======
311
No noticeable changes except that bpython should now work with

‎bpython.py‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,11 @@ def show_list( self, items, topline=None ):
417417
max_h = h - y
418418
else:
419419
max_h = y+1
420-
max_w = int(w * 0.6)
420+
max_w = int(w * 0.8)
421421

422422
self.list_win.erase()
423+
if items and '.' in items[0]:
424+
items = [ x.rpartition('.')[2] for x in items ]
423425

424426
if topline:
425427
height_offset = self.mkargspec(topline, down) + 1
@@ -430,8 +432,8 @@ def lsize():
430432
wl = max( len(i) for i in v_items ) + 1 # longest word length (and a space)
431433
if not wl:
432434
wl = 1
433-
cols = (max_w - 2) / wl
434-
rows = len( v_items ) / (cols or 1)
435+
cols = ((max_w - 2) / wl) or 1
436+
rows = len( v_items ) / cols
435437

436438
if cols * rows < len( v_items ):
437439
rows += 1
@@ -473,7 +475,11 @@ def lsize():
473475
elif wl + 3 > max_w:
474476
w = max_w
475477
else:
476-
w = (cols + 1) * wl + 3
478+
t = (cols + 1) * wl + 3
479+
if t > max_w:
480+
t = max_w
481+
w = t
482+
477483

478484
if height_offset and display_rows+5 >= max_h:
479485
del v_items[-(cols * (height_offset)):]
@@ -487,11 +493,12 @@ def lsize():
487493

488494
if v_items:
489495
self.list_win.addstr( '\n ' )
496+
490497

491498
for ix, i in enumerate(v_items):
492499
padding = (wl - len(i)) * ' '
493500
self.list_win.addstr( i + padding, curses.color_pair( self._C["c"]+1 ) )
494-
if ((cols == 1) or (ix and not ix % cols)) and ix+1 < len(v_items):
501+
if (cols == 1 or (ix and not (ix+1) % cols)) and ix + 1 < len(v_items):
495502
self.list_win.addstr( '\n ' )
496503

497504
# XXX: After all the trouble I had with sizing the list box (I'm not very good

0 commit comments

Comments
 (0)