Skip to content

Commit

Permalink
Merge commit 'dbdcb918d051d71c913e63ed6bea605088b457ed'
Browse files Browse the repository at this point in the history
  • Loading branch information
poelzi committed Mar 23, 2011
2 parents 1445d96 + dbdcb91 commit 95b4cdf
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions client/ulatency
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,31 @@ style = drug(**dict(
on_cyan = "\033[46m",
on_white = "\033[47m"))


def terminal_size():
import fcntl, termios, struct
h, w, hp, wp = struct.unpack('HHHH',
fcntl.ioctl(0, termios.TIOCGWINSZ,
struct.pack('HHHH', 0, 0, 0, 0)))
return w or 80, h
def ioctl_GWINSZ(fd):
try:
import fcntl, termios, struct, os
cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ,
'1234'))
except:
return None
return cr
cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)
if not cr:
try:
fd = os.open(os.ctermid(), os.O_RDONLY)
cr = ioctl_GWINSZ(fd)
os.close(fd)
except:
pass
if not cr:
try:
cr = (os.environment['LINES'], os.environment['COLUMNS'])
except:
cr = (25, 80)
return int(cr[1]), int(cr[0])


TERM_WIDTH = terminal_size()[0]

Expand Down

0 comments on commit 95b4cdf

Please sign in to comment.