##// END OF EJS Templates
Merging the new-extensions branch....
Merging the new-extensions branch. * Previously, the latex Sphinx docs were in a single chapter. This has been fixed by adding a sixth argument of True to the ``latex_documents`` attribute of :file:`conf.py`. * The ``psum`` example in the MPI documentation has been updated to mpi4py version 1.1.0. Thanks to J. Thomas for this fix. * The top-level, zero-install :file:`ipython.py` script has been updated to the new application launching API. * The extension loading functions have been renamed to :func:`load_ipython_extension` and :func:`unload_ipython_extension`. * The :mod:`IPython.extensions.pretty` extension has been moved out of quarantine and fully updated to the new extension API. * New magics for loading/unloading/reloading extensions have been added: ``%load_ext``, ``%unload_ext`` and ``%reload_ext``.

File last commit:

r2052:321c2741
r2286:4088ad0e merge
Show More
winconsole.py
46 lines | 1.4 KiB | text/x-python | PythonLexer
"""Set of functions to work with console on Windows.
"""
#*****************************************************************************
# Copyright (C) 2005 Alexander Belchenko <bialix@ukr.net>
#
# This file is placed in the public domain.
#
#*****************************************************************************
__author__ = 'Alexander Belchenko (e-mail: bialix AT ukr.net)'
__license__ = 'Public domain'
import struct
try:
import ctypes
except ImportError:
ctypes = None
def get_console_size(defaultx=80, defaulty=25):
""" Return size of current console.
This function try to determine actual size of current working
console window and return tuple (sizex, sizey) if success,
or default size (defaultx, defaulty) otherwise.
Dependencies: ctypes should be installed.
"""
if ctypes is None:
# no ctypes is found
return (defaultx, defaulty)
h = ctypes.windll.kernel32.GetStdHandle(-11)
csbi = ctypes.create_string_buffer(22)
res = ctypes.windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
if res:
(bufx, bufy, curx, cury, wattr,
left, top, right, bottom, maxx, maxy) = struct.unpack("hhhhHhhhhhh",
csbi.raw)
sizex = right - left + 1
sizey = bottom - top + 1
return (sizex, sizey)
else:
return (defaultx, defaulty)