Add an override to colify so we can set terminal dimensions.

This commit is contained in:
Todd Gamblin 2015-02-22 21:17:18 -08:00
parent 065e5ccd1a
commit d49c98188a
2 changed files with 10 additions and 3 deletions

View File

@ -48,9 +48,7 @@
# Set an environment variable so that colify will print output like it would to
# a terminal.
os.environ['COLIFY_TTY'] = 'true'
os.environ['COLUMNS'] = '80'
os.environ['LINES'] = '25'
os.environ['COLIFY_SIZE'] = '25x80'
# Enable todo items
todo_include_todos = True

View File

@ -169,6 +169,15 @@ def colify(elts, **options):
if not elts:
return (0, ())
# environment size is of the form "<rows>x<cols>"
env_size = os.environ.get('COLIFY_SIZE')
if env_size:
try:
r, c = env_size.split('x')
console_rows, console_cols = int(r), int(c)
tty = True
except: pass
# Use only one column if not a tty.
if not tty:
if tty is False or not output.isatty():