From 1fbf842f5ae540616b46a576963b58dfd4e6f2de Mon Sep 17 00:00:00 2001
From: Julie Pichon <julie.pichon@gmail.com>
Date: Sat, 30 Jan 2010 15:34:59 +0000
Subject: [PATCH] Parse additional output for xterm size reporting (#843)
---
library/pippy/console.py | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/library/pippy/console.py b/library/pippy/console.py
index 29ef2d5..8938c56 100644
a
|
b
|
def size(): |
26 | 26 | os.write(fd, '\x1B[18t') # write the 'query screen size' command |
27 | 27 | read_to_delimit('\x1b') # parse response. |
28 | 28 | read_to_delimit('[') |
29 | | rows = int(read_to_delimit(';')) |
30 | | cols = int(read_to_delimit('t')) |
| 29 | size = read_to_delimit('t') |
| 30 | # Output can either be '8;rows;cols' or 'rows;cols' |
| 31 | values = size.split(';') |
| 32 | if len(values) == 3: |
| 33 | rows = int(values[1]) |
| 34 | cols = int(values[2]) |
| 35 | else: |
| 36 | rows = int(values[0]) |
| 37 | cols = int(values[1]) |
31 | 38 | termios.tcsetattr(fd, termios.TCSANOW, oldattr) # reset tty |
32 | 39 | return cols, rows |
33 | 40 | |