home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1952 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.0 KB  |  27 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __author__ = 'Alexander Belchenko (e-mail: bialix AT ukr.net)'
  5. __license__ = 'Public domain'
  6. import struct
  7.  
  8. try:
  9.     import ctypes
  10. except ImportError:
  11.     ctypes = None
  12.  
  13.  
  14. def get_console_size(defaultx = 80, defaulty = 25):
  15.     if ctypes is None:
  16.         return (defaultx, defaulty)
  17.     h = ctypes.windll.kernel32.GetStdHandle(-11)
  18.     csbi = ctypes.create_string_buffer(22)
  19.     res = ctypes.windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
  20.     if res:
  21.         (bufx, bufy, curx, cury, wattr, left, top, right, bottom, maxx, maxy) = struct.unpack('hhhhHhhhhhh', csbi.raw)
  22.         sizex = (right - left) + 1
  23.         sizey = (bottom - top) + 1
  24.         return (sizex, sizey)
  25.     return (defaultx, defaulty)
  26.  
  27.