|
FiendishX Wanderer
Joined: 19 Nov 2005 Posts: 53
|
Posted: Wed Mar 12, 2008 9:27 pm
adding ansi patterns conditionally |
I have a line that generally looks like this...
[1;34m~~~~~~~~~[0;32m#####[1;34m~~~[0;32m#[1;37m?[1;34m~~~~~~~~[0m~~~~
with a bunch of characters with color codes interspersed.
And what I need it to do is take any block of regular symbols following a color code and put the preceding color code in front of each symbol.
so
[1;34m~~~~~~ would become
[1;34m~[1;34m~[1;34m~[1;34m~[1;34m~[1;34m~
etc. until the next color code. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Mar 13, 2008 12:09 am |
My question, really, is why? If they're not being coloured properly, there's something more systemic going on and adding codes of your own probably isn't going to fix it. If there's some other reason, I can't think of it.
|
|
|
|
FiendishX Wanderer
Joined: 19 Nov 2005 Posts: 53
|
Posted: Thu Mar 13, 2008 1:14 am |
Why ask why?
The reason why is that I want to be able to replace any of the symbols with a differently colored symbol of my choosing.
So say I have, for example, (green)-----------(white)######(blue)............ and I want to insert a red * somewhere in the middle there, but that will disrupt the coloration since the next symbol doesn't have its own color code. So I need to be able to insert a new color without disrupting other colors. And I need the insert to happen as quickly as possible.
So you see, the problem is not the color display. The problem is what happens when I put something else in the middle. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Mar 13, 2008 1:40 am |
I ask why because now you've told me what the real problem is, I can suggest a real solution. There's a much easier way to do that kind of replacement using MXP. Instead of inserting an ANSI code with your * and then trying to resume the previous color, you just insert <color red>*</color> and it'll do it all for you.
|
|
|
|
FiendishX Wanderer
Joined: 19 Nov 2005 Posts: 53
|
Posted: Thu Mar 13, 2008 2:38 am |
Hmm...
I never considered using mxp.
Though I'm still curious about non-mxp solutions. |
|
|
|
|
|