[Twisted-Python] Conch text attribute flattening quirks

Jonathan Jacobs jonathan+twisted at jsphere.com
Wed Feb 22 11:15:30 EST 2012

On Wed, Feb 22, 2012 at 17:25, Tim Allen <screwtape at froup.com> wrote:
> ...that is, there's no code for 'end bold' or 'end italics' (or blink, dim,
> underline, invisible, any kind of colouring, etc.) just an 'end all
> special attributes' code. Therefore it's reasonable for conch's helper
> library to not handle nested formatting, since no terminal program will
> produce such a thing, because it's impossible to represent in the
> VT100/VT200 formatting language.

I understand this, but then what is the point of placing content into
A.bold in the first place? Why not just drop A.bold into a flat
stream: [foo, A.bold, bar]

What's more confusing is that there are a handful of tests that
describe this nesting and even test it, although none of them (except
for the one marked TODO, which fails because of the problem I've
described) actually test adding things to the parent level after
nesting an attribute.

> I guess an argument could be made that the helper function should track
> which attributes are enabled at any particular point in the string, and
> calculate the correct sequence of disable-everything/re-enable-the-
> remaining-attributes codes, but evidently nobody's needed such a thing
> before.

It's not actually even all that hard, there is nothing in particular
to additionally track if you don't mind being a little inefficient
about it, which is how the IRC code in #3844 does it.


More information about the Twisted-Python mailing list