Reorder and extend glyph attributes

Faint, invisible, struck and fast blink are added as glyph attributes.
Since there's an edit here, let's take the opportunity to reorder them
so that they correspond to the two's power of the corresponding escape
code. (just for neatness, let's hope that property never gets used for
anything.)

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
dev
Anders Eurenius 2014-06-21 20:29:36 +02:00 committed by Roberto E. Vargas Caballero
parent 77569526c0
commit 50e6355e0d
1 changed files with 46 additions and 14 deletions

58
st.c
View File

@ -90,14 +90,18 @@ char *argv0;
enum glyph_attribute { enum glyph_attribute {
ATTR_NULL = 0, ATTR_NULL = 0,
ATTR_REVERSE = 1, ATTR_BOLD = 1,
ATTR_UNDERLINE = 2, ATTR_FAINT = 2,
ATTR_BOLD = 4, ATTR_ITALIC = 4,
ATTR_ITALIC = 8, ATTR_UNDERLINE = 8,
ATTR_BLINK = 16, ATTR_BLINK = 16,
ATTR_WRAP = 32, ATTR_FASTBLINK = 32,
ATTR_WIDE = 64, ATTR_REVERSE = 64,
ATTR_WDUMMY = 128, ATTR_INVISIBLE = 128,
ATTR_STRUCK = 256,
ATTR_WRAP = 512,
ATTR_WIDE = 1024,
ATTR_WDUMMY = 2048,
}; };
enum cursor_movement { enum cursor_movement {
@ -1681,15 +1685,25 @@ tsetattr(int *attr, int l) {
for(i = 0; i < l; i++) { for(i = 0; i < l; i++) {
switch(attr[i]) { switch(attr[i]) {
case 0: case 0:
term.c.attr.mode &= ~(ATTR_REVERSE | ATTR_UNDERLINE \ term.c.attr.mode &= ~(
| ATTR_BOLD | ATTR_ITALIC \ ATTR_BOLD |
| ATTR_BLINK); ATTR_FAINT |
ATTR_ITALIC |
ATTR_UNDERLINE |
ATTR_BLINK |
ATTR_FASTBLINK |
ATTR_REVERSE |
ATTR_INVISIBLE |
ATTR_STRUCK );
term.c.attr.fg = defaultfg; term.c.attr.fg = defaultfg;
term.c.attr.bg = defaultbg; term.c.attr.bg = defaultbg;
break; break;
case 1: case 1:
term.c.attr.mode |= ATTR_BOLD; term.c.attr.mode |= ATTR_BOLD;
break; break;
case 2:
term.c.attr.mode |= ATTR_FAINT;
break;
case 3: case 3:
term.c.attr.mode |= ATTR_ITALIC; term.c.attr.mode |= ATTR_ITALIC;
break; break;
@ -1697,16 +1711,26 @@ tsetattr(int *attr, int l) {
term.c.attr.mode |= ATTR_UNDERLINE; term.c.attr.mode |= ATTR_UNDERLINE;
break; break;
case 5: /* slow blink */ case 5: /* slow blink */
case 6: /* rapid blink */
term.c.attr.mode |= ATTR_BLINK; term.c.attr.mode |= ATTR_BLINK;
break; break;
case 6: /* rapid blink */
term.c.attr.mode |= ATTR_FASTBLINK;
break;
case 7: case 7:
term.c.attr.mode |= ATTR_REVERSE; term.c.attr.mode |= ATTR_REVERSE;
break; break;
case 8:
term.c.attr.mode |= ATTR_INVISIBLE;
break;
case 9:
term.c.attr.mode |= ATTR_STRUCK;
break;
case 21: case 21:
case 22:
term.c.attr.mode &= ~ATTR_BOLD; term.c.attr.mode &= ~ATTR_BOLD;
break; break;
case 22:
term.c.attr.mode &= ~ATTR_FAINT;
break;
case 23: case 23:
term.c.attr.mode &= ~ATTR_ITALIC; term.c.attr.mode &= ~ATTR_ITALIC;
break; break;
@ -1714,12 +1738,20 @@ tsetattr(int *attr, int l) {
term.c.attr.mode &= ~ATTR_UNDERLINE; term.c.attr.mode &= ~ATTR_UNDERLINE;
break; break;
case 25: case 25:
case 26:
term.c.attr.mode &= ~ATTR_BLINK; term.c.attr.mode &= ~ATTR_BLINK;
break; break;
case 26:
term.c.attr.mode &= ~ATTR_FASTBLINK;
break;
case 27: case 27:
term.c.attr.mode &= ~ATTR_REVERSE; term.c.attr.mode &= ~ATTR_REVERSE;
break; break;
case 28:
term.c.attr.mode &= ~ATTR_INVISIBLE;
break;
case 29:
term.c.attr.mode &= ~ATTR_STRUCK;
break;
case 38: case 38:
if ((idx = tdefcolor(attr, &i, l)) >= 0) if ((idx = tdefcolor(attr, &i, l)) >= 0)
term.c.attr.fg = idx; term.c.attr.fg = idx;