From: Gavin Sinclair Date: 2003-10-29T06:02:01+09:00 Subject: Re: Formatting (ANSI) highlighted strings On Wednesday, October 29, 2003, 2:54:03 AM, Austin wrote: > On Tue, 28 Oct 2003 17:32:13 +0900, Gavin Sinclair wrote: >> Using the 'text/highlight' package on RubyForge, you can emit coloured >> strings to the console like so: >> s = "string".bold.red.on_white >> Great. Now if I want to format that using: >> printf "%-10s goes here\n", s >> I'm not going to get (in B&W) >> string goes here >> Rather >> string goes here >> Because >> s.size > 10 # It contains escape sequences to enact colours. >> even though it only contains 6 printable characters. >> Does anyone have any alternative, or a bright idea? > s = "string".ljust(10).bold.red.on_white > ? Hmmm... might get a bit hairy with some more complex formats, but I think it might just be good enough. Thanks. Gavin