Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 251032
Collapse All | Expand All

(-)layman/overlays/overlay.py.orig (-1 / +24 lines)
Lines 231-239 Link Here
231
            else:
231
            else:
232
                return string[:length - 3] + '...'
232
                return string[:length - 3] + '...'
233
233
234
        def terminal_width():
235
            '''Determine width of terminal window.'''
236
            try:
237
                width = int(os.environ['COLUMNS'])
238
                if width > 0:
239
                    return width
240
            except:
241
                pass
242
            try:
243
                import struct, fcntl, termios
244
                query = struct.pack('HHHH', 0, 0, 0, 0)
245
                response = fcntl.ioctl(1, termios.TIOCGWINSZ, query)
246
                width = struct.unpack('HHHH', response)[1]
247
                if width > 0:
248
                    return width
249
            except:
250
                pass
251
            return 80
252
234
        name   = pad(self.name, 25)
253
        name   = pad(self.name, 25)
235
        mtype  = ' [' + pad(self.type, 10) + ']'
254
        mtype  = ' [' + pad(self.type, 10) + ']'
236
        source = ' (source: ' + pad(self.src, 29) + ')'
255
        srclen = terminal_width() - 43
256
        source = self.src
257
        if len(source) > srclen:
258
            source = source.replace("overlays.gentoo.org", "o.g.o")
259
        source = ' (' + pad(source, srclen) + ')'
237
260
238
        return name + mtype + source
261
        return name + mtype + source
239
262

Return to bug 251032