I am writing a program that prints colored lines, and the more I do with it the more I find myself working around line wrapping issues that come up.
It is a sort of terminal written in php, here is the prompt:
$return = readline("\033[44m\033[1;37m{$this->text}>>\033[0m ");
and scrolling through history, the non-printing characters play havoc on everything.
If I try to add escapes
$return = readline("\[\033[44m\033[1;37m\]{$this->text}>>\[\033[0m\] ");
then it prints the brackets...even if I add double backslashes.
\[\][timer]>>\[\]
I find the same thing for echo -e, I am really not sure whats going on.
Lastly, if I modify PS1 it works just fine.
[mike@crest ~]$ export PS1="\[\033[44m\033[1;37m\][timer]>>\[\033[0m\] "
[timer]>>
What am I missing here?
Edit: the coloring/display is not the problem. The problem is that bash will have line wrapping issues when invisible characters are printed without escapes...and when I add the escapes they are printed in plain text under all circumstances but PS1, and I'm not sure what the difference is, how to get it working in PHP.