def term_width():
 fallback = config['ui']['terminal_width'].get(int)
 try:
  import fcntl
  import termios
 except ImportError:
  return fallback
 try:
  buf = fcntl.ioctl(0, termios.TIOCGWINSZ, (' ' * 4))
 except IOError:
  return fallback
 try:
  (height, width) = struct.unpack('hh', buf)
 except struct.error:
  return fallback
 return width

def term_width ( ) : fallback = config [ 'ui' ] [ 'terminal_width' ] . get ( int ) try : import fcntl import termios except ImportError : return fallback try : buf = fcntl . ioctl ( 0 , termios . TIOCGWINSZ , ( ' ' * 4 ) ) except IOError : return fallback try : ( height , width ) = struct . unpack ( 'hh' , buf ) except struct . error : return fallback return width
get the width of the terminal .