~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/win32console.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-04-27 01:14:33 UTC
  • mfrom: (1686.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060427011433-95634ee1da8a2049
Merge in faster joins from weave to knit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
import struct
9
9
 
10
 
# We can cope without it; use a separate variable to help pyflakes
11
10
try:
12
11
   import ctypes
13
 
   has_ctypes = True
14
12
except ImportError:
15
 
    has_ctypes = False
16
 
 
17
 
 
18
 
WIN32_STDIN_HANDLE = -10
19
 
WIN32_STDOUT_HANDLE = -11
20
 
WIN32_STDERR_HANDLE = -12
 
13
   ctypes = None
21
14
 
22
15
 
23
16
def get_console_size(defaultx=80, defaulty=25):
29
22
 
30
23
   Dependencies: ctypes should be installed.
31
24
   """
32
 
   if not has_ctypes:
 
25
   if ctypes is None:
33
26
       # no ctypes is found
34
27
       return (defaultx, defaulty)
35
28
 
36
 
   # To avoid problem with redirecting output via pipe
37
 
   # need to use stderr instead of stdout
38
 
   h = ctypes.windll.kernel32.GetStdHandle(WIN32_STDERR_HANDLE)
 
29
   h = ctypes.windll.kernel32.GetStdHandle(-11)
39
30
   csbi = ctypes.create_string_buffer(22)
40
31
   res = ctypes.windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
41
32