~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/win32console.py

  • Committer: Martin Pool
  • Date: 2006-05-17 04:01:38 UTC
  • mto: (1704.2.17 bzr.mbp.integration)
  • mto: This revision was merged to the branch mainline in revision 1710.
  • Revision ID: mbp@sourcefrog.net-20060517040138-2cdf4e74bbc40afc
Fix setup.py to install launchpad plugin

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