##// END OF EJS Templates
Pdb calling, pickle (under certain circumstances, connected with %run) and...
Pdb calling, pickle (under certain circumstances, connected with %run) and input history bug fixes. The last two were subtle problems I've known have been lurking for a long time, I hope I finally got it all.

File last commit:

r65:0e36c216
r78:2b77f91f
Show More
winconsole.py
43 lines | 1.2 KiB | text/x-python | PythonLexer
"""
Set of functions to work with console on Windows.
Author: Alexander Belchenko (e-mail: bialix AT ukr.net)
License: 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)