[TF] Request for function.
Brought to you by:
kenkeys
|
From: fbneal at mac.c. (B. Neal) - 2003-04-02 13:10:50
|
At 11:26 +0200 4/2/03, Stefan Linnemann wrote: >Hello, once more, > >I have some variables, set from world input, that contain colour codes >as well as the value I seek. Now i'm trying to program a function to >strip the colour codes from the variable, and leave only the rest. >Alas my programming skills seem to desert me on this, all I achieve is >either an infinite loop or the value 1. > >Setting the emulation to ansi_strip is no solution, because much more >than the three values I capture are coloured, adn that helps >tremendously in recognising what to look for in play. It's only these >few values, that need their colours stripped. > >The problem is as follows: > there are one or two colour codes sequences at the start in the >variable, there may be a colour code sequence at the end. > Solution: >Step 1: Find escape character, if found, find first letter "m" after >that, call the position of this "m": i. >Step 2: From position after "i", search next escape char. If this is >not the following character, the wanted value lies between. If no >eacape character is found, the wanted value is from i+1 to end of >string. >-- There ar no other escape sequences in the string, only those colour >codes sequences. >-- So far the only colour code sequences are invariably of the form >\033[..m, with two cyphers at the dots. Two colour codes at the start >means twice this sequence. > >I should be able to program this myself, but I seem to misunderstand >several basic characteristics of Tinyfugue. > >Your help would be enormously appreciated. > >Stefan. Maybe I'm missing something here, but it seems that maybe the place to tackle this is where you set the var initially, instead of trying hackery ex post facto. B -- Brent Neal Geek of all Trades "Specialization is for insects" -- Robert A. Heinlein |