I think you probably got lost in a dangerous territory. Curses will almost certainly track the position of characters based on the output characters, and since it provides its own color processing, it will probably also not detect ANSI escape sequences.
This may work (have you tried it?), But it can also fill the window controls in general.
And, since you stated in a comment that this did not work, I think the answer will be no :-)
If you after a possible way to allow ANSI escape sequences in your lines, then one of the methods (kludge, although it exists) is to intercept the line and change it. Have a helper function like myPrintW() that takes a string and breaks it, something like (pseudocode):
def myPrintW(s): while s not end of string: s2 = position of color-change-sequence in s if s2 == NULL exit while printw characters from s (inclusive) to s2 (exclusive) decode color-change-sequence at s2 and issue relevant attron/off s = s2 + length of color-change-sequence endwhile enddef
This will basically break the string into regular character sequences and color changing sequences, and you process them separately. Converting sequences to the required attron/off calls will require a lookup table. Not beautiful, but sometimes pragmatism is best.
source share