[PATCH] obtain terminal_width via curses
robey at lag.net
Wed Apr 26 03:46:06 BST 2006
On 25 Apr 2006, at 18:36, Gustavo Niemeyer wrote:
> Hey Martin,
>> Thanks for the patch. There is an existing bug open for this,
>> That bug suggests using TIOCGWINSZ to do this, rather than curses,
>> which is at least conceptually more lightweight. Are there any
>> particular advantages to using curses?
> I've just added a comment to the bug with the function I use
> in Smart PM, based on TIOCGWINSZ.
I can't follow links right now because I'm offline, but apparently I
posted a patch for this back on Valentine's day. I can't remember
why it got rejected? Attached below my sig.
=== modified file 'bzrlib/osutils.py'
@@ -617,4 +617,12 @@
except (IndexError, KeyError, ValueError):
- return 80
+ # this only works on posix
+ import fcntl, termios, struct
+ height, width = struct.unpack('hh', fcntl.ioctl(sys.stdout,
termios.TIOCGWINSZ, " "))
+ return width
+ except ImportError:
+ return 80
More information about the bazaar