/* * NOTE: * On Linux console, the 'me' termcap setting \E[m resets _all_ attributes, * including color. However, if we use 'se' instead, it doesn't clear the * boldface. To compensate, we reset the colors when we put out any "ending" * sequence, such as 'me'. * * In rxvt (2.12), setting _any_ attribute seems to clobber the color settings. */ static void tcapattr(int attr) { static const struct { char **start; char **end; int mask; } tbl[] = { { &SO, &SE, VASEL|VAREV }, { &US, &UE, VAUL }, { &US, &UE, VAITAL }, { &MD, &ME, VABOLD }, }; static int last; attr = VATTRIB(attr); /* FIXME: color? */ attr &= ~(VAML|VAMLFOC); if (attr != last) { register int n; register char *s; int diff = attr ^ last; int ends = FALSE; /* turn OFF old attributes */ for (n = 0; n < TABLESIZE(tbl); n++) { if ((tbl[n].mask & diff) != 0 && (tbl[n].mask & attr) == 0 && (s = *(tbl[n].end)) != 0) { putpad(s); #if OPT_COLOR reinitialize_colors(); #endif ends = TRUE; diff &= ~(tbl[n].mask); } } /* turn ON new attributes */ for (n = 0; n < TABLESIZE(tbl); n++) { if ((tbl[n].mask & diff) != 0 && (tbl[n].mask & attr) != 0 && (s = *(tbl[n].start)) != 0) { putpad(s); diff &= ~(tbl[n].mask); } } if (SO != 0 && SE != 0) { if (ends && (attr & (VAREV|VASEL))) { putpad(SO); } else if (diff) { /* we didn't find it */ putpad(SE); } } last = attr; } }
int apply_attribute(void) { return (VATTRIB(videoattribute) != 0 #if OPT_HYPERTEXT || tb_length(hypercmd) != 0 #endif ); }