Ticket #843: 0001-Parse-additional-output-for-xterm-size-reporting-843.patch

File 0001-Parse-additional-output-for-xterm-size-reporting-843.patch, 1.1 KB (added by jpichon, 14 years ago)
  • library/pippy/console.py

    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(): 
    2626    os.write(fd, '\x1B[18t')        # write the 'query screen size' command
    2727    read_to_delimit('\x1b')         # parse response.
    2828    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])
    3138    termios.tcsetattr(fd, termios.TCSANOW, oldattr) # reset tty
    3239    return cols, rows
    3340