From 810e1327c2a4d381fe60317e0f6e05194a5405f9 Mon Sep 17 00:00:00 2001 From: Bob Farrell Date: Tue, 24 Jun 2008 23:54:27 +0100 Subject: [PATCH] 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. --- CHANGELOG | 8 ++++++++ bpython.py | 17 ++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2c44cfd..3aefd78 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +v0.6.1 +====== +Somehow it escaped my attention that the list window was never +fully using the rightmost column, except for the first row. This +is because me and numbers don't have the best relationship. I think +stability is really improving with the latest spat of bugfixes, +keep me informed of any bugs. + v0.6.0 ====== No noticeable changes except that bpython should now work with diff --git a/bpython.py b/bpython.py index bf0cbde..d862339 100644 --- a/bpython.py +++ b/bpython.py @@ -417,9 +417,11 @@ class Repl( object ): max_h = h - y else: max_h = y+1 - max_w = int(w * 0.6) + max_w = int(w * 0.8) self.list_win.erase() + if items and '.' in items[0]: + items = [ x.rpartition('.')[2] for x in items ] if topline: height_offset = self.mkargspec(topline, down) + 1 @@ -430,8 +432,8 @@ class Repl( object ): wl = max( len(i) for i in v_items ) + 1 # longest word length (and a space) if not wl: wl = 1 - cols = (max_w - 2) / wl - rows = len( v_items ) / (cols or 1) + cols = ((max_w - 2) / wl) or 1 + rows = len( v_items ) / cols if cols * rows < len( v_items ): rows += 1 @@ -473,7 +475,11 @@ class Repl( object ): elif wl + 3 > max_w: w = max_w else: - w = (cols + 1) * wl + 3 + t = (cols + 1) * wl + 3 + if t > max_w: + t = max_w + w = t + if height_offset and display_rows+5 >= max_h: del v_items[-(cols * (height_offset)):] @@ -487,11 +493,12 @@ class Repl( object ): if v_items: self.list_win.addstr( '\n ' ) + for ix, i in enumerate(v_items): padding = (wl - len(i)) * ' ' self.list_win.addstr( i + padding, curses.color_pair( self._C["c"]+1 ) ) - if ((cols == 1) or (ix and not ix % cols)) and ix+1 < len(v_items): + if (cols == 1 or (ix and not (ix+1) % cols)) and ix + 1 < len(v_items): self.list_win.addstr( '\n ' ) # XXX: After all the trouble I had with sizing the list box (I'm not very good