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>
This commit is contained in:
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

60
st.c
View File

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