[PATCH] obtain terminal_width via curses

Martin Pool mbp at sourcefrog.net
Wed Apr 26 01:45:57 BST 2006


On 25/04/2006, at 8:24 AM, Robert Widhopf-Fenk wrote:

> The attached patch modifies "bzr log --log-format line" to
> use the actual terminal width instead of a hard coded 79.
>
> Further osutils.py:terminal_width() is modified to use the
> curses module to get the current terminal width.
>
> In order to avoid flickering due to subsequent calls to
> curses.initsrc(), the width is saved in a global variable.
> It should not change the line buffering of stdout, but still
> seems to do it on my terminal/curses/python combination for
> the output of "bzr log ..."
>
> Robert
>
> <log-line.diff>

Thanks for the patch.  There is an existing bug open for this,
https://launchpad.net/products/bzr/+bug/3507

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?

-- 
Martin







More information about the bazaar mailing list