--- layman/overlays/overlay.py.orig 2008-12-15 15:13:28.000000000 +0100 +++ layman/overlays/overlay.py 2008-12-15 15:46:46.000000000 +0100 @@ -231,9 +231,32 @@ else: return string[:length - 3] + '...' + def terminal_width(): + '''Determine width of terminal window.''' + try: + width = int(os.environ['COLUMNS']) + if width > 0: + return width + except: + pass + try: + import struct, fcntl, termios + query = struct.pack('HHHH', 0, 0, 0, 0) + response = fcntl.ioctl(1, termios.TIOCGWINSZ, query) + width = struct.unpack('HHHH', response)[1] + if width > 0: + return width + except: + pass + return 80 + name = pad(self.name, 25) mtype = ' [' + pad(self.type, 10) + ']' - source = ' (source: ' + pad(self.src, 29) + ')' + srclen = terminal_width() - 43 + source = self.src + if len(source) > srclen: + source = source.replace("overlays.gentoo.org", "o.g.o") + source = ' (' + pad(source, srclen) + ')' return name + mtype + source