aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Eurenius <aes@spotify.com>2014-06-21 20:29:36 +0200
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2014-06-27 14:04:47 +0200
commit50e6355e0d6c9843b51ac4711980401205ce06c1 (patch)
treec07bfe2b32824404875e682018648d6320a04959
parent77569526c0166e6364bb635fceb8eeabd58ce683 (diff)
downloadst-50e6355e0d6c9843b51ac4711980401205ce06c1.tar.gz
st-50e6355e0d6c9843b51ac4711980401205ce06c1.zip
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>
-rw-r--r--st.c60
1 files changed, 46 insertions, 14 deletions
diff --git a/st.c b/st.c
index 2b6b717..9637834 100644
--- a/st.c
+++ b/st.c
@@ -89,15 +89,19 @@ char *argv0;
89#define VT102ID "\033[?6c" 89#define VT102ID "\033[?6c"
90 90
91enum glyph_attribute { 91enum glyph_attribute {
92 ATTR_NULL = 0, 92 ATTR_NULL = 0,
93 ATTR_REVERSE = 1, 93 ATTR_BOLD = 1,
94 ATTR_UNDERLINE = 2, 94 ATTR_FAINT = 2,
95 ATTR_BOLD = 4, 95 ATTR_ITALIC = 4,
96 ATTR_ITALIC = 8, 96 ATTR_UNDERLINE = 8,
97 ATTR_BLINK = 16, 97 ATTR_BLINK = 16,
98 ATTR_WRAP = 32, 98 ATTR_FASTBLINK = 32,
99 ATTR_WIDE = 64, 99 ATTR_REVERSE = 64,
100 ATTR_WDUMMY = 128, 100 ATTR_INVISIBLE = 128,
101 ATTR_STRUCK = 256,
102 ATTR_WRAP = 512,
103 ATTR_WIDE = 1024,
104 ATTR_WDUMMY = 2048,
101}; 105};
102 106
103enum cursor_movement { 107enum cursor_movement {
@@ -1681,15 +1685,25 @@ tsetattr(int *attr, int l) {
1681 for(i = 0; i < l; i++) { 1685 for(i = 0; i < l; i++) {
1682 switch(attr[i]) { 1686 switch(attr[i]) {
1683 case 0: 1687 case 0:
1684 term.c.attr.mode &= ~(ATTR_REVERSE | ATTR_UNDERLINE \ 1688 term.c.attr.mode &= ~(
1685 | ATTR_BOLD | ATTR_ITALIC \ 1689 ATTR_BOLD |
1686 | ATTR_BLINK); 1690 ATTR_FAINT |
1691 ATTR_ITALIC |
1692 ATTR_UNDERLINE |
1693 ATTR_BLINK |
1694 ATTR_FASTBLINK |
1695 ATTR_REVERSE |
1696 ATTR_INVISIBLE |
1697 ATTR_STRUCK );
1687 term.c.attr.fg = defaultfg; 1698 term.c.attr.fg = defaultfg;
1688 term.c.attr.bg = defaultbg; 1699 term.c.attr.bg = defaultbg;
1689 break; 1700 break;
1690 case 1: 1701 case 1:
1691 term.c.attr.mode |= ATTR_BOLD; 1702 term.c.attr.mode |= ATTR_BOLD;
1692 break; 1703 break;
1704 case 2:
1705 term.c.attr.mode |= ATTR_FAINT;
1706 break;
1693 case 3: 1707 case 3:
1694 term.c.attr.mode |= ATTR_ITALIC; 1708 term.c.attr.mode |= ATTR_ITALIC;
1695 break; 1709 break;
@@ -1697,16 +1711,26 @@ tsetattr(int *attr, int l) {
1697 term.c.attr.mode |= ATTR_UNDERLINE; 1711 term.c.attr.mode |= ATTR_UNDERLINE;
1698 break; 1712 break;
1699 case 5: /* slow blink */ 1713 case 5: /* slow blink */
1700 case 6: /* rapid blink */
1701 term.c.attr.mode |= ATTR_BLINK; 1714 term.c.attr.mode |= ATTR_BLINK;
1702 break; 1715 break;
1716 case 6: /* rapid blink */
1717 term.c.attr.mode |= ATTR_FASTBLINK;
1718 break;
1703 case 7: 1719 case 7:
1704 term.c.attr.mode |= ATTR_REVERSE; 1720 term.c.attr.mode |= ATTR_REVERSE;
1705 break; 1721 break;
1722 case 8:
1723 term.c.attr.mode |= ATTR_INVISIBLE;
1724 break;
1725 case 9:
1726 term.c.attr.mode |= ATTR_STRUCK;
1727 break;
1706 case 21: 1728 case 21:
1707 case 22:
1708 term.c.attr.mode &= ~ATTR_BOLD; 1729 term.c.attr.mode &= ~ATTR_BOLD;
1709 break; 1730 break;
1731 case 22:
1732 term.c.attr.mode &= ~ATTR_FAINT;
1733 break;
1710 case 23: 1734 case 23:
1711 term.c.attr.mode &= ~ATTR_ITALIC; 1735 term.c.attr.mode &= ~ATTR_ITALIC;
1712 break; 1736 break;
@@ -1714,12 +1738,20 @@ tsetattr(int *attr, int l) {
1714 term.c.attr.mode &= ~ATTR_UNDERLINE; 1738 term.c.attr.mode &= ~ATTR_UNDERLINE;
1715 break; 1739 break;
1716 case 25: 1740 case 25:
1717 case 26:
1718 term.c.attr.mode &= ~ATTR_BLINK; 1741 term.c.attr.mode &= ~ATTR_BLINK;
1719 break; 1742 break;
1743 case 26:
1744 term.c.attr.mode &= ~ATTR_FASTBLINK;
1745 break;
1720 case 27: 1746 case 27:
1721 term.c.attr.mode &= ~ATTR_REVERSE; 1747 term.c.attr.mode &= ~ATTR_REVERSE;
1722 break; 1748 break;
1749 case 28:
1750 term.c.attr.mode &= ~ATTR_INVISIBLE;
1751 break;
1752 case 29:
1753 term.c.attr.mode &= ~ATTR_STRUCK;
1754 break;
1723 case 38: 1755 case 38:
1724 if ((idx = tdefcolor(attr, &i, l)) >= 0) 1756 if ((idx = tdefcolor(attr, &i, l)) >= 0)
1725 term.c.attr.fg = idx; 1757 term.c.attr.fg = idx;