def _get_size_windows():
 res = None
 try:
  from ctypes import create_string_buffer, windll
  h = windll.kernel32.GetStdHandle((-12))
  csbi = create_string_buffer(22)
  res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
 except:
  return None
 if res:
  data = struct.unpack('hhhhHhhhhhh', csbi.raw)
  cols = ((data[7] - data[5]) + 1)
  rows = ((data[8] - data[6]) + 1)
  return (cols, rows)
 else:
  return None

def _get_size_windows ( ) : res = None try : from ctypes import create_string_buffer , windll h = windll . kernel32 . GetStdHandle ( ( - 12 ) ) csbi = create_string_buffer ( 22 ) res = windll . kernel32 . GetConsoleScreenBufferInfo ( h , csbi ) except : return None if res : data = struct . unpack ( 'hhhhHhhhhhh' , csbi . raw ) cols = ( ( data [ 7 ] - data [ 5 ] ) + 1 ) rows = ( ( data [ 8 ] - data [ 6 ] ) + 1 ) return ( cols , rows ) else : return None
attempt to discover the dimensions of a terminal window .