/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/win32console.py

  • Committer: Robert Collins
  • Date: 2006-04-19 23:32:08 UTC
  • mto: (1711.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1674.
  • Revision ID: robertc@robertcollins.net-20060419233208-2ed6906796994316
Make knit the default format.
Adjust affect tests to either have knit specific values or to be more generic,
as appropriate.
Disable all SFTP prefetching for known paramikos - direct readv support is now
a TODO.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
"""
 
3
Set of functions to work with console on Windows.
 
4
Author: Alexander Belchenko (e-mail: bialix AT ukr.net)
 
5
License: Public domain
 
6
"""
 
7
 
 
8
import struct
 
9
 
 
10
try:
 
11
   import ctypes
 
12
except ImportError:
 
13
   ctypes = None
 
14
 
 
15
 
 
16
def get_console_size(defaultx=80, defaulty=25):
 
17
   """ Return size of current console.
 
18
 
 
19
   This function try to determine actual size of current working
 
20
   console window and return tuple (sizex, sizey) if success,
 
21
   or default size (defaultx, defaulty) otherwise.
 
22
 
 
23
   Dependencies: ctypes should be installed.
 
24
   """
 
25
   if ctypes is None:
 
26
       # no ctypes is found
 
27
       return (defaultx, defaulty)
 
28
 
 
29
   h = ctypes.windll.kernel32.GetStdHandle(-11)
 
30
   csbi = ctypes.create_string_buffer(22)
 
31
   res = ctypes.windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
 
32
 
 
33
   if res:
 
34
       (bufx, bufy, curx, cury, wattr,
 
35
        left, top, right, bottom, maxx, maxy) = struct.unpack("hhhhHhhhhhh", csbi.raw)
 
36
       sizex = right - left + 1
 
37
       sizey = bottom - top + 1
 
38
       return (sizex, sizey)
 
39
   else:
 
40
       return (defaultx, defaulty)