Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.1

Request #14835 Add Console_Color support
Submitted: 2008-10-20 13:00 UTC
From: ifeghali Assigned: yunosh
Status: Closed Package: Console_Table (version 1.1.2)
PHP Version: 5.1.6 OS: CentOS
Roadmaps: (Not assigned)    
Subscription  


 [2008-10-20 13:00 UTC] ifeghali (Igor Feghali)
Description: ------------ Upper and bottom lines of the table are generated with wrong length when printing colored data. Test script: --------------- <?php require_once "Console/Color.php"; require_once "Console/Table.php"; $t = new Console_Table(); $t->addRow(array(Console_Color::convert("%bI am Blue%n"))); print $t->getTable(); ?> Expected result: ---------------- +-------------+ | I am Blue | +-------------+ Actual result: -------------- +--------------------+ | I am Blue | +--------------------+

Comments

 [2008-10-20 13:08 UTC] yunosh (Jan Schneider)
Color coding on terminals is adding escape characters to the colored strings. There is no means in Console_Table to determine whether a character is a control (escape) character, or a "real" character.
 [2008-10-20 15:01 UTC] ifeghali (Igor Feghali)
you could for example rely on Console_Color::strip()[1] to wipe out the ANSI color codes from the string when calculating its length. This of course could be enabled by a new option. [1] http://pear.php.net/package/Console_Color/docs/latest/Console_Color/Console_Color.html#methodstrip
 [2008-10-20 17:06 UTC] ifeghali (Igor Feghali)
If you want I can provide a patch as soon as I get home.
 [2008-10-20 22:23 UTC] yunosh (Jan Schneider)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/Console_Table