> Make a subclass of String (or delegate) that tracks "embedded" ANSI =A0
> codes along with the text. The class should add methods for wrapping =A0
> the text in ANSI codes. Implement as much of the core String API as =A0
> possible. So for example:
>
> =A0 =A0 s1 =3D AnsiString.new("Hi")
> =A0 =A0 s2 =3D AnsiString.new("there!)
>
> =A0 =A0 s1.red =A0 =A0# wrap text in red/escape ANSI codes
> =A0 =A0 s1.blue =A0 # wrap text in blue/escape ANSI codes

Make that 's2.blue'.

> =A0 =A0 s3 =3D s1 + ' ' + s2 =A0#=3D> New AnsiString
> =A0 =A0 s3.to_str =A0 =A0 =A0 =A0 =A0 #=3D> "\e[31mHi\e[0m \e[34mthere!\e=
[0m"

I've found it pretty challenging to keep the ANSI codes in sync with
the text while still being able to manipulate the text like a normal
string. I'm curious to see how other people approach it.

T.