Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Sep 2008 21:57:40 GMT
From:      abc@ai1.anchorage.mtaonline.net
To:        "freebsd-questions" <questions@freebsd.org>
Subject:   ANSI bug?
Message-ID:  <200809222157.m8MLveol046801@en26.ai1.anchorage.mtaonline.net>

next in thread | raw e-mail | index | archive | help
i am thinking there is a flaw in the ANSI code,
and this program demonstrates this 'flaw'.  when
the 'inverse' attribute is set on the ANSI color
string, the 'clear to EOL' ANSI string does so
without respect to the 'inverse' attribute.

for example:

NORMAL
Foreground=White
Background=Red
CLEAR-TO-EOL=Red Background.

INVERSE
Foreground=Red
Background=White
CLEAR-TO-EOL=Red Background.
(it makes more sense for CLEAR-TO-EOL
to make a White Background in this instance).

///////////////////////////////////////////////////////////////////////////////
int main            (int argc, char* argv[]) {

//         ESC  [     [at]  ;    3     [fg]  ;    4     [bg]  m
char a[]={ 0x1b,0x5b, 0x30, 0x3b,0x33, 0x37, 0x3b,0x34, 0x31, 0x6d };
char b[]={ 0x1b,0x5b, 0x31, 0x3b,0x33, 0x37, 0x3b,0x34, 0x31, 0x6d };
char c[]={ 0x1b,0x5b, 0x37, 0x3b,0x33, 0x37, 0x3b,0x34, 0x31, 0x6d };
char d[]={ 0x1b,0x5b, 0x30, 0x3b,0x33, 0x31, 0x3b,0x34, 0x37, 0x6d };
char e[]={ 0x1b,0x5b, 0x31, 0x3b,0x33, 0x31, 0x3b,0x34, 0x37, 0x6d };
char f[]={ 0x1b,0x5b, 0x37, 0x3b,0x33, 0x31, 0x3b,0x34, 0x37, 0x6d };

char k[]={ 0x1b,0x5b,0x4b }; // clear to EOL ...

char* s="0123456789";

write(STDO, a, 10); write(STDO, k,  3); write(STDO, s, 10); printf("\n");
write(STDO, b, 10); write(STDO, k,  3); write(STDO, s, 10); printf("\n");
write(STDO, c, 10); write(STDO, k,  3); write(STDO, s, 10); printf("\n");
write(STDO, d, 10); write(STDO, k,  3); write(STDO, s, 10); printf("\n");
write(STDO, e, 10); write(STDO, k,  3); write(STDO, s, 10); printf("\n");
write(STDO, f, 10); write(STDO, k,  3); write(STDO, s, 10); printf("\n");

// 'c' and 'f' do not "inverse" the "clear to EOL" ...

exit(0); }
///////////////////////////////////////////////////////////////////////////////



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809222157.m8MLveol046801>