Skip to content

Commit 782a2d1

Browse files
author
Bob Farrell
committed
Sizing of autocomplete window yet again fixed!
I hate this kind of stuff; I'm pretty bad at it. But I think I've made it more stable now. committer: Bob Farrell <bob@keys.(none)>
1 parent ebb1065 commit 782a2d1

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

‎bpython.py‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,11 @@ def lsize():
412412
break
413413

414414
rows = shared.rows
415-
if rows + height_offset <= max_h:
415+
if rows + height_offset < max_h:
416416
rows += height_offset
417+
display_rows = rows
418+
else:
419+
display_rows = rows + height_offset
417420

418421
cols = shared.cols
419422
wl = shared.wl
@@ -425,26 +428,25 @@ def lsize():
425428
else:
426429
w = (cols + 1) * wl + 3
427430

431+
if height_offset and display_rows+5 >= max_h:
432+
del v_items[-(cols * (height_offset)):]
433+
428434
self.list_win.resize( rows+2, w )#(cols + 1) * wl + 3 )
429435

430436
if down:
431437
self.list_win.mvwin(y+1, 0)
432438
else:
433439
self.list_win.mvwin(y-rows-2, 0)
434440

435-
if height_offset and rows >= max_h:
436-
#v_items = ['lol']
437-
del v_items[-(cols * height_offset):]
438-
439441
if v_items:
440442
self.list_win.addstr( '\n ' )
443+
441444
for ix, i in enumerate(v_items):
442445
padding = (wl - len(i)) * ' '
443446
self.list_win.addstr( i + padding, curses.color_pair( self._C["c"]+1 ) )
444447
if (cols == 1) or (ix and not ix % cols and ix < len(v_items)):
445448
self.list_win.addstr( '\n ' )
446-
#self.list_win.refresh()
447-
#time.sleep(0.5)
449+
448450
self.statusbar.win.touchwin()
449451
self.statusbar.win.noutrefresh()
450452
self.list_win.border()
@@ -459,13 +461,14 @@ def mkargspec( self, topline, down ):
459461
It's also kind of messy due to it having to call so many addstr() to get
460462
the colouring right, but it seems to be pretty sturdy."""
461463

462-
r = 0
464+
r = 3
463465
fn = topline[0]
464466
args = topline[1][0]
465467
kwargs = topline[1][3]
466468
_args = topline[1][1]
467469
_kwargs = topline[1][2]
468470
max_w = int(self.scr.getmaxyx()[1] * 0.6)
471+
self.list_win.erase()
469472
self.list_win.resize( 3, max_w )
470473
h, w = self.list_win.getmaxyx()
471474

@@ -489,10 +492,11 @@ def mkargspec( self, topline, down ):
489492
self.list_win.mvwin( ty-1, 1 )
490493
self.list_win.resize(h,w)
491494
elif down and h + r < maxh-ty:
492-
h +=1
495+
h += 1
493496
self.list_win.resize(h,w)
494497
else:
495-
r += 1
498+
break
499+
r += 1
496500
self.list_win.addstr('\n\t')
497501

498502
self.list_win.addstr( str(i), curses.color_pair( self._C["g"]+1 ) | curses.A_BOLD )

0 commit comments

Comments
 (0)