Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Support clint.textui.max_width as context manager #148

Merged

Conversation

wkentaro
Copy link
Contributor

issue: #2

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from clint.textui import puts, max_width, indent

with max_width(6):
    puts('Hello world')

with max_width(20):
    puts('Hello world')

with indent(4):
    with max_width(6):
        puts('Hello world')

with max_width(20):
    puts('Hello world')
    with max_width(6):
        puts('Hello world')
    puts('Hello world')

to get output::

Hello
world
Hello world
    Hello
    world
Hello world
Hello
world
Hello world

@wkentaro wkentaro force-pushed the maxwidth-with-context-manager branch from c83c92a to a348dcb Compare August 16, 2015 08:08
@wkentaro wkentaro force-pushed the maxwidth-with-context-manager branch 2 times, most recently from 1fdb90d to 47bf87d Compare September 10, 2015 19:27
@wkentaro wkentaro changed the title Add clint.textui.maxwidth context manager Add clint.textui.max_width context manager Sep 10, 2015
@wkentaro wkentaro changed the title Add clint.textui.max_width context manager Support clint.textui.max_width as context manager Sep 10, 2015
@wkentaro
Copy link
Contributor Author

This also supports:

>>> max_width('Hello world', 6)
Hello
world

@wkentaro
Copy link
Contributor Author

ping

@kennethreitz kennethreitz merged commit dc8fbfd into kennethreitz:master Aug 29, 2017
@kennethreitz
Copy link
Owner

✨🍰✨✨🍰✨✨🍰✨

@wkentaro wkentaro deleted the maxwidth-with-context-manager branch August 29, 2017 19:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants