We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
shutil
1 parent 9dac80b commit 7f51cc4Copy full SHA for 7f51cc4
sphinx/_cli/console_utilities.py
@@ -2,7 +2,6 @@
2
3
import os
4
import re
5
-import shutil
6
import sys
7
from typing import Dict, Pattern
8
@@ -24,7 +23,17 @@ def terminal_safe(s: str) -> str:
24
23
25
def get_terminal_width() -> int:
26
"""Return the width of the terminal in columns."""
27
- return shutil.get_terminal_size().columns - 1
+ try:
+ columns = int(os.environ.get('COLUMNS', 0))
28
+ except ValueError:
29
+ columns = 0
30
+ if columns > 1:
31
+ return columns - 1
32
33
+ return os.get_terminal_size(sys.__stdout__.fileno()).columns - 1
34
+ except (AttributeError, ValueError, OSError):
35
+ # fallback
36
+ return 80 - 1
37
38
39
_tw: int = get_terminal_width()
0 commit comments