/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: Martin Pool
  • Date: 2006-10-06 02:04:17 UTC
  • mfrom: (1908.10.1 bench_usecases.merge2)
  • mto: This revision was merged to the branch mainline in revision 2068.
  • Revision ID: mbp@sourcefrog.net-20061006020417-4949ca86f4417a4d
merge additional fix from cfbolz

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
10
11
try:
11
12
   import ctypes
 
13
   has_ctypes = True
12
14
except ImportError:
13
 
   ctypes = None
 
15
    has_ctypes = False
 
16
 
 
17
 
 
18
WIN32_STDIN_HANDLE = -10
 
19
WIN32_STDOUT_HANDLE = -11
 
20
WIN32_STDERR_HANDLE = -12
14
21
 
15
22
 
16
23
def get_console_size(defaultx=80, defaulty=25):
22
29
 
23
30
   Dependencies: ctypes should be installed.
24
31
   """
25
 
   if ctypes is None:
 
32
   if not has_ctypes:
26
33
       # no ctypes is found
27
34
       return (defaultx, defaulty)
28
35
 
29
 
   h = ctypes.windll.kernel32.GetStdHandle(-11)
 
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)
30
39
   csbi = ctypes.create_string_buffer(22)
31
40
   res = ctypes.windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
32
41