Browse Source

Remove win32 support for detecting terminal size

Matthew Wang 10 years ago
parent
commit
ac439e26ed
1 changed files with 10 additions and 16 deletions
  1. 10
    16
      cdiff.py

+ 10
- 16
cdiff.py View File

@@ -665,25 +665,19 @@ def decode(line):
665 665
 
666 666
     return '*** cdiff: undecodable bytes ***\n'
667 667
 
668
-def terminal_size():
669
-    """
670
-    Returns terminal size.
671 668
 
672
-    Taken from this gist:
673
-    https://gist.github.com/marsam/7268750
669
+def terminal_size():
670
+    """Returns terminal size. Taken from https://gist.github.com/marsam/7268750
671
+    but removed win32 support which depends on 3rd party extension.
674 672
     """
675 673
     width, height = None, None
676
-    if sys.platform == 'win32':
677
-        import win32utils
678
-        width, height = win32utils.get_console_size(defaultx=width, defaulty=height)
679
-    else:
680
-        try:
681
-            import struct, fcntl, termios
682
-            s = struct.pack('HHHH', 0, 0, 0, 0)
683
-            x = fcntl.ioctl(1, termios.TIOCGWINSZ, s)
684
-            height, width = struct.unpack('HHHH', x)[0:2]
685
-        except (IOError, AttributeError):
686
-            pass
674
+    try:
675
+        import struct, fcntl, termios
676
+        s = struct.pack('HHHH', 0, 0, 0, 0)
677
+        x = fcntl.ioctl(1, termios.TIOCGWINSZ, s)
678
+        height, width = struct.unpack('HHHH', x)[0:2]
679
+    except (IOError, AttributeError):
680
+        pass
687 681
     return width, height
688 682
 
689 683