mercurial/win32.py
branchstable
changeset 13285 2ef915184ff2
parent 12966 5f80f44d23c5
child 13374 1c613c1ae43d
equal deleted inserted replaced
13249:75d0c38a0bca 13285:2ef915184ff2
   168 
   168 
   169 def termwidth():
   169 def termwidth():
   170     try:
   170     try:
   171         # Query stderr to avoid problems with redirections
   171         # Query stderr to avoid problems with redirections
   172         screenbuf = win32console.GetStdHandle(win32console.STD_ERROR_HANDLE)
   172         screenbuf = win32console.GetStdHandle(win32console.STD_ERROR_HANDLE)
       
   173         if screenbuf is None:
       
   174             return 79
   173         try:
   175         try:
   174             window = screenbuf.GetConsoleScreenBufferInfo()['Window']
   176             window = screenbuf.GetConsoleScreenBufferInfo()['Window']
   175             width = window.Right - window.Left
   177             width = window.Right - window.Left
   176             return width
   178             return width
   177         finally:
   179         finally: