diff options
| author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-03-21 04:25:24 -0400 |
|---|---|---|
| committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-03-21 04:25:24 -0400 |
| commit | 0014b4d4c6bde10c0be2813f43705b0170234cd6 (patch) | |
| tree | 2fe2e814a17738b34710dac44f8276bebbc453ae /cmd2.py | |
| parent | 57e53eed70f3a317d95a0f446eaa60c24392a388 (diff) | |
| download | cmd2-git-0014b4d4c6bde10c0be2813f43705b0170234cd6.tar.gz | |
Added generic code for getting terminal size for Python versions prior to 3.3
Diffstat (limited to 'cmd2.py')
| -rwxr-xr-x | cmd2.py | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -1560,7 +1560,13 @@ class Cmd(cmd.Cmd): if sys.version_info >= (3, 3): num_cols = shutil.get_terminal_size().columns else: - num_cols = 80 + proc = subprocess.Popen('stty size', shell=True, stdout=subprocess.PIPE) + out, err = proc.communicate() + if six.PY2: + rows, columns = out.split() + else: + rows, columns = out.decode().split() + num_cols = int(columns) if matches_to_display is None: self.columnize(matches, num_cols) |
